From 111e49ffd7f9847d9b65815c44fe3e9a6ec6f9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Sat, 27 Jan 2024 22:29:29 +0100 Subject: [PATCH] Minor theme changes --- src/powerkit_dialog.cpp | 8 +------- src/powerkit_systray.cpp | 22 +--------------------- src/powerkit_theme.cpp | 25 +++++++++++++++++++++++++ src/powerkit_theme.h | 1 + 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/powerkit_dialog.cpp b/src/powerkit_dialog.cpp index 9b7d7a6..7eda58e 100644 --- a/src/powerkit_dialog.cpp +++ b/src/powerkit_dialog.cpp @@ -51,13 +51,6 @@ Dialog::Dialog(QWidget *parent, , resumeLockScreen(nullptr) , bypassKernel(nullptr) { - -#if QT_VERSION >= 0x050000 - qApp->setStyle("Fusion"); -#else - qApp->setStyle("Clearlooks"); -#endif - // setup dialog if (quitOnClose) { setAttribute(Qt::WA_QuitOnClose, true); } setWindowTitle(tr("Power Manager")); @@ -81,6 +74,7 @@ Dialog::Dialog(QWidget *parent, PowerSettings::getConf(); // setup theme + Theme::setAppTheme(); Theme::setIconTheme(); setWindowIcon(QIcon::fromTheme(DEFAULT_AC_ICON)); diff --git a/src/powerkit_systray.cpp b/src/powerkit_systray.cpp index e6b97f3..9705dd0 100644 --- a/src/powerkit_systray.cpp +++ b/src/powerkit_systray.cpp @@ -85,27 +85,6 @@ SysTray::SysTray(QObject *parent) , pstateMaxSlider(nullptr) , pstateTurboCheckbox(nullptr) { - // TODO: we should not force theme - qApp->setStyle("Fusion"); - // set (dark) colors - QPalette palette; - palette.setColor(QPalette::Window, QColor(53,53,53)); - palette.setColor(QPalette::WindowText, Qt::white); - palette.setColor(QPalette::Base, QColor(15,15,15)); - palette.setColor(QPalette::AlternateBase, QColor(53,53,53)); - palette.setColor(QPalette::Link, Qt::white); - palette.setColor(QPalette::LinkVisited, Qt::white); - palette.setColor(QPalette::ToolTipText, Qt::black); - palette.setColor(QPalette::Text, Qt::white); - palette.setColor(QPalette::Button, QColor(53,53,53)); - palette.setColor(QPalette::ButtonText, Qt::white); - palette.setColor(QPalette::BrightText, Qt::red); - palette.setColor(QPalette::Highlight, QColor(196,110,33)); - palette.setColor(QPalette::HighlightedText, Qt::white); - palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray); - palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray); - qApp->setPalette(palette); - // setup tray tray = new TrayIcon(this); connect(tray, @@ -226,6 +205,7 @@ SysTray::SysTray(QObject *parent) PowerSettings::getConf(); // setup theme + Theme::setAppTheme(); Theme::setIconTheme(); if (tray->icon().isNull()) { tray->setIcon(QIcon::fromTheme(DEFAULT_BATTERY_ICON)); diff --git a/src/powerkit_theme.cpp b/src/powerkit_theme.cpp index 51cfde0..3bc4d73 100644 --- a/src/powerkit_theme.cpp +++ b/src/powerkit_theme.cpp @@ -12,11 +12,36 @@ #include #include #include +#include #include #include "powerkit_def.h" #include "powerkit_settings.h" +void Theme::setAppTheme() +{ + bool native = PowerSettings::getValue("native_theme", false).toBool(); + if (native) { return; } + qApp->setStyle("Fusion"); + QPalette palette; + palette.setColor(QPalette::Window, QColor(53,53,53)); + palette.setColor(QPalette::WindowText, Qt::white); + palette.setColor(QPalette::Base, QColor(15,15,15)); + palette.setColor(QPalette::AlternateBase, QColor(53,53,53)); + palette.setColor(QPalette::Link, Qt::white); + palette.setColor(QPalette::LinkVisited, Qt::white); + palette.setColor(QPalette::ToolTipText, Qt::black); + palette.setColor(QPalette::Text, Qt::white); + palette.setColor(QPalette::Button, QColor(53,53,53)); + palette.setColor(QPalette::ButtonText, Qt::white); + palette.setColor(QPalette::BrightText, Qt::red); + palette.setColor(QPalette::Highlight, QColor(196,110,33)); + palette.setColor(QPalette::HighlightedText, Qt::white); + palette.setColor(QPalette::Disabled, QPalette::Text, Qt::darkGray); + palette.setColor(QPalette::Disabled, QPalette::ButtonText, Qt::darkGray); + qApp->setPalette(palette); +} + void Theme::setIconTheme() { // setup icon theme search path diff --git a/src/powerkit_theme.h b/src/powerkit_theme.h index 0c18e0a..4707296 100644 --- a/src/powerkit_theme.h +++ b/src/powerkit_theme.h @@ -12,6 +12,7 @@ class Theme { public: + static void setAppTheme(); static void setIconTheme(); };