From d5b46dfb8650e019b81f953c0e5ebb9271a2d87d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Dec 2017 12:51:56 +0100 Subject: [PATCH] [plasmalnf] Improve theme-listing handling - if key is missing or badly typed, enable all (explicitly) - document settings and code --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 12 ++++++++---- src/modules/plasmalnf/PlasmaLnfPage.h | 9 +++++++++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 2 ++ src/modules/plasmalnf/plasmalnf.conf | 12 +++++++----- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 0c3d94079..2b171cc40 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -77,16 +77,20 @@ PlasmaLnfPage::setLnfPath( const QString& path ) void PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes) { - if ( themes.isEmpty() ) - m_enabledThemes = plasma_themes(); - else - m_enabledThemes = themes; + m_enabledThemes = themes; updateThemeNames(); winnowThemes(); fillUi(); } +void +PlasmaLnfPage::setEnabledThemesAll() +{ + setEnabledThemes( plasma_themes() ); +} + + void PlasmaLnfPage::updateThemeNames() { auto plasmaThemes = plasma_themes(); diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index 59fffc93a..e489e99a7 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -33,6 +33,12 @@ namespace Ui class PlasmaLnfPage; } +/** @brief Page for selecting a Plasma Look-and-Feel theme. + * + * You must call setEnabledThemes -- either overload -- once + * to get the selection widgets. Note that calling that with + * an empty list will result in zero (0) selectable themes. + */ class PlasmaLnfPage : public QWidget { Q_OBJECT @@ -40,7 +46,10 @@ public: explicit PlasmaLnfPage( QWidget* parent = nullptr ); void setLnfPath( const QString& path ); + /** @brief enable only the listed themes. */ void setEnabledThemes( const ThemeInfoList& themes ); + /** @brief enable all installed plasma themes. */ + void setEnabledThemesAll(); signals: void plasmaThemeSelected( const QString& id ); diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 4dcfd2f47..db8529d56 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -158,6 +158,8 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) cDebug() << "WARNING: only one theme enabled in plasmalnf"; m_widget->setEnabledThemes( allThemes ); } + else + m_widget->setEnabledThemesAll(); // All of them } void diff --git a/src/modules/plasmalnf/plasmalnf.conf b/src/modules/plasmalnf/plasmalnf.conf index 4aeca2471..aa9865117 100644 --- a/src/modules/plasmalnf/plasmalnf.conf +++ b/src/modules/plasmalnf/plasmalnf.conf @@ -12,12 +12,14 @@ lnftool: "/usr/bin/lookandfeeltool" # liveuser: "live" # You can limit the list of Plasma look-and-feel themes by listing ids -# here. If this key is not present, or the list is empty, all of the -# installed themes are listed. If only one theme is listed, why are -# you using this module at all? 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. +# 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!). # +# 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. +# Themes with no image get a "missing screenshot" image; if the +# image file is not found, they get a color swatch based on the image name. themes: - org.kde.fuzzy-pig.desktop - theme: org.kde.breeze.desktop