From 653e4c6adfbad6505f80bc6456c7e37a0b7fda88 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 18 Apr 2018 09:33:05 +0200 Subject: [PATCH] fixed some light mode issues --- src/widgets/basewidget.cpp | 6 ++++++ src/widgets/basewidget.hpp | 2 ++ src/widgets/helper/splitheader.cpp | 1 - src/widgets/helper/splitinput.cpp | 3 --- src/widgets/selectchanneldialog.cpp | 18 +++++++++++------- src/widgets/selectchanneldialog.hpp | 2 +- src/widgets/settingsdialog.cpp | 13 +++++++++---- src/widgets/settingsdialog.hpp | 3 ++- src/widgets/window.cpp | 2 -- 9 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/widgets/basewidget.cpp b/src/widgets/basewidget.cpp index 4f1cedef8..a33ec288a 100644 --- a/src/widgets/basewidget.cpp +++ b/src/widgets/basewidget.cpp @@ -112,6 +112,12 @@ void BaseWidget::childEvent(QChildEvent *event) } } +void BaseWidget::showEvent(QShowEvent *) +{ + this->scaleChangedEvent(this->getScale()); + this->themeRefreshEvent(); +} + void BaseWidget::setScale(float value) { // update scale value diff --git a/src/widgets/basewidget.hpp b/src/widgets/basewidget.hpp index 32dafa1bb..4b1e3f5fb 100644 --- a/src/widgets/basewidget.hpp +++ b/src/widgets/basewidget.hpp @@ -41,6 +41,8 @@ protected: virtual void scaleChangedEvent(float newScale); virtual void themeRefreshEvent(); + virtual void showEvent(QShowEvent *) override; + void setScale(float value); private: diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index f67863023..28927d88b 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -74,7 +74,6 @@ SplitHeader::SplitHeader(Split *_split) // ---- misc this->layout()->setMargin(0); - this->themeRefreshEvent(); this->scaleChangedEvent(this->getScale()); this->updateChannelText(); diff --git a/src/widgets/helper/splitinput.cpp b/src/widgets/helper/splitinput.cpp index 69a94e185..79cf1e9c2 100644 --- a/src/widgets/helper/splitinput.cpp +++ b/src/widgets/helper/splitinput.cpp @@ -31,7 +31,6 @@ SplitInput::SplitInput(Split *_chatWidget) // misc this->installKeyPressedEvent(); - this->themeRefreshEvent(); this->scaleChangedEvent(this->getScale()); } @@ -112,8 +111,6 @@ void SplitInput::scaleChangedEvent(float scale) // set maximum height this->setMaximumHeight((int)(150 * this->getScale())); - - this->themeRefreshEvent(); } void SplitInput::themeRefreshEvent() diff --git a/src/widgets/selectchanneldialog.cpp b/src/widgets/selectchanneldialog.cpp index f118c3041..b4a045d3d 100644 --- a/src/widgets/selectchanneldialog.cpp +++ b/src/widgets/selectchanneldialog.cpp @@ -123,8 +123,6 @@ SelectChannelDialog::SelectChannelDialog() this->setScaleIndependantSize(300, 210); - this->setStyleSheet("QRadioButton { color: #fff } QLabel { color: #fff }"); - // Shortcuts auto *shortcut_ok = new QShortcut(QKeySequence("Return"), this); QObject::connect(shortcut_ok, &QShortcut::activated, [=] { this->ok(); }); @@ -255,15 +253,21 @@ bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *eve return false; } -void SelectChannelDialog::SelectChannelDialog::showEvent(QShowEvent *) -{ - // QTimer::singleShot(100, [=] { this->setSelectedChannel(this->selectedChannel); }); -} - void SelectChannelDialog::closeEvent(QCloseEvent *) { this->closed.invoke(); } +void SelectChannelDialog::themeRefreshEvent() +{ + BaseWindow::themeRefreshEvent(); + + if (this->themeManager.isLightTheme()) { + this->setStyleSheet("QRadioButton { color: #000 } QLabel { color: #000 }"); + } else { + this->setStyleSheet("QRadioButton { color: #fff } QLabel { color: #fff }"); + } +} + } // namespace widgets } // namespace chatterino diff --git a/src/widgets/selectchanneldialog.hpp b/src/widgets/selectchanneldialog.hpp index 3517b5810..96b78dec0 100644 --- a/src/widgets/selectchanneldialog.hpp +++ b/src/widgets/selectchanneldialog.hpp @@ -25,7 +25,7 @@ public: protected: virtual void closeEvent(QCloseEvent *) override; - virtual void showEvent(QShowEvent *) override; + virtual void themeRefreshEvent() override; private: class EventFilter : public QObject diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index 039c6ee8b..abdeb24a3 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -56,10 +56,6 @@ void SettingsDialog::initUi() } // ---- misc - QPalette palette; - palette.setColor(QPalette::Background, QColor("#444")); - this->setPalette(palette); - this->ui.tabContainerContainer->setObjectName("tabWidget"); this->ui.pageStack->setObjectName("pages"); @@ -166,6 +162,15 @@ void SettingsDialog::scaleChangedEvent(float newDpi) this->ui.tabContainerContainer->setFixedWidth((int)(200 * newDpi)); } +void SettingsDialog::themeRefreshEvent() +{ + BaseWindow::themeRefreshEvent(); + + QPalette palette; + palette.setColor(QPalette::Background, QColor("#444")); + this->setPalette(palette); +} + // void SettingsDialog::setChildrensFont(QLayout *object, QFont &font, int indent) //{ // // for (QWidget *widget : this->widgets) { diff --git a/src/widgets/settingsdialog.hpp b/src/widgets/settingsdialog.hpp index 362809cf0..d5750d4f3 100644 --- a/src/widgets/settingsdialog.hpp +++ b/src/widgets/settingsdialog.hpp @@ -32,7 +32,8 @@ public: static void showDialog(PreferredTab preferredTab = PreferredTab::NoPreference); protected: - void scaleChangedEvent(float newDpi) override; + virtual void scaleChangedEvent(float newDpi) override; + virtual void themeRefreshEvent() override; private: void refresh(); diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 0b9911f45..31aff5a61 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -61,8 +61,6 @@ Window::Window(singletons::ThemeManager &_themeManager, WindowType _type) // set margin layout->setMargin(0); - this->themeRefreshEvent(); - /// Initialize program-wide hotkeys // CTRL+P: Open Settings Dialog CreateWindowShortcut(this, "CTRL+P", [] { SettingsDialog::showDialog(); });