2021-04-29 07:49:08 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright (C) 2021 Edelhirsch Software GmbH
|
|
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
|
|
*****************************************************************************/
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
#include "Skin.h"
|
|
|
|
|
|
|
|
#include "Box.h"
|
|
|
|
#include "BoxWithButtons.h"
|
2021-08-24 08:46:26 +02:00
|
|
|
#include "CircularProgressBar.h"
|
|
|
|
#include "CircularProgressBarSkinlet.h"
|
2021-04-26 06:22:35 +02:00
|
|
|
#include "Diagram.h"
|
|
|
|
#include "DiagramSkinlet.h"
|
2022-07-14 14:35:57 +02:00
|
|
|
#include "GridBox.h"
|
2021-11-19 15:02:57 +01:00
|
|
|
#include "LightDisplay.h"
|
|
|
|
#include "LightDisplaySkinlet.h"
|
2022-07-14 14:26:45 +02:00
|
|
|
#include "DashboardPage.h"
|
2021-04-26 06:22:35 +02:00
|
|
|
#include "MenuBar.h"
|
2021-08-04 18:55:18 +02:00
|
|
|
#include "RoundedIcon.h"
|
|
|
|
#include "RoundButton.h"
|
2021-10-31 11:16:03 +01:00
|
|
|
#include "TopBar.h"
|
2021-08-04 18:55:18 +02:00
|
|
|
#include "UsageBox.h"
|
2021-04-26 06:22:35 +02:00
|
|
|
#include "UsageDiagram.h"
|
|
|
|
|
2021-10-20 07:50:25 +02:00
|
|
|
#include <QskArcMetrics.h>
|
2021-08-04 18:55:18 +02:00
|
|
|
#include <QskBoxShapeMetrics.h>
|
2021-04-26 06:22:35 +02:00
|
|
|
#include <QskBoxBorderMetrics.h>
|
|
|
|
#include <QskBoxBorderColors.h>
|
|
|
|
#include <QskFunctions.h>
|
2022-08-31 09:22:31 +02:00
|
|
|
#include <QskShadowMetrics.h>
|
2021-04-26 06:22:35 +02:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-08-04 09:31:16 +02:00
|
|
|
Skin::Skin( const Palette& palette, QObject* parent )
|
|
|
|
: QskSkin( parent )
|
2021-04-26 06:22:35 +02:00
|
|
|
{
|
2021-08-24 08:46:26 +02:00
|
|
|
declareSkinlet< CircularProgressBar, CircularProgressBarSkinlet >();
|
2021-04-26 06:22:35 +02:00
|
|
|
declareSkinlet< Diagram, DiagramSkinlet >();
|
2021-11-19 15:02:57 +01:00
|
|
|
declareSkinlet< LightDisplay, LightDisplaySkinlet >();
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
initHints( palette );
|
|
|
|
}
|
|
|
|
|
|
|
|
Skin::~Skin()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Skin::initHints( const Palette& palette )
|
|
|
|
{
|
|
|
|
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( Skin::TitleFont, qskFont( 10, true ) );
|
|
|
|
|
|
|
|
QskSkinHintTableEditor ed( &hintTable() );
|
|
|
|
|
|
|
|
ed.setPadding( MainContentGridBox::Panel, {19, 0, 27, 24} );
|
|
|
|
|
|
|
|
|
|
|
|
// menu bar:
|
|
|
|
ed.setPadding( MenuBar::Panel, {0, 35, 0, 12} );
|
|
|
|
|
|
|
|
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 );
|
|
|
|
color.setAlphaF( 0.14 );
|
|
|
|
ed.setGradient( MenuItem::Panel | MenuItem::Active, color );
|
|
|
|
|
|
|
|
ed.setColor( MenuBarLabel::Text, Qt::white );
|
|
|
|
ed.setFontRole( MenuBarLabel::Text, QskSkin::SmallFont );
|
|
|
|
|
|
|
|
ed.setMargin( MenuBarTopLabel::Graphic, { 50, 0, 50, 54 } );
|
|
|
|
|
|
|
|
ed.setMetric( MenuBarGraphicLabel::Graphic | QskAspect::Size, 14 );
|
|
|
|
ed.setAlignment( MenuBarGraphicLabel::Graphic, Qt::AlignCenter );
|
|
|
|
|
|
|
|
|
|
|
|
// top bar:
|
|
|
|
ed.setPadding( TopBar::Panel, {25, 35, 25, 0} );
|
|
|
|
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setColor( TopBarItem::Item1 | QskAspect::TextColor, 0xffff3122 );
|
|
|
|
ed.setColor( TopBarItem::Item2 | QskAspect::TextColor, 0xff6776ff );
|
|
|
|
ed.setColor( TopBarItem::Item3 | QskAspect::TextColor, 0xfff99055 );
|
|
|
|
ed.setColor( TopBarItem::Item4 | QskAspect::TextColor, 0xff6776ff );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2022-10-31 14:42:08 +01:00
|
|
|
// arcs are counterclockwise, so specify the 2nd color first:
|
|
|
|
ed.setGradient( TopBarItem::Item1, 0xffff3122, 0xffff5c00 );
|
|
|
|
ed.setGradient( TopBarItem::Item2, 0xff6100ff, 0xff6776ff );
|
|
|
|
ed.setGradient( TopBarItem::Item3, 0xffff3122, 0xffffce50 );
|
|
|
|
ed.setGradient( TopBarItem::Item4, 0xff6100ff, 0xff6776ff );
|
2021-08-24 08:46:26 +02:00
|
|
|
|
|
|
|
// the bar gradient is defined through the top bar items above
|
2021-12-02 17:15:41 +01:00
|
|
|
ed.setArcMetrics( CircularProgressBar::Groove, { 8.53, 90, -360 } );
|
2021-10-20 07:50:25 +02:00
|
|
|
// the span angle will be set in the progress bar, we just give a dummy
|
|
|
|
// value here:
|
2021-12-02 17:15:41 +01:00
|
|
|
ed.setArcMetrics( CircularProgressBar::Bar, { 8.53, 90, -180 } );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
ed.setFontRole( TimeTitleLabel::Text, Skin::TitleFont );
|
|
|
|
|
|
|
|
ed.setFontRole( TimeLabel::Text, QskSkin::HugeFont );
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setColor( TimeLabel::Text, 0xff6776ff );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2022-08-31 09:22:31 +02:00
|
|
|
// boxes:
|
|
|
|
ed.setPadding( Box::Panel, 8 );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
// content in boxes (indoor temperature, humidity etc.):
|
2021-08-04 18:55:18 +02:00
|
|
|
ed.setFontRole( UsageBox::Separator, QskSkin::SmallFont );
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setColor( UsageBox::Separator, 0xffdddddd );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
ed.setPadding( BoxWithButtons::Panel, 8 );
|
|
|
|
|
2021-08-26 15:24:13 +02:00
|
|
|
for ( auto subControl : { RoundedIcon::Panel, RoundedIcon::PalePanel } )
|
|
|
|
{
|
|
|
|
ed.setBoxShape( subControl, 6 );
|
|
|
|
|
2022-11-13 17:22:09 +01:00
|
|
|
QskGradient normal( 0xff6776ff, 0xff6100ff );
|
|
|
|
normal.setLinearDirection( Qt::Vertical );
|
|
|
|
|
|
|
|
QskGradient bright( 0xffff7d34, 0xffff3122 );
|
|
|
|
bright.setLinearDirection( Qt::Vertical );
|
2021-08-26 15:24:13 +02:00
|
|
|
|
|
|
|
if ( subControl == RoundedIcon::PalePanel )
|
|
|
|
{
|
|
|
|
const uint alpha = 38;
|
|
|
|
normal.setAlpha( alpha );
|
|
|
|
bright.setAlpha( alpha );
|
|
|
|
}
|
|
|
|
|
|
|
|
ed.setGradient( subControl, normal );
|
|
|
|
ed.setGradient( subControl | RoundedIcon::Bright, bright );
|
|
|
|
}
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2021-08-04 18:55:18 +02:00
|
|
|
ed.setFontRole( BoxWithButtons::ValueText, QskSkin::HugeFont );
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setColor( BoxWithButtons::ValueText, 0xff929cb2 );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2021-08-26 15:24:13 +02:00
|
|
|
ed.setPadding( BoxWithButtons::ValuePanel, 0, 10, 0, 0 );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2021-08-26 15:24:13 +02:00
|
|
|
ed.setStrutSize( RoundButton::Panel, 27, 38 );
|
|
|
|
ed.setBoxShape( RoundButton::Panel, 0, 0, 30, 30 );
|
|
|
|
ed.setBoxShape( RoundButton::Panel | RoundButton::Top, 30, 30, 0, 0 );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
// diagram:
|
2021-08-26 15:24:13 +02:00
|
|
|
ed.setBoxBorderMetrics( UsageDiagramBox::DaysBox, 0, 0, 3, 3 );
|
2021-08-05 11:06:48 +02:00
|
|
|
ed.setFontRole( UsageDiagramBox::DayText, QskSkin::TinyFont );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2021-08-05 11:06:48 +02:00
|
|
|
ed.setStrutSize( UsageDiagramLegend::Symbol, 8, 8 );
|
|
|
|
ed.setBoxShape( UsageDiagramLegend::Symbol, 100, Qt::RelativeSize ); // a circle
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setGradient( UsageDiagramLegend::Symbol | UsageDiagramLegend::Water, { 0xff6776ff } );
|
|
|
|
ed.setGradient( UsageDiagramLegend::Symbol | UsageDiagramLegend::Electricity, { 0xffff3122 } );
|
|
|
|
ed.setGradient( UsageDiagramLegend::Symbol | UsageDiagramLegend::Gas, { 0xffff7d34 } );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2021-08-05 11:06:48 +02:00
|
|
|
ed.setPadding( UsageDiagramBox::Panel, 0 );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
// new diagram:
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setColor( Diagram::ChartArea1, 0x666776ff );
|
|
|
|
ed.setColor( Diagram::ChartArea2, 0x66ff3122 );
|
|
|
|
ed.setColor( Diagram::ChartArea3, 0x66ff7d34 );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2022-07-14 14:43:21 +02:00
|
|
|
ed.setColor( Diagram::ChartBar1, 0xff6776ff );
|
|
|
|
ed.setColor( Diagram::ChartBar2, 0xffff3122 );
|
|
|
|
ed.setColor( Diagram::ChartBar3, 0xffff7d34 );
|
|
|
|
|
|
|
|
ed.setStrutSize( Diagram::ChartBar1, { 6, -1 } );
|
|
|
|
ed.setStrutSize( Diagram::ChartBar2, { 6, -1 } );
|
|
|
|
ed.setStrutSize( Diagram::ChartBar3, { 6, -1 } );
|
|
|
|
|
2022-08-02 11:05:28 +02:00
|
|
|
ed.setBoxShape( Diagram::ChartBar1, { 3, 3, 0, 0 } );
|
|
|
|
ed.setBoxShape( Diagram::ChartBar2, { 3, 3, 0, 0 } );
|
|
|
|
ed.setBoxShape( Diagram::ChartBar3, { 3, 3, 0, 0 } );
|
2022-07-14 14:43:21 +02:00
|
|
|
|
2021-04-26 06:22:35 +02:00
|
|
|
// light intensity:
|
2021-11-19 15:02:57 +01:00
|
|
|
ed.setBoxShape( LightDisplay::Panel, 100, Qt::RelativeSize );
|
|
|
|
|
2021-12-02 17:15:41 +01:00
|
|
|
ed.setArcMetrics( LightDisplay::ColdAndWarmArc, 8.785, 0, 180 );
|
2022-10-31 14:42:08 +01:00
|
|
|
const QskGradient coldGradient(
|
|
|
|
{ { 0.0, 0xffff3122 }, { 0.2, 0xfffeeeb7 }, { 0.3, 0xffa7b0ff },
|
|
|
|
{ 0.5, 0xff6776ff }, { 1.0, Qt::black } } );
|
2021-11-19 15:02:57 +01:00
|
|
|
ed.setGradient( LightDisplay::ColdAndWarmArc, coldGradient );
|
|
|
|
|
|
|
|
ed.setMetric( LightDisplay::Tickmarks, 1 );
|
2021-12-02 17:15:41 +01:00
|
|
|
ed.setArcMetrics( LightDisplay::Tickmarks, { 4.69, 0, 180 } );
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setColor( LightDisplay::Tickmarks, 0x55929cb2 );
|
2021-11-19 15:02:57 +01:00
|
|
|
|
2021-08-04 18:55:18 +02:00
|
|
|
ed.setFontRole( LightDisplay::ValueText, QskSkin::LargeFont );
|
2022-10-26 10:50:11 +02:00
|
|
|
ed.setColor( LightDisplay::ValueText, 0xff929cb2 );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
2021-11-19 15:02:57 +01:00
|
|
|
ed.setStrutSize( LightDisplay::Knob, { 20, 20 } );
|
|
|
|
ed.setBoxBorderMetrics( LightDisplay::Knob, 1 );
|
|
|
|
ed.setBoxBorderColors( LightDisplay::Knob, 0xffc4c4c4 );
|
|
|
|
ed.setBoxShape( LightDisplay::Knob, 100, Qt::RelativeSize );
|
|
|
|
|
2021-04-26 06:22:35 +02:00
|
|
|
// palette dependent skin hints:
|
|
|
|
ed.setGradient( MenuBar::Panel, palette.menuBar );
|
2022-07-14 14:26:45 +02:00
|
|
|
ed.setGradient( DashboardPage::Panel, palette.mainContent );
|
2022-08-31 09:22:31 +02:00
|
|
|
|
2022-10-26 17:02:06 +02:00
|
|
|
ed.setColor( Box::Panel, palette.box );
|
2022-08-31 09:22:31 +02:00
|
|
|
QskShadowMetrics shadowMetrics( 0, 10 );
|
|
|
|
ed.setShadowMetrics( Box::Panel, shadowMetrics );
|
|
|
|
ed.setShadowColor( Box::Panel, palette.shadow );
|
|
|
|
|
2021-04-26 06:22:35 +02:00
|
|
|
ed.setGradient( BoxWithButtons::Panel, palette.box );
|
2022-08-31 09:22:31 +02:00
|
|
|
ed.setShadowMetrics( BoxWithButtons::Panel, shadowMetrics );
|
|
|
|
ed.setShadowColor( BoxWithButtons::Panel, palette.shadow );
|
|
|
|
|
2021-08-05 11:06:48 +02:00
|
|
|
ed.setGradient( UsageDiagramBox::Panel, palette.box );
|
2022-08-31 09:22:31 +02:00
|
|
|
ed.setShadowMetrics( UsageDiagramBox::Panel, shadowMetrics );
|
|
|
|
ed.setShadowColor( UsageDiagramBox::Panel, palette.shadow );
|
|
|
|
|
2021-11-19 15:02:57 +01:00
|
|
|
ed.setGradient( LightDisplay::Panel, palette.box );
|
|
|
|
ed.setGradient( LightDisplay::Knob, palette.box );
|
2021-04-26 06:22:35 +02:00
|
|
|
ed.setGradient( RoundButton::Panel, palette.roundButton );
|
2021-08-05 11:06:48 +02:00
|
|
|
ed.setBoxBorderColors( UsageDiagramBox::DaysBox, palette.weekdayBox );
|
2021-04-26 06:22:35 +02:00
|
|
|
ed.setColor( QskTextLabel::Text, palette.text );
|
2021-08-05 11:06:48 +02:00
|
|
|
ed.setColor( UsageDiagramBox::DayText, palette.text );
|
2021-08-24 08:46:26 +02:00
|
|
|
ed.setGradient( CircularProgressBar::Groove, palette.circularProgressBarGroove );
|
2021-04-26 06:22:35 +02:00
|
|
|
}
|
2022-10-26 10:50:11 +02:00
|
|
|
|
|
|
|
Skin::Palette DaytimeSkin::palette() const
|
|
|
|
{
|
|
|
|
return {
|
2022-10-26 11:00:57 +02:00
|
|
|
0xff6d7bfb,
|
|
|
|
0xfffbfbfb,
|
2022-10-26 10:50:11 +02:00
|
|
|
Qt::white,
|
2022-10-26 11:00:57 +02:00
|
|
|
0xfff7f7f7,
|
|
|
|
0xfff4f4f4,
|
2022-10-26 10:50:11 +02:00
|
|
|
Qt::black,
|
|
|
|
0xffe5e5e5,
|
2022-10-31 14:42:08 +01:00
|
|
|
{ { { 0.0, 0xffc4c4c4 }, { 0.5, 0xfff8f8f8 }, { 1.0, 0xffc4c4c4 } } }
|
2022-10-26 10:50:11 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
Skin::Palette NighttimeSkin::palette() const
|
|
|
|
{
|
|
|
|
return {
|
2022-10-26 11:00:57 +02:00
|
|
|
0xff2937A7,
|
|
|
|
0xff040404,
|
2022-10-26 10:50:11 +02:00
|
|
|
Qt::black,
|
2022-10-26 11:00:57 +02:00
|
|
|
0xff0a0a0a,
|
|
|
|
0xff0c0c0c,
|
2022-10-26 10:50:11 +02:00
|
|
|
Qt::white,
|
|
|
|
0xff1a1a1a,
|
2022-10-31 14:42:08 +01:00
|
|
|
{ { { 0.0, 0xff666666 }, { 0.5, 0xff222222 }, { 1.0, 0xff333333 } } }
|
2022-10-26 10:50:11 +02:00
|
|
|
};
|
|
|
|
}
|