diff --git a/examples/iot-dashboard/Card.cpp b/examples/iot-dashboard/Card.cpp index 4d336ebc..28533ca5 100644 --- a/examples/iot-dashboard/Card.cpp +++ b/examples/iot-dashboard/Card.cpp @@ -1,12 +1,26 @@ #include "Card.h" +#include "DaytimeSkin.h" +#include +#include +#include #include -Card::Card(const QString &title, QskControl *content, QQuickItem *parent ) : QskLinearBox( Qt::Vertical, parent ), - m_title( title ) +Card::Card( const QString& title, QQuickItem* parent ) + : QskLinearBox( Qt::Vertical, parent ) + , m_title( title ) + , m_label( new QskTextLabel( m_title, this ) ) { - m_label = new QskTextLabel( m_title, this ); - m_content = content; - m_content->setParentItem( this ); // ### maybe do it differently - m_content->setParent( this ); + setAutoAddChildren( true ); + setAutoLayoutChildren( true ); + + setMarginsHint( Panel | QskAspect::Padding, 15 ); + setPanel( true ); + setBoxShapeHint( QskBox::Panel, 6 ); + setBoxBorderMetricsHint( QskBox::Panel, 2 ); + QskBoxBorderColors borderColors( "#dddddd" ); + borderColors.setAlpha( 100 ); + setBoxBorderColorsHint( QskBox::Panel, borderColors ); + + m_label->setFontRole( DaytimeSkin::TitleFont ); } diff --git a/examples/iot-dashboard/Card.h b/examples/iot-dashboard/Card.h index e8df8d6a..e5386ab4 100644 --- a/examples/iot-dashboard/Card.h +++ b/examples/iot-dashboard/Card.h @@ -7,13 +7,13 @@ class QskTextLabel; class Card : public QskLinearBox { -public: - Card( const QString& title, QskControl* content, QQuickItem* parent ); + public: + Card( const QString& title, QQuickItem* parent ); -private: - QString m_title; - QskTextLabel* m_label; - QskControl* m_content; + private: + QString m_title; + QskTextLabel* m_label; + QskControl* m_content; }; #endif // CARD_H diff --git a/examples/iot-dashboard/MainContent.cpp b/examples/iot-dashboard/MainContent.cpp index 03c03069..66c97533 100644 --- a/examples/iot-dashboard/MainContent.cpp +++ b/examples/iot-dashboard/MainContent.cpp @@ -29,9 +29,9 @@ MainContent::MainContent( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, par gridBox->setPanel( true ); gridBox->setBoxShapeHint( QskBox::Panel, 6 ); gridBox->setBoxBorderMetricsHint( QskBox::Panel, 2 ); - QskBoxBorderColors borderColors( "#dddddd" ); - borderColors.setAlpha( 100 ); - gridBox->setBoxBorderColorsHint( QskBox::Panel, borderColors ); +// QskBoxBorderColors borderColors( "#dddddd" ); +// borderColors.setAlpha( 100 ); +// gridBox->setBoxBorderColorsHint( QskBox::Panel, borderColors ); auto* usage = new Usage( gridBox ); gridBox->addItem( usage, 0, 0, 2, 1 ); @@ -51,8 +51,3 @@ MainContent::MainContent( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, par auto* lightIntensity = new LightIntensity( gridBox ); gridBox->addItem( lightIntensity, 2, 2 ); } - -void MainContent::addCard( const QString& title, QskControl* content, int column ) -{ - new Card( title, content, m_columns.at( column ) ); -} diff --git a/examples/iot-dashboard/MainContent.h b/examples/iot-dashboard/MainContent.h index a7120879..8ecc66b3 100644 --- a/examples/iot-dashboard/MainContent.h +++ b/examples/iot-dashboard/MainContent.h @@ -5,15 +5,13 @@ class MainContent : public QskLinearBox { - Q_OBJECT + Q_OBJECT -public: - MainContent( QQuickItem* parent ); + public: + MainContent( QQuickItem* parent ); -private: - void addCard( const QString& title, QskControl* content, int column = -1 ); - - QList< QskLinearBox* > m_columns; + private: + QList< QskLinearBox* > m_columns; }; #endif // MAINCONTENT_H diff --git a/examples/iot-dashboard/Usage.cpp b/examples/iot-dashboard/Usage.cpp index f9413af5..1568e864 100644 --- a/examples/iot-dashboard/Usage.cpp +++ b/examples/iot-dashboard/Usage.cpp @@ -3,37 +3,32 @@ #include -Usage::Usage(QQuickItem *parent) - : QskLinearBox(Qt::Vertical, parent) +Usage::Usage( QQuickItem* parent ) + : Card( "Usage", parent ) { - setMargins(17); + auto* content = new QskLinearBox( Qt::Vertical, this ); - auto* title = new QskTextLabel("Usage", this); - title->setFontRole(DaytimeSkin::TitleFont); + auto* today = new QskLinearBox( Qt::Horizontal, content ); + auto* todayText = new QskTextLabel( "Usage today", today ); + todayText->setFontRole( QskSkin::SmallFont ); + auto* todaySpacer = new QskTextLabel( "_____", today ); + todaySpacer->setTextColor( "#dddddd" ); + auto* todayValue = new QskTextLabel( "0,5 kwH", today ); + todayValue->setFontRole( QskSkin::SmallFont ); - auto* content = new QskLinearBox(Qt::Vertical, this); + auto* month = new QskLinearBox( Qt::Horizontal, content ); + auto* monthText = new QskTextLabel( "Usage this month", month ); + monthText->setFontRole( QskSkin::SmallFont ); + auto* monthSpacer = new QskTextLabel( "_____", month ); + monthSpacer->setTextColor( "#dddddd" ); + auto* monthValue = new QskTextLabel( "66 kwH", month ); + monthValue->setFontRole( QskSkin::SmallFont ); - auto* today = new QskLinearBox(Qt::Horizontal, content); - auto* todayText = new QskTextLabel("Usage today", today); - todayText->setFontRole(QskSkin::SmallFont); - auto* todaySpacer = new QskTextLabel("_____", today); - todaySpacer->setTextColor("#dddddd"); - auto* todayValue = new QskTextLabel("0,5 kwH", today); - todayValue->setFontRole(QskSkin::SmallFont); - - auto* month = new QskLinearBox(Qt::Horizontal, content); - auto* monthText = new QskTextLabel("Usage this month", month); - monthText->setFontRole(QskSkin::SmallFont); - auto* monthSpacer = new QskTextLabel("_____", month); - monthSpacer->setTextColor("#dddddd"); - auto* monthValue = new QskTextLabel("66 kwH", month); - monthValue->setFontRole(QskSkin::SmallFont); - - auto* total = new QskLinearBox(Qt::Horizontal, content); - auto* totalText = new QskTextLabel("Total working hours", total); - totalText->setFontRole(QskSkin::SmallFont); - auto* totalSpacer = new QskTextLabel("_____", total); - totalSpacer->setTextColor("#dddddd"); - auto* totalValue = new QskTextLabel("125 hrs", total); - totalValue->setFontRole(QskSkin::SmallFont); + auto* total = new QskLinearBox( Qt::Horizontal, content ); + auto* totalText = new QskTextLabel( "Total working hours", total ); + totalText->setFontRole( QskSkin::SmallFont ); + auto* totalSpacer = new QskTextLabel( "_____", total ); + totalSpacer->setTextColor( "#dddddd" ); + auto* totalValue = new QskTextLabel( "125 hrs", total ); + totalValue->setFontRole( QskSkin::SmallFont ); } diff --git a/examples/iot-dashboard/Usage.h b/examples/iot-dashboard/Usage.h index 0f6a2a0d..a51277d0 100644 --- a/examples/iot-dashboard/Usage.h +++ b/examples/iot-dashboard/Usage.h @@ -1,12 +1,13 @@ #ifndef USAGE_H #define USAGE_H +#include "Card.h" #include -class Usage : public QskLinearBox +class Usage : public Card { -public: - Usage( QQuickItem* parent); + public: + Usage( QQuickItem* parent ); }; #endif // USAGE_H