Merge pull request #739 from Cranken/enableHighlightTab

Option to disable highlight of tab; disabled switching tabs by only right clicking
This commit is contained in:
pajlada 2018-09-30 12:30:52 +00:00 committed by GitHub
commit 0e794f5a6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View file

@ -62,12 +62,14 @@ NotebookTab::NotebookTab(Notebook *notebook)
this->menu_.addAction("Close", this->menu_.addAction("Close",
[=]() { this->notebook_->removePage(this->page); }); [=]() { this->notebook_->removePage(this->page); });
// this->menu.addAction(enableHighlightsOnNewMessageAction); auto highlightNewMessagesAction =
new QAction("Enable highlights on new messages", &this->menu_);
// QObject::connect(enableHighlightsOnNewMessageAction, highlightNewMessagesAction->setCheckable(true);
// &QAction::toggled, [this](bool newValue) { highlightNewMessagesAction->setChecked(true);
// Log("New value is {}", newValue); // QObject::connect(
// }); highlightNewMessagesAction, &QAction::triggered,
[this](bool checked) { this->highlightEnabled_ = checked; });
this->menu_.addAction(highlightNewMessagesAction);
} }
void NotebookTab::themeChangedEvent() void NotebookTab::themeChangedEvent()
@ -168,7 +170,7 @@ void NotebookTab::setSelected(bool value)
void NotebookTab::setHighlightState(HighlightState newHighlightStyle) void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
{ {
if (this->isSelected()) { if (this->isSelected() || !this->highlightEnabled_) {
return; return;
} }
if (this->highlightState_ != HighlightState::Highlighted && if (this->highlightState_ != HighlightState::Highlighted &&
@ -356,12 +358,14 @@ bool NotebookTab::shouldDrawXButton()
void NotebookTab::mousePressEvent(QMouseEvent *event) void NotebookTab::mousePressEvent(QMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) {
this->mouseDown_ = true; this->mouseDown_ = true;
this->mouseDownX_ = this->getXRect().contains(event->pos()); this->mouseDownX_ = this->getXRect().contains(event->pos());
this->update();
this->notebook_->select(page); this->notebook_->select(page);
}
this->update();
if (this->notebook_->getAllowUserTabManagement()) { if (this->notebook_->getAllowUserTabManagement()) {
switch (event->button()) { switch (event->button()) {

View file

@ -82,6 +82,7 @@ private:
bool mouseDownX_ = false; bool mouseDownX_ = false;
HighlightState highlightState_ = HighlightState::None; HighlightState highlightState_ = HighlightState::None;
bool highlightEnabled_ = true;
QMenu menu_; QMenu menu_;