From b787c350d5c0fcea2ebd92a1a0fc7875694e3296 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Wed, 6 Apr 2022 18:00:16 +0800 Subject: [PATCH] add: theme style name defines --- DSView/pv/config/appconfig.cpp | 4 ++-- DSView/pv/config/appconfig.h | 4 +++- DSView/pv/toolbars/trigbar.cpp | 13 +++++-------- DSView/pv/toolbars/trigbar.h | 4 ---- DSView/pv/ui/dscombobox.cpp | 2 +- DSView/pv/view/devmode.h | 2 +- DSView/pv/widgets/border.cpp | 4 ++-- 7 files changed, 14 insertions(+), 19 deletions(-) diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index fd4036b7..08c69fa6 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -137,7 +137,7 @@ void _saveDockOptions(DockOptions &o, QSettings &st, const char *group){ void _loadFrame(FrameOptions &o, QSettings &st){ st.beginGroup("MainFrame"); - getFiled("style", st, o.style, "dark"); + getFiled("style", st, o.style, THEME_STYLE_DARK); getFiled("language", st, o.language, -1); getFiled("isMax", st, o.isMax, false); getFiled("left", st, o.left, 0); @@ -313,7 +313,7 @@ QString GetIconPath() { QString style = AppConfig::Instance()._frameOptions.style; if (style == ""){ - style = "dark"; + style = THEME_STYLE_DARK; } return ":/icons/" + style; } diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index e68dd203..a78a85eb 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -29,7 +29,9 @@ #define LAN_CN 25 #define LAN_EN 31 -//#define DARK_STYLE "dark" +#define THEME_STYLE_DARK "dark" +#define THEME_STYLE_LIGHT "light" + #define APP_NAME "DSView" //--------------------api--- diff --git a/DSView/pv/toolbars/trigbar.cpp b/DSView/pv/toolbars/trigbar.cpp index 202eb572..211892ac 100755 --- a/DSView/pv/toolbars/trigbar.cpp +++ b/DSView/pv/toolbars/trigbar.cpp @@ -36,10 +36,7 @@ namespace pv { namespace toolbars { - -const QString TrigBar::DARK_STYLE = "dark"; -const QString TrigBar::LIGHT_STYLE = "light"; - + TrigBar::TrigBar(SigSession *session, QWidget *parent) : QToolBar("Trig Bar", parent), _session(session), @@ -326,15 +323,15 @@ void TrigBar::on_actionMath_triggered() void TrigBar::on_actionDark_triggered() { - sig_setTheme(DARK_STYLE); - QString icon = GetIconPath() + "/" + DARK_STYLE + ".svg"; + sig_setTheme(THEME_STYLE_DARK); + QString icon = GetIconPath() + "/" + THEME_STYLE_DARK + ".svg"; _themes->setIcon(QIcon(icon)); } void TrigBar::on_actionLight_triggered() { - sig_setTheme(LIGHT_STYLE); - QString icon = GetIconPath() + "/" + LIGHT_STYLE +".svg"; + sig_setTheme(THEME_STYLE_LIGHT); + QString icon = GetIconPath() + "/" + THEME_STYLE_LIGHT +".svg"; _themes->setIcon(QIcon(icon)); } diff --git a/DSView/pv/toolbars/trigbar.h b/DSView/pv/toolbars/trigbar.h index 68f6c219..06add2a8 100755 --- a/DSView/pv/toolbars/trigbar.h +++ b/DSView/pv/toolbars/trigbar.h @@ -42,10 +42,6 @@ class TrigBar : public QToolBar { Q_OBJECT -protected: - static const QString DARK_STYLE; - static const QString LIGHT_STYLE; - public: explicit TrigBar(SigSession *session, QWidget *parent = 0); diff --git a/DSView/pv/ui/dscombobox.cpp b/DSView/pv/ui/dscombobox.cpp index 6e7343bb..cc3e38c5 100644 --- a/DSView/pv/ui/dscombobox.cpp +++ b/DSView/pv/ui/dscombobox.cpp @@ -65,7 +65,7 @@ DsComboBox::DsComboBox(QWidget *parent) : QComboBox(parent) int h = rc.bottom() - rc.top() + 15; popup->setGeometry(x, y, w, h); - if (AppConfig::Instance()._frameOptions.style == "dark"){ + if (AppConfig::Instance()._frameOptions.style == THEME_STYLE_DARK){ popup->setStyleSheet("background-color:#262626;"); } else{ diff --git a/DSView/pv/view/devmode.h b/DSView/pv/view/devmode.h index 0d148da6..8ad6bbd0 100755 --- a/DSView/pv/view/devmode.h +++ b/DSView/pv/view/devmode.h @@ -55,7 +55,7 @@ private: static const int GRID_COLS = 3; public: - DevMode(QWidget *parent, SigSession *ession); + DevMode(QWidget *parent, SigSession *session); private: void paintEvent(QPaintEvent *event); diff --git a/DSView/pv/widgets/border.cpp b/DSView/pv/widgets/border.cpp index 79737213..25d55439 100755 --- a/DSView/pv/widgets/border.cpp +++ b/DSView/pv/widgets/border.cpp @@ -59,7 +59,7 @@ void Border::paintEvent(QPaintEvent *) AppConfig &app = AppConfig::Instance(); QString style = app._frameOptions.style; - if (style == "dark") { + if (style == THEME_STYLE_DARK) { linearGrad.setColorAt(0, dark_border0); linearGrad.setColorAt(0.25, dark_border1); linearGrad.setColorAt(0.5, dark_border2); @@ -74,7 +74,7 @@ void Border::paintEvent(QPaintEvent *) } QRadialGradient radialGrad(QPointF(0, 0), width()); - if (style == "dark") { + if (style == THEME_STYLE_DARK) { radialGrad.setColorAt(0, dark_border0); radialGrad.setColorAt(0.25, dark_border1); radialGrad.setColorAt(0.5, dark_border2);