diff --git a/CHANGELOG.md b/CHANGELOG.md index bd17c715a..ee104f69b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Minor: Changed the English in two rate-limited system messages (#1878) - Minor: Added image for streamer mode in the user popup icon. - Minor: Added vip and unvip buttons. +- Minor: Added settings for displaying where the last message was. - Minor: Commands are now saved upon pressing Ok in the settings window - Minor: Colorized nicknames now enabled by default - Minor: Show channels live now enabled by default diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index cc2d77845..eca85d320 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -65,8 +65,8 @@ public: "h:mm"}; BoolSetting showLastMessageIndicator = { "/appearance/messages/showLastMessageIndicator", false}; - IntSetting lastMessagePattern = {"/appearance/messages/lastMessagePattern", - Qt::VerPattern}; + EnumSetting lastMessagePattern = { + "/appearance/messages/lastMessagePattern", Qt::VerPattern}; QStringSetting lastMessageColor = {"/appearance/messages/lastMessageColor", ""}; BoolSetting showEmptyInput = {"/appearance/showEmptyInputBox", true}; diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 5eb4d7781..3a5a0ff9b 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -14,6 +14,8 @@ #include "util/Helpers.hpp" #include "util/IncognitoBrowser.hpp" #include "widgets/BaseWindow.hpp" +#include "widgets/dialogs/ColorPickerDialog.hpp" +#include "widgets/helper/ColorButton.hpp" #include "widgets/helper/Line.hpp" #define CHROME_EXTENSION_LINK \ @@ -159,6 +161,36 @@ ComboBox *SettingsLayout::addDropdown( return combo; } +ColorButton *SettingsLayout::addColorButton( + const QString &text, const QColor &color, + pajlada::Settings::Setting &setting) +{ + auto colorButton = new ColorButton(color); + auto layout = new QHBoxLayout(); + auto label = new QLabel(text + ":"); + layout->addWidget(label); + layout->addStretch(1); + layout->addWidget(colorButton); + this->addLayout(layout); + QObject::connect( + colorButton, &ColorButton::clicked, [&setting, colorButton]() { + auto dialog = new ColorPickerDialog(QColor(setting)); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + dialog->closed.connect([&setting, colorButton, &dialog] { + QColor selected = dialog->selectedColor(); + + if (selected.isValid()) + { + setting = selected.name(QColor::HexArgb); + colorButton->setColor(selected); + } + }); + }); + + return colorButton; +} + DescriptionLabel *SettingsLayout::addDescription(const QString &text) { auto label = new DescriptionLabel(text); @@ -384,9 +416,34 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addTitle("Messages"); layout.addCheckbox("Separate with lines", s.separateMessages); layout.addCheckbox("Alternate background color", s.alternateMessages); - // layout.addCheckbox("Mark last message you read"); - // layout.addDropdown("Last read message style", {"Default"}); layout.addCheckbox("Show deleted messages", s.hideModerated, true); + layout.addCheckbox("Show last message line", s.showLastMessageIndicator); + layout.addDropdown::type>( + "Last message line style", {"Dotted", "Solid"}, s.lastMessagePattern, + [](int value) { + switch (value) + { + case Qt::VerPattern: + return 0; + case Qt::SolidPattern: + default: + return 1; + } + }, + [](DropdownArgs args) { + switch (args.index) + { + case 0: + return Qt::VerPattern; + case 1: + default: + return Qt::SolidPattern; + } + }, + false); + layout.addColorButton("Last message line color", + QColor(getSettings()->lastMessageColor.getValue()), + getSettings()->lastMessageColor); layout.addCheckbox("Highlight messages redeemed with Channel Points", s.enableRedeemedHighlight); layout.addDropdown( diff --git a/src/widgets/settingspages/GeneralPage.hpp b/src/widgets/settingspages/GeneralPage.hpp index d0dc0e4ed..a74dbb823 100644 --- a/src/widgets/settingspages/GeneralPage.hpp +++ b/src/widgets/settingspages/GeneralPage.hpp @@ -9,6 +9,7 @@ #include "pajlada/signals/signal.hpp" #include "singletons/Settings.hpp" #include "singletons/WindowManager.hpp" +#include "widgets/helper/ColorButton.hpp" #include "widgets/settingspages/SettingsPage.hpp" class QLabel; @@ -72,6 +73,8 @@ public: ComboBox *addDropdown(const QString &text, const QStringList &items, pajlada::Settings::Setting &setting, bool editable = false); + ColorButton *addColorButton(const QString &text, const QColor &color, + pajlada::Settings::Setting &setting); template QPushButton *makeButton(const QString &text, OnClick onClick)