diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp index c39590934..fdae4bdc9 100644 --- a/src/messages/layouts/MessageLayout.cpp +++ b/src/messages/layouts/MessageLayout.cpp @@ -183,10 +183,15 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, // draw last read message line if (isLastReadMessage) { - QColor color = - isWindowFocused - ? app->themes->tabs.selected.backgrounds.regular.color() - : app->themes->tabs.selected.backgrounds.unfocused.color(); + QColor color; + if (getSettings()->lastMessageColor != "") { + color = QColor(getSettings()->lastMessageColor.getValue()); + } else { + color = + isWindowFocused + ? app->themes->tabs.selected.backgrounds.regular.color() + : app->themes->tabs.selected.backgrounds.unfocused.color(); + } QBrush brush(color, static_cast( getSettings()->lastMessagePattern.getValue())); diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 9baab7cdb..6829a0f06 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -33,6 +33,8 @@ public: "/appearance/messages/showLastMessageIndicator", false}; IntSetting lastMessagePattern = {"/appearance/messages/lastMessagePattern", Qt::VerPattern}; + QStringSetting lastMessageColor = {"/appearance/messages/lastMessageColor", + ""}; BoolSetting showEmptyInput = {"/appearance/showEmptyInputBox", true}; BoolSetting showMessageLength = {"/appearance/messages/showMessageLength", false}; diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index 3ec63fc29..2a0eaf208 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -11,6 +11,7 @@ #include "widgets/helper/NotebookButton.hpp" #include "widgets/helper/NotebookTab.hpp" #include "widgets/helper/Shortcut.hpp" +#include "widgets/splits/Split.hpp" #include "widgets/splits/SplitContainer.hpp" #include @@ -490,4 +491,17 @@ SplitContainer *SplitNotebook::getOrAddSelectedPage() : this->addPage(); } +void SplitNotebook::select(QWidget *page) +{ + if (auto selectedPage = this->getSelectedPage()) { + if (auto splitContainer = + dynamic_cast(selectedPage)) { + for (auto split : splitContainer->getSplits()) { + split->updateLastReadMessage(); + } + } + } + this->Notebook::select(page); +} + } // namespace chatterino diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index b0cb22c9d..bf4d33226 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -30,7 +30,7 @@ public: void removeCurrentPage(); int indexOf(QWidget *page) const; - void select(QWidget *page); + virtual void select(QWidget *page); void selectIndex(int index); void selectNextTab(); void selectPreviousTab(); @@ -90,6 +90,7 @@ public: SplitContainer *addPage(bool select = false); SplitContainer *getOrAddSelectedPage(); + void select(QWidget *page) override; private: void addCustomButtons(); diff --git a/src/widgets/settingspages/LookPage.cpp b/src/widgets/settingspages/LookPage.cpp index fbb175c8b..08f447cc0 100644 --- a/src/widgets/settingspages/LookPage.cpp +++ b/src/widgets/settingspages/LookPage.cpp @@ -11,6 +11,7 @@ #include "widgets/helper/ChannelView.hpp" #include "widgets/helper/Line.hpp" +#include #include #include #include @@ -351,11 +352,60 @@ void LookPage::addLastReadMessageIndicatorPatternSelector( }(); }); + // color picker + + QLabel *colorPreview = new QLabel(); + + auto updatePreviewColor = [colorPreview](QColor newColor) { + QPixmap pixmap(16, 16); + pixmap.fill(QColor(0, 0, 0, 255)); + + QPainter painter(&pixmap); + QBrush brush(newColor); + painter.fillRect(1, 1, pixmap.width() - 2, pixmap.height() - 2, brush); + colorPreview->setPixmap(pixmap); + }; + + auto getCurrentColor = []() { + return getSettings()->lastMessageColor != "" + ? QColor(getSettings()->lastMessageColor.getValue()) + : getApp() + ->themes->tabs.selected.backgrounds.regular.color(); + }; + + updatePreviewColor(getCurrentColor()); + + QPushButton *button = new QPushButton("Select Color"); + button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed); + + QObject::connect( + button, &QPushButton::clicked, [updatePreviewColor, getCurrentColor]() { + QColor newColor = QColorDialog::getColor(getCurrentColor()); + if (newColor.isValid()) { + updatePreviewColor(newColor); + getSettings()->lastMessageColor = newColor.name(); + } + }); + + QPushButton *resetButton = new QPushButton("Reset Color"); + resetButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed); + + QObject::connect( + resetButton, &QPushButton::clicked, [updatePreviewColor]() { + QColor defaultColor = + getApp()->themes->tabs.selected.backgrounds.regular.color(); + updatePreviewColor(defaultColor); + getSettings()->lastMessageColor = ""; + }); + // layout auto hbox = layout.emplace().withoutMargin(); hbox.append(this->createCheckBox(LAST_MSG, getSettings()->showLastMessageIndicator)); hbox.append(combo); + hbox.append(colorPreview); + hbox.append(button); + hbox.append(resetButton); hbox->addStretch(1); }