renamed Notebook2 to Notebook

This commit is contained in:
fourtf 2018-05-23 11:59:37 +02:00
parent dafbda6a4a
commit 8b3fb691a7
12 changed files with 78 additions and 78 deletions

View file

@ -32,7 +32,7 @@ EmotePopup::EmotePopup()
auto *layout = new QVBoxLayout(this);
this->getLayoutContainer()->setLayout(layout);
Notebook2 *notebook = new Notebook2(this);
Notebook *notebook = new Notebook(this);
layout->addWidget(notebook);
layout->setMargin(0);

View file

@ -136,7 +136,7 @@ void NotebookButton::dropEvent(QDropEvent *event)
if (SplitContainer::isDraggingSplit) {
event->acceptProposedAction();
Notebook2 *notebook = dynamic_cast<Notebook2 *>(this->parentWidget());
Notebook *notebook = dynamic_cast<Notebook *>(this->parentWidget());
if (notebook != nuuls) {
SplitContainer *page = new SplitContainer(notebook);

View file

@ -19,7 +19,7 @@
namespace chatterino {
namespace widgets {
NotebookTab2::NotebookTab2(Notebook2 *_notebook)
NotebookTab::NotebookTab(Notebook *_notebook)
: BaseWidget(_notebook)
, positionChangedAnimation(this, "pos")
, notebook(_notebook)
@ -31,7 +31,7 @@ NotebookTab2::NotebookTab2(Notebook2 *_notebook)
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
app->settings->showTabCloseButton.connect(boost::bind(&NotebookTab2::hideTabXChanged, this, _1),
app->settings->showTabCloseButton.connect(boost::bind(&NotebookTab::hideTabXChanged, this, _1),
this->managedConnections);
this->setMouseTracking(true);
@ -75,12 +75,12 @@ NotebookTab2::NotebookTab2(Notebook2 *_notebook)
// });
}
void NotebookTab2::themeRefreshEvent()
void NotebookTab::themeRefreshEvent()
{
this->update();
}
void NotebookTab2::updateSize()
void NotebookTab::updateSize()
{
auto app = getApp();
float scale = getScale();
@ -106,12 +106,12 @@ void NotebookTab2::updateSize()
// }
}
const QString &NotebookTab2::getTitle() const
const QString &NotebookTab::getTitle() const
{
return this->title;
}
void NotebookTab2::setTitle(const QString &newTitle)
void NotebookTab::setTitle(const QString &newTitle)
{
if (this->title != newTitle) {
this->title = newTitle;
@ -120,12 +120,12 @@ void NotebookTab2::setTitle(const QString &newTitle)
}
}
bool NotebookTab2::isSelected() const
bool NotebookTab::isSelected() const
{
return this->selected;
}
void NotebookTab2::setSelected(bool value)
void NotebookTab::setSelected(bool value)
{
this->selected = value;
@ -134,7 +134,7 @@ void NotebookTab2::setSelected(bool value)
this->update();
}
void NotebookTab2::setHighlightState(HighlightState newHighlightStyle)
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
{
if (this->isSelected()) {
return;
@ -147,18 +147,18 @@ void NotebookTab2::setHighlightState(HighlightState newHighlightStyle)
}
}
QRect NotebookTab2::getDesiredRect() const
QRect NotebookTab::getDesiredRect() const
{
return QRect(positionAnimationDesiredPoint, size());
}
void NotebookTab2::hideTabXChanged(bool)
void NotebookTab::hideTabXChanged(bool)
{
this->updateSize();
this->update();
}
void NotebookTab2::moveAnimated(QPoint pos, bool animated)
void NotebookTab::moveAnimated(QPoint pos, bool animated)
{
this->positionAnimationDesiredPoint = pos;
@ -182,7 +182,7 @@ void NotebookTab2::moveAnimated(QPoint pos, bool animated)
this->positionChangedAnimation.start();
}
void NotebookTab2::paintEvent(QPaintEvent *)
void NotebookTab::paintEvent(QPaintEvent *)
{
auto app = getApp();
QPainter painter(this);
@ -292,17 +292,17 @@ void NotebookTab2::paintEvent(QPaintEvent *)
}
}
bool NotebookTab2::hasXButton()
bool NotebookTab::hasXButton()
{
return getApp()->settings->showTabCloseButton && this->notebook->getAllowUserTabManagement();
}
bool NotebookTab2::shouldDrawXButton()
bool NotebookTab::shouldDrawXButton()
{
return this->hasXButton() && (mouseOver || selected);
}
void NotebookTab2::mousePressEvent(QMouseEvent *event)
void NotebookTab::mousePressEvent(QMouseEvent *event)
{
this->mouseDown = true;
this->mouseDownX = this->getXRect().contains(event->pos());
@ -320,7 +320,7 @@ void NotebookTab2::mousePressEvent(QMouseEvent *event)
}
}
void NotebookTab2::mouseReleaseEvent(QMouseEvent *event)
void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
{
this->mouseDown = false;
@ -339,14 +339,14 @@ void NotebookTab2::mouseReleaseEvent(QMouseEvent *event)
}
}
void NotebookTab2::enterEvent(QEvent *)
void NotebookTab::enterEvent(QEvent *)
{
this->mouseOver = true;
this->update();
}
void NotebookTab2::leaveEvent(QEvent *)
void NotebookTab::leaveEvent(QEvent *)
{
this->mouseOverX = false;
this->mouseOver = false;
@ -354,14 +354,14 @@ void NotebookTab2::leaveEvent(QEvent *)
this->update();
}
void NotebookTab2::dragEnterEvent(QDragEnterEvent *)
void NotebookTab::dragEnterEvent(QDragEnterEvent *)
{
if (this->notebook->getAllowUserTabManagement()) {
this->notebook->select(this->page);
}
}
void NotebookTab2::mouseMoveEvent(QMouseEvent *event)
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
{
auto app = getApp();
@ -393,7 +393,7 @@ void NotebookTab2::mouseMoveEvent(QMouseEvent *event)
}
}
QRect NotebookTab2::getXRect()
QRect NotebookTab::getXRect()
{
// if (!this->notebook->getAllowUserTabManagement()) {
// return QRect();

View file

@ -14,15 +14,15 @@ namespace widgets {
#define NOTEBOOK_TAB_HEIGHT 28
// class Notebook;
class Notebook2;
class Notebook;
class SplitContainer;
class NotebookTab2 : public BaseWidget
class NotebookTab : public BaseWidget
{
Q_OBJECT
public:
explicit NotebookTab2(Notebook2 *_notebook);
explicit NotebookTab(Notebook *_notebook);
void updateSize();
@ -61,7 +61,7 @@ private:
bool positionChangedAnimationRunning = false;
QPoint positionAnimationDesiredPoint;
Notebook2 *notebook;
Notebook *notebook;
QString title;

View file

@ -244,7 +244,7 @@ void SplitInput::installKeyPressedEvent()
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
Notebook2 *notebook = static_cast<Notebook2 *>(page->parentWidget());
Notebook *notebook = static_cast<Notebook *>(page->parentWidget());
notebook->selectNextTab();
}
@ -253,7 +253,7 @@ void SplitInput::installKeyPressedEvent()
SplitContainer *page =
static_cast<SplitContainer *>(this->chatWidget->parentWidget());
Notebook2 *notebook = static_cast<Notebook2 *>(page->parentWidget());
Notebook *notebook = static_cast<Notebook *>(page->parentWidget());
notebook->selectPreviousTab();
}

View file

@ -25,7 +25,7 @@
namespace chatterino {
namespace widgets {
Notebook2::Notebook2(QWidget *parent)
Notebook::Notebook(QWidget *parent)
: BaseWidget(parent)
, addButton(this)
{
@ -38,9 +38,9 @@ Notebook2::Notebook2(QWidget *parent)
QObject::connect(shortcut_prev, &QShortcut::activated, [this] { this->selectPreviousTab(); });
}
NotebookTab2 *Notebook2::addPage(QWidget *page, QString title, bool select)
NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select)
{
auto *tab = new NotebookTab2(this);
auto *tab = new NotebookTab(this);
tab->page = page;
if (!title.isEmpty()) {
@ -66,7 +66,7 @@ NotebookTab2 *Notebook2::addPage(QWidget *page, QString title, bool select)
return tab;
}
void Notebook2::removePage(QWidget *page)
void Notebook::removePage(QWidget *page)
{
for (int i = 0; i < this->items.count(); i++) {
if (this->items[i].page == page) {
@ -93,14 +93,14 @@ void Notebook2::removePage(QWidget *page)
this->performLayout();
}
void Notebook2::removeCurrentPage()
void Notebook::removeCurrentPage()
{
if (this->selectedPage != nullptr) {
this->removePage(this->selectedPage);
}
}
int Notebook2::indexOf(QWidget *page) const
int Notebook::indexOf(QWidget *page) const
{
for (int i = 0; i < this->items.count(); i++) {
if (this->items[i].page == page) {
@ -111,7 +111,7 @@ int Notebook2::indexOf(QWidget *page) const
return -1;
}
void Notebook2::select(QWidget *page)
void Notebook::select(QWidget *page)
{
if (page == this->selectedPage) {
return;
@ -120,7 +120,7 @@ void Notebook2::select(QWidget *page)
if (page != nullptr) {
page->setHidden(false);
NotebookTab2 *tab = this->getTabFromPage(page);
NotebookTab *tab = this->getTabFromPage(page);
tab->setSelected(true);
tab->raise();
}
@ -128,7 +128,7 @@ void Notebook2::select(QWidget *page)
if (this->selectedPage != nullptr) {
this->selectedPage->setHidden(true);
NotebookTab2 *tab = this->getTabFromPage(selectedPage);
NotebookTab *tab = this->getTabFromPage(selectedPage);
tab->setSelected(false);
// for (auto split : this->selectedPage->getSplits()) {
@ -141,7 +141,7 @@ void Notebook2::select(QWidget *page)
this->performLayout();
}
void Notebook2::selectIndex(int index)
void Notebook::selectIndex(int index)
{
if (index < 0 || this->items.count() <= index) {
return;
@ -150,7 +150,7 @@ void Notebook2::selectIndex(int index)
this->select(this->items[index].page);
}
void Notebook2::selectNextTab()
void Notebook::selectNextTab()
{
if (this->items.size() <= 1) {
return;
@ -161,7 +161,7 @@ void Notebook2::selectNextTab()
this->select(this->items[index].page);
}
void Notebook2::selectPreviousTab()
void Notebook::selectPreviousTab()
{
if (this->items.size() <= 1) {
return;
@ -176,27 +176,27 @@ void Notebook2::selectPreviousTab()
this->select(this->items[index].page);
}
int Notebook2::getPageCount() const
int Notebook::getPageCount() const
{
return this->items.count();
}
QWidget *Notebook2::getPageAt(int index) const
QWidget *Notebook::getPageAt(int index) const
{
return this->items[index].page;
}
int Notebook2::getSelectedIndex() const
int Notebook::getSelectedIndex() const
{
return this->indexOf(this->selectedPage);
}
QWidget *Notebook2::getSelectedPage() const
QWidget *Notebook::getSelectedPage() const
{
return this->selectedPage;
}
QWidget *Notebook2::tabAt(QPoint point, int &index, int maxWidth)
QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth)
{
int i = 0;
@ -218,36 +218,36 @@ QWidget *Notebook2::tabAt(QPoint point, int &index, int maxWidth)
return nullptr;
}
void Notebook2::rearrangePage(QWidget *page, int index)
void Notebook::rearrangePage(QWidget *page, int index)
{
this->items.move(this->indexOf(page), index);
this->performLayout();
}
bool Notebook2::getAllowUserTabManagement() const
bool Notebook::getAllowUserTabManagement() const
{
return this->allowUserTabManagement;
}
void Notebook2::setAllowUserTabManagement(bool value)
void Notebook::setAllowUserTabManagement(bool value)
{
this->allowUserTabManagement = value;
}
bool Notebook2::getShowAddButton() const
bool Notebook::getShowAddButton() const
{
return this->showAddButton;
}
void Notebook2::setShowAddButton(bool value)
void Notebook::setShowAddButton(bool value)
{
this->showAddButton = value;
this->addButton.setHidden(!value);
}
void Notebook2::scaleChangedEvent(float scale)
void Notebook::scaleChangedEvent(float scale)
{
float h = NOTEBOOK_TAB_HEIGHT * this->getScale();
@ -260,12 +260,12 @@ void Notebook2::scaleChangedEvent(float scale)
}
}
void Notebook2::resizeEvent(QResizeEvent *)
void Notebook::resizeEvent(QResizeEvent *)
{
this->performLayout();
}
void Notebook2::performLayout(bool animated)
void Notebook::performLayout(bool animated)
{
auto app = getApp();
@ -347,7 +347,7 @@ void Notebook2::performLayout(bool animated)
}
}
void Notebook2::paintEvent(QPaintEvent *event)
void Notebook::paintEvent(QPaintEvent *event)
{
BaseWidget::paintEvent(event);
@ -356,12 +356,12 @@ void Notebook2::paintEvent(QPaintEvent *event)
this->themeManager->tabs.bottomLine);
}
NotebookButton *Notebook2::getAddButton()
NotebookButton *Notebook::getAddButton()
{
return &this->addButton;
}
NotebookTab2 *Notebook2::getTabFromPage(QWidget *page)
NotebookTab *Notebook::getTabFromPage(QWidget *page)
{
for (auto &it : this->items) {
if (it.page == page) {
@ -373,7 +373,7 @@ NotebookTab2 *Notebook2::getTabFromPage(QWidget *page)
}
SplitNotebook::SplitNotebook(QWidget *parent)
: Notebook2(parent)
: Notebook(parent)
{
this->connect(this->getAddButton(), &NotebookButton::clicked,
[this]() { QTimer::singleShot(80, this, [this] { this->addPage(true); }); });
@ -382,7 +382,7 @@ SplitNotebook::SplitNotebook(QWidget *parent)
SplitContainer *SplitNotebook::addPage(bool select)
{
SplitContainer *container = new SplitContainer(this);
auto *tab = Notebook2::addPage(container, QString(), select);
auto *tab = Notebook::addPage(container, QString(), select);
container->setTab(tab);
tab->setParent(this);
tab->show();

View file

@ -14,14 +14,14 @@ namespace widgets {
class Window;
class Notebook2 : public BaseWidget
class Notebook : public BaseWidget
{
Q_OBJECT
public:
explicit Notebook2(QWidget *parent);
explicit Notebook(QWidget *parent);
NotebookTab2 *addPage(QWidget *page, QString title = QString(), bool select = false);
NotebookTab *addPage(QWidget *page, QString title = QString(), bool select = false);
void removePage(QWidget *page);
void removeCurrentPage();
@ -56,7 +56,7 @@ protected:
private:
struct Item {
NotebookTab2 *tab;
NotebookTab *tab;
QWidget *page;
};
@ -69,10 +69,10 @@ private:
bool showAddButton = false;
int lineY = 20;
NotebookTab2 *getTabFromPage(QWidget *page);
NotebookTab *getTabFromPage(QWidget *page);
};
class SplitNotebook : public Notebook2
class SplitNotebook : public Notebook
{
public:
SplitNotebook(QWidget *parent);

View file

@ -26,7 +26,7 @@ SelectChannelDialog::SelectChannelDialog()
util::LayoutCreator<QWidget> layoutWidget(this->getLayoutContainer());
auto layout = layoutWidget.setLayoutType<QVBoxLayout>().withoutMargin();
auto notebook = layout.emplace<Notebook2>(this).assign(&this->ui.notebook);
auto notebook = layout.emplace<Notebook>(this).assign(&this->ui.notebook);
// twitch
{
@ -99,7 +99,7 @@ SelectChannelDialog::SelectChannelDialog()
QWidget::setTabOrder(*watching_btn, *channel_btn);
// tab
NotebookTab2 *tab = notebook->addPage(obj.getElement());
NotebookTab *tab = notebook->addPage(obj.getElement());
tab->setTitle("Twitch");
}

View file

@ -38,7 +38,7 @@ private:
};
struct {
Notebook2 *notebook;
Notebook *notebook;
struct {
QRadioButton *channel;
QLineEdit *channelName;

View file

@ -29,7 +29,7 @@ namespace widgets {
bool SplitContainer::isDraggingSplit = false;
Split *SplitContainer::draggingSplit = nullptr;
SplitContainer::SplitContainer(Notebook2 *parent)
SplitContainer::SplitContainer(Notebook *parent)
: BaseWidget(parent)
, tab(nullptr)
, dropPreview(this)
@ -67,12 +67,12 @@ SplitContainer::SplitContainer(Notebook2 *parent)
this->setAcceptDrops(true);
}
NotebookTab2 *SplitContainer::getTab() const
NotebookTab *SplitContainer::getTab() const
{
return this->tab;
}
void SplitContainer::setTab(NotebookTab2 *_tab)
void SplitContainer::setTab(NotebookTab *_tab)
{
this->tab = _tab;
@ -280,7 +280,7 @@ void SplitContainer::paintEvent(QPaintEvent *)
QString text = "Click to add a split";
Notebook2 *notebook = dynamic_cast<Notebook2 *>(this->parentWidget());
Notebook *notebook = dynamic_cast<Notebook *>(this->parentWidget());
if (notebook != nullptr) {
if (notebook->getPageCount() > 1) {

View file

@ -165,7 +165,7 @@ private:
};
public:
SplitContainer(Notebook2 *parent);
SplitContainer(Notebook *parent);
void appendNewSplit(bool openChannelNameDialog);
void appendSplit(Split *split);
@ -189,13 +189,13 @@ public:
void refreshTabTitle();
NotebookTab2 *getTab() const;
NotebookTab *getTab() const;
Node *getBaseNode()
{
return &this->baseNode;
}
void setTab(NotebookTab2 *tab);
void setTab(NotebookTab *tab);
static bool isDraggingSplit;
static Split *draggingSplit;
@ -234,7 +234,7 @@ private:
Node baseNode;
NotebookTab2 *tab;
NotebookTab *tab;
std::vector<Split *> splits;
bool isDragging = false;

View file

@ -49,7 +49,7 @@ private:
SplitNotebook notebook;
friend class Notebook2;
friend class Notebook;
public:
void save();