From a70acbfda9b137bb968c441cc3c4fc3ca2a855ef Mon Sep 17 00:00:00 2001 From: nerix Date: Thu, 20 Mar 2025 14:03:46 +0100 Subject: [PATCH] fix: use a palette for dialogs (#6098) --- CHANGELOG.md | 1 + src/singletons/Theme.cpp | 23 +++++++++++++++++++++ src/singletons/Theme.hpp | 3 +++ src/widgets/dialogs/EmotePopup.cpp | 5 +---- src/widgets/dialogs/SelectChannelDialog.cpp | 7 +------ src/widgets/helper/SearchPopup.cpp | 5 +---- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d769cf48..612781e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unversioned - Bugfix: Fixed the channel name input not being focused when opening the select-channel dialog. (#6096) +- Bugfix: Fixed inputs in dialogs not having a border around and padding in them. (#6098) ## 2.5.3-beta.1 diff --git a/src/singletons/Theme.cpp b/src/singletons/Theme.cpp index 0c29d429..a8453c9f 100644 --- a/src/singletons/Theme.cpp +++ b/src/singletons/Theme.cpp @@ -555,6 +555,29 @@ void Theme::parseFrom(const QJsonObject &root, bool isCustomTheme) this->buttons.copy = getResources().buttons.copyLight; this->buttons.pin = getResources().buttons.pinDisabledLight; } + + // This assumes that we never update the application palette + auto palette = QApplication::palette(); + + if (this->isLightTheme()) + { + palette.setColor(QPalette::Window, this->window.background); + palette.setColor(QPalette::Base, {0xe9, 0xe9, 0xe9}); + palette.setColor(QPalette::AlternateBase, {0xe0, 0xe0, 0xe0}); + palette.setColor(QPalette::Button, {0xd9, 0xd9, 0xd9}); + palette.setColor(QPalette::Text, this->window.text); + palette.setColor(QPalette::WindowText, this->window.text); + palette.setColor(QPalette::ButtonText, this->window.text); + palette.setColor(QPalette::BrightText, Qt::red); + palette.setColor(QPalette::ToolTipBase, Qt::white); + palette.setColor(QPalette::ToolTipText, Qt::black); + palette.setColor(QPalette::Link, Qt::blue); + palette.setColor(QPalette::LinkVisited, Qt::magenta); + palette.setColor(QPalette::Highlight, {42, 130, 218}); + palette.setColor(QPalette::HighlightedText, Qt::white); + palette.setColor(QPalette::PlaceholderText, {0x90, 0x90, 0x90}); + } + this->palette = palette; } bool Theme::isAutoReloading() const diff --git a/src/singletons/Theme.hpp b/src/singletons/Theme.hpp index ac9fa070..1ae50797 100644 --- a/src/singletons/Theme.hpp +++ b/src/singletons/Theme.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -155,6 +156,8 @@ public: QPixmap pin; } buttons; + QPalette palette; + void normalizeColor(QColor &color) const; void update(); diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 0807be34..798d41ec 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -667,10 +667,7 @@ void EmotePopup::themeChangedEvent() { BasePopup::themeChangedEvent(); - // NOTE: This currently overrides the QLineEdit's font size. - // If the dialog is open when the theme is changed, things will look a bit off. - // This can be alleviated by us using a single application-wide style sheet for these things. - this->search_->setStyleSheet(this->theme->splits.input.styleSheet); + this->setPalette(getTheme()->palette); } void EmotePopup::closeEvent(QCloseEvent *event) diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index e9109394..236e1937 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -375,12 +375,7 @@ void SelectChannelDialog::themeChangedEvent() { BaseWindow::themeChangedEvent(); - auto &ui = this->ui_; - - // NOTE: This currently overrides the QLineEdit's font size. - // If the dialog is open when the theme is changed, things will look a bit off. - // This can be alleviated by us using a single application-wide style sheet for these things. - ui.channelName->setStyleSheet(this->theme->splits.input.styleSheet); + this->setPalette(getTheme()->palette); } void SelectChannelDialog::scaleChangedEvent(float newScale) diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index 2fce61a8..e63cfae2 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -219,10 +219,7 @@ void SearchPopup::themeChangedEvent() { BasePopup::themeChangedEvent(); - // NOTE: This currently overrides the QLineEdit's font size. - // If the dialog is open when the theme is changed, things will look a bit off. - // This can be alleviated by us using a single application-wide style sheet for these things. - this->searchInput_->setStyleSheet(this->theme->splits.input.styleSheet); + this->setPalette(getTheme()->palette); } void SearchPopup::search()