From 10018cdabf1819336422b91d1da35db3a1ce4e61 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Fri, 26 Mar 2021 09:45:33 +0100 Subject: [PATCH] use astyle --- examples/iot-dashboard/MainWindow.h | 14 ++--- examples/iot-dashboard/MenuBar.cpp | 56 +++++++++++--------- examples/iot-dashboard/MenuBar.h | 32 ++++++------ examples/iot-dashboard/PieChart.cpp | 2 +- examples/iot-dashboard/PieChart.h | 22 ++++---- examples/iot-dashboard/PieChartSkinlet.cpp | 6 +-- examples/iot-dashboard/PieChartSkinlet.h | 28 +++++----- examples/iot-dashboard/RoundedIcon.cpp | 22 ++++---- examples/iot-dashboard/RoundedIcon.h | 20 +++---- examples/iot-dashboard/TopBar.cpp | 61 +++++++++++----------- examples/iot-dashboard/TopBar.h | 20 +++---- 11 files changed, 145 insertions(+), 138 deletions(-) diff --git a/examples/iot-dashboard/MainWindow.h b/examples/iot-dashboard/MainWindow.h index 9743e4ee..54de05c5 100644 --- a/examples/iot-dashboard/MainWindow.h +++ b/examples/iot-dashboard/MainWindow.h @@ -9,15 +9,15 @@ class QskLinearBox; class MainWindow : public QskWindow { - Q_OBJECT + Q_OBJECT -public: - MainWindow(); + public: + MainWindow(); -private: - QskLinearBox* m_mainLayout; - MenuBar* m_menuBar; - MainContent* m_mainContent; + private: + 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 065e40b1..e5b7ee2a 100644 --- a/examples/iot-dashboard/MenuBar.cpp +++ b/examples/iot-dashboard/MenuBar.cpp @@ -16,76 +16,82 @@ MenuItem::MenuItem( const QString& name, QQuickItem* parent ) : QskLinearBox( Qt setAutoLayoutChildren( true ); setAutoAddChildren( true ); setFixedSize( {140, 40} ); - setMargins({0, 0, 0, 0}); - setPadding({30, 0, 30, 0}); - setSpacing(6); + setMargins( {0, 0, 0, 0} ); + setPadding( {30, 0, 30, 0} ); + setSpacing( 6 ); - setAcceptHoverEvents(true); - setPanel(true); + setAcceptHoverEvents( true ); + setPanel( true ); QString fileName = ":/images/" + name.toLower() + ".png"; // width: 14 QImage image( fileName ); auto graphic = QskGraphic::fromImage( image ); auto* graphicLabel = new QskGraphicLabel( graphic, this ); - graphicLabel->setSizePolicy(QskSizePolicy::Fixed, QskSizePolicy::Fixed); - graphicLabel->setFixedWidth(14); - graphicLabel->setAlignment(Qt::AlignCenter); + graphicLabel->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); + graphicLabel->setFixedWidth( 14 ); + graphicLabel->setAlignment( Qt::AlignCenter ); auto* textLabel = new QskTextLabel( name, this ); textLabel->setTextColor( Qt::white ); // ### style - textLabel->setFontRole(QskSkin::SmallFont); // ### style + textLabel->setFontRole( QskSkin::SmallFont ); // ### style } QskAspect::Subcontrol MenuItem::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const { - if ( subControl == QskBox::Panel ) + if( subControl == QskBox::Panel ) + { return MenuItem::Panel; + } return subControl; } -void MenuItem::setActive(bool active) +void MenuItem::setActive( bool active ) { QColor color; - if(active) { + if( active ) + { color = Qt::white; - color.setAlphaF(0.14); - } else { + color.setAlphaF( 0.14 ); + } + else + { color = Qt::transparent; } - setBackgroundColor(color); + + setBackgroundColor( color ); } -MenuBar::MenuBar( QQuickItem *parent ) : QskLinearBox( Qt::Vertical, parent ) +MenuBar::MenuBar( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent ) { setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Preferred ); setAutoLayoutChildren( true ); setAutoAddChildren( true ); - setSpacing(8); - setMargins({0, 35, 0, 12}); + setSpacing( 8 ); + setMargins( {0, 35, 0, 12} ); setBackgroundColor( "#6D7BFB" ); // ### style auto* mainIcon = ":/images/main-icon.png"; - QImage image(mainIcon); + QImage image( mainIcon ); auto graphic = QskGraphic::fromImage( image ); auto* graphicLabel = new QskGraphicLabel( graphic, this ); - graphicLabel->setAlignment(Qt::AlignTop); - graphicLabel->setMargins( { 50, 0, 50, 54 }); - graphicLabel->setSizePolicy(QskSizePolicy::Fixed, QskSizePolicy::Fixed); + graphicLabel->setAlignment( Qt::AlignTop ); + graphicLabel->setMargins( { 50, 0, 50, 54 } ); + graphicLabel->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); m_entryStrings = { "Dashboard", "Rooms", "Devices", "Statistics", "Storage", "Members" }; - for( const auto &entryString : m_entryStrings ) + for( const auto& entryString : m_entryStrings ) { auto* entry = new MenuItem( entryString, this ); - m_entries.append(entry); + m_entries.append( entry ); } - m_entries.at(m_activeEntry)->setActive(true); + m_entries.at( m_activeEntry )->setActive( true ); addSpacer( 0, 1 ); // fill the space at the bottom diff --git a/examples/iot-dashboard/MenuBar.h b/examples/iot-dashboard/MenuBar.h index c5b92959..15dba50d 100644 --- a/examples/iot-dashboard/MenuBar.h +++ b/examples/iot-dashboard/MenuBar.h @@ -5,33 +5,33 @@ class MenuItem : public QskLinearBox { - Q_OBJECT + Q_OBJECT -public: - QSK_SUBCONTROLS( Panel ) + public: + QSK_SUBCONTROLS( Panel ) - MenuItem( const QString& name, QQuickItem* parent ); + MenuItem( const QString& name, QQuickItem* parent ); - QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol subControl ) const override final; + QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol subControl ) const override final; - void setActive(bool active); + void setActive( bool active ); -private: - QString m_name; - bool m_isActive = false; + private: + QString m_name; + bool m_isActive = false; }; class MenuBar : public QskLinearBox { - Q_OBJECT + Q_OBJECT -public: - MenuBar( QQuickItem* parent ); + public: + MenuBar( QQuickItem* parent ); -private: - QList< QString > m_entryStrings; - QList< MenuItem* > m_entries; - uint m_activeEntry = 0; + private: + QList< QString > m_entryStrings; + QList< MenuItem* > m_entries; + uint m_activeEntry = 0; }; #endif // MENUBAR_H diff --git a/examples/iot-dashboard/PieChart.cpp b/examples/iot-dashboard/PieChart.cpp index 82dac3bb..5206a0d6 100644 --- a/examples/iot-dashboard/PieChart.cpp +++ b/examples/iot-dashboard/PieChart.cpp @@ -3,7 +3,7 @@ QSK_SUBCONTROL( PieChart, Panel ) QSK_SUBCONTROL( PieChart, Labels ) -PieChart::PieChart( QQuickItem *parent ) : QskControl( parent ) +PieChart::PieChart( QQuickItem* parent ) : QskControl( parent ) { } diff --git a/examples/iot-dashboard/PieChart.h b/examples/iot-dashboard/PieChart.h index c23014e5..270c0a2b 100644 --- a/examples/iot-dashboard/PieChart.h +++ b/examples/iot-dashboard/PieChart.h @@ -5,22 +5,22 @@ class PieChart : public QskControl { - Q_OBJECT + Q_OBJECT -public: - QSK_SUBCONTROLS( Panel, Labels ) + public: + QSK_SUBCONTROLS( Panel, Labels ) - PieChart( QQuickItem* parent = nullptr ); + PieChart( QQuickItem* parent = nullptr ); - QVector< float > angles() const; - void setAngles( const QVector< float >& angles ); + QVector< float > angles() const; + void setAngles( const QVector< float >& angles ); - QVector< QString > labels() const; - void setLabels( const QVector< QString >& labels ); + QVector< QString > labels() const; + void setLabels( const QVector< QString >& labels ); -private: - QVector< float > m_angles; - QVector< QString > m_labels; + private: + QVector< float > m_angles; + QVector< QString > m_labels; }; #endif // PIECHART_H diff --git a/examples/iot-dashboard/PieChartSkinlet.cpp b/examples/iot-dashboard/PieChartSkinlet.cpp index 63d30a3d..86cf2c21 100644 --- a/examples/iot-dashboard/PieChartSkinlet.cpp +++ b/examples/iot-dashboard/PieChartSkinlet.cpp @@ -20,7 +20,7 @@ QSGNode* PieChartSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 n { const auto pieChart = static_cast< const PieChart* >( skinnable ); - switch ( nodeRole ) + switch( nodeRole ) { case PanelRole: return updatePanelNode( pieChart, node ); @@ -37,7 +37,7 @@ QSGNode* PieChartSkinlet::updatePanelNode( const PieChart* pieChart, QSGNode* no { auto boxNode = static_cast< QskBoxNode* >( node ); - if ( boxNode == nullptr ) + if( boxNode == nullptr ) { boxNode = new QskBoxNode; } @@ -69,7 +69,7 @@ QSGNode* PieChartSkinlet::updateLabelsNode( const PieChart* pieChart, QSGNode* / { const int labelsCount = pieChart->labels().count(); - if ( labelsCount < 1 ) + if( labelsCount < 1 ) { return nullptr; } diff --git a/examples/iot-dashboard/PieChartSkinlet.h b/examples/iot-dashboard/PieChartSkinlet.h index 53a8ecbf..366d60b9 100644 --- a/examples/iot-dashboard/PieChartSkinlet.h +++ b/examples/iot-dashboard/PieChartSkinlet.h @@ -7,25 +7,25 @@ class PieChart; class PieChartSkinlet : public QskSkinlet { - Q_GADGET + Q_GADGET -public: - enum NodeRole - { - PanelRole, - LabelsRole - }; + public: + enum NodeRole + { + PanelRole, + LabelsRole + }; - Q_INVOKABLE PieChartSkinlet( QskSkin* skin = nullptr ); + Q_INVOKABLE PieChartSkinlet( QskSkin* skin = nullptr ); - QRectF subControlRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const override; + QRectF subControlRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const override; -protected: - virtual QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* node ) const override; + protected: + virtual QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* node ) const override; -private: - QSGNode* updatePanelNode( const PieChart*, QSGNode* ) const; - QSGNode* updateLabelsNode( const PieChart*, QSGNode* ) const; + private: + QSGNode* updatePanelNode( const PieChart*, QSGNode* ) const; + QSGNode* updateLabelsNode( const PieChart*, QSGNode* ) const; }; #endif // PIECHARTSKINLET_H diff --git a/examples/iot-dashboard/RoundedIcon.cpp b/examples/iot-dashboard/RoundedIcon.cpp index 034db78a..cee58e4b 100644 --- a/examples/iot-dashboard/RoundedIcon.cpp +++ b/examples/iot-dashboard/RoundedIcon.cpp @@ -6,21 +6,21 @@ #include -RoundedIcon::RoundedIcon(const QString& iconName, const QskGradient& gradient, QQuickItem* parent) - : QskBox(parent) - , m_iconName(iconName) - , m_gradient(gradient) +RoundedIcon::RoundedIcon( const QString& iconName, const QskGradient& gradient, QQuickItem* parent ) + : QskBox( parent ) + , m_iconName( iconName ) + , m_gradient( gradient ) { - setPanel(true); + setPanel( true ); setPolishOnResize( true ); - setGradientHint(Panel, gradient); - setBoxShapeHint(Panel, 6 ); + setGradientHint( Panel, gradient ); + setBoxShapeHint( Panel, 6 ); - setSizePolicy(QskSizePolicy::Minimum, QskSizePolicy::Constrained); + setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Constrained ); QString fileName = ":/images/" + iconName + ".png"; - if(QFile::exists(fileName)) + if( QFile::exists( fileName ) ) { QImage image( fileName ); auto graphic = QskGraphic::fromImage( image ); @@ -30,9 +30,9 @@ RoundedIcon::RoundedIcon(const QString& iconName, const QskGradient& gradient, Q void RoundedIcon::updateLayout() { - if(m_graphicLabel) + if( m_graphicLabel ) { - m_graphicLabel->setSize( {36, 36}); + m_graphicLabel->setSize( {36, 36} ); m_graphicLabel->setPosition( { ( width() - m_graphicLabel->width() ) / 2, ( height() - m_graphicLabel->height() ) / 2 } ); } } diff --git a/examples/iot-dashboard/RoundedIcon.h b/examples/iot-dashboard/RoundedIcon.h index aed72861..2c4f7a13 100644 --- a/examples/iot-dashboard/RoundedIcon.h +++ b/examples/iot-dashboard/RoundedIcon.h @@ -8,19 +8,19 @@ class QskGraphicLabel; class RoundedIcon : public QskBox { - Q_OBJECT + Q_OBJECT -public: - RoundedIcon(const QString& iconName, const QskGradient& gradient, QQuickItem *parent = nullptr); + public: + RoundedIcon( const QString& iconName, const QskGradient& gradient, QQuickItem* parent = nullptr ); -protected: - void updateLayout() override; - virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override; + protected: + void updateLayout() override; + virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override; -private: - QString m_iconName; - QskGradient m_gradient; - QskGraphicLabel* m_graphicLabel = nullptr; + private: + QString m_iconName; + QskGradient m_gradient; + QskGraphicLabel* m_graphicLabel = nullptr; }; #endif // ROUNDEDICON_H diff --git a/examples/iot-dashboard/TopBar.cpp b/examples/iot-dashboard/TopBar.cpp index 2c5db4ea..f72962e4 100644 --- a/examples/iot-dashboard/TopBar.cpp +++ b/examples/iot-dashboard/TopBar.cpp @@ -11,31 +11,31 @@ TopBarItem::TopBarItem(const QString& name, const QColor &textColor, const QGrad { setAutoLayoutChildren( true ); setAutoAddChildren( true ); - setSpacing(15); + setSpacing( 15 ); auto* textLabel = new QskTextLabel( name, this ); - textLabel->setFontRole(QskSkin::SmallFont); // ### style + textLabel->setFontRole( QskSkin::SmallFont ); // ### style auto* pieChartAndDisplay = new QskLinearBox( Qt::Horizontal, this ); - pieChartAndDisplay->setSpacing(10); + pieChartAndDisplay->setSpacing( 10 ); auto* pieChart = new PieChartPainted(textColor, gradient, progress, value, pieChartAndDisplay); auto* display = new QskLinearBox( Qt::Vertical, pieChartAndDisplay ); - display->setSpacing(0); - display->addSpacer(0, 1); - auto* displayValue = new QskTextLabel(QString::number(value), display); - displayValue->setFontRole(QskSkin::MediumFont); - auto* displayUnit = new QskTextLabel("kwH", display); - displayUnit->setFontRole(QskSkin::SmallFont); - display->addSpacer(0, 1); + display->setSpacing( 0 ); + display->addSpacer( 0, 1 ); + auto* displayValue = new QskTextLabel( QString::number( value ), display ); + displayValue->setFontRole( QskSkin::MediumFont ); + auto* displayUnit = new QskTextLabel( "kwH", display ); + displayUnit->setFontRole( QskSkin::SmallFont ); + display->addSpacer( 0, 1 ); } -TopBar::TopBar(QQuickItem *parent) : QskLinearBox(Qt::Horizontal, parent) +TopBar::TopBar( QQuickItem* parent ) : QskLinearBox( Qt::Horizontal, parent ) { - setAutoLayoutChildren(true); - setAutoAddChildren(true); - setSizePolicy(QskSizePolicy::Preferred, QskSizePolicy::Fixed); - setMargins({25, 35, 25, 0}); + setAutoLayoutChildren( true ); + setAutoAddChildren( true ); + setSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Fixed ); + setMargins( {25, 35, 25, 0} ); QStringList itemStrings = { "Living Room", "Bedroom", "Bathroom", "Kitchen" }; QColor textColors[] = {"#ff3122", "#6776ff", "#f99055", "#6776ff"}; @@ -43,30 +43,31 @@ TopBar::TopBar(QQuickItem *parent) : QskLinearBox(Qt::Horizontal, parent) "#6776FF", "#6100FF", "#FFCE50", "#FF3122", // "#00ff00", "#ffffff", // ### remove - "#6776FF", "#6100FF"}; + "#6776FF", "#6100FF" + }; int progressValues[] = {25, 45, 15, 86}; int values[] = {175, 205, 115, 289}; - for(int a = 0; a < itemStrings.count(); a++) + for( int a = 0; a < itemStrings.count(); a++ ) { - QLinearGradient gradient(0, 0, 30, 0); // ### do this properly and dependent on the size - QGradientStop stop1(0.0, gradientColors[2 * a]); - QGradientStop stop2(1.0, gradientColors[2 * a + 1]); - gradient.setStops({stop1, stop2}); + QLinearGradient gradient( 0, 0, 30, 0 ); // ### do this properly and dependent on the size + QGradientStop stop1( 0.0, gradientColors[2 * a] ); + QGradientStop stop2( 1.0, gradientColors[2 * a + 1] ); + gradient.setStops( {stop1, stop2} ); - auto* item = new TopBarItem( itemStrings.at(a), textColors[a], gradient, progressValues[a], values[a], this ); - m_entries.append(item); + auto* item = new TopBarItem( itemStrings.at( a ), textColors[a], gradient, progressValues[a], values[a], this ); + m_entries.append( item ); } - auto* timeControl = new QskLinearBox(Qt::Vertical, this); - timeControl->setMargins({0, 0, 50, 0}); - auto* timeTitle = new QskTextLabel("Current time", timeControl); // ### make bold or so - timeTitle->setFontRole(QskSkin::TinyFont); + auto* timeControl = new QskLinearBox( Qt::Vertical, this ); + timeControl->setMargins( {0, 0, 50, 0} ); + auto* timeTitle = new QskTextLabel( "Current time", timeControl ); // ### make bold or so + timeTitle->setFontRole( QskSkin::TinyFont ); auto now = QTime::currentTime(); auto timeString = now.toString(); - auto* timeDisplay = new QskTextLabel(timeString, timeControl); - timeDisplay->setFontRole(QskSkin::HugeFont); - timeDisplay->setTextColor("#6776FF"); + auto* timeDisplay = new QskTextLabel( timeString, timeControl ); + timeDisplay->setFontRole( QskSkin::HugeFont ); + timeDisplay->setTextColor( "#6776FF" ); } diff --git a/examples/iot-dashboard/TopBar.h b/examples/iot-dashboard/TopBar.h index 3865750d..7af876f3 100644 --- a/examples/iot-dashboard/TopBar.h +++ b/examples/iot-dashboard/TopBar.h @@ -5,22 +5,22 @@ class TopBarItem : public QskLinearBox { - Q_OBJECT + Q_OBJECT -public: - TopBarItem(const QString& name, const QColor& textColor, const QGradient &gradient, int progress, int value, QQuickItem* parent ); + public: + TopBarItem( const QString& name, const QColor& textColor, const QGradient& gradient, int progress, int value, QQuickItem* parent ); -private: - QString m_name; + private: + QString m_name; }; class TopBar : public QskLinearBox { - Q_OBJECT + Q_OBJECT -public: - TopBar(QQuickItem* parent); + public: + TopBar( QQuickItem* parent ); -private: - QList< TopBarItem* > m_entries; + private: + QList< TopBarItem* > m_entries; };