From 2db80364b130c894b70aea4c22c6ab91d76d8653 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 7 Apr 2021 16:03:36 +0200 Subject: [PATCH] style button boxes some more --- examples/iot-dashboard/BoxWithButtons.cpp | 5 +++-- examples/iot-dashboard/BoxWithButtons.h | 25 +++++++++++++++++++++++ examples/iot-dashboard/Skin.cpp | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/examples/iot-dashboard/BoxWithButtons.cpp b/examples/iot-dashboard/BoxWithButtons.cpp index 58b55e51..131d77d5 100644 --- a/examples/iot-dashboard/BoxWithButtons.cpp +++ b/examples/iot-dashboard/BoxWithButtons.cpp @@ -8,6 +8,8 @@ QSK_SUBCONTROL( ButtonValueLabel, Text ) +QSK_SUBCONTROL( TitleAndValueBox, Panel ) + QSK_SUBCONTROL( BoxWithButtons, Panel ) QSK_SUBCONTROL( IndoorTemperature, Panel ) @@ -26,8 +28,7 @@ BoxWithButtons::BoxWithButtons( const QString& title, const QString& value, bool iconFile = iconFile.replace( ' ', '-' ); new RoundedIcon( iconFile, isBright, false, layout ); - auto* titleAndValue = new QskLinearBox( Qt::Vertical, layout ); - titleAndValue->setMargins( {0, 10, 0, 0} ); + auto* titleAndValue = new TitleAndValueBox( Qt::Vertical, layout ); auto* titleLabel = new QskTextLabel( title, titleAndValue ); titleLabel->setFontRole( Skin::TitleFont ); diff --git a/examples/iot-dashboard/BoxWithButtons.h b/examples/iot-dashboard/BoxWithButtons.h index c413b9f8..3fc5d4ce 100644 --- a/examples/iot-dashboard/BoxWithButtons.h +++ b/examples/iot-dashboard/BoxWithButtons.h @@ -30,6 +30,31 @@ class ButtonValueLabel : public QskTextLabel } }; +class TitleAndValueBox : public QskLinearBox +{ + Q_OBJECT + + public: + QSK_SUBCONTROLS( Panel ) + + TitleAndValueBox( Qt::Orientation orientation, QQuickItem* parent ) + : QskLinearBox( orientation, parent ) + { + setPanel( true ); + } + + QskAspect::Subcontrol effectiveSubcontrol( + QskAspect::Subcontrol subControl ) const override final + { + if( subControl == QskLinearBox::Panel ) + { + return Panel; + } + + return subControl; + } +}; + class BoxWithButtons : public Box { public: diff --git a/examples/iot-dashboard/Skin.cpp b/examples/iot-dashboard/Skin.cpp index 0ec64cb6..a06039bd 100644 --- a/examples/iot-dashboard/Skin.cpp +++ b/examples/iot-dashboard/Skin.cpp @@ -112,6 +112,8 @@ void Skin::initHints( const Palette& palette ) ed.setFontRole( ButtonValueLabel::Text, QskSkin::HugeFont ); ed.setColor( ButtonValueLabel::Text, "#929cb2" ); + ed.setPadding( TitleAndValueBox::Panel, {0, 10, 0, 0} ); + ed.setStrutSize( RoundButton::Panel, {27, 38} ); ed.setBoxShape( RoundButton::Panel, {0, 0, 30, 30} ); ed.setBoxShape( RoundButton::Panel | RoundButton::Top, {30, 30, 0, 0} );