From cd3a6024b8c7ae4146d8969856a95d7f67510316 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 7 Apr 2021 15:04:52 +0200 Subject: [PATCH] style button value label --- examples/iot-dashboard/BoxWithButtons.cpp | 6 +++--- examples/iot-dashboard/BoxWithButtons.h | 24 +++++++++++++++++++++++ examples/iot-dashboard/Skin.cpp | 2 ++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/examples/iot-dashboard/BoxWithButtons.cpp b/examples/iot-dashboard/BoxWithButtons.cpp index 8a4c8c19..58b55e51 100644 --- a/examples/iot-dashboard/BoxWithButtons.cpp +++ b/examples/iot-dashboard/BoxWithButtons.cpp @@ -6,6 +6,8 @@ #include +QSK_SUBCONTROL( ButtonValueLabel, Text ) + QSK_SUBCONTROL( BoxWithButtons, Panel ) QSK_SUBCONTROL( IndoorTemperature, Panel ) @@ -30,9 +32,7 @@ BoxWithButtons::BoxWithButtons( const QString& title, const QString& value, bool auto* titleLabel = new QskTextLabel( title, titleAndValue ); titleLabel->setFontRole( Skin::TitleFont ); - auto* valueLabel = new QskTextLabel( value, titleAndValue ); - valueLabel->setFontRole( QskSkin::HugeFont ); - valueLabel->setTextColor( "#929CB2" ); + new ButtonValueLabel( value, titleAndValue ); new UpAndDownButton( layout ); } diff --git a/examples/iot-dashboard/BoxWithButtons.h b/examples/iot-dashboard/BoxWithButtons.h index a81cf2ee..c413b9f8 100644 --- a/examples/iot-dashboard/BoxWithButtons.h +++ b/examples/iot-dashboard/BoxWithButtons.h @@ -5,6 +5,30 @@ #include "RoundedIcon.h" #include +#include + +class ButtonValueLabel : public QskTextLabel +{ + Q_OBJECT + + public: + QSK_SUBCONTROLS( Text ) + + ButtonValueLabel( const QString& text, QQuickItem* parent ) : QskTextLabel( text, parent ) + { + } + + QskAspect::Subcontrol effectiveSubcontrol( + QskAspect::Subcontrol subControl ) const override final + { + if( subControl == QskTextLabel::Text ) + { + return Text; + } + + return subControl; + } +}; class BoxWithButtons : public Box { diff --git a/examples/iot-dashboard/Skin.cpp b/examples/iot-dashboard/Skin.cpp index f0f8b6b1..e11ed558 100644 --- a/examples/iot-dashboard/Skin.cpp +++ b/examples/iot-dashboard/Skin.cpp @@ -100,6 +100,8 @@ void Skin::initHints( const Palette& palette ) ed.setColor( TimeLabel::Text, "#6776FF" ); // content in boxes (indoor temperature, humidity etc.): + ed.setFontRole( ButtonValueLabel::Text, QskSkin::HugeFont ); + ed.setColor( ButtonValueLabel::Text, "#929cb2" ); ed.setPadding( BoxWithButtons::Panel, 8 ); ed.setBoxShape( RoundedIcon::Panel, 6 );