From f3a151759392628333d210be309a6254c7674a79 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Fri, 22 May 2020 11:48:05 +0200 Subject: [PATCH] more content --- examples/iot-dashboard/Card.cpp | 12 +++++++ examples/iot-dashboard/Card.h | 19 +++++++++++ examples/iot-dashboard/MainContent.cpp | 33 ++++++++++++++++++ examples/iot-dashboard/MainContent.h | 19 +++++++++++ examples/iot-dashboard/MainWindow.cpp | 17 +++------- examples/iot-dashboard/MainWindow.h | 7 ++-- examples/iot-dashboard/MenuBar.cpp | 34 ++++++++++++++++--- examples/iot-dashboard/MenuBar.h | 11 ++++++ examples/iot-dashboard/images.qrc | 8 +++++ examples/iot-dashboard/images/calendar.png | Bin 1008 -> 0 bytes examples/iot-dashboard/images/details.png | Bin 0 -> 375 bytes examples/iot-dashboard/images/gear.png | Bin 1626 -> 0 bytes examples/iot-dashboard/images/home.png | Bin 976 -> 1753 bytes examples/iot-dashboard/images/network.png | Bin 1538 -> 0 bytes examples/iot-dashboard/images/settings.png | Bin 0 -> 729 bytes examples/iot-dashboard/images/statistics.png | Bin 0 -> 518 bytes examples/iot-dashboard/iot-dashboard.pro | 6 ++++ examples/iot-dashboard/main.cpp | 4 +-- 18 files changed, 147 insertions(+), 23 deletions(-) create mode 100644 examples/iot-dashboard/Card.cpp create mode 100644 examples/iot-dashboard/Card.h create mode 100644 examples/iot-dashboard/MainContent.cpp create mode 100644 examples/iot-dashboard/MainContent.h create mode 100644 examples/iot-dashboard/images.qrc delete mode 100644 examples/iot-dashboard/images/calendar.png create mode 100644 examples/iot-dashboard/images/details.png delete mode 100644 examples/iot-dashboard/images/gear.png delete mode 100644 examples/iot-dashboard/images/network.png create mode 100644 examples/iot-dashboard/images/settings.png create mode 100644 examples/iot-dashboard/images/statistics.png diff --git a/examples/iot-dashboard/Card.cpp b/examples/iot-dashboard/Card.cpp new file mode 100644 index 00000000..98f2970c --- /dev/null +++ b/examples/iot-dashboard/Card.cpp @@ -0,0 +1,12 @@ +#include "Card.h" + +#include + +Card::Card(const QString &title, QskControl *content, QQuickItem *parent ) : QskLinearBox( Qt::Vertical, parent ), + m_title( title ) +{ + m_label = new QskTextLabel( m_title, this ); + m_content = content; + m_content->setParentItem( this ); + m_content->setParent( this ); +} diff --git a/examples/iot-dashboard/Card.h b/examples/iot-dashboard/Card.h new file mode 100644 index 00000000..e8df8d6a --- /dev/null +++ b/examples/iot-dashboard/Card.h @@ -0,0 +1,19 @@ +#ifndef CARD_H +#define CARD_H + +#include + +class QskTextLabel; + +class Card : public QskLinearBox +{ +public: + Card( const QString& title, QskControl* content, QQuickItem* parent ); + +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 new file mode 100644 index 00000000..0edc1d7a --- /dev/null +++ b/examples/iot-dashboard/MainContent.cpp @@ -0,0 +1,33 @@ +#include "MainContent.h" + +#include "Card.h" + +#include + +MainContent::MainContent( QQuickItem *parent ) : QskLinearBox( Qt::Horizontal, parent ) +{ + setSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Expanding ); + + for( int a = 0; a < 4; ++a ) + { + auto* column = new QskLinearBox( Qt::Vertical, this ); + m_columns.append( column ); + } + + auto* pieChart = new QskTextLabel( "here pie chart" ); + addCard( "Sample usage", pieChart, 0 ); + + auto* barGraph = new QskTextLabel( "here bar graph" ); + addCard( "Power consumption", barGraph, 0 ); + + auto* statistics = new QskTextLabel( "here detailed statistics" ); + addCard( "Detailed statistics", statistics, 1 ); + + auto* users = new QskTextLabel( "here users" ); + addCard( "Users", users, 1 ); +} + +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 new file mode 100644 index 00000000..a7120879 --- /dev/null +++ b/examples/iot-dashboard/MainContent.h @@ -0,0 +1,19 @@ +#ifndef MAINCONTENT_H +#define MAINCONTENT_H + +#include + +class MainContent : public QskLinearBox +{ + Q_OBJECT + +public: + MainContent( QQuickItem* parent ); + +private: + void addCard( const QString& title, QskControl* content, int column = -1 ); + + QList< QskLinearBox* > m_columns; +}; + +#endif // MAINCONTENT_H diff --git a/examples/iot-dashboard/MainWindow.cpp b/examples/iot-dashboard/MainWindow.cpp index 0479aae1..c764f392 100644 --- a/examples/iot-dashboard/MainWindow.cpp +++ b/examples/iot-dashboard/MainWindow.cpp @@ -1,4 +1,6 @@ #include "MainWindow.h" + +#include "MainContent.h" #include "MenuBar.h" #include @@ -9,17 +11,6 @@ MainWindow::MainWindow() : QskWindow() setTitle( "IOT dashboard" ); m_mainLayout = new QskLinearBox( Qt::Horizontal, contentItem() ); - - addMenuBar(); - addMainContent(); -} - -void MainWindow::addMenuBar() -{ - auto* menuBar = new MenuBar( m_mainLayout ); -} - -void MainWindow::addMainContent() -{ - + m_menuBar = new MenuBar( m_mainLayout ); + m_mainContent = new MainContent( m_mainLayout ); } diff --git a/examples/iot-dashboard/MainWindow.h b/examples/iot-dashboard/MainWindow.h index 36a5b63a..9743e4ee 100644 --- a/examples/iot-dashboard/MainWindow.h +++ b/examples/iot-dashboard/MainWindow.h @@ -3,6 +3,8 @@ #include +class MainContent; +class MenuBar; class QskLinearBox; class MainWindow : public QskWindow @@ -13,10 +15,9 @@ public: MainWindow(); private: - void addMenuBar(); - void addMainContent(); - QskLinearBox* m_mainLayout; + MenuBar* m_menuBar; + MainContent* m_mainContent; }; #endif // MAINWINDOW_H diff --git a/examples/iot-dashboard/MenuBar.cpp b/examples/iot-dashboard/MenuBar.cpp index 51497e04..0126d6ef 100644 --- a/examples/iot-dashboard/MenuBar.cpp +++ b/examples/iot-dashboard/MenuBar.cpp @@ -1,20 +1,44 @@ #include "MenuBar.h" +#include +#include +#include #include -MenuBar::MenuBar( QQuickItem *parent ) : QskLinearBox( Qt::Vertical, parent ) +#include + +MenuItem::MenuItem( const QString& name, QQuickItem* parent ) : QskLinearBox( Qt::Horizontal, parent ), + m_name( name ) { - setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Expanding ); setAutoLayoutChildren( true ); setAutoAddChildren( true ); + QString fileName = ":/images/" + name.toLower() + ".png"; + QImage image( fileName ); + auto graphic = QskGraphic::fromImage( image ); + auto* graphicLabel = new QskGraphicLabel( graphic, this ); + graphicLabel->setFixedSize( 32, 32 ); + + auto* textLabel = new QskTextLabel( name, this ); + textLabel->setTextColor( Qt::white ); // ### style +} + +MenuBar::MenuBar( QQuickItem *parent ) : QskLinearBox( Qt::Vertical, parent ) +{ + setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Preferred ); + setAutoLayoutChildren( true ); + setAutoAddChildren( true ); + setMargins( 35 ); // ### style + setSpacing( 30 ); // ### style + setBackgroundColor( { 0, 35, 102 } ); // ### style - m_entries = { "Home", "Details", "Statistics", "Usage" }; + m_entries = { "Home", "Details", "Statistics", "Settings" }; for( const auto entry : m_entries ) { - auto* label = new QskTextLabel( entry, this ); - label->setTextColor( Qt::white ); // ### style + auto* menuItem = new MenuItem( entry, this ); } + + addSpacer( 0, 1 ); // fill the space at the bottom } diff --git a/examples/iot-dashboard/MenuBar.h b/examples/iot-dashboard/MenuBar.h index 9f0e1fd9..1f5e5a21 100644 --- a/examples/iot-dashboard/MenuBar.h +++ b/examples/iot-dashboard/MenuBar.h @@ -3,6 +3,17 @@ #include +class MenuItem : public QskLinearBox +{ + Q_OBJECT + +public: + MenuItem( const QString& name, QQuickItem* parent ); + +private: + QString m_name; +}; + class MenuBar : public QskLinearBox { Q_OBJECT diff --git a/examples/iot-dashboard/images.qrc b/examples/iot-dashboard/images.qrc new file mode 100644 index 00000000..a12a5750 --- /dev/null +++ b/examples/iot-dashboard/images.qrc @@ -0,0 +1,8 @@ + + + images/statistics.png + images/settings.png + images/home.png + images/details.png + + diff --git a/examples/iot-dashboard/images/calendar.png b/examples/iot-dashboard/images/calendar.png deleted file mode 100644 index e543eaeed5e79d95021be58bd64d0b3bec265863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008P>0026e000+ooVrmw00002 zVoOIv0063uBQgL0010qNS#tmY4#WTe4#WYKD-Ig~000McNliru{GK~!ko#hKqv990y@KMQM%tU^+#HMl^bQA(>5O$k3!=m%0 z=yeJ`R`C9~S{0sic$XiTFoh8SWZ{uH6!!ebPn*A6a+GAa{o zD?wt3oh?;9M-UbXvN_RL!6z&t2<=LrAVQP?Ta!@A^hKUa8}o`B|Bf;o9YPRBQZgTa zQo;zLoCTj@o6_4nt>nUo3e_s#D0jRHmJvoQwxfK)2odF4D5jsN0;$=14me|L^EI%Zy^h8cz~d&|z64D2o2|_hQ^3p42X#ZB1ejjaYC3M21pYBiPQ2hU?QX03+0)d}^EmYXrX!=n%1e{GQzySXM`)zIZ11p3ajpqTx%M@EU zz>Faf{mP#ThXwk1nK{$JM!&sF|nzb60y03~!qSaf7zbY(hYa%Ew3WdJfT zGB7PLH7znSR4_R@FgZFkFe@-HIxsL&>T#+7001R)MObuXVRU6WZEs|0W_bWIFfuSL zFf}bQGE^`*IxsmpH83kMFgh?WBe%&G0000PbVXQnQ*UN;cVTj60C#tHE@^ISb7Ns} YWiD@WXPfRk8UO$Q07*qoM6N<$g8CG}D*ylh diff --git a/examples/iot-dashboard/images/home.png b/examples/iot-dashboard/images/home.png index 3ff42c35d9d159b1a22515269b6ad9588c7bce5e..82f22fb824ac8639c872075e661e9cab81642dd8 100644 GIT binary patch literal 1753 zcmd5-Yfuwc7`<5*%t}QGm12uim}at_iV|U}K^p@W!L@PI=@^uf;#yywsq#h;Ws^x; z#jyj}9Y@e$tPTnh9a=5EK-l_#R2r;^fChpX5edTjy`fJ3Dt5|i-9eZlJ zD9nPaX?G|+fjHZXQu0S6kNz}(?=NHxpOayM>jhQo_nK|J;x#{m=2XWdDhQxbcBpuw zJxsTK_IxhMfHDC(E?CZ^fJ~&he3bWAUPnqAg?vBhEJ2X%yGi7aH*~}q$LErIHW55H zxQ_4QgM$a9TPIN;8gye|k{IMm1<#orj6#ppw@I{n87hR-T~3%3Tf%g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Vuc9rKw$_XvfDtE?RP9Cy6rcj&R^IK=&E-G1W( z#w;6Iry4bgTKLbR66f%V*;peOe>uuc_nFfItW%A>{FkT^{s>x{;2<}(4# z5sxN?H=J!;tfjo7u9~@kPbO5dJb<6!agDo%(Zg=r11zpAa|_LnhOLtQa8@pXKVGn| z@X+0ot=vF$j$4oYEOULw!B;Wu0gMl%N?UT|ou=}9XEMLH z;&;jlC5Pm@?bgf;o=JZXM7`L5FG%uNRa)Mv=M4Ae=Vrt_nDCgHb1wg$NAVjNn)ei1 z%rM(}Lh_3OW7npJ%<(O^Cey8l!E zghhQcd22D?NY%?PN}v7CMhd8i N!PC{xWt~$(698Upejoq< diff --git a/examples/iot-dashboard/images/network.png b/examples/iot-dashboard/images/network.png deleted file mode 100644 index 5ea3a5d6febb85636984117fc369a461f1554f2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1538 zcmZ`(c{tPw82*vWm~qv_*s&=olxvJtOrmk*7-U*UW{ANYa!pJ|?j~imj?FDm5tYa_ z?z71eax6B3md4H?XDY`C?eypVvCs3p-}`*;_r1^i-vjo01&PU0I_iZuq~8g=Kkk< zA`Bd|Hpe(pr&>4>iRpZ~?zO=yKw(*dlg1(Q-yTVIVg13rPbR3Mcikkz5}Z1q_Z&v> zuv~U<`ZzACMhePy@Pb~t*PqSrcS*L zXu~TrgH9!4^|jr6y(rbC!=*CU+Gy?L7OlFiu*@f*b8P^=kpXRZLG5ZSF4B(GCgKt{PZNWJ+pVUdes+4}8m8G!@b-ANiA{4~ z+{LtgD~H09fU2wUuMa&`Ae zk4PO9lq9lz8ZtPhY|{OB#|=GCVz}~F!*3hAWI+w>QYyyRix*_sEHu9^n?m`sV~StG zsv!J)a$)Z#Y$5eX6728AhmF?>%QAOdAbI2@+1lALj28IzXZ>-SiKxtI9L;g>EuIfu z-Zb5MBcs>K$bc^<{_WuZ;P z{!AV7Ft2v|18nl9K4DM66zrZ^KN>dIG;Y(-T-WpYQ;@RJ^477{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xjz`3M6 zS2Gv=z)F%cQ{Xl=E&#ic#T${X@k8JU7$xp{?&2LdNNRlY0cO+|E2G>1`Tzg`07*qo IM6N<$g8ux|%K!iX literal 0 HcmV?d00001 diff --git a/examples/iot-dashboard/iot-dashboard.pro b/examples/iot-dashboard/iot-dashboard.pro index ac3eca95..473a98a7 100644 --- a/examples/iot-dashboard/iot-dashboard.pro +++ b/examples/iot-dashboard/iot-dashboard.pro @@ -1,11 +1,17 @@ CONFIG += qskexample SOURCES += \ + Card.cpp \ + MainContent.cpp \ MenuBar.cpp \ main.cpp \ MainWindow.cpp HEADERS += \ + Card.h \ + MainContent.h \ MainWindow.h \ MenuBar.h +RESOURCES += \ + images.qrc diff --git a/examples/iot-dashboard/main.cpp b/examples/iot-dashboard/main.cpp index f44215d1..3d0f63d1 100644 --- a/examples/iot-dashboard/main.cpp +++ b/examples/iot-dashboard/main.cpp @@ -1,3 +1,5 @@ +#include "MainWindow.h" + #include #include @@ -8,8 +10,6 @@ #include -#include "MainWindow.h" - int main( int argc, char* argv[] ) { QGuiApplication app( argc, argv );