From 1f8283b186b57050d6a28b26893a1d51a7b94402 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 20 Jun 2023 09:20:51 +0200 Subject: [PATCH] respect the ordering from the skin factories instead of sorting them alphabetically --- src/controls/QskSkinManager.cpp | 15 ++++++--------- support/SkinnyNamespace.cpp | 17 +++++++---------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/controls/QskSkinManager.cpp b/src/controls/QskSkinManager.cpp index d2ad8b04..048a4757 100644 --- a/src/controls/QskSkinManager.cpp +++ b/src/controls/QskSkinManager.cpp @@ -200,7 +200,7 @@ namespace if ( !m_isValid ) const_cast< FactoryMap* >( this )->rebuild(); - return m_skinMap.keys(); + return m_skinNames; } void insertFactory( FactoryLoader* loader ) @@ -269,6 +269,7 @@ namespace void rebuild() { m_skinMap.clear(); + m_skinNames.clear(); // first we try all factories, that have been added manually for ( auto it = m_factoryMap.constBegin(); it != m_factoryMap.constEnd(); ++it ) @@ -287,7 +288,6 @@ namespace rebuild( it.key(), data.loader->skinNames() ); } - m_skinNames = m_skinMap.keys(); m_isValid = true; } @@ -296,7 +296,10 @@ namespace for ( const auto& name : skinNames ) { if ( !m_skinMap.contains( name ) ) + { m_skinMap.insert( name, factoryId ); + m_skinNames += name; + } } } @@ -487,16 +490,10 @@ QskSkin* QskSkinManager::createSkin( const QString& skinName ) const auto factory = map.factory( name ); if ( factory == nullptr ) { - /* - Once the Fusion skin has been implemented it will be used - as fallback. For the moment we implement - another stupid fallback. TODO ... - */ - const auto names = map.skinNames(); if ( !names.isEmpty() ) { - name = names.last(); + name = names.first(); factory = map.factory( name ); } } diff --git a/support/SkinnyNamespace.cpp b/support/SkinnyNamespace.cpp index c0e5891d..31da9c91 100644 --- a/support/SkinnyNamespace.cpp +++ b/support/SkinnyNamespace.cpp @@ -55,7 +55,9 @@ static bool pluginPath = initPluginPath(); static void initSkins() { - if ( qskSkinManager->skinNames().isEmpty() ) + auto skinNames = qskSkinManager->skinNames(); + + if ( skinNames.isEmpty() ) { /* To avoid having problems with not finding the skin plugins @@ -67,17 +69,12 @@ static bool pluginPath = initPluginPath(); qskSkinManager->registerFactory( "Fluent2Factory", new QskFluent2SkinFactory() ); qWarning() << "Couldn't find skin plugins, adding some manually."; + + skinNames = qskSkinManager->skinNames(); } -#if 1 - /* - QskSkinManager is sorting in alphabetic order, but we want to have - the light material skin as initial skin. TODO ... - */ - const auto names = qskSkinManager->skinNames(); - if ( names.count() > 1 ) - qskSetup->setSkin( names[1] ); -#endif + if ( !skinNames.isEmpty() ) + qskSetup->setSkin( skinNames[0] ); } Q_COREAPP_STARTUP_FUNCTION( initSkins )