diff --git a/examples/iot-dashboard/MenuBar.cpp b/examples/iot-dashboard/MenuBar.cpp index e124a2a2..35853d57 100644 --- a/examples/iot-dashboard/MenuBar.cpp +++ b/examples/iot-dashboard/MenuBar.cpp @@ -8,6 +8,7 @@ #include +QSK_SUBCONTROL( MenuBarTopLabel, Graphic ) QSK_SUBCONTROL( MenuBarGraphicLabel, Graphic ) QSK_SUBCONTROL( MenuBarLabel, Text ) QSK_SUBCONTROL( MenuItem, Panel ) @@ -57,9 +58,8 @@ MenuBar::MenuBar( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent ) auto* mainIcon = ":/images/main-icon.png"; QImage image( mainIcon ); auto graphic = QskGraphic::fromImage( image ); - auto* graphicLabel = new QskGraphicLabel( graphic, this ); - graphicLabel->setAlignment( Qt::AlignTop ); - graphicLabel->setMargins( { 50, 0, 50, 54 } ); + auto* graphicLabel = new MenuBarTopLabel( graphic, this ); + graphicLabel->setMargins( marginHint( MenuBarTopLabel::Graphic ) ); graphicLabel->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); m_entryStrings = { "Dashboard", "Rooms", "Devices", "Statistics", "Storage", "Members" }; diff --git a/examples/iot-dashboard/MenuBar.h b/examples/iot-dashboard/MenuBar.h index b800e755..42e024ea 100644 --- a/examples/iot-dashboard/MenuBar.h +++ b/examples/iot-dashboard/MenuBar.h @@ -5,6 +5,30 @@ #include #include +class MenuBarTopLabel : public QskGraphicLabel +{ + Q_OBJECT + + public: + QSK_SUBCONTROLS( Graphic ) + + MenuBarTopLabel( const QskGraphic& graphic, QQuickItem* parent = nullptr ) + : QskGraphicLabel( graphic, parent ) + { + } + + QskAspect::Subcontrol effectiveSubcontrol( + QskAspect::Subcontrol subControl ) const override final + { + if( subControl == QskGraphicLabel::Graphic ) + { + return Graphic; + } + + return subControl; + } +}; + class MenuBarGraphicLabel : public QskGraphicLabel { Q_OBJECT diff --git a/examples/iot-dashboard/Skin.cpp b/examples/iot-dashboard/Skin.cpp index a06039bd..93effa34 100644 --- a/examples/iot-dashboard/Skin.cpp +++ b/examples/iot-dashboard/Skin.cpp @@ -79,6 +79,8 @@ void Skin::initHints( const Palette& palette ) ed.setColor( MenuBarLabel::Text, Qt::white ); ed.setFontRole( MenuBarLabel::Text, QskSkin::SmallFont ); + ed.setMargin( MenuBarTopLabel::Graphic, { 50, 0, 50, 54 } ); + ed.setAlignment( MenuBarGraphicLabel::Graphic, Qt::AlignCenter ); // top bar: