diff --git a/src/modules/plasmalnf/Config.cpp b/src/modules/plasmalnf/Config.cpp index 215aef1d6..9e5183383 100644 --- a/src/modules/plasmalnf/Config.cpp +++ b/src/modules/plasmalnf/Config.cpp @@ -58,6 +58,37 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) preselect = currentPlasmaTheme(); } m_preselectThemeId = preselect; + + if ( configurationMap.contains( "themes" ) && configurationMap.value( "themes" ).type() == QVariant::List ) + { + QMap< QString, QString > listedThemes; + auto themeList = configurationMap.value( "themes" ).toList(); + // Create the ThemInfo objects for the listed themes; information + // about the themes from Plasma (e.g. human-readable name and description) + // are filled in by update_names() in PlasmaLnfPage. + for ( const auto& i : themeList ) + if ( i.type() == QVariant::Map ) + { + auto iv = i.toMap(); + listedThemes.insert( iv.value( "theme" ).toString(), iv.value( "image" ).toString() ); + } + else if ( i.type() == QVariant::String ) + { + listedThemes.insert( i.toString(), QString() ); + } + + if ( listedThemes.count() == 1 ) + { + cWarning() << "only one theme enabled in plasmalnf"; + } + m_themeModel->setThemeImage( listedThemes ); + + bool showAll = CalamaresUtils::getBool( configurationMap, "showAll", false ); + if ( !listedThemes.isEmpty() && !showAll ) + { + m_themeModel->showOnlyThemes( listedThemes ); + } + } } Calamares::JobList diff --git a/src/modules/plasmalnf/ThemeInfo.cpp b/src/modules/plasmalnf/ThemeInfo.cpp index 2cf389a7c..51b19c8fa 100644 --- a/src/modules/plasmalnf/ThemeInfo.cpp +++ b/src/modules/plasmalnf/ThemeInfo.cpp @@ -90,7 +90,7 @@ ThemesModel::showTheme( const QString& id, bool show ) } void -ThemesModel::showTheme( const QMap< QString, QString >& onlyThese ) +ThemesModel::showOnlyThemes( const QMap< QString, QString >& onlyThese ) { for ( auto& t : m_themes ) { diff --git a/src/modules/plasmalnf/ThemeInfo.h b/src/modules/plasmalnf/ThemeInfo.h index 3ac83c771..978aee70e 100644 --- a/src/modules/plasmalnf/ThemeInfo.h +++ b/src/modules/plasmalnf/ThemeInfo.h @@ -119,7 +119,7 @@ public: void showTheme( const QString& id, bool show = true ); /// @brief Shows the keys in the @p onlyThese map, and hides the rest - void showTheme( const QMap< QString, QString >& onlyThese ); + void showOnlyThemes( const QMap< QString, QString >& onlyThese ); private: ThemeInfoList m_themes; diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf index fd59389a8..105f247ef 100644 --- a/src/modules/plasmalnf/plasmalnf.conf +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -24,10 +24,18 @@ lnftool: "/usr/bin/lookandfeeltool" # # liveuser: "live" +# If *showAll* is true, then all installed themes are shown in the +# UI for selection, even if they are not listed in *themes* (below). +# This allows selection of all themes even while not all of them are +# listed in *themes* -- which is useful to show screenshots for those +# you do have a screenshot for. If *themes* is empty or missing, +# the value of *showAll* is treated as `true`. +showAll: false + # You can limit the list of Plasma look-and-feel themes by listing ids # here. If this key is not present, all of the installed themes are listed. # If the key is present, only installed themes that are **also** included -# in the list are shown (could be none!). See the *showAll* key, below, +# in the list are shown (could be none!). See the *showAll* key, above, # to change that. # # Themes may be listed by id, (e.g. fluffy-bunny, below) or as a theme @@ -58,13 +66,6 @@ themes: image: "breeze-dark.png" - org.kde.fluffy-bunny.desktop -# If *showAll* is true, then all installed themes are shown in the -# UI for selection, even if they are not listed in *themes*. This -# allows selection of all themes even while not all of them are -# listed in *themes* -- which is useful to show screenshots for those -# you do have a screenshot for. -showAll: false - # You can pre-select one of the themes; it is not applied # immediately, but its radio-button is switched on to indicate # that that is the theme (that is most likely) currently in use.