From cd2ab5e0cdf76facbba2d1382bf14acd7f76574a Mon Sep 17 00:00:00 2001 From: tuckerrrrrrrrrrrr Date: Sat, 15 Feb 2020 21:00:38 -0800 Subject: [PATCH 1/8] flash highlight color instead of red in channel tab --- src/widgets/helper/ChannelView.cpp | 2 ++ src/widgets/helper/ChannelView.hpp | 3 +++ src/widgets/helper/NotebookTab.cpp | 22 +++++++++++++++++++++- src/widgets/helper/NotebookTab.hpp | 3 +++ src/widgets/splits/SplitContainer.cpp | 8 ++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index c2542354d..34d6cb8a9 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -652,10 +652,12 @@ void ChannelView::messageAppended(MessagePtr &message, !messageFlags->has(MessageFlag::Subscription)) { this->tabHighlightRequested.invoke(HighlightState::Highlighted); + this->tabHighlightColorRequested.invoke(message->highlightColor); } else { this->tabHighlightRequested.invoke(HighlightState::NewMessage); + this->tabHighlightColorRequested.invoke(nullptr); } } diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 308681624..9f6bf64b5 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -85,6 +86,8 @@ public: pajlada::Signals::Signal mouseDown; pajlada::Signals::NoArgSignal selectionChanged; pajlada::Signals::Signal tabHighlightRequested; + pajlada::Signals::Signal> + tabHighlightColorRequested; pajlada::Signals::NoArgSignal liveStatusChanged; pajlada::Signals::Signal linkClicked; pajlada::Signals::Signal joinToChannel; diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index e82424ecd..145657348 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -190,6 +190,7 @@ void NotebookTab::setSelected(bool value) this->selected_ = value; this->highlightState_ = HighlightState::None; + this->highlightColor_ = nullptr; this->update(); } @@ -219,7 +220,8 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle) { return; } - if (this->highlightState_ != HighlightState::Highlighted) + if (this->highlightState_ != HighlightState::Highlighted && + this->highlightColor_ == nullptr) { this->highlightState_ = newHighlightStyle; @@ -238,6 +240,15 @@ bool NotebookTab::hasHighlightsEnabled() const return this->highlightEnabled_; } +void NotebookTab::setHighlightColor(std::shared_ptr color) +{ + if (this->highlightColor_ != color) + { + this->highlightColor_ = color; + this->update(); + } +} + QRect NotebookTab::getDesiredRect() const { return QRect(this->positionAnimationDesiredPoint_, size()); @@ -317,6 +328,15 @@ void NotebookTab::paintEvent(QPaintEvent *) painter.fillRect(bgRect, tabBackground); + if (this->highlightColor_ != nullptr) + { + auto col = *this->highlightColor_.get(); + col.setAlpha(255); + colors.line.regular = col; + colors.line.hover = col; + colors.line.unfocused = col; + } + // top line painter.fillRect( QRectF(0, ceil((this->selected_ ? 0.f : 1.f) * scale), this->width(), diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index 70d251d2e..ded809878 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -4,6 +4,7 @@ #include "widgets/BaseWidget.hpp" #include "widgets/helper/Button.hpp" +#include #include #include #include @@ -45,6 +46,7 @@ public: void setHighlightState(HighlightState style); void setHighlightsEnabled(const bool &newVal); bool hasHighlightsEnabled() const; + void setHighlightColor(std::shared_ptr color); void moveAnimated(QPoint pos, bool animated = true); @@ -95,6 +97,7 @@ private: HighlightState highlightState_ = HighlightState::None; bool highlightEnabled_ = true; QAction *highlightNewMessagesAction_; + std::shared_ptr highlightColor_; bool isLive_{}; diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index 004cb0d1e..c14143dcb 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -207,6 +207,12 @@ void SplitContainer::addSplit(Split *split) } }); + split->getChannelView().tabHighlightColorRequested.connect( + [this](std::shared_ptr color) { + if (color != nullptr) + this->tab_->setHighlightColor(color); + }); + split->getChannelView().liveStatusChanged.connect([this]() { this->refreshTabLiveStatus(); // }); @@ -265,6 +271,8 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split) split->getChannelView().tabHighlightRequested.disconnectAll(); + split->getChannelView().tabHighlightColorRequested.disconnectAll(); + return position; } From b38bfd4feb5018a8957bdbbac640fe684ce87b9e Mon Sep 17 00:00:00 2001 From: tuckerrrrrrrrrrrr Date: Sat, 15 Feb 2020 22:40:41 -0800 Subject: [PATCH 2/8] fix tab highlighting when focused --- src/widgets/helper/NotebookTab.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 145657348..c29b98430 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -328,7 +328,8 @@ void NotebookTab::paintEvent(QPaintEvent *) painter.fillRect(bgRect, tabBackground); - if (this->highlightColor_ != nullptr) + if (this->highlightState_ == HighlightState::Highlighted && + this->highlightColor_ != nullptr) { auto col = *this->highlightColor_.get(); col.setAlpha(255); From 5e25722d9ad54afa6e9a6ad8c390199e705c056c Mon Sep 17 00:00:00 2001 From: tuckerrrrrrrrrrrr Date: Sun, 16 Feb 2020 09:45:11 -0800 Subject: [PATCH 3/8] remove pointless condition in setHighlightState I put it there last night and I think I forgot about it :) --- src/widgets/helper/NotebookTab.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index c29b98430..b2f9c44b7 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -220,8 +220,7 @@ void NotebookTab::setHighlightState(HighlightState newHighlightStyle) { return; } - if (this->highlightState_ != HighlightState::Highlighted && - this->highlightColor_ == nullptr) + if (this->highlightState_ != HighlightState::Highlighted) { this->highlightState_ = newHighlightStyle; From e9bebfe788e5bedb56d005f54f94651397c6cc23 Mon Sep 17 00:00:00 2001 From: tuckerrrrrrrrrrrr Date: Sun, 16 Feb 2020 10:27:37 -0800 Subject: [PATCH 4/8] clean up setting tab line color --- src/widgets/helper/NotebookTab.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index b2f9c44b7..d70d7e42e 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -332,9 +332,7 @@ void NotebookTab::paintEvent(QPaintEvent *) { auto col = *this->highlightColor_.get(); col.setAlpha(255); - colors.line.regular = col; - colors.line.hover = col; - colors.line.unfocused = col; + colors.line = {col, col, col}; } // top line From 2a9b8e15c4128395334a92e5a7954773368ae4b7 Mon Sep 17 00:00:00 2001 From: tuckerrrrrrrrrrrr Date: Sat, 14 Mar 2020 09:40:23 -0700 Subject: [PATCH 5/8] Remove tabHighlightColorRequested signal Moved the functionality to tabHighlightRequested instead of having two signals that modify similar things --- src/widgets/helper/ChannelView.cpp | 8 ++++---- src/widgets/helper/ChannelView.hpp | 5 ++--- src/widgets/splits/SplitContainer.cpp | 10 +++------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 34d6cb8a9..95233084e 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -651,13 +651,13 @@ void ChannelView::messageAppended(MessagePtr &message, if (messageFlags->has(MessageFlag::Highlighted) && !messageFlags->has(MessageFlag::Subscription)) { - this->tabHighlightRequested.invoke(HighlightState::Highlighted); - this->tabHighlightColorRequested.invoke(message->highlightColor); + this->tabHighlightRequested.invoke(HighlightState::Highlighted, + message->highlightColor); } else { - this->tabHighlightRequested.invoke(HighlightState::NewMessage); - this->tabHighlightColorRequested.invoke(nullptr); + this->tabHighlightRequested.invoke(HighlightState::NewMessage, + nullptr); } } diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 9f6bf64b5..70f9264cf 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -85,9 +85,8 @@ public: pajlada::Signals::Signal mouseDown; pajlada::Signals::NoArgSignal selectionChanged; - pajlada::Signals::Signal tabHighlightRequested; - pajlada::Signals::Signal> - tabHighlightColorRequested; + pajlada::Signals::Signal> + tabHighlightRequested; pajlada::Signals::NoArgSignal liveStatusChanged; pajlada::Signals::Signal linkClicked; pajlada::Signals::Signal joinToChannel; diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index c14143dcb..5cc218eac 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -200,17 +200,15 @@ void SplitContainer::addSplit(Split *split) this->refreshTab(); split->getChannelView().tabHighlightRequested.connect( - [this](HighlightState state) { + [this](HighlightState state, std::shared_ptr color) { if (this->tab_ != nullptr) { this->tab_->setHighlightState(state); } - }); - - split->getChannelView().tabHighlightColorRequested.connect( - [this](std::shared_ptr color) { if (color != nullptr) + { this->tab_->setHighlightColor(color); + } }); split->getChannelView().liveStatusChanged.connect([this]() { @@ -271,8 +269,6 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split) split->getChannelView().tabHighlightRequested.disconnectAll(); - split->getChannelView().tabHighlightColorRequested.disconnectAll(); - return position; } From 50b2decd1baaf15cf345e478a57eb6a7c6ba2d46 Mon Sep 17 00:00:00 2001 From: tuckerrrrrrrrrrrr Date: Sun, 15 Mar 2020 07:11:16 -0700 Subject: [PATCH 6/8] Check tabHighlightRequested color in safer scope The little bit that set the tab's highlight color never checked whether the tab was a nullptr or not i'm a little silly --- src/widgets/splits/SplitContainer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index 5cc218eac..311d7d3ca 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -204,10 +204,11 @@ void SplitContainer::addSplit(Split *split) if (this->tab_ != nullptr) { this->tab_->setHighlightState(state); - } - if (color != nullptr) - { - this->tab_->setHighlightColor(color); + + if (color != nullptr) + { + this->tab_->setHighlightColor(color); + } } }); From 16042e7f8adf7481427230dd303d6d6c9422baf4 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 28 Aug 2022 12:56:16 +0200 Subject: [PATCH 7/8] Change fallback highlight color This makes the color look almost identical in highlights, but completely identical in tab highlights --- src/controllers/highlights/HighlightPhrase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/highlights/HighlightPhrase.cpp b/src/controllers/highlights/HighlightPhrase.cpp index ab8436c31..e6e479692 100644 --- a/src/controllers/highlights/HighlightPhrase.cpp +++ b/src/controllers/highlights/HighlightPhrase.cpp @@ -9,7 +9,7 @@ namespace { } // namespace -QColor HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR = QColor(127, 63, 73, 127); +QColor HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR = QColor(238, 97, 102, 65); QColor HighlightPhrase::FALLBACK_REDEEMED_HIGHLIGHT_COLOR = QColor(28, 126, 141, 60); QColor HighlightPhrase::FALLBACK_FIRST_MESSAGE_HIGHLIGHT_COLOR = From 8d9617df96df186a0a211f27546990c399d8c71c Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 28 Aug 2022 12:56:59 +0200 Subject: [PATCH 8/8] Remove unneccesary dereference of the highlightcolor --- src/widgets/helper/NotebookTab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index cc00ab950..0dce3e286 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -414,7 +414,7 @@ void NotebookTab::paintEvent(QPaintEvent *) if (this->highlightState_ == HighlightState::Highlighted && this->highlightColor_ != nullptr) { - auto col = *this->highlightColor_.get(); + QColor col = *this->highlightColor_; col.setAlpha(255); colors.line = {col, col, col}; }