use astyle
This commit is contained in:
parent
640cfd17d7
commit
10018cdabf
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
QSK_SUBCONTROL( PieChart, Panel )
|
||||
QSK_SUBCONTROL( PieChart, Labels )
|
||||
|
||||
PieChart::PieChart( QQuickItem *parent ) : QskControl( parent )
|
||||
PieChart::PieChart( QQuickItem* parent ) : QskControl( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,21 +6,21 @@
|
|||
|
||||
#include <QImage>
|
||||
|
||||
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 } );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue