diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index e6e1ca365..540aea934 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -334,7 +334,7 @@ void Notebook::setShowAddButton(bool value) void Notebook::scaleChangedEvent(float scale) { - float h = NOTEBOOK_TAB_HEIGHT * this->getScale(); + float h = (NOTEBOOK_TAB_HEIGHT - 1) * this->getScale(); this->addButton_->setFixedSize(h, h); @@ -367,7 +367,7 @@ void Notebook::performLayout(bool animated) continue; } - btn->setFixedSize(tabHeight, tabHeight); + btn->setFixedSize(tabHeight, tabHeight - 1); btn->move(x, 0); x += tabHeight; } diff --git a/src/widgets/helper/NotebookButton.cpp b/src/widgets/helper/NotebookButton.cpp index 5e20c6ef3..4ed9a37d7 100644 --- a/src/widgets/helper/NotebookButton.cpp +++ b/src/widgets/helper/NotebookButton.cpp @@ -159,9 +159,7 @@ void NotebookButton::mouseReleaseEvent(QMouseEvent *event) void NotebookButton::dragEnterEvent(QDragEnterEvent *event) { if (!event->mimeData()->hasFormat("chatterino/split")) - { return; - } event->acceptProposedAction(); diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 27060a892..0f793b933 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -42,20 +42,7 @@ NotebookTab::NotebookTab(Notebook *notebook) this->setMouseTracking(true); - this->menu_.addAction("Rename", [this]() { - TextInputDialog d(this); - - d.setWindowTitle( - "Change tab title (Leave empty for default behaviour)"); - d.setText(this->getCustomTitle()); - d.highlightText(); - - if (d.exec() == QDialog::Accepted) - { - QString newTitle = d.getText(); - this->setCustomTitle(newTitle); - } - }); + this->menu_.addAction("Rename", [this]() { this->showRenameDialog(); }); this->menu_.addAction("Close", [=]() { this->notebook_->removePage(this->page); }); @@ -70,6 +57,21 @@ NotebookTab::NotebookTab(Notebook *notebook) this->menu_.addAction(highlightNewMessagesAction_); } +void NotebookTab::showRenameDialog() +{ + TextInputDialog d(this); + + d.setWindowTitle("Choose tab title (Empty for default)"); + d.setText(this->getCustomTitle()); + d.highlightText(); + + if (d.exec() == QDialog::Accepted) + { + QString newTitle = d.getText(); + this->setCustomTitle(newTitle); + } +} + void NotebookTab::themeChangedEvent() { this->update(); @@ -278,21 +280,13 @@ void NotebookTab::paintEvent(QPaintEvent *) Theme::TabColors regular = this->theme->tabs.regular; if (this->selected_) - { colors = this->theme->tabs.selected; - } else if (this->highlightState_ == HighlightState::Highlighted) - { colors = this->theme->tabs.highlighted; - } else if (this->highlightState_ == HighlightState::NewMessage) - { colors = this->theme->tabs.newMessage; - } else - { colors = this->theme->tabs.regular; - } bool windowFocused = this->window() == QApplication::activeWindow(); @@ -387,18 +381,18 @@ void NotebookTab::paintEvent(QPaintEvent *) } } + // draw mouse over effect + if (!this->selected_) + { + this->fancyPaint(painter); + } + // draw line at bottom if (!this->selected_ && this->isInLastRow_) { painter.fillRect(0, this->height() - 1, this->width(), 1, app->themes->window.background); } - - // draw mouse over effect - if (!this->selected_) - { - this->fancyPaint(painter); - } } bool NotebookTab::hasXButton() @@ -477,6 +471,15 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event) } } +void NotebookTab::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton && + this->notebook_->getAllowUserTabManagement()) + { + this->showRenameDialog(); + } +} + void NotebookTab::enterEvent(QEvent *event) { this->mouseOver_ = true; diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index 0cd6d1091..3d8a5cacb 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -58,6 +58,7 @@ protected: virtual void mousePressEvent(QMouseEvent *event) override; virtual void mouseReleaseEvent(QMouseEvent *event) override; + virtual void mouseDoubleClickEvent(QMouseEvent *event) override; virtual void enterEvent(QEvent *) override; virtual void leaveEvent(QEvent *) override; @@ -67,6 +68,8 @@ protected: virtual void wheelEvent(QWheelEvent *event) override; private: + void showRenameDialog(); + bool hasXButton(); bool shouldDrawXButton(); QRect getXRect();