From fb93a8288e74cdbcca90b905dadc72649d9e76ff Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 29 Mar 2018 10:09:45 -0400 Subject: [PATCH] [plasmalnf] Simplify showAll handling - Only need the showAll parameter once, when passing in the list of themes to show. --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 15 +++++---------- src/modules/plasmalnf/PlasmaLnfPage.h | 11 +++++++---- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 11 +++++------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 247fa950b..c65e79ba2 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -82,11 +82,11 @@ PlasmaLnfPage::setLnfPath( const QString& path ) } void -PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes) +PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes, bool showAll ) { m_enabledThemes = themes; - if ( m_showAll ) + if ( showAll ) { auto plasmaThemes = plasma_themes(); for ( auto& installed_theme : plasmaThemes ) @@ -102,7 +102,9 @@ PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes) void PlasmaLnfPage::setEnabledThemesAll() { - setEnabledThemes( plasma_themes() ); + // Don't need to set showAll=true, because we're already passing in + // the complete list of installed themes. + setEnabledThemes( plasma_themes(), false ); } void @@ -113,13 +115,6 @@ PlasmaLnfPage::setPreselect( const QString& id ) fillUi(); } -void -PlasmaLnfPage::setShowAll(bool b) -{ - m_showAll = b; -} - - void PlasmaLnfPage::updateThemeNames() { auto plasmaThemes = plasma_themes(); diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index 564b61fef..49a6ff69a 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -46,14 +46,17 @@ public: explicit PlasmaLnfPage( QWidget* parent = nullptr ); void setLnfPath( const QString& path ); - /** @brief enable only the listed themes. */ - void setEnabledThemes( const ThemeInfoList& themes ); + /** @brief enable only the listed themes. + * + * Shows the listed @p themes with full information (e.g. screenshot). + * If @p showAll is true, then also show all installed themes + * not explicitly listed (without a screenshot). + */ + void setEnabledThemes( const ThemeInfoList& themes, bool showAll ); /** @brief enable all installed plasma themes. */ 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 ); diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 929d57360..498a40fe0 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -165,12 +165,11 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) 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 ) { - ThemeInfoList allThemes; + ThemeInfoList 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) @@ -179,14 +178,14 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) if ( i.type() == QVariant::Map ) { auto iv = i.toMap(); - allThemes.append( ThemeInfo( iv.value( "theme" ).toString(), iv.value( "image" ).toString() ) ); + listedThemes.append( ThemeInfo( iv.value( "theme" ).toString(), iv.value( "image" ).toString() ) ); } else if ( i.type() == QVariant::String ) - allThemes.append( ThemeInfo( i.toString() ) ); + listedThemes.append( ThemeInfo( i.toString() ) ); - if ( allThemes.length() == 1 ) + if ( listedThemes.length() == 1 ) cDebug() << "WARNING: only one theme enabled in plasmalnf"; - m_widget->setEnabledThemes( allThemes ); + m_widget->setEnabledThemes( listedThemes, showAll ); } else m_widget->setEnabledThemesAll(); // All of them