From c74845e56286d39e326dcbb0b3868064b9b6bacd Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 31 Mar 2021 17:50:57 +0200 Subject: [PATCH] simplify temperature and humidity --- examples/iot-dashboard/BoxWithButtons.cpp | 4 +++- examples/iot-dashboard/BoxWithButtons.h | 27 +++++++++++++++++++++++ examples/iot-dashboard/RoundedIcon.cpp | 4 ++-- examples/iot-dashboard/RoundedIcon.h | 13 +++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/examples/iot-dashboard/BoxWithButtons.cpp b/examples/iot-dashboard/BoxWithButtons.cpp index 970e10b6..e42dea83 100644 --- a/examples/iot-dashboard/BoxWithButtons.cpp +++ b/examples/iot-dashboard/BoxWithButtons.cpp @@ -6,6 +6,8 @@ #include +QSK_SUBCONTROL( BigRoundedIcon, Panel ) + QSK_SUBCONTROL( BoxWithButtons, Panel ) BoxWithButtons::BoxWithButtons( const QString& title, const QskGradient& gradient, QQuickItem* parent ) @@ -19,7 +21,7 @@ BoxWithButtons::BoxWithButtons( const QString& title, const QskGradient& gradien QString iconFile = title.toLower(); iconFile = iconFile.replace( ' ', '-' ); - auto* icon = new RoundedIcon( iconFile, gradient, layout ); + auto* icon = new BigRoundedIcon( iconFile, gradient, layout ); icon->setFixedSize( 68, 68 ); // ### fix properly auto* titleAndValue = new QskLinearBox( Qt::Vertical, layout ); diff --git a/examples/iot-dashboard/BoxWithButtons.h b/examples/iot-dashboard/BoxWithButtons.h index f101fcb0..fd6438e0 100644 --- a/examples/iot-dashboard/BoxWithButtons.h +++ b/examples/iot-dashboard/BoxWithButtons.h @@ -2,6 +2,33 @@ #define BOXWITHBUTTONS_H #include "Box.h" +#include "RoundedIcon.h" + +#include + +class BigRoundedIcon : public RoundedIcon +{ + public: + QSK_SUBCONTROLS( Panel ) + + BigRoundedIcon( const QString& iconName, const QskGradient& gradient, QQuickItem* parent = nullptr ) + : RoundedIcon( iconName, gradient, parent ) + { + setGradientHint( Panel, gradient ); + setBoxShapeHint( Panel, 6 ); + } + + QskAspect::Subcontrol effectiveSubcontrol( + QskAspect::Subcontrol subControl ) const override final + { + if( subControl == QskBox::Panel ) + { + return Panel; + } + + return subControl; + } +}; class BoxWithButtons : public Box { diff --git a/examples/iot-dashboard/RoundedIcon.cpp b/examples/iot-dashboard/RoundedIcon.cpp index cee58e4b..f902c804 100644 --- a/examples/iot-dashboard/RoundedIcon.cpp +++ b/examples/iot-dashboard/RoundedIcon.cpp @@ -6,6 +6,8 @@ #include +QSK_SUBCONTROL( RoundedIcon, Panel ) + RoundedIcon::RoundedIcon( const QString& iconName, const QskGradient& gradient, QQuickItem* parent ) : QskBox( parent ) , m_iconName( iconName ) @@ -13,8 +15,6 @@ RoundedIcon::RoundedIcon( const QString& iconName, const QskGradient& gradient, { setPanel( true ); setPolishOnResize( true ); - setGradientHint( Panel, gradient ); - setBoxShapeHint( Panel, 6 ); setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Constrained ); diff --git a/examples/iot-dashboard/RoundedIcon.h b/examples/iot-dashboard/RoundedIcon.h index 2c4f7a13..9f1b429f 100644 --- a/examples/iot-dashboard/RoundedIcon.h +++ b/examples/iot-dashboard/RoundedIcon.h @@ -11,8 +11,21 @@ class RoundedIcon : public QskBox Q_OBJECT public: + QSK_SUBCONTROLS( Panel ) + RoundedIcon( const QString& iconName, const QskGradient& gradient, QQuickItem* parent = nullptr ); + QskAspect::Subcontrol effectiveSubcontrol( + QskAspect::Subcontrol subControl ) const override + { + if( subControl == QskBox::Panel ) + { + return Panel; + } + + return subControl; + } + protected: void updateLayout() override; virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;