From c15702cf3b3d8bb7e756a516e9a7d925df3b29c9 Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Sun, 26 Sep 2021 21:05:03 -0500 Subject: [PATCH] Finish implementing gauge --- assets/themes/0_Dark.json | 4 ++-- assets/themes/1_Light.json | 2 +- src/Misc/ThemeManager.cpp | 10 +++++----- src/Misc/ThemeManager.h | 8 ++++---- src/Widgets/Bar.cpp | 8 ++++---- src/Widgets/Gauge.cpp | 5 +++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/assets/themes/0_Dark.json b/assets/themes/0_Dark.json index 209b6f4a..6c4b63fc 100644 --- a/assets/themes/0_Dark.json +++ b/assets/themes/0_Dark.json @@ -49,7 +49,7 @@ "widgetIndicator2":"#d72d60", "widgetIndicator3":"#2d6073", "widgetAlternativeBackground":"#121218", - "widgetControlBackground":"#111111", + "widgetControlBackground":"#bebebe", "gyroSky":"#5c93c5", "gyroText":"#ffffff", "gyroGround":"#7d5233", @@ -61,7 +61,7 @@ "mapSkyHighAltitude":"#283e51", "connectButtonChecked":"#d72d60", "connectButtonUnchecked":"#2eed5c", - "barWidgetColors":[ + "widgetColors":[ "#f94144", "#f3722c", "#f8961e", diff --git a/assets/themes/1_Light.json b/assets/themes/1_Light.json index 71a9ccfe..a3239452 100644 --- a/assets/themes/1_Light.json +++ b/assets/themes/1_Light.json @@ -61,7 +61,7 @@ "mapSkyHighAltitude":"#283e51", "connectButtonChecked":"#fe696e", "connectButtonUnchecked":"#26cd40", - "barWidgetColors":[ + "widgetColors":[ "#f94144", "#f3722c", "#f8961e", diff --git a/src/Misc/ThemeManager.cpp b/src/Misc/ThemeManager.cpp index 1fcacd61..ce0e472c 100644 --- a/src/Misc/ThemeManager.cpp +++ b/src/Misc/ThemeManager.cpp @@ -193,10 +193,10 @@ void ThemeManager::loadTheme(const int id) // clang-format on // Read bar widget colors - m_barWidgetColors.clear(); - auto list = colors.value("barWidgetColors").toArray(); + m_widgetColors.clear(); + auto list = colors.value("widgetColors").toArray(); for (int i = 0; i < list.count(); ++i) - m_barWidgetColors.append(list.at(i).toString()); + m_widgetColors.append(list.at(i).toString()); // Update application palette QPalette palette; @@ -556,9 +556,9 @@ QColor ThemeManager::connectButtonUnchecked() const return m_connectButtonUnchecked; } -QStringList ThemeManager::barWidgetColors() const +QStringList ThemeManager::widgetColors() const { - return m_barWidgetColors; + return m_widgetColors; } QStringList ThemeManager::availableThemes() const diff --git a/src/Misc/ThemeManager.h b/src/Misc/ThemeManager.h index 0320a48d..0caa99f4 100644 --- a/src/Misc/ThemeManager.h +++ b/src/Misc/ThemeManager.h @@ -213,8 +213,8 @@ class ThemeManager : public QObject Q_PROPERTY(QColor connectButtonUnchecked READ connectButtonUnchecked NOTIFY themeChanged) - Q_PROPERTY(QStringList barWidgetColors - READ barWidgetColors + Q_PROPERTY(QStringList widgetColors + READ widgetColors NOTIFY themeChanged) Q_PROPERTY(QStringList availableThemes READ availableThemes @@ -290,7 +290,7 @@ public: QColor connectButtonChecked() const; QColor connectButtonUnchecked() const; - QStringList barWidgetColors() const; + QStringList widgetColors() const; QStringList availableThemes() const; public slots: @@ -368,7 +368,7 @@ private: QColor m_mapSkyHighAltitude; QColor m_connectButtonChecked; QColor m_connectButtonUnchecked; - QStringList m_barWidgetColors; + QStringList m_widgetColors; }; } diff --git a/src/Widgets/Bar.cpp b/src/Widgets/Bar.cpp index 451faa1f..dfed673f 100644 --- a/src/Widgets/Bar.cpp +++ b/src/Widgets/Bar.cpp @@ -85,11 +85,11 @@ Bar::Bar(const int index) // Get thermo color QString color; - auto barcl = theme->barWidgetColors(); - if (barcl.count() > m_index) - color = barcl.at(m_index); + auto colors = theme->widgetColors(); + if (colors.count() > m_index) + color = colors.at(m_index); else - color = barcl.at(barcl.count() % m_index); + color = colors.at(colors.count() % m_index); // Configure thermo style m_thermo.setPipeWidth(64); diff --git a/src/Widgets/Gauge.cpp b/src/Widgets/Gauge.cpp index e76afc33..fc026779 100644 --- a/src/Widgets/Gauge.cpp +++ b/src/Widgets/Gauge.cpp @@ -25,6 +25,7 @@ #include "Misc/ThemeManager.h" #include +#include #include #include #include @@ -76,7 +77,7 @@ void GaugeObject::drawScaleContents(QPainter *painter, const QPointF ¢er, // Paint label painter->setFont(labelFont); - painter->setPen(palette().color(QPalette::Highlight)); + painter->setPen(Misc::ThemeManager::getInstance()->widgetIndicator1()); painter->drawText(rect, flags, QString("%1 %2").arg(QString::number(value(), 'f', 2), m_label)); } @@ -98,7 +99,7 @@ Gauge::Gauge(const int index) // Get needle & knob color QString needleColor; - auto colors = theme->barWidgetColors(); + auto colors = theme->widgetColors(); auto knobColor = theme->widgetControlBackground(); if (colors.count() > m_index) needleColor = colors.at(m_index);