QskSkin::ColorScheme with scoped value names

This commit is contained in:
Uwe Rathmann 2023-07-03 07:29:29 +02:00
parent 620fff1206
commit 9e7e52898e
6 changed files with 17 additions and 13 deletions

View File

@ -28,12 +28,12 @@ QskSkin* QskFluent2SkinFactory::createSkin( const QString& skinName )
{ {
if ( QString::compare( skinName, fluent2LightSkinName, Qt::CaseInsensitive ) == 0 ) if ( QString::compare( skinName, fluent2LightSkinName, Qt::CaseInsensitive ) == 0 )
{ {
QskFluent2Theme theme( QskSkin::Light ); QskFluent2Theme theme( QskSkin::LightScheme );
return new QskFluent2Skin( theme ); return new QskFluent2Skin( theme );
} }
else if ( QString::compare( skinName, fluent2DarkSkinName, Qt::CaseInsensitive ) == 0 ) else if ( QString::compare( skinName, fluent2DarkSkinName, Qt::CaseInsensitive ) == 0 )
{ {
QskFluent2Theme theme( QskSkin::Dark ); QskFluent2Theme theme( QskSkin::DarkScheme );
return new QskFluent2Skin( theme ); return new QskFluent2Skin( theme );
} }

View File

@ -31,7 +31,7 @@ QskFluent2Theme::QskFluent2Theme( QskSkin::ColorScheme colorScheme )
QskFluent2Theme::QskFluent2Theme( QskSkin::ColorScheme colorScheme, QskFluent2Theme::QskFluent2Theme( QskSkin::ColorScheme colorScheme,
const std::array< QRgb, NumAccentColors >& accentColors ) const std::array< QRgb, NumAccentColors >& accentColors )
{ {
if( colorScheme == QskSkin::Light ) if( colorScheme == QskSkin::LightScheme )
{ {
// Fill color: // Fill color:
@ -133,7 +133,7 @@ QskFluent2Theme::QskFluent2Theme( QskSkin::ColorScheme colorScheme,
// ### should actually be drawn twice with different values: // ### should actually be drawn twice with different values:
shadow.dialog = { QskShadowMetrics( 0, 21, QPointF( 0, 2 ) ), rgbGray( 0, 0.1474 ) }; shadow.dialog = { QskShadowMetrics( 0, 21, QPointF( 0, 2 ) ), rgbGray( 0, 0.1474 ) };
} }
else if( colorScheme == QskSkin::Dark ) else if( colorScheme == QskSkin::DarkScheme )
{ {
// Fill color: // Fill color:

View File

@ -54,7 +54,6 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QScreen> #include <QScreen>
#include <QStyleHints>
static const int qskDuration = 150; static const int qskDuration = 150;
@ -1210,7 +1209,7 @@ QskMaterial3Theme::QskMaterial3Theme( QskSkin::ColorScheme colorScheme,
std::array< QskHctColor, NumPaletteTypes > palettes ) std::array< QskHctColor, NumPaletteTypes > palettes )
: m_palettes( palettes ) : m_palettes( palettes )
{ {
if ( colorScheme == QskSkin::Light ) if ( colorScheme == QskSkin::LightScheme )
{ {
primary = m_palettes[ Primary ].toned( 40 ).rgb(); primary = m_palettes[ Primary ].toned( 40 ).rgb();
onPrimary = m_palettes[ Primary ].toned( 100 ).rgb(); onPrimary = m_palettes[ Primary ].toned( 100 ).rgb();
@ -1244,7 +1243,7 @@ QskMaterial3Theme::QskMaterial3Theme( QskSkin::ColorScheme colorScheme,
shadow = m_palettes[ Neutral ].toned( 0 ).rgb(); shadow = m_palettes[ Neutral ].toned( 0 ).rgb();
} }
else if ( colorScheme == QskSkin::Dark ) else if ( colorScheme == QskSkin::DarkScheme )
{ {
primary = m_palettes[ Primary ].toned( 80 ).rgb(); primary = m_palettes[ Primary ].toned( 80 ).rgb();
onPrimary = m_palettes[ Primary ].toned( 20 ).rgb(); onPrimary = m_palettes[ Primary ].toned( 20 ).rgb();

View File

@ -27,12 +27,12 @@ QskSkin* QskMaterial3SkinFactory::createSkin( const QString& skinName )
{ {
if ( QString::compare( skinName, materialLightSkinName, Qt::CaseInsensitive ) == 0 ) if ( QString::compare( skinName, materialLightSkinName, Qt::CaseInsensitive ) == 0 )
{ {
QskMaterial3Theme theme( QskSkin::Light ); QskMaterial3Theme theme( QskSkin::LightScheme );
return new QskMaterial3Skin( theme ); return new QskMaterial3Skin( theme );
} }
else if ( QString::compare( skinName, materialDarkSkinName, Qt::CaseInsensitive ) == 0 ) else if ( QString::compare( skinName, materialDarkSkinName, Qt::CaseInsensitive ) == 0 )
{ {
QskMaterial3Theme theme( QskSkin::Dark ); QskMaterial3Theme theme( QskSkin::DarkScheme );
return new QskMaterial3Skin( theme ); return new QskMaterial3Skin( theme );
} }

View File

@ -50,10 +50,12 @@ class QSK_EXPORT QskSkin : public QObject
// Use Qt::ColorScheme once minimum version is Qt 6.5 // Use Qt::ColorScheme once minimum version is Qt 6.5
enum ColorScheme enum ColorScheme
{ {
Unknown, UnknownScheme,
Light,
Dark LightScheme,
DarkScheme
}; };
Q_ENUM( ColorScheme )
#endif #endif
QskSkin( QObject* parent = nullptr ); QskSkin( QObject* parent = nullptr );

View File

@ -8,14 +8,17 @@
#include <qdir.h> #include <qdir.h>
#include <qglobalstatic.h> #include <qglobalstatic.h>
#include <qguiapplication.h>
#include <qjsonarray.h> #include <qjsonarray.h>
#include <qjsonobject.h> #include <qjsonobject.h>
#include <qmap.h> #include <qmap.h>
#include <qpluginloader.h> #include <qpluginloader.h>
#include <qpointer.h> #include <qpointer.h>
#include <qset.h> #include <qset.h>
#if QT_VERSION >= QT_VERSION_CHECK( 6, 5, 0 )
#include <qguiapplication.h>
#include <qstylehints.h> #include <qstylehints.h>
#endif
static inline QStringList qskSplitPath( const QString& s ) static inline QStringList qskSplitPath( const QString& s )
{ {