From e87eb7ef088d40563040ba4ebbc12191743881a9 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 7 Apr 2021 18:07:46 +0200 Subject: [PATCH] style usage spacer --- examples/iot-dashboard/Skin.cpp | 4 ++++ examples/iot-dashboard/Usage.cpp | 11 +++++------ examples/iot-dashboard/Usage.h | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/examples/iot-dashboard/Skin.cpp b/examples/iot-dashboard/Skin.cpp index c193325d..050c39e6 100644 --- a/examples/iot-dashboard/Skin.cpp +++ b/examples/iot-dashboard/Skin.cpp @@ -9,6 +9,7 @@ #include "PieChartPainted.h" #include "TopBar.h" #include "UpAndDownButton.h" +#include "Usage.h" #include #include @@ -110,6 +111,9 @@ void Skin::initHints( const Palette& palette ) // content in boxes (indoor temperature, humidity etc.): + ed.setFontRole( UsageSpacer::Text, QskSkin::SmallFont ); + ed.setColor( UsageSpacer::Text, "#dddddd" ); + ed.setPadding( BoxWithButtons::Panel, 8 ); ed.setBoxShape( RoundedIcon::Panel, 6 ); diff --git a/examples/iot-dashboard/Usage.cpp b/examples/iot-dashboard/Usage.cpp index 3762b784..4204d72a 100644 --- a/examples/iot-dashboard/Usage.cpp +++ b/examples/iot-dashboard/Usage.cpp @@ -3,6 +3,8 @@ #include +QSK_SUBCONTROL( UsageSpacer, Text ) + Usage::Usage( QQuickItem* parent ) : Box( "Usage", parent ) { @@ -11,24 +13,21 @@ Usage::Usage( QQuickItem* parent ) auto* today = new QskLinearBox( Qt::Horizontal, content ); auto* todayText = new QskTextLabel( "Usage today", today ); todayText->setFontRole( QskSkin::SmallFont ); - auto* todaySpacer = new QskTextLabel( "_____", today ); - todaySpacer->setTextColor( "#dddddd" ); + new UsageSpacer( today ); auto* todayValue = new QskTextLabel( "0,5 kwH", today ); todayValue->setFontRole( QskSkin::SmallFont ); auto* month = new QskLinearBox( Qt::Horizontal, content ); auto* monthText = new QskTextLabel( "Usage this month", month ); monthText->setFontRole( QskSkin::SmallFont ); - auto* monthSpacer = new QskTextLabel( "_____", month ); - monthSpacer->setTextColor( "#dddddd" ); + new UsageSpacer( month ); auto* monthValue = new QskTextLabel( "66 kwH", month ); monthValue->setFontRole( QskSkin::SmallFont ); auto* total = new QskLinearBox( Qt::Horizontal, content ); auto* totalText = new QskTextLabel( "Total working hours", total ); totalText->setFontRole( QskSkin::SmallFont ); - auto* totalSpacer = new QskTextLabel( "_____", total ); - totalSpacer->setTextColor( "#dddddd" ); + new UsageSpacer( total ); auto* totalValue = new QskTextLabel( "125 hrs", total ); totalValue->setFontRole( QskSkin::SmallFont ); } diff --git a/examples/iot-dashboard/Usage.h b/examples/iot-dashboard/Usage.h index 727c671f..8d9594fa 100644 --- a/examples/iot-dashboard/Usage.h +++ b/examples/iot-dashboard/Usage.h @@ -2,7 +2,33 @@ #define USAGE_H #include "Box.h" + #include +#include + +class UsageSpacer : public QskTextLabel +{ + Q_OBJECT + + public: + QSK_SUBCONTROLS( Text ) + + UsageSpacer( QQuickItem* parent = nullptr ) + : QskTextLabel( "_____", parent ) + { + } + + QskAspect::Subcontrol effectiveSubcontrol( + QskAspect::Subcontrol subControl ) const override final + { + if( subControl == QskTextLabel::Text ) + { + return Text; + } + + return subControl; + } +}; class Usage : public Box {