qskinny/playground/dashboard/SkinFactory.cpp

90 lines
2.5 KiB
C++
Raw Normal View History

2019-06-20 12:02:28 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
2017-07-25 21:34:27 +02:00
#include "SkinFactory.h"
2022-07-14 18:50:17 +02:00
#include "Dial.h"
#include "DialSkinlet.h"
2020-12-13 19:38:46 +01:00
#include <QskBoxBorderColors.h>
#include <QskTextLabel.h>
2020-12-26 12:57:08 +01:00
#include <QskSkinHintTableEditor.h>
2020-12-13 19:38:46 +01:00
#include <QskSkin.h>
#include <QskPlatform.h>
2022-07-14 18:50:17 +02:00
#include <QskRgbValue.h>
2020-12-13 19:38:46 +01:00
namespace
{
inline QFont qskFont( qreal pointSize )
{
QFont font( "Roboto" );
font.setPointSizeF( pointSize / qskDpiScaled( 1.0 ) );
return font;
}
class Skin : public QskSkin
{
public:
2021-08-04 09:31:16 +02:00
Skin()
2020-12-13 19:38:46 +01:00
{
2022-07-14 18:50:17 +02:00
using namespace QskRgb;
declareSkinlet< Dial, DialSkinlet >();
2020-12-13 19:38:46 +01:00
setFont( QskSkin::DefaultFont, qskFont( 13 ) );
setFont( QskSkin::LargeFont, qskFont( 20 ) );
2022-07-14 18:50:17 +02:00
const auto rgb1 = qRgb( 1, 16, 27 ); // Maastricht blue
const auto rgb2 = qRgb( 255, 0, 22 ); // Ruddy
const auto rgb3 = qRgb( 41, 234, 212 ); // Turquoise
const auto rgb4 = qRgb( 253, 255, 252 ); // baby powder
2020-12-13 19:38:46 +01:00
2020-12-26 12:57:08 +01:00
QskSkinHintTableEditor ed( &hintTable() );
2022-07-14 18:50:17 +02:00
ed.setColor( QskTextLabel::Text, rgb4 );
2020-12-13 19:38:46 +01:00
{
2022-07-14 18:50:17 +02:00
using Q = Dial;
2020-12-13 19:38:46 +01:00
2020-12-26 12:57:08 +01:00
ed.setBoxBorderMetrics( Q::Panel, 2 );
ed.setBoxShape( Q::Panel, 100, Qt::RelativeSize );
2022-07-14 18:50:17 +02:00
ed.setGradient( Q::Panel, rgb1 );
ed.setBoxBorderColors( Q::Panel, rgb3 );
2020-12-13 19:38:46 +01:00
2020-12-26 12:57:08 +01:00
ed.setBoxBorderMetrics( Q::Knob, 2 );
ed.setStrutSize( Q::Knob, 30, 30 );
ed.setBoxShape( Q::Knob, 100, Qt::RelativeSize );
ed.setGradient( Q::Knob,
2022-07-14 18:50:17 +02:00
QskGradient( QskGradient::Diagonal, rgb2, rgb1 ) );
2020-12-13 19:38:46 +01:00
2020-12-26 12:57:08 +01:00
ed.setMetric( Q::Needle | QskAspect::Size, 2 );
ed.setMetric( Q::Needle | QskAspect::Margin, 10 );
2022-07-14 18:50:17 +02:00
ed.setColor( Q::Needle, rgb2 );
2020-12-13 19:38:46 +01:00
2020-12-26 12:57:08 +01:00
ed.setSpacing( Q::TickLabels, 4 );
ed.setStrutSize( Q::TickLabels, 2, 15 );
2022-07-14 18:50:17 +02:00
ed.setColor( Q::TickLabels, rgb4 );
2020-12-26 12:57:08 +01:00
ed.setFontRole( Q::TickLabels, QskSkin::SmallFont );
2020-12-13 19:38:46 +01:00
}
}
};
}
2017-07-25 21:34:27 +02:00
QStringList SkinFactory::skinNames() const
{
2022-07-14 18:50:17 +02:00
return { "Skin" };
2017-07-25 21:34:27 +02:00
}
QskSkin* SkinFactory::createSkin( const QString& skinName )
{
2022-07-14 18:50:17 +02:00
if ( skinName == "Skin" )
return new Skin();
2017-07-25 21:34:27 +02:00
return nullptr;
}
#include "moc_SkinFactory.cpp"