From 3181270afe59a7e33e3e85ef81254644f6f3727f Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Thu, 5 Aug 2021 11:06:48 +0200 Subject: [PATCH] layout code improved --- examples/iotdashboard/Box.cpp | 8 +- examples/iotdashboard/MainContent.cpp | 2 +- examples/iotdashboard/RoundedIcon.h | 1 - examples/iotdashboard/Skin.cpp | 31 ++- examples/iotdashboard/TopBar.h | 2 - examples/iotdashboard/UsageDiagram.cpp | 257 ++++++++++++++----------- examples/iotdashboard/UsageDiagram.h | 89 +-------- examples/iotdashboard/main.cpp | 22 +-- 8 files changed, 178 insertions(+), 234 deletions(-) diff --git a/examples/iotdashboard/Box.cpp b/examples/iotdashboard/Box.cpp index 2e9d6d2f..d1a254a0 100644 --- a/examples/iotdashboard/Box.cpp +++ b/examples/iotdashboard/Box.cpp @@ -19,9 +19,11 @@ Box::Box( const QString& title, QQuickItem* parent ) setPanel( true ); setSubcontrolProxy( QskBox::Panel, Box::Panel ); - auto label = new QskTextLabel( title, this ); - label->setFontRole( Skin::TitleFont ); - label->setVisible( !title.isEmpty() ); + if ( !title.isEmpty() ) + { + auto label = new QskTextLabel( title, this ); + label->setFontRole( Skin::TitleFont ); + } } #include "moc_Box.cpp" diff --git a/examples/iotdashboard/MainContent.cpp b/examples/iotdashboard/MainContent.cpp index a2f8fe1b..5580c15f 100644 --- a/examples/iotdashboard/MainContent.cpp +++ b/examples/iotdashboard/MainContent.cpp @@ -137,7 +137,7 @@ MainContent::MainContent( QQuickItem* parent ) gridBox->addItem( new IndoorTemperature(), 0, 1 ); gridBox->addItem( new Humidity(), 1, 1 ); gridBox->addItem( new MyDevices(), 0, 2, 2, 1 ); - gridBox->addItem( new UsageDiagram(), 2, 0, 0, 2 ); + gridBox->addItem( new UsageDiagramBox(), 2, 0, 0, 2 ); gridBox->addItem( new LightIntensity(), 2, 2 ); gridBox->setColumnStretchFactor( 0, 37 ); // factors add up to 100 diff --git a/examples/iotdashboard/RoundedIcon.h b/examples/iotdashboard/RoundedIcon.h index ca3091e8..7098d19f 100644 --- a/examples/iotdashboard/RoundedIcon.h +++ b/examples/iotdashboard/RoundedIcon.h @@ -6,7 +6,6 @@ #pragma once #include -#include class QskGraphicLabel; diff --git a/examples/iotdashboard/Skin.cpp b/examples/iotdashboard/Skin.cpp index 74654d11..acf051ab 100644 --- a/examples/iotdashboard/Skin.cpp +++ b/examples/iotdashboard/Skin.cpp @@ -144,49 +144,40 @@ void Skin::initHints( const Palette& palette ) ed.setBoxShape( RoundButton::Panel, {0, 0, 30, 30} ); ed.setBoxShape( RoundButton::Panel | RoundButton::Top, {30, 30, 0, 0} ); - // diagram: - ed.setBoxBorderMetrics( WeekdayBox::Panel, {0, 0, 3, 3} ); + ed.setBoxBorderMetrics( UsageDiagramBox::DaysBox, {0, 0, 3, 3} ); + ed.setFontRole( UsageDiagramBox::DayText, QskSkin::TinyFont ); - ed.setMetric( CaptionColorBox::Panel | QskAspect::Size, 8 ); - ed.setBoxShape( CaptionColorBox::Panel | QskAspect::Size, 4 ); - ed.setGradient( CaptionColorBox::Panel | CaptionItem::Water, {"#6776ff"} ); - ed.setGradient( CaptionColorBox::Panel | CaptionItem::Electricity, {"#ff3122"} ); - ed.setGradient( CaptionColorBox::Panel | CaptionItem::Gas, {"#ff7d34"} ); - - ed.setPadding( UsageDiagram::Panel, 0 ); - - ed.setFontRole( WeekdayLabel::Text, QskSkin::TinyFont ); - ed.setPadding( WeekdayLabel::Panel, {0, 5, 0, 10} ); - ed.setAlignment( WeekdayLabel::Text, Qt::AlignCenter ); - - ed.setPadding( CaptionBox::Panel, {10, 10, 20, 0} ); + ed.setStrutSize( UsageDiagramLegend::Symbol, 8, 8 ); + ed.setBoxShape( UsageDiagramLegend::Symbol, 100, Qt::RelativeSize ); // a circle + ed.setGradient( UsageDiagramLegend::Symbol | UsageDiagramLegend::Water, {"#6776ff"} ); + ed.setGradient( UsageDiagramLegend::Symbol | UsageDiagramLegend::Electricity, {"#ff3122"} ); + ed.setGradient( UsageDiagramLegend::Symbol | UsageDiagramLegend::Gas, {"#ff7d34"} ); + ed.setPadding( UsageDiagramBox::Panel, 0 ); // new diagram: ed.setColor( Diagram::ChartArea1, "#666776ff" ); ed.setColor( Diagram::ChartArea2, "#66ff3122" ); ed.setColor( Diagram::ChartArea3, "#66ff7d34" ); - // light intensity: ed.setGradient( LightDisplay::ColdPart, { Qt::Horizontal, "#a7b0ff", "#6776ff" } ); ed.setGradient( LightDisplay::WarmPart, { Qt::Horizontal, "#feeeb7", "#ff3122" } ); ed.setFontRole( LightDisplay::ValueText, QskSkin::LargeFont ); ed.setColor( LightDisplay::ValueText, "#929cb2" ); - // palette dependent skin hints: ed.setGradient( MenuBar::Panel, palette.menuBar ); ed.setGradient( MainContent::Panel, palette.mainContent ); ed.setGradient( Box::Panel, palette.box ); ed.setGradient( BoxWithButtons::Panel, palette.box ); - ed.setGradient( UsageDiagram::Panel, palette.box ); + ed.setGradient( UsageDiagramBox::Panel, palette.box ); ed.setColor( LightDisplay::Panel, palette.lightDisplay ); ed.setColor( PieChartPainted::Panel, palette.pieChart ); ed.setGradient( RoundButton::Panel, palette.roundButton ); - ed.setBoxBorderColors( WeekdayBox::Panel, palette.weekdayBox ); + ed.setBoxBorderColors( UsageDiagramBox::DaysBox, palette.weekdayBox ); ed.setColor( QskTextLabel::Text, palette.text ); - ed.setColor( WeekdayLabel::Text, palette.text ); + ed.setColor( UsageDiagramBox::DayText, palette.text ); ed.setColor( ShadowPositioner::Panel, palette.shadow ); } diff --git a/examples/iotdashboard/TopBar.h b/examples/iotdashboard/TopBar.h index 1f595c1c..65c7cd94 100644 --- a/examples/iotdashboard/TopBar.h +++ b/examples/iotdashboard/TopBar.h @@ -8,8 +8,6 @@ #include #include -#include - class TimeTitleLabel : public QskTextLabel { Q_OBJECT diff --git a/examples/iotdashboard/UsageDiagram.cpp b/examples/iotdashboard/UsageDiagram.cpp index f51de198..81cfdf55 100644 --- a/examples/iotdashboard/UsageDiagram.cpp +++ b/examples/iotdashboard/UsageDiagram.cpp @@ -4,138 +4,175 @@ *****************************************************************************/ #include "UsageDiagram.h" - #include "Diagram.h" -#include -#include -#include #include #include #include -#include -#include +QSK_SUBCONTROL( UsageDiagramLegend, Panel ) +QSK_SUBCONTROL( UsageDiagramLegend, Symbol ) -#include +QSK_STATE( UsageDiagramLegend, Water, ( QskAspect::FirstUserState << 1 ) ) +QSK_STATE( UsageDiagramLegend, Electricity, ( QskAspect::FirstUserState << 2 ) ) +QSK_STATE( UsageDiagramLegend, Gas, ( QskAspect::FirstUserState << 3 ) ) -QSK_SUBCONTROL( WeekdayLabel, Panel ) -QSK_SUBCONTROL( WeekdayLabel, Text ) -QSK_SUBCONTROL( WeekdayBox, Panel ) +QSK_SUBCONTROL( UsageDiagramBox, Panel ) +QSK_SUBCONTROL( UsageDiagramBox, DaysBox ) +QSK_SUBCONTROL( UsageDiagramBox, DayText ) -QSK_SUBCONTROL( CaptionColorBox, Panel ) - -QSK_SUBCONTROL( CaptionItem, Panel ) -QSK_STATE( CaptionItem, Water, ( QskAspect::FirstUserState << 1 ) ) -QSK_STATE( CaptionItem, Electricity, ( QskAspect::FirstUserState << 2 ) ) -QSK_STATE( CaptionItem, Gas, ( QskAspect::FirstUserState << 3 ) ) - -QSK_SUBCONTROL( CaptionBox, Panel ) - -QSK_SUBCONTROL( UsageDiagram, Panel ) - -CaptionItem::CaptionItem( QskAspect::State state, QQuickItem* parent ) - : QskLinearBox( Qt::Horizontal, parent ) +namespace { - setSpacing( 10 ); - auto* box = new CaptionColorBox( this ); - box->setSkinState( state ); - - QString text; - - if( state == CaptionItem::Water ) + class LegendItem : public QskLinearBox { - text = "Water"; - } - else if( state == CaptionItem::Electricity ) - { - text = "Electricity"; - } - else if( state == CaptionItem::Gas ) - { - text = "Gas"; - } - - auto* textLabel = new QskTextLabel( text, this ); - textLabel->setFontRole( QskSkin::TinyFont ); - - const qreal size = metric( CaptionColorBox::Panel | QskAspect::Size ); - box->setFixedSize( {size, size} ); -} - - -static constexpr int segments = 7; - -UsageDiagram::UsageDiagram( QQuickItem* parent ) - : Box( QString(), parent ) - , m_diagram( new Diagram( this ) ) - , m_weekdays( new QskGridBox( this ) ) -{ - setAutoAddChildren( false ); - setAutoLayoutChildren( true ); - - setSubcontrolProxy( QskBox::Panel, Panel ); - - int number = 100; - - // These values are calculated with a boost::math::cubic_b_spline. - // We just output the values here to get rid of the dependency: - const std::vector< std::vector< qreal > > yValues = - { - {64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 63.99, 63.96, 63.85, 63.64, 63.30, 62.79, 62.09, 61.14, 59.93, 58.42, 56.59, 54.50, 52.23, 49.84, 47.42, 45.03, 42.76, 40.68, 38.85, 37.36, 36.27, 35.55, 35.19, 35.14, 35.39, 35.91, 36.65, 37.60, 38.73, 40.00, 41.39, 42.87, 44.41, 46.00, 47.60, 49.19, 50.76, 52.26, 53.68, 55.00, 56.19, 57.24, 58.15, 58.90, 59.51, 59.95, 60.23, 60.33, 60.26, 60.00, 59.56, 58.94, 58.17, 57.27, 56.24, 55.12, 53.92, 52.65, 51.34, 50.00, 48.65, 47.32, 46.03, 44.79, 43.65, 42.61, 41.70, 40.95, 40.37, 40.00, 39.85, 39.94, 40.26, 40.84, 41.67, 42.77, 44.15, 45.80, 47.75, 50.00, 52.54, 55.30, 58.19, 61.13, 64.04, 66.82, 69.40, 71.67, 73.57}, - {36.00, 36.01, 36.11, 36.37, 36.88, 37.73, 38.98, 40.73, 43.07, 46.06, 49.80, 54.31, 59.38, 64.73, 70.09, 75.20, 79.77, 83.55, 86.24, 87.59, 87.33, 85.26, 81.61, 76.64, 70.67, 63.98, 56.86, 49.61, 42.52, 35.89, 30.00, 25.09, 21.14, 18.08, 15.83, 14.31, 13.45, 13.16, 13.37, 14.01, 15.00, 16.26, 17.73, 19.36, 21.07, 22.82, 24.55, 26.19, 27.68, 28.97, 30.00, 30.73, 31.25, 31.65, 32.04, 32.52, 33.21, 34.19, 35.58, 37.48, 40.00, 43.17, 46.80, 50.61, 54.33, 57.71, 60.47, 62.35, 63.07, 62.38, 60.00, 55.79, 50.12, 43.46, 36.31, 29.13, 22.43, 16.68, 12.37, 9.98, 10.00, 12.73, 17.76, 24.50, 32.36, 40.75, 49.09, 56.77, 63.21, 67.81, 70.00, 69.37, 66.28, 61.29, 54.96, 47.85, 40.51, 33.50, 27.37, 22.68}, - {43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.51, 43.59, 43.80, 44.20, 44.87, 45.86, 47.25, 49.10, 51.47, 54.43, 58.01, 62.05, 66.38, 70.80, 75.12, 79.16, 82.73, 85.64, 87.70, 88.73, 88.60, 87.42, 85.34, 82.55, 79.20, 75.47, 71.51, 67.51, 63.61, 60.00, 56.80, 54.04, 51.68, 49.71, 48.11, 46.86, 45.95, 45.35, 45.04, 45.00, 45.22, 45.71, 46.46, 47.50, 48.82, 50.43, 52.35, 54.58, 57.13, 60.00, 63.17, 66.45, 69.62, 72.46, 74.74, 76.24, 76.74, 76.01, 73.84, 70.00, 64.39, 57.37, 49.45, 41.12, 32.86, 25.18, 18.56, 13.49, 10.48} - }; - - for( int i = 0; i < 3; ++i ) - { - auto y = yValues[i]; - - QVector< QPointF > dataPoints; - dataPoints.reserve( number ); - - for( int x = 0; x < number; ++x ) + public: + LegendItem( QskAspect::State state, QQuickItem* parent = nullptr ) + : QskLinearBox( Qt::Horizontal, parent ) { - QPointF p( x, y[x] ); + setSpacing( 10 ); - dataPoints.append( p ); + auto symbol = new QskBox( true ); + symbol->setSubcontrolProxy( QskBox::Panel, UsageDiagramLegend::Symbol ); + symbol->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); + symbol->setSkinState( state ); + + QString text; + + if( state == UsageDiagramLegend::Water ) + { + text = "Water"; + } + else if( state == UsageDiagramLegend::Electricity ) + { + text = "Electricity"; + } + else if( state == UsageDiagramLegend::Gas ) + { + text = "Gas"; + } + + auto label = new QskTextLabel( text ); + label->setFontRole( QskSkin::TinyFont ); + + addItem( symbol ); + addItem( label ); } - m_diagram->addDataPoints( dataPoints, Diagram::Area ); - } + }; - m_diagram->setYMax( 100 ); - addItem( m_diagram ); - - - m_weekdays->setSpacing( 0 ); - QStringList weekdays = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; - - for( int i = 0; i < segments; ++i ) + class UsageDiagram : public Diagram { - auto* box = new WeekdayBox( m_weekdays ); - m_weekdays->addItem( box, 0, i ); - auto* label = new WeekdayLabel( weekdays.at( i ), m_weekdays ); - m_weekdays->addItem( label, 1, i ); - } + public: + UsageDiagram( QQuickItem* parent = nullptr ) + : Diagram( parent ) + { + // These values are calculated with a boost::math::cubic_b_spline. + // We just output the values here to get rid of the dependency: - addItem( m_weekdays, Qt::AlignBottom ); + const qreal water[] = + { + 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, 64.00, + 64.00, 63.99, 63.96, 63.85, 63.64, 63.30, 62.79, 62.09, 61.14, 59.93, + 58.42, 56.59, 54.50, 52.23, 49.84, 47.42, 45.03, 42.76, 40.68, 38.85, + 37.36, 36.27, 35.55, 35.19, 35.14, 35.39, 35.91, 36.65, 37.60, 38.73, + 40.00, 41.39, 42.87, 44.41, 46.00, 47.60, 49.19, 50.76, 52.26, 53.68, + 55.00, 56.19, 57.24, 58.15, 58.90, 59.51, 59.95, 60.23, 60.33, 60.26, + 60.00, 59.56, 58.94, 58.17, 57.27, 56.24, 55.12, 53.92, 52.65, 51.34, + 50.00, 48.65, 47.32, 46.03, 44.79, 43.65, 42.61, 41.70, 40.95, 40.37, + 40.00, 39.85, 39.94, 40.26, 40.84, 41.67, 42.77, 44.15, 45.80, 47.75, + 50.00, 52.54, 55.30, 58.19, 61.13, 64.04, 66.82, 69.40, 71.67, 73.57 + }; - m_captionBox = new CaptionBox( this ); - addItem( m_captionBox, Qt::AlignRight ); - m_captionBox->setSizePolicy( QskSizePolicy::Maximum, QskSizePolicy::Maximum ); - m_captionBox->setSpacing( 30 ); - m_captionBox->addItem( new CaptionItem( CaptionItem::Water, this ) ); - m_captionBox->addItem( new CaptionItem( CaptionItem::Electricity, this ) ); - m_captionBox->addItem( new CaptionItem( CaptionItem::Gas, this ) ); + const qreal electricity[] = + { + 36.00, 36.01, 36.11, 36.37, 36.88, 37.73, 38.98, 40.73, 43.07, 46.06, + 49.80, 54.31, 59.38, 64.73, 70.09, 75.20, 79.77, 83.55, 86.24, 87.59, + 87.33, 85.26, 81.61, 76.64, 70.67, 63.98, 56.86, 49.61, 42.52, 35.89, + 30.00, 25.09, 21.14, 18.08, 15.83, 14.31, 13.45, 13.16, 13.37, 14.01, + 15.00, 16.26, 17.73, 19.36, 21.07, 22.82, 24.55, 26.19, 27.68, 28.97, + 30.00, 30.73, 31.25, 31.65, 32.04, 32.52, 33.21, 34.19, 35.58, 37.48, + 40.00, 43.17, 46.80, 50.61, 54.33, 57.71, 60.47, 62.35, 63.07, 62.38, + 60.00, 55.79, 50.12, 43.46, 36.31, 29.13, 22.43, 16.68, 12.37, 9.98, + 10.00, 12.73, 17.76, 24.50, 32.36, 40.75, 49.09, 56.77, 63.21, 67.81, + 70.00, 69.37, 66.28, 61.29, 54.96, 47.85, 40.51, 33.50, 27.37, 22.68 + }; + + const qreal gas[] = + { + 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, + 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, + 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, 43.50, + 43.50, 43.51, 43.59, 43.80, 44.20, 44.87, 45.86, 47.25, 49.10, 51.47, + 54.43, 58.01, 62.05, 66.38, 70.80, 75.12, 79.16, 82.73, 85.64, 87.70, + 88.73, 88.60, 87.42, 85.34, 82.55, 79.20, 75.47, 71.51, 67.51, 63.61, + 60.00, 56.80, 54.04, 51.68, 49.71, 48.11, 46.86, 45.95, 45.35, 45.04, + 45.00, 45.22, 45.71, 46.46, 47.50, 48.82, 50.43, 52.35, 54.58, 57.13, + 60.00, 63.17, 66.45, 69.62, 72.46, 74.74, 76.24, 76.74, 76.01, 73.84, + 70.00, 64.39, 57.37, 49.45, 41.12, 32.86, 25.18, 18.56, 13.49, 10.48 + }; + + addCurve( water, sizeof( water ) / sizeof( qreal ) ); + addCurve( electricity, sizeof( electricity ) / sizeof( qreal ) ); + addCurve( gas, sizeof( gas ) / sizeof( qreal ) ); + + setYMax( 100 ); + } + + private: + void addCurve( const qreal values[], const size_t count ) + { + QVector< QPointF > points; + points.reserve( count ); + + for( size_t i = 0; i < count; i++ ) + points += QPointF( i, values[i] ); + + addDataPoints( points, Diagram::Area ); + } + }; } -void UsageDiagram::updateLayout() +UsageDiagramLegend::UsageDiagramLegend( QQuickItem* parent ) + : QskLinearBox( parent ) { - auto weekdaysHeight = m_weekdays->preferredSize().height(); - m_diagram->setHeight( m_diagram->height() - weekdaysHeight ); - const qreal captionX = width() - m_captionBox->width(); - m_captionBox->setPosition( captionX, 0 ); + initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); + + setMargins( 10, 10, 20, 10 ); + setSpacing( 30 ); + + addItem( new LegendItem( UsageDiagramLegend::Water ) ); + addItem( new LegendItem( UsageDiagramLegend::Electricity ) ); + addItem( new LegendItem( UsageDiagramLegend::Gas ) ); +} + +UsageDiagramBox::UsageDiagramBox( QQuickItem* parent ) + : Box( QString(), parent ) +{ + setSubcontrolProxy( QskBox::Panel, Panel ); + + auto gridBox = new QskGridBox(); + gridBox->setSpacing( 0 ); + + gridBox->addItem( new UsageDiagramLegend(), 0, 0, 1, -1, Qt::AlignTop | Qt::AlignRight ); + gridBox->addItem( new UsageDiagram(), 0, 0, 1, -1 ); + + const char* days[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; + + for( size_t i = 0; i < sizeof( days ) / sizeof( days[0] ) ; i++ ) + { + auto box = new QskBox( true ); + box->setSubcontrolProxy( QskBox::Panel, UsageDiagramBox::DaysBox ); + + auto label = new QskTextLabel( days[i] ); + label->setSubcontrolProxy( QskTextLabel::Text, UsageDiagramBox::DayText ); + label->setAlignment( Qt::AlignCenter ); + label->setMargins( 0, 10, 0, 10 ); + + gridBox->addItem( box, 0, i ); + gridBox->addItem( label, 1, i ); + } + + addItem( gridBox ); } #include "moc_UsageDiagram.cpp" diff --git a/examples/iotdashboard/UsageDiagram.h b/examples/iotdashboard/UsageDiagram.h index 1e48ae5e..8c4bfe2a 100644 --- a/examples/iotdashboard/UsageDiagram.h +++ b/examples/iotdashboard/UsageDiagram.h @@ -7,98 +7,21 @@ #include "Box.h" -#include -#include - -class Diagram; -class DiagramContent; -class QskGridBox; - -class WeekdayLabel : public QskTextLabel +class UsageDiagramLegend : public QskLinearBox { - Q_OBJECT - public: - QSK_SUBCONTROLS( Panel, Text ) - - WeekdayLabel( const QString& text, QQuickItem* parent ) - : QskTextLabel( text, parent ) - { - setPanel( true ); - - setSubcontrolProxy( QskTextLabel::Panel, Panel ); - setSubcontrolProxy( QskTextLabel::Text, Text ); - } -}; - -class WeekdayBox : public QskBox -{ - Q_OBJECT - - public: - QSK_SUBCONTROLS( Panel ) - - WeekdayBox( QQuickItem* parent ): - QskBox( true, parent ) - { - setSubcontrolProxy( QskBox::Panel, WeekdayBox::Panel ); - } -}; - -class CaptionColorBox : public QskBox -{ - Q_OBJECT - - public: - QSK_SUBCONTROLS( Panel ) - - CaptionColorBox( QQuickItem* parent ): - QskBox( true, parent ) - { - setSubcontrolProxy( QskBox::Panel, Panel ); - } -}; - -class CaptionItem : public QskLinearBox -{ - Q_OBJECT - - public: - QSK_SUBCONTROLS( Panel ) + QSK_SUBCONTROLS( Panel, Symbol ) QSK_STATES( Water, Electricity, Gas ) - CaptionItem( QskAspect::State state, QQuickItem* parent ); + UsageDiagramLegend( QQuickItem* parent = nullptr ); }; -class CaptionBox : public QskLinearBox +class UsageDiagramBox : public Box { Q_OBJECT public: - QSK_SUBCONTROLS( Panel ) + QSK_SUBCONTROLS( Panel, DaysBox, DayText ) - CaptionBox( QQuickItem* parent ): - QskLinearBox( Qt::Horizontal, parent ) - { - setPanel( true ); - setSubcontrolProxy( QskBox::Panel, Panel ); - } -}; - -class UsageDiagram : public Box -{ - Q_OBJECT - - public: - QSK_SUBCONTROLS( Panel ) - - UsageDiagram( QQuickItem* parent = nullptr ); - - protected: - void updateLayout() override; - - private: - Diagram* m_diagram; - QskLinearBox* m_captionBox; - QskGridBox* m_weekdays; + UsageDiagramBox( QQuickItem* parent = nullptr ); }; diff --git a/examples/iotdashboard/main.cpp b/examples/iotdashboard/main.cpp index b2b71dcc..4eb2338c 100644 --- a/examples/iotdashboard/main.cpp +++ b/examples/iotdashboard/main.cpp @@ -4,23 +4,20 @@ *****************************************************************************/ #include "MainWindow.h" - #include "Skin.h" #include #include -#include -#include #include #include #include #include #include +#include #include - namespace { class SkinFactory : public QskSkinFactory @@ -57,24 +54,21 @@ namespace int main( int argc, char* argv[] ) { +#ifdef ITEM_STATISTICS + QskObjectCounter counter( true ); +#endif + QGuiApplication app( argc, argv ); SkinnyFont::init( &app ); - SkinFactory skinFactory; - + // disable default skins qskSkinManager->setPluginPaths( QStringList() ); // no plugins - qskSkinManager->unregisterFactory( "materialfactory" ); qskSkinManager->unregisterFactory( "squiekfactory" ); + qskSkinManager->registerFactory( - QStringLiteral( "SampleSkinFactory" ), &skinFactory ); - -// QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL + Qt::Key_T ), -// false, skinFactory, SLOT(toggleScheme()) ); - -// QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL + Qt::Key_S ), -// true, &skinFactory, SLOT( rotateSkin() ) ); + QStringLiteral( "SampleSkinFactory" ), new SkinFactory() ); qskSetup->setSkin( "DaytimeSkin" );