Finish implementing gauge

This commit is contained in:
Alex Spataru 2021-09-26 21:05:03 -05:00
parent 728156917c
commit c15702cf3b
6 changed files with 19 additions and 18 deletions

View File

@ -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",

View File

@ -61,7 +61,7 @@
"mapSkyHighAltitude":"#283e51",
"connectButtonChecked":"#fe696e",
"connectButtonUnchecked":"#26cd40",
"barWidgetColors":[
"widgetColors":[
"#f94144",
"#f3722c",
"#f8961e",

View File

@ -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

View File

@ -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;
};
}

View File

@ -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);

View File

@ -25,6 +25,7 @@
#include "Misc/ThemeManager.h"
#include <QPainter>
#include <QApplication>
#include <QResizeEvent>
#include <QwtDialNeedle>
#include <QwtRoundScaleDraw>
@ -76,7 +77,7 @@ void GaugeObject::drawScaleContents(QPainter *painter, const QPointF &center,
// 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);