refactor skins
This commit is contained in:
parent
98751d1ae0
commit
23a14f0fb7
|
@ -1,20 +0,0 @@
|
|||
#ifndef DAYTIMESKIN_H
|
||||
#define DAYTIMESKIN_H
|
||||
|
||||
#include <QskSkin.h>
|
||||
|
||||
class DaytimeSkin : public QskSkin
|
||||
{
|
||||
public:
|
||||
DaytimeSkin( QObject* parent = nullptr );
|
||||
|
||||
enum SkinFontRole
|
||||
{
|
||||
TitleFont = QskSkin::HugeFont + 1,
|
||||
};
|
||||
|
||||
private:
|
||||
void initHints();
|
||||
};
|
||||
|
||||
#endif // DAYTIMESKIN_H
|
|
@ -1,77 +0,0 @@
|
|||
#include "NighttimeSkin.h"
|
||||
|
||||
#include "Box.h"
|
||||
#include "Diagram.h"
|
||||
#include "LightIntensity.h"
|
||||
#include "MainContent.h"
|
||||
#include "MenuBar.h"
|
||||
#include "QskShadowedRectangle.h"
|
||||
#include "QskShadowedRectangleSkinlet.h"
|
||||
#include "PieChartPainted.h"
|
||||
#include "UpAndDownButton.h"
|
||||
|
||||
#include <QskBoxBorderMetrics.h>
|
||||
#include <QskBoxBorderColors.h>
|
||||
#include <QskFunctions.h>
|
||||
#include <QskSkinHintTableEditor.h>
|
||||
#include <QskTextLabel.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 ) );
|
||||
|
||||
QskSkinHintTableEditor ed( &hintTable() );
|
||||
|
||||
ed.setPadding( MenuBar::Panel, {0, 35, 0, 12} );
|
||||
ed.setGradient( MenuBar::Panel, {"#2937A7"} );
|
||||
|
||||
ed.setStrutSize( MenuItem::Panel | QskAspect::Size, {140, 40} );
|
||||
ed.setPadding( MenuItem::Panel, {30, 0, 30, 0} );
|
||||
QColor color( Qt::white );
|
||||
color.setAlphaF( 0.09 );
|
||||
ed.setGradient( MenuItem::Panel | QskControl::Hovered, color );
|
||||
|
||||
ed.setGradient( MainContent::Panel, {"#040404"} );
|
||||
ed.setGradient( Box::Panel, {"#000000"} );
|
||||
ed.setColor( LightDisplay::Panel, "#000000" );
|
||||
ed.setColor( PieChartPainted::Panel, "#000000" );
|
||||
ed.setGradient( RoundButton::Panel, {"#0a0a0a"} );
|
||||
ed.setBoxBorderColors( WeekdayBox::Panel, {"#0c0c0c"} );
|
||||
|
||||
ed.setColor( QskTextLabel::Text, "#ffffff" );
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
#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,4 +1,4 @@
|
|||
#include "DaytimeSkin.h"
|
||||
#include "Skin.h"
|
||||
|
||||
#include "Box.h"
|
||||
#include "Diagram.h"
|
||||
|
@ -35,13 +35,17 @@ namespace
|
|||
|
||||
}
|
||||
|
||||
DaytimeSkin::DaytimeSkin( QObject* parent ) : QskSkin( parent )
|
||||
Skin::Skin( const Palette& palette, QObject* parent ) : QskSkin( parent )
|
||||
{
|
||||
declareSkinlet< QskShadowedRectangle, QskShadowedRectangleSkinlet >();
|
||||
initHints();
|
||||
initHints( palette );
|
||||
}
|
||||
|
||||
void DaytimeSkin::initHints()
|
||||
Skin::~Skin()
|
||||
{
|
||||
}
|
||||
|
||||
void Skin::initHints( const Palette& palette )
|
||||
{
|
||||
QFontDatabase db;
|
||||
db.addApplicationFont( ":/fonts/ProximaNova-Regular.otf" ); // ### use fontconfig
|
||||
|
@ -53,12 +57,11 @@ void DaytimeSkin::initHints()
|
|||
setFont( QskSkin::LargeFont, qskFont( 20 ) );
|
||||
setFont( QskSkin::HugeFont, qskFont( 27, true ) );
|
||||
|
||||
setFont( DaytimeSkin::TitleFont, qskFont( 10, true ) );
|
||||
setFont( Skin::TitleFont, qskFont( 10, true ) );
|
||||
|
||||
QskSkinHintTableEditor ed( &hintTable() );
|
||||
|
||||
ed.setPadding( MenuBar::Panel, {0, 35, 0, 12} );
|
||||
ed.setGradient( MenuBar::Panel, {"#6D7BFB"} );
|
||||
|
||||
ed.setStrutSize( MenuItem::Panel | QskAspect::Size, {140, 40} );
|
||||
ed.setPadding( MenuItem::Panel, {30, 0, 30, 0} );
|
||||
|
@ -66,12 +69,13 @@ void DaytimeSkin::initHints()
|
|||
color.setAlphaF( 0.09 );
|
||||
ed.setGradient( MenuItem::Panel | QskControl::Hovered, color );
|
||||
|
||||
ed.setGradient( MainContent::Panel, {"#fbfbfb"} );
|
||||
ed.setGradient( Box::Panel, {"#ffffff"} );
|
||||
ed.setColor( LightDisplay::Panel, "#ffffff" );
|
||||
ed.setColor( PieChartPainted::Panel, "#ffffff" );
|
||||
ed.setGradient( RoundButton::Panel, {"#f7f7f7"} );
|
||||
ed.setBoxBorderColors( WeekdayBox::Panel, {"#f4f4f4"} );
|
||||
ed.setColor( QskTextLabel::Text, "#000000" );
|
||||
|
||||
ed.setGradient( MenuBar::Panel, palette.menuBar );
|
||||
ed.setGradient( MainContent::Panel, palette.mainContent );
|
||||
ed.setGradient( Box::Panel, palette.box );
|
||||
ed.setColor( LightDisplay::Panel, palette.lightDisplay );
|
||||
ed.setColor( PieChartPainted::Panel, palette.pieChart );
|
||||
ed.setGradient( RoundButton::Panel, palette.roundButton );
|
||||
ed.setBoxBorderColors( WeekdayBox::Panel, palette.weekdayBox );
|
||||
ed.setColor( QskTextLabel::Text, palette.text );
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
#ifndef DSKIN_H
|
||||
#define DSKIN_H
|
||||
|
||||
#include <QskGradient.h>
|
||||
#include <QskSkin.h>
|
||||
|
||||
class Skin : public QskSkin
|
||||
{
|
||||
public:
|
||||
class Palette
|
||||
{
|
||||
public:
|
||||
Palette( QskGradient menuBar, QskGradient mainContent, QskGradient box,
|
||||
QColor lightDisplay, QColor pieChart, QskGradient roundButton,
|
||||
QColor weekdayBox, QColor text )
|
||||
: menuBar( menuBar )
|
||||
, mainContent( mainContent )
|
||||
, box( box )
|
||||
, lightDisplay( lightDisplay )
|
||||
, pieChart( pieChart )
|
||||
, roundButton( roundButton )
|
||||
, weekdayBox( weekdayBox )
|
||||
, text( text )
|
||||
{
|
||||
}
|
||||
QskGradient menuBar;
|
||||
QskGradient mainContent;
|
||||
QskGradient box;
|
||||
QColor lightDisplay;
|
||||
QColor pieChart;
|
||||
QskGradient roundButton;
|
||||
QColor weekdayBox;
|
||||
QColor text;
|
||||
};
|
||||
|
||||
Skin( const Palette& palette, QObject* parent = nullptr );
|
||||
virtual ~Skin();
|
||||
|
||||
enum SkinFontRole
|
||||
{
|
||||
TitleFont = QskSkin::HugeFont + 1,
|
||||
};
|
||||
|
||||
private:
|
||||
void initHints( const Palette& palette );
|
||||
};
|
||||
|
||||
class DaytimeSkin : public Skin
|
||||
{
|
||||
public:
|
||||
DaytimeSkin( QObject* parent = nullptr )
|
||||
: Skin(
|
||||
Skin::Palette( {"#6D7BFB"}, {"#fbfbfb"}, {"#ffffff"},
|
||||
"#ffffff", "#ffffff", {"#f7f7f7"},
|
||||
{"#f4f4f4"}, "#000000" )
|
||||
, parent )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class NighttimeSkin : public Skin
|
||||
{
|
||||
public:
|
||||
NighttimeSkin( QObject* parent = nullptr )
|
||||
: Skin(
|
||||
Skin::Palette( {"#2937A7"}, {"#040404"}, {"#000000"},
|
||||
"#000000", "#000000", {"#0a0a0a"},
|
||||
{"#0c0c0c"}, "#ffffff" )
|
||||
, parent )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SKIN_H
|
|
@ -3,7 +3,6 @@ CONFIG += qskexample
|
|||
SOURCES += \
|
||||
Box.cpp \
|
||||
CircularProgressBar.cpp \
|
||||
DaytimeSkin.cpp \
|
||||
Diagram.cpp \
|
||||
Humidity.cpp \
|
||||
IndoorTemperature.cpp \
|
||||
|
@ -11,13 +10,13 @@ SOURCES += \
|
|||
MainContent.cpp \
|
||||
MenuBar.cpp \
|
||||
MyDevices.cpp \
|
||||
NighttimeSkin.cpp \
|
||||
PieChart.cpp \
|
||||
PieChartPainted.cpp \
|
||||
PieChartSkinlet.cpp \
|
||||
QskShadowedRectangle.cpp \
|
||||
QskShadowedRectangleSkinlet.cpp \
|
||||
RoundedIcon.cpp \
|
||||
Skin.cpp \
|
||||
TopBar.cpp \
|
||||
UpAndDownButton.cpp \
|
||||
Usage.cpp \
|
||||
|
@ -27,7 +26,6 @@ SOURCES += \
|
|||
HEADERS += \
|
||||
Box.h \
|
||||
CircularProgressBar.h \
|
||||
DaytimeSkin.h \
|
||||
Diagram.h \
|
||||
Humidity.h \
|
||||
IndoorTemperature.h \
|
||||
|
@ -36,13 +34,13 @@ HEADERS += \
|
|||
MainWindow.h \
|
||||
MenuBar.h \
|
||||
MyDevices.h \
|
||||
NighttimeSkin.h \
|
||||
PieChart.h \
|
||||
PieChartPainted.h \
|
||||
PieChartSkinlet.h \
|
||||
QskShadowedRectangle.h \
|
||||
QskShadowedRectangleSkinlet.h \
|
||||
RoundedIcon.h \
|
||||
Skin.h \
|
||||
TopBar.h \
|
||||
UpAndDownButton.h \
|
||||
Usage.h
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "MainWindow.h"
|
||||
|
||||
#include "DaytimeSkin.h"
|
||||
#include "NighttimeSkin.h"
|
||||
#include "Skin.h"
|
||||
|
||||
#include <SkinnyFont.h>
|
||||
#include <SkinnyShortcut.h>
|
||||
|
|
Loading…
Reference in New Issue