[plasmalnf] Simplify showAll handling
- Only need the showAll parameter once, when passing in the list of themes to show.
This commit is contained in:
parent
b0828faadb
commit
fb93a8288e
@ -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();
|
||||
|
@ -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 );
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user