From f25f31a83762cbdc71bb38e245153b3f5860ad36 Mon Sep 17 00:00:00 2001 From: Cranken Date: Sat, 29 Sep 2018 22:24:48 +0200 Subject: [PATCH] Added button on tab to enable/disable highlighting. --- src/widgets/helper/NotebookTab.cpp | 15 ++++++++------- src/widgets/helper/NotebookTab.hpp | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 4225d904b..8dd399c0e 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -62,12 +62,13 @@ NotebookTab::NotebookTab(Notebook *notebook) this->menu_.addAction("Close", [=]() { this->notebook_->removePage(this->page); }); - // this->menu.addAction(enableHighlightsOnNewMessageAction); - - // QObject::connect(enableHighlightsOnNewMessageAction, - // &QAction::toggled, [this](bool newValue) { - // Log("New value is {}", newValue); // - // }); + auto highlightNewMessagesAction = new QAction("Enable highlights on new messages", &this->menu_); + highlightNewMessagesAction->setCheckable(true); + highlightNewMessagesAction->setChecked(true); + QObject::connect(highlightNewMessagesAction, &QAction::triggered, [this] (bool checked) { + this->highlightEnabled = checked; + }); + this->menu_.addAction(highlightNewMessagesAction); } void NotebookTab::themeChangedEvent() @@ -168,7 +169,7 @@ void NotebookTab::setSelected(bool value) void NotebookTab::setHighlightState(HighlightState newHighlightStyle) { - if (this->isSelected()) { + if (this->isSelected() || !this->highlightEnabled) { return; } if (this->highlightState_ != HighlightState::Highlighted && diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index a97e1a23b..59c4b1bcd 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -82,6 +82,7 @@ private: bool mouseDownX_ = false; HighlightState highlightState_ = HighlightState::None; + bool highlightEnabled = true; QMenu menu_;