From b0828faadb4eccbd4c2441d23860e452b406a434 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 29 Mar 2018 09:57:19 -0400 Subject: [PATCH] [plasmalnf] New setting to show all installed LnF themes - This enables working in three modes: - No themes listed; all are shown without screenshots, - Themes listed, showAll false; only those are shown, - Themes listed, showAll true; the installed-but-not-listed themes are shown after the listed ones, and have limited info. --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 15 +++++++++++++++ src/modules/plasmalnf/PlasmaLnfPage.h | 3 +++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 5 +++++ src/modules/plasmalnf/plasmalnf.conf | 12 ++++++++++-- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 2638ca9b1..247fa950b 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -57,6 +57,7 @@ static ThemeInfoList plasma_themes() PlasmaLnfPage::PlasmaLnfPage( QWidget* parent ) : QWidget( parent ) , ui( new Ui::PlasmaLnfPage ) + , m_showAll( false ) , m_buttonGroup( nullptr ) { ui->setupUi( this ); @@ -85,6 +86,14 @@ PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes) { m_enabledThemes = themes; + if ( m_showAll ) + { + auto plasmaThemes = plasma_themes(); + for ( auto& installed_theme : plasmaThemes ) + if ( !m_enabledThemes.findById( installed_theme.id ) ) + m_enabledThemes.append( installed_theme ); + } + updateThemeNames(); winnowThemes(); fillUi(); @@ -104,6 +113,12 @@ PlasmaLnfPage::setPreselect( const QString& id ) fillUi(); } +void +PlasmaLnfPage::setShowAll(bool b) +{ + m_showAll = b; +} + void PlasmaLnfPage::updateThemeNames() { diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index 104fca83d..564b61fef 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -52,6 +52,8 @@ public: void setEnabledThemesAll(); /** @brief set which theme is to be preselected. */ void setPreselect( const QString& id ); + /** @brief set whether to show all themes, not just the listed ones. */ + void setShowAll( bool b ); signals: void plasmaThemeSelected( const QString& id ); @@ -67,6 +69,7 @@ private: Ui::PlasmaLnfPage* ui; QString m_lnfPath; QString m_preselect; + bool m_showAll; // If true, don't winnow according to enabledThemes ThemeInfoList m_enabledThemes; QButtonGroup *m_buttonGroup; diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 2ba4f7bca..929d57360 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -162,6 +162,11 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) if ( !preselect.isEmpty() ) m_widget->setPreselect( preselect ); + bool showAll( false ); + if ( configurationMap.contains( "showAll" ) && configurationMap.value( "showAll" ).type() == QVariant::Bool ) + showAll = configurationMap.value( "showAll" ).toBool(); + m_widget->setShowAll( showAll ); + if ( configurationMap.contains( "themes" ) && configurationMap.value( "themes" ).type() == QVariant::List ) { diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf index e6ed88e77..a3a80fcff 100644 --- a/src/modules/plasmalnf/plasmalnf.conf +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -13,8 +13,9 @@ lnftool: "/usr/bin/lookandfeeltool" # 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!). +# 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, +# to change that. # # Themes may be listed by id, (e.g. fluffy-bunny, below) or as a theme # and an image (e.g. breeze) which will be used to show a screenshot. @@ -28,6 +29,13 @@ 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.