From 642718474c19479208482e08ad61dbf0a42089d2 Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 29 Apr 2023 18:50:13 +0200 Subject: [PATCH] Dim disabled items in context menus (#4423) --- CHANGELOG.md | 1 + resources/qss/settings.qss | 11 +++++++++++ src/singletons/Theme.cpp | 8 ++++++++ src/singletons/Theme.hpp | 2 ++ src/widgets/BaseWindow.cpp | 5 +++++ src/widgets/BaseWindow.hpp | 17 +++++++++-------- src/widgets/dialogs/SettingsDialog.cpp | 7 ++++--- 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4af010239..d53698ae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Bugfix: Fixed emote & badge tooltips not showing up when thumbnails were hidden. (#4509) - Bugfix: Fixed links with invalid IPv4 addresses being parsed. (#4576) - Bugfix: Fixed Icon reverting to default when application is open. (#4577) +- Bugfix: Fixed disabled items in context-menus having a weird text-effect or the default text color. (#4423) - Dev: Disabling precompiled headers on Windows is now tested in CI. (#4472) - Dev: Themes are now stored as JSON files in `resources/themes`. (#4471, #4533) - Dev: Ignore unhandled BTTV user-events. (#4438) diff --git a/resources/qss/settings.qss b/resources/qss/settings.qss index 6d5114423..a191b146d 100644 --- a/resources/qss/settings.qss +++ b/resources/qss/settings.qss @@ -66,3 +66,14 @@ chatterino--NavigationLabel { font-size: 15px; color: #A6DDF4; } + +QMenu { + background: #242424; + border: #555555; + color: #ffffff; + selection-background-color: #555555; +} + +QMenu::item:disabled { + color: #8c7f7f; +} diff --git a/src/singletons/Theme.cpp b/src/singletons/Theme.cpp index 1b4f40cd2..1eec47d16 100644 --- a/src/singletons/Theme.cpp +++ b/src/singletons/Theme.cpp @@ -212,6 +212,14 @@ void Theme::parseFrom(const QJsonObject &root) (this->isLightTheme() ? "#68B1FF" : this->tabs.selected.backgrounds.regular.name()); + this->window.contextMenuStyleSheet = + QStringLiteral("QMenu { background: %1; border: %2; color: %3; " + "selection-background-color: %2; } " + "QMenu::item:disabled { color: #8c7f7f; }") + .arg(splits.input.background.name(QColor::HexArgb), + tabs.selected.backgrounds.regular.name(QColor::HexArgb), + tabs.selected.text.name(QColor::HexArgb)); + // Usercard buttons if (this->isLightTheme()) { diff --git a/src/singletons/Theme.hpp b/src/singletons/Theme.hpp index 034bb799e..e6345f65b 100644 --- a/src/singletons/Theme.hpp +++ b/src/singletons/Theme.hpp @@ -39,6 +39,8 @@ public: struct { QColor background; QColor text; + + QString contextMenuStyleSheet; } window; /// TABS diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index 60365081e..3da6f9aab 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -292,6 +292,11 @@ bool BaseWindow::supportsCustomWindowFrame() void BaseWindow::themeChangedEvent() { + if (!this->flags_.has(BaseWindow::DisableStyleSheet)) + { + this->setStyleSheet(this->theme->window.contextMenuStyleSheet); + } + if (this->hasCustomWindowFrame()) { QPalette palette; diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index 106cc1a3e..c231f26a9 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -24,16 +24,17 @@ class BaseWindow : public BaseWidget Q_OBJECT public: - enum Flags { + enum Flags : uint32_t { None = 0, EnableCustomFrame = 1, - Frameless = 2, - TopMost = 4, - DisableCustomScaling = 8, - FramelessDraggable = 16, - DontFocus = 32, - Dialog = 64, - DisableLayoutSave = 128, + Frameless = (1 << 1), + TopMost = (1 << 2), + DisableCustomScaling = (1 << 3), + FramelessDraggable = (1 << 4), + DontFocus = (1 << 5), + Dialog = (1 << 6), + DisableLayoutSave = (1 << 7), + DisableStyleSheet = (1 << 8), }; enum ActionOnFocusLoss { Nothing, Delete, Close, Hide }; diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 5bd218860..aabd8bc59 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -29,9 +29,10 @@ namespace chatterino { SettingsDialog::SettingsDialog(QWidget *parent) - : BaseWindow({BaseWindow::Flags::DisableCustomScaling, - BaseWindow::Flags::Dialog, BaseWindow::DisableLayoutSave}, - parent) + : BaseWindow( + {BaseWindow::Flags::DisableCustomScaling, BaseWindow::Flags::Dialog, + BaseWindow::DisableLayoutSave, BaseWindow::DisableStyleSheet}, + parent) { this->setObjectName("SettingsDialog"); this->setWindowTitle("Chatterino Settings");