add night time skin
This commit is contained in:
parent
e360c16be3
commit
2a3913ef06
|
@ -8,6 +8,8 @@
|
||||||
#include <QskBoxShapeMetrics.h>
|
#include <QskBoxShapeMetrics.h>
|
||||||
#include <QskTextLabel.h>
|
#include <QskTextLabel.h>
|
||||||
|
|
||||||
|
QSK_SUBCONTROL( Box, Panel )
|
||||||
|
|
||||||
ShadowBox::ShadowBox( QQuickItem* parent )
|
ShadowBox::ShadowBox( QQuickItem* parent )
|
||||||
: QskControl( parent )
|
: QskControl( parent )
|
||||||
// , m_control( control )
|
// , m_control( control )
|
||||||
|
@ -73,3 +75,13 @@ Box::Box( const QString& title, QQuickItem* parent )
|
||||||
m_label->setVisible( false );
|
m_label->setVisible( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QskAspect::Subcontrol Box::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const
|
||||||
|
{
|
||||||
|
if( subControl == QskBox::Panel )
|
||||||
|
{
|
||||||
|
return Box::Panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subControl;
|
||||||
|
}
|
||||||
|
|
|
@ -23,9 +23,15 @@ class ShadowBox : public QskControl
|
||||||
|
|
||||||
class Box : public QskLinearBox
|
class Box : public QskLinearBox
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
QSK_SUBCONTROLS( Panel )
|
||||||
|
|
||||||
Box( const QString& title, QQuickItem* parent );
|
Box( const QString& title, QQuickItem* parent );
|
||||||
|
|
||||||
|
QskAspect::Subcontrol effectiveSubcontrol(
|
||||||
|
QskAspect::Subcontrol subControl ) const override final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_title;
|
QString m_title;
|
||||||
QskTextLabel* m_label;
|
QskTextLabel* m_label;
|
||||||
|
|
|
@ -2,38 +2,38 @@
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
CircularProgressBar::CircularProgressBar(const QGradient &gradient, int progress, QQuickItem *parent)
|
CircularProgressBar::CircularProgressBar( const QGradient& gradient, int progress, QQuickItem* parent )
|
||||||
: QQuickPaintedItem(parent)
|
: QQuickPaintedItem( parent )
|
||||||
, m_gradient(gradient)
|
, m_gradient( gradient )
|
||||||
, m_progress(progress)
|
, m_progress( progress )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CircularProgressBar::paint(QPainter *painter)
|
void CircularProgressBar::paint( QPainter* painter )
|
||||||
{
|
{
|
||||||
auto size = contentsSize();
|
auto size = contentsSize();
|
||||||
QRectF outerRect({0, 0}, size);
|
QRectF outerRect( {0, 0}, size );
|
||||||
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
painter->setRenderHint( QPainter::Antialiasing, true );
|
||||||
|
|
||||||
QRadialGradient gradient(size.width() / 2, size.height() / 2, 45);
|
QRadialGradient gradient( size.width() / 2, size.height() / 2, 45 );
|
||||||
QGradientStop stop1(0.0, "#c0c0c0");
|
QGradientStop stop1( 0.0, "#c0c0c0" );
|
||||||
QGradientStop stop2(0.5, "#f0f0f0");
|
QGradientStop stop2( 0.5, "#f0f0f0" );
|
||||||
QGradientStop stop3(1.0, "#c0c0c0");
|
QGradientStop stop3( 1.0, "#c0c0c0" );
|
||||||
gradient.setStops({stop1, stop2, stop3});
|
gradient.setStops( {stop1, stop2, stop3} );
|
||||||
|
|
||||||
painter->setBrush(gradient);
|
painter->setBrush( gradient );
|
||||||
painter->setPen(Qt::white);
|
painter->setPen( m_backgroundColor );
|
||||||
painter->drawEllipse(outerRect);
|
painter->drawEllipse( outerRect );
|
||||||
|
|
||||||
int startAngle = 1440;
|
int startAngle = 1440;
|
||||||
int endAngle = -16 * (m_progress / 100.0) * 360;
|
int endAngle = -16 * ( m_progress / 100.0 ) * 360;
|
||||||
|
|
||||||
painter->setBrush(m_gradient);
|
painter->setBrush( m_gradient );
|
||||||
painter->drawPie(outerRect, startAngle, endAngle);
|
painter->drawPie( outerRect, startAngle, endAngle );
|
||||||
|
|
||||||
painter->setBrush(Qt::white);
|
painter->setBrush( m_backgroundColor );
|
||||||
painter->setPen(Qt::white);
|
painter->setPen( m_backgroundColor );
|
||||||
QRectF innerRect(width() / 2, width() / 2, size.width() - width(), size.height() - width());
|
QRectF innerRect( width() / 2, width() / 2, size.width() - width(), size.height() - width() );
|
||||||
painter->drawEllipse(innerRect);
|
painter->drawEllipse( innerRect );
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,23 +6,33 @@
|
||||||
|
|
||||||
class CircularProgressBar : public QQuickPaintedItem
|
class CircularProgressBar : public QQuickPaintedItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CircularProgressBar(const QGradient& gradient, int progress, QQuickItem* parent = nullptr);
|
CircularProgressBar( const QGradient& gradient, int progress, QQuickItem* parent = nullptr );
|
||||||
|
|
||||||
virtual void paint(QPainter *painter) override;
|
virtual void paint( QPainter* painter ) override;
|
||||||
|
|
||||||
double width() const {
|
double width() const
|
||||||
return m_width;
|
{
|
||||||
}
|
return m_width;
|
||||||
|
}
|
||||||
|
|
||||||
void setWidth(double width) {
|
void setWidth( double width )
|
||||||
m_width = width;
|
{
|
||||||
}
|
m_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
void setBackgroundColor( const QColor& color )
|
||||||
QGradient m_gradient;
|
{
|
||||||
double m_width = 20;
|
m_backgroundColor = color;
|
||||||
int m_progress;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGradient m_gradient;
|
||||||
|
QColor m_backgroundColor;
|
||||||
|
double m_width = 20;
|
||||||
|
int m_progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CIRCULARPROGRESSBAR_H
|
#endif // CIRCULARPROGRESSBAR_H
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#include "DaytimeSkin.h"
|
#include "DaytimeSkin.h"
|
||||||
|
|
||||||
|
#include "Box.h"
|
||||||
|
#include "LightIntensity.h"
|
||||||
|
#include "MainContent.h"
|
||||||
#include "MenuBar.h"
|
#include "MenuBar.h"
|
||||||
#include "QskShadowedRectangle.h"
|
#include "QskShadowedRectangle.h"
|
||||||
#include "QskShadowedRectangleSkinlet.h"
|
#include "QskShadowedRectangleSkinlet.h"
|
||||||
#include "PieChart.h"
|
#include "PieChartPainted.h"
|
||||||
#include "PieChartSkinlet.h"
|
|
||||||
|
|
||||||
#include <QskBoxBorderMetrics.h>
|
#include <QskBoxBorderMetrics.h>
|
||||||
#include <QskBoxBorderColors.h>
|
#include <QskBoxBorderColors.h>
|
||||||
|
@ -32,7 +34,6 @@ namespace
|
||||||
DaytimeSkin::DaytimeSkin( QObject* parent ) : QskSkin( parent )
|
DaytimeSkin::DaytimeSkin( QObject* parent ) : QskSkin( parent )
|
||||||
{
|
{
|
||||||
declareSkinlet< QskShadowedRectangle, QskShadowedRectangleSkinlet >();
|
declareSkinlet< QskShadowedRectangle, QskShadowedRectangleSkinlet >();
|
||||||
declareSkinlet< PieChart, PieChartSkinlet >();
|
|
||||||
initHints();
|
initHints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +51,13 @@ void DaytimeSkin::initHints()
|
||||||
|
|
||||||
setFont( DaytimeSkin::TitleFont, qskFont( 10, true ) );
|
setFont( DaytimeSkin::TitleFont, qskFont( 10, true ) );
|
||||||
|
|
||||||
|
|
||||||
|
setGradient( MainContent::Panel, {"#fbfbfb"} );
|
||||||
|
setGradient( Box::Panel, {"#ffffff"} );
|
||||||
|
setColor( LightDisplay::Panel, "#ffffff" );
|
||||||
|
setColor( PieChartPainted::Panel, "#ffffff" );
|
||||||
|
|
||||||
QColor color( Qt::white );
|
QColor color( Qt::white );
|
||||||
color.setAlphaF( 0.09 );
|
color.setAlphaF( 0.09 );
|
||||||
setGradient( MenuItem::Panel | QskControl::Hovered, color );
|
setGradient( MenuItem::Panel | QskControl::Hovered, color );
|
||||||
|
|
||||||
setBoxBorderMetrics( PieChart::Panel, 2 );
|
|
||||||
setGradient( PieChart::Panel, Qt::blue );
|
|
||||||
setBoxBorderColors( PieChart::Panel, Qt::green );
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,16 @@
|
||||||
|
|
||||||
class DaytimeSkin : public QskSkin
|
class DaytimeSkin : public QskSkin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DaytimeSkin( QObject* parent = nullptr );
|
DaytimeSkin( QObject* parent = nullptr );
|
||||||
|
|
||||||
enum SkinFontRole {
|
enum SkinFontRole
|
||||||
TitleFont = QskSkin::HugeFont + 1,
|
{
|
||||||
};
|
TitleFont = QskSkin::HugeFont + 1,
|
||||||
|
};
|
||||||
private:
|
|
||||||
void initHints();
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initHints();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DAYTIMESKIN_H
|
#endif // DAYTIMESKIN_H
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
Humidity::Humidity( QQuickItem* parent )
|
Humidity::Humidity( QQuickItem* parent )
|
||||||
: Box( "", parent )
|
: Box( "", parent )
|
||||||
{
|
{
|
||||||
|
setPanel( true );
|
||||||
setMarginsHint( Panel | QskAspect::Padding, 8 );
|
setMarginsHint( Panel | QskAspect::Padding, 8 );
|
||||||
setSizePolicy( Qt::Vertical, QskSizePolicy::Maximum );
|
setSizePolicy( Qt::Vertical, QskSizePolicy::Maximum );
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
IndoorTemperature::IndoorTemperature( QQuickItem* parent )
|
IndoorTemperature::IndoorTemperature( QQuickItem* parent )
|
||||||
: Box( "", parent )
|
: Box( "", parent )
|
||||||
{
|
{
|
||||||
|
setPanel( true );
|
||||||
setMarginsHint( Panel | QskAspect::Padding, 8 );
|
setMarginsHint( Panel | QskAspect::Padding, 8 );
|
||||||
setSizePolicy( Qt::Vertical, QskSizePolicy::Maximum );
|
setSizePolicy( Qt::Vertical, QskSizePolicy::Maximum );
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
#include "LightIntensity.h"
|
#include "LightIntensity.h"
|
||||||
#include "DaytimeSkin.h"
|
#include "DaytimeSkin.h"
|
||||||
|
|
||||||
|
#include <QskSetup.h>
|
||||||
#include <QskTextLabel.h>
|
#include <QskTextLabel.h>
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QRadialGradient>
|
#include <QRadialGradient>
|
||||||
|
|
||||||
|
QSK_SUBCONTROL( LightDisplay, Panel )
|
||||||
|
|
||||||
LightDimmer::LightDimmer( QQuickItem* parent )
|
LightDimmer::LightDimmer( QQuickItem* parent )
|
||||||
: QQuickPaintedItem( parent )
|
: QQuickPaintedItem( parent )
|
||||||
{
|
{
|
||||||
|
@ -28,7 +31,8 @@ void LightDimmer::paint( QPainter* painter )
|
||||||
gradient.setStops( {stop1, stop2, stop3} );
|
gradient.setStops( {stop1, stop2, stop3} );
|
||||||
|
|
||||||
painter->setBrush( gradient );
|
painter->setBrush( gradient );
|
||||||
painter->setPen( Qt::white );
|
|
||||||
|
painter->setPen( m_backgroundColor );
|
||||||
painter->drawEllipse( outerRect );
|
painter->drawEllipse( outerRect );
|
||||||
|
|
||||||
int startAngle = 16 * 180;
|
int startAngle = 16 * 180;
|
||||||
|
@ -48,12 +52,12 @@ void LightDimmer::paint( QPainter* painter )
|
||||||
painter->setBrush( redGradient );
|
painter->setBrush( redGradient );
|
||||||
painter->drawPie( outerRect, 16 * 90, endAngle );
|
painter->drawPie( outerRect, 16 * 90, endAngle );
|
||||||
|
|
||||||
painter->setBrush( Qt::white );
|
painter->setBrush( m_backgroundColor );
|
||||||
painter->setPen( Qt::white );
|
painter->setPen( m_backgroundColor );
|
||||||
QRectF innerRect( thickness() / 2, thickness() / 2 + offset, size.width() - thickness(), size.height() - thickness() );
|
QRectF innerRect( thickness() / 2, thickness() / 2 + offset, size.width() - thickness(), size.height() - thickness() );
|
||||||
painter->drawEllipse( innerRect );
|
painter->drawEllipse( innerRect );
|
||||||
|
|
||||||
painter->setBrush( Qt::white );
|
painter->setBrush( m_backgroundColor );
|
||||||
painter->setPen( "#c4c4c4" );
|
painter->setPen( "#c4c4c4" );
|
||||||
QRectF knobRect( ( contentsSize().width() - knobDiameter ) / 2, 1, knobDiameter, knobDiameter );
|
QRectF knobRect( ( contentsSize().width() - knobDiameter ) / 2, 1, knobDiameter, knobDiameter );
|
||||||
painter->drawEllipse( knobRect );
|
painter->drawEllipse( knobRect );
|
||||||
|
@ -75,6 +79,25 @@ LightDisplay::LightDisplay( QQuickItem* parent )
|
||||||
m_rightLabel->setZ( 1 );
|
m_rightLabel->setZ( 1 );
|
||||||
|
|
||||||
setAutoLayoutChildren( true );
|
setAutoLayoutChildren( true );
|
||||||
|
|
||||||
|
const QColor c = color( Panel );
|
||||||
|
m_dimmer->setBackgroundColor( c );
|
||||||
|
|
||||||
|
connect( qskSetup, &QskSetup::skinChanged, [this]()
|
||||||
|
{
|
||||||
|
const QColor c = color( Panel );
|
||||||
|
m_dimmer->setBackgroundColor( c );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
QskAspect::Subcontrol LightDisplay::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const
|
||||||
|
{
|
||||||
|
if( subControl == QskBox::Panel )
|
||||||
|
{
|
||||||
|
return LightDisplay::Panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightDisplay::updateLayout()
|
void LightDisplay::updateLayout()
|
||||||
|
|
|
@ -24,8 +24,14 @@ class LightDimmer: public QQuickPaintedItem
|
||||||
m_thickness = thickness;
|
m_thickness = thickness;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setBackgroundColor( const QColor& color )
|
||||||
|
{
|
||||||
|
m_backgroundColor = color;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double m_thickness = 17.57;
|
double m_thickness = 17.57;
|
||||||
|
QColor m_backgroundColor;
|
||||||
|
|
||||||
virtual void paint( QPainter* painter ) override;
|
virtual void paint( QPainter* painter ) override;
|
||||||
};
|
};
|
||||||
|
@ -35,8 +41,13 @@ class LightDisplay : public QskControl
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QSK_SUBCONTROLS( Panel )
|
||||||
|
|
||||||
LightDisplay( QQuickItem* parent );
|
LightDisplay( QQuickItem* parent );
|
||||||
|
|
||||||
|
QskAspect::Subcontrol effectiveSubcontrol(
|
||||||
|
QskAspect::Subcontrol subControl ) const override final;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateLayout() override;
|
void updateLayout() override;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
QSK_SUBCONTROL( MainContent, Panel )
|
||||||
|
|
||||||
ShadowPositioner::ShadowPositioner( QQuickItem* parent ) : QskControl( parent )
|
ShadowPositioner::ShadowPositioner( QQuickItem* parent ) : QskControl( parent )
|
||||||
{
|
{
|
||||||
setAutoLayoutChildren( true );
|
setAutoLayoutChildren( true );
|
||||||
|
@ -67,7 +69,7 @@ MainContent::MainContent( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, par
|
||||||
setSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Expanding );
|
setSizePolicy( QskSizePolicy::Expanding, QskSizePolicy::Expanding );
|
||||||
setDefaultAlignment( Qt::AlignTop );
|
setDefaultAlignment( Qt::AlignTop );
|
||||||
setSpacing( 24 );
|
setSpacing( 24 );
|
||||||
setBackgroundColor( "#FBFBFB" );
|
setPanel( true );
|
||||||
|
|
||||||
auto* topBar = new TopBar( this );
|
auto* topBar = new TopBar( this );
|
||||||
addItem( topBar );
|
addItem( topBar );
|
||||||
|
@ -103,6 +105,16 @@ MainContent::MainContent( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, par
|
||||||
m_shadowPositioner->setGridBox( gridBox );
|
m_shadowPositioner->setGridBox( gridBox );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QskAspect::Subcontrol MainContent::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const
|
||||||
|
{
|
||||||
|
if( subControl == QskBox::Panel )
|
||||||
|
{
|
||||||
|
return MainContent::Panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subControl;
|
||||||
|
}
|
||||||
|
|
||||||
void MainContent::geometryChanged( const QRectF& newGeometry, const QRectF& oldGeometry )
|
void MainContent::geometryChanged( const QRectF& newGeometry, const QRectF& oldGeometry )
|
||||||
{
|
{
|
||||||
QskLinearBox::geometryChanged( newGeometry, oldGeometry );
|
QskLinearBox::geometryChanged( newGeometry, oldGeometry );
|
||||||
|
|
|
@ -26,8 +26,13 @@ class MainContent : public QskLinearBox
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QSK_SUBCONTROLS( Panel )
|
||||||
|
|
||||||
MainContent( QQuickItem* parent );
|
MainContent( QQuickItem* parent );
|
||||||
|
|
||||||
|
QskAspect::Subcontrol effectiveSubcontrol(
|
||||||
|
QskAspect::Subcontrol subControl ) const override final;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void geometryChanged( const QRectF&, const QRectF& ) override;
|
void geometryChanged( const QRectF&, const QRectF& ) override;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
#include "NighttimeSkin.h"
|
||||||
|
|
||||||
|
#include "Box.h"
|
||||||
|
#include "LightIntensity.h"
|
||||||
|
#include "MainContent.h"
|
||||||
|
#include "MenuBar.h"
|
||||||
|
#include "QskShadowedRectangle.h"
|
||||||
|
#include "QskShadowedRectangleSkinlet.h"
|
||||||
|
#include "PieChartPainted.h"
|
||||||
|
|
||||||
|
#include <QskBoxBorderMetrics.h>
|
||||||
|
#include <QskBoxBorderColors.h>
|
||||||
|
#include <QskFunctions.h>
|
||||||
|
|
||||||
|
#include <QFontDatabase>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static inline QFont qskFont( qreal pointSize, bool semiBold = false )
|
||||||
|
{
|
||||||
|
QFont font( "Proxima Nova" );
|
||||||
|
|
||||||
|
if( semiBold )
|
||||||
|
{
|
||||||
|
font.setWeight( QFont::Bold );
|
||||||
|
}
|
||||||
|
|
||||||
|
font.setPointSizeF( pointSize /*/ qskDpiScaled( 1.0 )*/ );
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NighttimeSkin::NighttimeSkin( QObject* parent ) : QskSkin( parent )
|
||||||
|
{
|
||||||
|
declareSkinlet< QskShadowedRectangle, QskShadowedRectangleSkinlet >();
|
||||||
|
initHints();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NighttimeSkin::initHints()
|
||||||
|
{
|
||||||
|
QFontDatabase db;
|
||||||
|
db.addApplicationFont( ":/fonts/ProximaNova-Regular.otf" ); // ### use fontconfig
|
||||||
|
|
||||||
|
setFont( QskSkin::DefaultFont, qskFont( 12 ) );
|
||||||
|
setFont( QskSkin::TinyFont, qskFont( 9 ) );
|
||||||
|
setFont( QskSkin::SmallFont, qskFont( 10 ) );
|
||||||
|
setFont( QskSkin::MediumFont, qskFont( 13 ) );
|
||||||
|
setFont( QskSkin::LargeFont, qskFont( 20 ) );
|
||||||
|
setFont( QskSkin::HugeFont, qskFont( 27, true ) );
|
||||||
|
|
||||||
|
setFont( NighttimeSkin::TitleFont, qskFont( 10, true ) );
|
||||||
|
|
||||||
|
|
||||||
|
setGradient( MainContent::Panel, {"#040404"} );
|
||||||
|
setGradient( Box::Panel, {"#000000"} );
|
||||||
|
setColor( LightDisplay::Panel, "#000000" );
|
||||||
|
setColor( PieChartPainted::Panel, "#000000" );
|
||||||
|
|
||||||
|
QColor color( Qt::white );
|
||||||
|
color.setAlphaF( 0.09 );
|
||||||
|
setGradient( MenuItem::Panel | QskControl::Hovered, Qt::yellow ); // ### nicer color
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef NIGHTTIMESKIN_H
|
||||||
|
#define NIGHTTIMESKIN_H
|
||||||
|
|
||||||
|
#include <QskSkin.h>
|
||||||
|
|
||||||
|
class NighttimeSkin : public QskSkin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NighttimeSkin( QObject* parent = nullptr );
|
||||||
|
|
||||||
|
enum SkinFontRole
|
||||||
|
{
|
||||||
|
TitleFont = QskSkin::HugeFont + 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initHints();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NIGHTTIMESKIN_H
|
|
@ -1,43 +1,66 @@
|
||||||
#include "PieChartPainted.h"
|
#include "PieChartPainted.h"
|
||||||
|
|
||||||
|
#include <QskBox.h>
|
||||||
|
#include <QskSetup.h>
|
||||||
#include <QskSkin.h>
|
#include <QskSkin.h>
|
||||||
#include <QskTextLabel.h>
|
#include <QskTextLabel.h>
|
||||||
|
|
||||||
#include <QFontMetricsF>
|
#include <QFontMetricsF>
|
||||||
#include <QQuickPaintedItem>
|
#include <QQuickPaintedItem>
|
||||||
|
|
||||||
PieChartPainted::PieChartPainted(const QColor& color, const QGradient& gradient, int progress, int value, QQuickItem *parent)
|
QSK_SUBCONTROL( PieChartPainted, Panel )
|
||||||
: QskControl(parent)
|
|
||||||
, m_color(color)
|
PieChartPainted::PieChartPainted( const QColor& color, const QGradient& gradient, int progress, int value, QQuickItem* parent )
|
||||||
, m_gradient(gradient)
|
: QskControl( parent )
|
||||||
, m_progressBar(new CircularProgressBar(gradient, progress, this))
|
, m_color( color )
|
||||||
, m_progressLabel(new QskTextLabel(this))
|
, m_gradient( gradient )
|
||||||
|
, m_progressBar( new CircularProgressBar( gradient, progress, this ) )
|
||||||
|
, m_progressLabel( new QskTextLabel( this ) )
|
||||||
// , m_numberLabel(new QskTextLabel(QString::number(value), this))
|
// , m_numberLabel(new QskTextLabel(QString::number(value), this))
|
||||||
// , m_unitLabel(new QskTextLabel("kwH", this))
|
// , m_unitLabel(new QskTextLabel("kwH", this))
|
||||||
{
|
{
|
||||||
setAutoLayoutChildren(true);
|
setAutoLayoutChildren( true );
|
||||||
|
|
||||||
auto progressText = QString::number(progress) + " %";
|
auto progressText = QString::number( progress ) + " %";
|
||||||
m_progressLabel->setText(progressText);
|
m_progressLabel->setText( progressText );
|
||||||
m_progressLabel->setFontRole(QskSkin::SmallFont);
|
m_progressLabel->setFontRole( QskSkin::SmallFont );
|
||||||
m_progressLabel->setTextColor(color);
|
m_progressLabel->setTextColor( color );
|
||||||
|
|
||||||
|
const QColor c = this->color( Panel );
|
||||||
|
m_progressBar->setBackgroundColor( c );
|
||||||
|
|
||||||
|
connect( qskSetup, &QskSetup::skinChanged, [this]()
|
||||||
|
{
|
||||||
|
const QColor c = this->color( Panel );
|
||||||
|
m_progressBar->setBackgroundColor( c );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF PieChartPainted::contentsSizeHint(Qt::SizeHint /*sizeHint*/, const QSizeF& /*size*/) const
|
QskAspect::Subcontrol PieChartPainted::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const
|
||||||
|
{
|
||||||
|
if( subControl == QskBox::Panel )
|
||||||
|
{
|
||||||
|
return PieChartPainted::Panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF PieChartPainted::contentsSizeHint( Qt::SizeHint /*sizeHint*/, const QSizeF& /*size*/ ) const
|
||||||
{
|
{
|
||||||
return {57, 57};
|
return {57, 57};
|
||||||
}
|
}
|
||||||
|
|
||||||
void PieChartPainted::updateLayout()
|
void PieChartPainted::updateLayout()
|
||||||
{
|
{
|
||||||
m_progressBar->setContentsSize(size().toSize());
|
m_progressBar->setContentsSize( size().toSize() );
|
||||||
m_progressBar->update();
|
m_progressBar->update();
|
||||||
|
|
||||||
auto rect = contentsRect();
|
auto rect = contentsRect();
|
||||||
QFontMetricsF progressMetrics(m_progressLabel->effectiveFont(QskTextLabel::Text));
|
QFontMetricsF progressMetrics( m_progressLabel->effectiveFont( QskTextLabel::Text ) );
|
||||||
auto textWidth = progressMetrics.width(m_progressLabel->text());
|
auto textWidth = progressMetrics.width( m_progressLabel->text() );
|
||||||
auto posX = rect.width() / 2 - textWidth / 2;
|
auto posX = rect.width() / 2 - textWidth / 2;
|
||||||
auto posY = rect.height() / 2 - progressMetrics.height() / 2;
|
auto posY = rect.height() / 2 - progressMetrics.height() / 2;
|
||||||
m_progressLabel->setPosition({posX, posY});
|
m_progressLabel->setPosition( {posX, posY} );
|
||||||
m_progressLabel->setFixedWidth(textWidth);
|
m_progressLabel->setFixedWidth( textWidth );
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,17 +10,22 @@ class QQuickPaintedItem;
|
||||||
|
|
||||||
class PieChartPainted : public QskControl
|
class PieChartPainted : public QskControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PieChartPainted(const QColor& color, const QGradient& gradient, int progress, int value, QQuickItem* parent = nullptr);
|
QSK_SUBCONTROLS( Panel )
|
||||||
|
|
||||||
virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
PieChartPainted( const QColor& color, const QGradient& gradient, int progress, int value, QQuickItem* parent = nullptr );
|
||||||
void updateLayout() override;
|
|
||||||
|
|
||||||
private:
|
QskAspect::Subcontrol effectiveSubcontrol(
|
||||||
QColor m_color;
|
QskAspect::Subcontrol subControl ) const override final;
|
||||||
QGradient m_gradient;
|
|
||||||
CircularProgressBar* m_progressBar;
|
virtual QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||||
QskTextLabel* m_progressLabel;
|
void updateLayout() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QColor m_color;
|
||||||
|
QGradient m_gradient;
|
||||||
|
CircularProgressBar* m_progressBar;
|
||||||
|
QskTextLabel* m_progressLabel;
|
||||||
// QskTextLabel* m_numberLabel;
|
// QskTextLabel* m_numberLabel;
|
||||||
// QskTextLabel* m_unitLabel;
|
// QskTextLabel* m_unitLabel;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
Usage::Usage( QQuickItem* parent )
|
Usage::Usage( QQuickItem* parent )
|
||||||
: Box( "Usage", parent )
|
: Box( "Usage", parent )
|
||||||
{
|
{
|
||||||
setBackgroundColor( Qt::transparent );
|
|
||||||
auto* content = new QskLinearBox( Qt::Vertical, this );
|
auto* content = new QskLinearBox( Qt::Vertical, this );
|
||||||
|
|
||||||
auto* today = new QskLinearBox( Qt::Horizontal, content );
|
auto* today = new QskLinearBox( Qt::Horizontal, content );
|
||||||
|
|
|
@ -11,6 +11,7 @@ SOURCES += \
|
||||||
MainContent.cpp \
|
MainContent.cpp \
|
||||||
MenuBar.cpp \
|
MenuBar.cpp \
|
||||||
MyDevices.cpp \
|
MyDevices.cpp \
|
||||||
|
NighttimeSkin.cpp \
|
||||||
PieChart.cpp \
|
PieChart.cpp \
|
||||||
PieChartPainted.cpp \
|
PieChartPainted.cpp \
|
||||||
PieChartSkinlet.cpp \
|
PieChartSkinlet.cpp \
|
||||||
|
@ -34,6 +35,7 @@ HEADERS += \
|
||||||
MainWindow.h \
|
MainWindow.h \
|
||||||
MenuBar.h \
|
MenuBar.h \
|
||||||
MyDevices.h \
|
MyDevices.h \
|
||||||
|
NighttimeSkin.h \
|
||||||
PieChart.h \
|
PieChart.h \
|
||||||
PieChartPainted.h \
|
PieChartPainted.h \
|
||||||
PieChartSkinlet.h \
|
PieChartSkinlet.h \
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include "DaytimeSkin.h"
|
#include "DaytimeSkin.h"
|
||||||
|
#include "NighttimeSkin.h"
|
||||||
|
|
||||||
#include <SkinnyFont.h>
|
#include <SkinnyFont.h>
|
||||||
#include <SkinnyShortcut.h>
|
#include <SkinnyShortcut.h>
|
||||||
|
@ -16,29 +17,36 @@
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace
|
||||||
|
{
|
||||||
class SkinFactory : public QskSkinFactory
|
class SkinFactory : public QskSkinFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SkinFactory( QObject* parent = nullptr ) : QskSkinFactory( parent )
|
SkinFactory( QObject* parent = nullptr ) : QskSkinFactory( parent )
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList skinNames() const override
|
|
||||||
{
|
|
||||||
return { "DaytimeSkin" };
|
|
||||||
}
|
|
||||||
QskSkin* createSkin( const QString& skinName ) override
|
|
||||||
{
|
|
||||||
if( skinName == "DaytimeSkin" )
|
|
||||||
{
|
{
|
||||||
return new DaytimeSkin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
QStringList skinNames() const override
|
||||||
}
|
{
|
||||||
|
return { "DaytimeSkin", "NighttimeSkin" };
|
||||||
|
}
|
||||||
|
|
||||||
|
QskSkin* createSkin( const QString& skinName ) override
|
||||||
|
{
|
||||||
|
if( skinName == "DaytimeSkin" )
|
||||||
|
{
|
||||||
|
return new DaytimeSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( skinName == "NighttimeSkin" )
|
||||||
|
{
|
||||||
|
return new NighttimeSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +59,9 @@ int main( int argc, char* argv[] )
|
||||||
SkinFactory skinFactory;
|
SkinFactory skinFactory;
|
||||||
|
|
||||||
qskSkinManager->setPluginPaths( QStringList() ); // no plugins
|
qskSkinManager->setPluginPaths( QStringList() ); // no plugins
|
||||||
|
|
||||||
|
qskSkinManager->unregisterFactory( "materialfactory" );
|
||||||
|
qskSkinManager->unregisterFactory( "squiekfactory" );
|
||||||
qskSkinManager->registerFactory(
|
qskSkinManager->registerFactory(
|
||||||
QStringLiteral( "SampleSkinFactory" ), &skinFactory );
|
QStringLiteral( "SampleSkinFactory" ), &skinFactory );
|
||||||
|
|
||||||
|
@ -58,13 +69,13 @@ int main( int argc, char* argv[] )
|
||||||
// false, skinFactory, SLOT(toggleScheme()) );
|
// false, skinFactory, SLOT(toggleScheme()) );
|
||||||
|
|
||||||
// QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL + Qt::Key_S ),
|
// QskShortcutMap::addShortcut( QKeySequence( Qt::CTRL + Qt::Key_S ),
|
||||||
// false, skinFactory, SLOT(rotateSkin()) );
|
// true, &skinFactory, SLOT( rotateSkin() ) );
|
||||||
|
|
||||||
qskSetup->setSkin( "DaytimeSkin" );
|
qskSetup->setSkin( "DaytimeSkin" );
|
||||||
|
|
||||||
// With CTRL-B you can rotate a couple of visual debug modes
|
// With CTRL-B you can rotate a couple of visual debug modes
|
||||||
SkinnyShortcut::enable( SkinnyShortcut::DebugBackground |
|
SkinnyShortcut::enable( SkinnyShortcut::RotateSkin | SkinnyShortcut::DebugBackground |
|
||||||
SkinnyShortcut::DebugStatistics | SkinnyShortcut::Quit );
|
SkinnyShortcut::DebugStatistics | SkinnyShortcut::Quit );
|
||||||
|
|
||||||
MainWindow window;
|
MainWindow window;
|
||||||
window.show();
|
window.show();
|
||||||
|
|
Loading…
Reference in New Issue