use different colors
This commit is contained in:
parent
a024cdb4e5
commit
a56ced89c8
|
@ -2,8 +2,9 @@
|
|||
|
||||
#include <QPainter>
|
||||
|
||||
CircularProgressBar::CircularProgressBar(int progress, QQuickItem *parent)
|
||||
CircularProgressBar::CircularProgressBar(const QColor &color, int progress, QQuickItem *parent)
|
||||
: QQuickPaintedItem(parent)
|
||||
, m_color(color)
|
||||
, m_progress(progress)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
class CircularProgressBar : public QQuickPaintedItem
|
||||
{
|
||||
public:
|
||||
CircularProgressBar(int progress, QQuickItem* parent = nullptr);
|
||||
CircularProgressBar(const QColor& color, int progress, QQuickItem* parent = nullptr);
|
||||
|
||||
virtual void paint(QPainter *painter) override;
|
||||
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
#include <QFontMetricsF>
|
||||
#include <QQuickPaintedItem>
|
||||
|
||||
PieChartPainted::PieChartPainted(int progress, int value, QQuickItem *parent)
|
||||
PieChartPainted::PieChartPainted(const QColor &color, int progress, int value, QQuickItem *parent)
|
||||
: QskControl(parent)
|
||||
, m_progressBar(new CircularProgressBar(progress, this))
|
||||
, m_color(color)
|
||||
, m_progressBar(new CircularProgressBar(color, progress, this))
|
||||
, m_progressLabel(new QskTextLabel(this))
|
||||
// , m_numberLabel(new QskTextLabel(QString::number(value), this))
|
||||
// , m_unitLabel(new QskTextLabel("kwH", this))
|
||||
|
@ -18,6 +19,7 @@ PieChartPainted::PieChartPainted(int progress, int value, QQuickItem *parent)
|
|||
auto progressText = QString::number(progress) + " %";
|
||||
m_progressLabel->setText(progressText);
|
||||
m_progressLabel->setFontRole(QskSkin::SmallFont);
|
||||
m_progressLabel->setTextColor(color);
|
||||
}
|
||||
|
||||
QSizeF PieChartPainted::contentsSizeHint(Qt::SizeHint sizeHint, const QSizeF& size) const
|
||||
|
@ -29,7 +31,6 @@ QSizeF PieChartPainted::contentsSizeHint(Qt::SizeHint sizeHint, const QSizeF& si
|
|||
|
||||
void PieChartPainted::updateLayout()
|
||||
{
|
||||
m_progressBar->setColor(Qt::magenta);
|
||||
m_progressBar->setContentsSize(size().toSize());
|
||||
m_progressBar->update();
|
||||
|
||||
|
|
|
@ -11,12 +11,13 @@ class QQuickPaintedItem;
|
|||
class PieChartPainted : public QskControl
|
||||
{
|
||||
public:
|
||||
PieChartPainted(int progress, int value, QQuickItem* parent = nullptr);
|
||||
PieChartPainted(const QColor& color, int progress, int value, QQuickItem* parent = nullptr);
|
||||
|
||||
virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||
void updateLayout() override;
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
CircularProgressBar* m_progressBar;
|
||||
QskTextLabel* m_progressLabel;
|
||||
// QskTextLabel* m_numberLabel;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <QTime>
|
||||
|
||||
TopBarItem::TopBarItem(const QString& name, int progress, int value, QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent ),
|
||||
TopBarItem::TopBarItem(const QString& name, const QColor &color, int progress, int value, QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent ),
|
||||
m_name( name )
|
||||
{
|
||||
setAutoLayoutChildren( true );
|
||||
|
@ -19,7 +19,7 @@ TopBarItem::TopBarItem(const QString& name, int progress, int value, QQuickItem*
|
|||
auto* textLabel = new QskTextLabel( name, this );
|
||||
textLabel->setFontRole(QskSkin::SmallFont); // ### style
|
||||
|
||||
auto* pieChart = new PieChartPainted(progress, value, this);
|
||||
auto* pieChart = new PieChartPainted(color, progress, value, this);
|
||||
}
|
||||
|
||||
TopBar::TopBar(QQuickItem *parent) : QskLinearBox(Qt::Horizontal, parent)
|
||||
|
@ -30,12 +30,13 @@ TopBar::TopBar(QQuickItem *parent) : QskLinearBox(Qt::Horizontal, parent)
|
|||
setFixedHeight(100);
|
||||
|
||||
QStringList itemStrings = { "Living Room", "Bedroom", "Bathroom", "Kitchen" };
|
||||
QColor colors[] = {"#ff3122", "#6776ff", "#f99055", "#6776ff"};
|
||||
int progressValues[] = {25, 45, 15, 86};
|
||||
int values[] = {175, 205, 115, 289};
|
||||
|
||||
for(int a = 0; a < itemStrings.count(); a++)
|
||||
{
|
||||
auto* item = new TopBarItem( itemStrings.at(a), progressValues[a], values[a], this );
|
||||
auto* item = new TopBarItem( itemStrings.at(a), colors[a], progressValues[a], values[a], this );
|
||||
m_entries.append(item);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class TopBarItem : public QskLinearBox
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TopBarItem(const QString& name, int progress, int value, QQuickItem* parent );
|
||||
TopBarItem(const QString& name, const QColor& color, int progress, int value, QQuickItem* parent );
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
|
|
Loading…
Reference in New Issue