use astyle

This commit is contained in:
Peter Hartmann 2021-03-26 09:45:33 +01:00
parent 640cfd17d7
commit 10018cdabf
11 changed files with 145 additions and 138 deletions

View File

@ -9,15 +9,15 @@ class QskLinearBox;
class MainWindow : public QskWindow class MainWindow : public QskWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWindow(); MainWindow();
private: private:
QskLinearBox* m_mainLayout; QskLinearBox* m_mainLayout;
MenuBar* m_menuBar; MenuBar* m_menuBar;
MainContent* m_mainContent; MainContent* m_mainContent;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -16,76 +16,82 @@ MenuItem::MenuItem( const QString& name, QQuickItem* parent ) : QskLinearBox( Qt
setAutoLayoutChildren( true ); setAutoLayoutChildren( true );
setAutoAddChildren( true ); setAutoAddChildren( true );
setFixedSize( {140, 40} ); setFixedSize( {140, 40} );
setMargins({0, 0, 0, 0}); setMargins( {0, 0, 0, 0} );
setPadding({30, 0, 30, 0}); setPadding( {30, 0, 30, 0} );
setSpacing(6); setSpacing( 6 );
setAcceptHoverEvents(true); setAcceptHoverEvents( true );
setPanel(true); setPanel( true );
QString fileName = ":/images/" + name.toLower() + ".png"; // width: 14 QString fileName = ":/images/" + name.toLower() + ".png"; // width: 14
QImage image( fileName ); QImage image( fileName );
auto graphic = QskGraphic::fromImage( image ); auto graphic = QskGraphic::fromImage( image );
auto* graphicLabel = new QskGraphicLabel( graphic, this ); auto* graphicLabel = new QskGraphicLabel( graphic, this );
graphicLabel->setSizePolicy(QskSizePolicy::Fixed, QskSizePolicy::Fixed); graphicLabel->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
graphicLabel->setFixedWidth(14); graphicLabel->setFixedWidth( 14 );
graphicLabel->setAlignment(Qt::AlignCenter); graphicLabel->setAlignment( Qt::AlignCenter );
auto* textLabel = new QskTextLabel( name, this ); auto* textLabel = new QskTextLabel( name, this );
textLabel->setTextColor( Qt::white ); // ### style textLabel->setTextColor( Qt::white ); // ### style
textLabel->setFontRole(QskSkin::SmallFont); // ### style textLabel->setFontRole( QskSkin::SmallFont ); // ### style
} }
QskAspect::Subcontrol MenuItem::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const QskAspect::Subcontrol MenuItem::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const
{ {
if ( subControl == QskBox::Panel ) if( subControl == QskBox::Panel )
{
return MenuItem::Panel; return MenuItem::Panel;
}
return subControl; return subControl;
} }
void MenuItem::setActive(bool active) void MenuItem::setActive( bool active )
{ {
QColor color; QColor color;
if(active) { if( active )
{
color = Qt::white; color = Qt::white;
color.setAlphaF(0.14); color.setAlphaF( 0.14 );
} else { }
else
{
color = Qt::transparent; 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 ); setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Preferred );
setAutoLayoutChildren( true ); setAutoLayoutChildren( true );
setAutoAddChildren( true ); setAutoAddChildren( true );
setSpacing(8); setSpacing( 8 );
setMargins({0, 35, 0, 12}); setMargins( {0, 35, 0, 12} );
setBackgroundColor( "#6D7BFB" ); // ### style setBackgroundColor( "#6D7BFB" ); // ### style
auto* mainIcon = ":/images/main-icon.png"; auto* mainIcon = ":/images/main-icon.png";
QImage image(mainIcon); QImage image( mainIcon );
auto graphic = QskGraphic::fromImage( image ); auto graphic = QskGraphic::fromImage( image );
auto* graphicLabel = new QskGraphicLabel( graphic, this ); auto* graphicLabel = new QskGraphicLabel( graphic, this );
graphicLabel->setAlignment(Qt::AlignTop); graphicLabel->setAlignment( Qt::AlignTop );
graphicLabel->setMargins( { 50, 0, 50, 54 }); graphicLabel->setMargins( { 50, 0, 50, 54 } );
graphicLabel->setSizePolicy(QskSizePolicy::Fixed, QskSizePolicy::Fixed); graphicLabel->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
m_entryStrings = { "Dashboard", "Rooms", "Devices", "Statistics", "Storage", "Members" }; 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 ); 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 addSpacer( 0, 1 ); // fill the space at the bottom

View File

@ -5,33 +5,33 @@
class MenuItem : public QskLinearBox class MenuItem : public QskLinearBox
{ {
Q_OBJECT Q_OBJECT
public: public:
QSK_SUBCONTROLS( Panel ) 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: private:
QString m_name; QString m_name;
bool m_isActive = false; bool m_isActive = false;
}; };
class MenuBar : public QskLinearBox class MenuBar : public QskLinearBox
{ {
Q_OBJECT Q_OBJECT
public: public:
MenuBar( QQuickItem* parent ); MenuBar( QQuickItem* parent );
private: private:
QList< QString > m_entryStrings; QList< QString > m_entryStrings;
QList< MenuItem* > m_entries; QList< MenuItem* > m_entries;
uint m_activeEntry = 0; uint m_activeEntry = 0;
}; };
#endif // MENUBAR_H #endif // MENUBAR_H

View File

@ -3,7 +3,7 @@
QSK_SUBCONTROL( PieChart, Panel ) QSK_SUBCONTROL( PieChart, Panel )
QSK_SUBCONTROL( PieChart, Labels ) QSK_SUBCONTROL( PieChart, Labels )
PieChart::PieChart( QQuickItem *parent ) : QskControl( parent ) PieChart::PieChart( QQuickItem* parent ) : QskControl( parent )
{ {
} }

View File

@ -5,22 +5,22 @@
class PieChart : public QskControl class PieChart : public QskControl
{ {
Q_OBJECT Q_OBJECT
public: public:
QSK_SUBCONTROLS( Panel, Labels ) QSK_SUBCONTROLS( Panel, Labels )
PieChart( QQuickItem* parent = nullptr ); PieChart( QQuickItem* parent = nullptr );
QVector< float > angles() const; QVector< float > angles() const;
void setAngles( const QVector< float >& angles ); void setAngles( const QVector< float >& angles );
QVector< QString > labels() const; QVector< QString > labels() const;
void setLabels( const QVector< QString >& labels ); void setLabels( const QVector< QString >& labels );
private: private:
QVector< float > m_angles; QVector< float > m_angles;
QVector< QString > m_labels; QVector< QString > m_labels;
}; };
#endif // PIECHART_H #endif // PIECHART_H

View File

@ -20,7 +20,7 @@ QSGNode* PieChartSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 n
{ {
const auto pieChart = static_cast< const PieChart* >( skinnable ); const auto pieChart = static_cast< const PieChart* >( skinnable );
switch ( nodeRole ) switch( nodeRole )
{ {
case PanelRole: case PanelRole:
return updatePanelNode( pieChart, node ); return updatePanelNode( pieChart, node );
@ -37,7 +37,7 @@ QSGNode* PieChartSkinlet::updatePanelNode( const PieChart* pieChart, QSGNode* no
{ {
auto boxNode = static_cast< QskBoxNode* >( node ); auto boxNode = static_cast< QskBoxNode* >( node );
if ( boxNode == nullptr ) if( boxNode == nullptr )
{ {
boxNode = new QskBoxNode; boxNode = new QskBoxNode;
} }
@ -69,7 +69,7 @@ QSGNode* PieChartSkinlet::updateLabelsNode( const PieChart* pieChart, QSGNode* /
{ {
const int labelsCount = pieChart->labels().count(); const int labelsCount = pieChart->labels().count();
if ( labelsCount < 1 ) if( labelsCount < 1 )
{ {
return nullptr; return nullptr;
} }

View File

@ -7,25 +7,25 @@ class PieChart;
class PieChartSkinlet : public QskSkinlet class PieChartSkinlet : public QskSkinlet
{ {
Q_GADGET Q_GADGET
public: public:
enum NodeRole enum NodeRole
{ {
PanelRole, PanelRole,
LabelsRole 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: protected:
virtual QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* node ) const override; virtual QSGNode* updateSubNode( const QskSkinnable*, quint8 nodeRole, QSGNode* node ) const override;
private: private:
QSGNode* updatePanelNode( const PieChart*, QSGNode* ) const; QSGNode* updatePanelNode( const PieChart*, QSGNode* ) const;
QSGNode* updateLabelsNode( const PieChart*, QSGNode* ) const; QSGNode* updateLabelsNode( const PieChart*, QSGNode* ) const;
}; };
#endif // PIECHARTSKINLET_H #endif // PIECHARTSKINLET_H

View File

@ -6,21 +6,21 @@
#include <QImage> #include <QImage>
RoundedIcon::RoundedIcon(const QString& iconName, const QskGradient& gradient, QQuickItem* parent) RoundedIcon::RoundedIcon( const QString& iconName, const QskGradient& gradient, QQuickItem* parent )
: QskBox(parent) : QskBox( parent )
, m_iconName(iconName) , m_iconName( iconName )
, m_gradient(gradient) , m_gradient( gradient )
{ {
setPanel(true); setPanel( true );
setPolishOnResize( true ); setPolishOnResize( true );
setGradientHint(Panel, gradient); setGradientHint( Panel, gradient );
setBoxShapeHint(Panel, 6 ); setBoxShapeHint( Panel, 6 );
setSizePolicy(QskSizePolicy::Minimum, QskSizePolicy::Constrained); setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Constrained );
QString fileName = ":/images/" + iconName + ".png"; QString fileName = ":/images/" + iconName + ".png";
if(QFile::exists(fileName)) if( QFile::exists( fileName ) )
{ {
QImage image( fileName ); QImage image( fileName );
auto graphic = QskGraphic::fromImage( image ); auto graphic = QskGraphic::fromImage( image );
@ -30,9 +30,9 @@ RoundedIcon::RoundedIcon(const QString& iconName, const QskGradient& gradient, Q
void RoundedIcon::updateLayout() 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 } ); m_graphicLabel->setPosition( { ( width() - m_graphicLabel->width() ) / 2, ( height() - m_graphicLabel->height() ) / 2 } );
} }
} }

View File

@ -8,19 +8,19 @@ class QskGraphicLabel;
class RoundedIcon : public QskBox class RoundedIcon : public QskBox
{ {
Q_OBJECT Q_OBJECT
public: public:
RoundedIcon(const QString& iconName, const QskGradient& gradient, QQuickItem *parent = nullptr); RoundedIcon( const QString& iconName, const QskGradient& gradient, QQuickItem* parent = nullptr );
protected: protected:
void updateLayout() override; void updateLayout() override;
virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override; virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
private: private:
QString m_iconName; QString m_iconName;
QskGradient m_gradient; QskGradient m_gradient;
QskGraphicLabel* m_graphicLabel = nullptr; QskGraphicLabel* m_graphicLabel = nullptr;
}; };
#endif // ROUNDEDICON_H #endif // ROUNDEDICON_H

View File

@ -11,31 +11,31 @@ TopBarItem::TopBarItem(const QString& name, const QColor &textColor, const QGrad
{ {
setAutoLayoutChildren( true ); setAutoLayoutChildren( true );
setAutoAddChildren( true ); setAutoAddChildren( true );
setSpacing(15); setSpacing( 15 );
auto* textLabel = new QskTextLabel( name, this ); auto* textLabel = new QskTextLabel( name, this );
textLabel->setFontRole(QskSkin::SmallFont); // ### style textLabel->setFontRole( QskSkin::SmallFont ); // ### style
auto* pieChartAndDisplay = new QskLinearBox( Qt::Horizontal, this ); auto* pieChartAndDisplay = new QskLinearBox( Qt::Horizontal, this );
pieChartAndDisplay->setSpacing(10); pieChartAndDisplay->setSpacing( 10 );
auto* pieChart = new PieChartPainted(textColor, gradient, progress, value, pieChartAndDisplay); auto* pieChart = new PieChartPainted(textColor, gradient, progress, value, pieChartAndDisplay);
auto* display = new QskLinearBox( Qt::Vertical, pieChartAndDisplay ); auto* display = new QskLinearBox( Qt::Vertical, pieChartAndDisplay );
display->setSpacing(0); display->setSpacing( 0 );
display->addSpacer(0, 1); display->addSpacer( 0, 1 );
auto* displayValue = new QskTextLabel(QString::number(value), display); auto* displayValue = new QskTextLabel( QString::number( value ), display );
displayValue->setFontRole(QskSkin::MediumFont); displayValue->setFontRole( QskSkin::MediumFont );
auto* displayUnit = new QskTextLabel("kwH", display); auto* displayUnit = new QskTextLabel( "kwH", display );
displayUnit->setFontRole(QskSkin::SmallFont); displayUnit->setFontRole( QskSkin::SmallFont );
display->addSpacer(0, 1); display->addSpacer( 0, 1 );
} }
TopBar::TopBar(QQuickItem *parent) : QskLinearBox(Qt::Horizontal, parent) TopBar::TopBar( QQuickItem* parent ) : QskLinearBox( Qt::Horizontal, parent )
{ {
setAutoLayoutChildren(true); setAutoLayoutChildren( true );
setAutoAddChildren(true); setAutoAddChildren( true );
setSizePolicy(QskSizePolicy::Preferred, QskSizePolicy::Fixed); setSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Fixed );
setMargins({25, 35, 25, 0}); setMargins( {25, 35, 25, 0} );
QStringList itemStrings = { "Living Room", "Bedroom", "Bathroom", "Kitchen" }; QStringList itemStrings = { "Living Room", "Bedroom", "Bathroom", "Kitchen" };
QColor textColors[] = {"#ff3122", "#6776ff", "#f99055", "#6776ff"}; QColor textColors[] = {"#ff3122", "#6776ff", "#f99055", "#6776ff"};
@ -43,30 +43,31 @@ TopBar::TopBar(QQuickItem *parent) : QskLinearBox(Qt::Horizontal, parent)
"#6776FF", "#6100FF", "#6776FF", "#6100FF",
"#FFCE50", "#FF3122", "#FFCE50", "#FF3122",
// "#00ff00", "#ffffff", // ### remove // "#00ff00", "#ffffff", // ### remove
"#6776FF", "#6100FF"}; "#6776FF", "#6100FF"
};
int progressValues[] = {25, 45, 15, 86}; int progressValues[] = {25, 45, 15, 86};
int values[] = {175, 205, 115, 289}; 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 QLinearGradient gradient( 0, 0, 30, 0 ); // ### do this properly and dependent on the size
QGradientStop stop1(0.0, gradientColors[2 * a]); QGradientStop stop1( 0.0, gradientColors[2 * a] );
QGradientStop stop2(1.0, gradientColors[2 * a + 1]); QGradientStop stop2( 1.0, gradientColors[2 * a + 1] );
gradient.setStops({stop1, stop2}); gradient.setStops( {stop1, stop2} );
auto* item = new TopBarItem( itemStrings.at(a), textColors[a], gradient, progressValues[a], values[a], this ); auto* item = new TopBarItem( itemStrings.at( a ), textColors[a], gradient, progressValues[a], values[a], this );
m_entries.append(item); m_entries.append( item );
} }
auto* timeControl = new QskLinearBox(Qt::Vertical, this); auto* timeControl = new QskLinearBox( Qt::Vertical, this );
timeControl->setMargins({0, 0, 50, 0}); timeControl->setMargins( {0, 0, 50, 0} );
auto* timeTitle = new QskTextLabel("Current time", timeControl); // ### make bold or so auto* timeTitle = new QskTextLabel( "Current time", timeControl ); // ### make bold or so
timeTitle->setFontRole(QskSkin::TinyFont); timeTitle->setFontRole( QskSkin::TinyFont );
auto now = QTime::currentTime(); auto now = QTime::currentTime();
auto timeString = now.toString(); auto timeString = now.toString();
auto* timeDisplay = new QskTextLabel(timeString, timeControl); auto* timeDisplay = new QskTextLabel( timeString, timeControl );
timeDisplay->setFontRole(QskSkin::HugeFont); timeDisplay->setFontRole( QskSkin::HugeFont );
timeDisplay->setTextColor("#6776FF"); timeDisplay->setTextColor( "#6776FF" );
} }

View File

@ -5,22 +5,22 @@
class TopBarItem : public QskLinearBox class TopBarItem : public QskLinearBox
{ {
Q_OBJECT Q_OBJECT
public: public:
TopBarItem(const QString& name, const QColor& textColor, const QGradient &gradient, int progress, int value, QQuickItem* parent ); TopBarItem( const QString& name, const QColor& textColor, const QGradient& gradient, int progress, int value, QQuickItem* parent );
private: private:
QString m_name; QString m_name;
}; };
class TopBar : public QskLinearBox class TopBar : public QskLinearBox
{ {
Q_OBJECT Q_OBJECT
public: public:
TopBar(QQuickItem* parent); TopBar( QQuickItem* parent );
private: private:
QList< TopBarItem* > m_entries; QList< TopBarItem* > m_entries;
}; };