[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
|
void
|
||||||
PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes)
|
PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes, bool showAll )
|
||||||
{
|
{
|
||||||
m_enabledThemes = themes;
|
m_enabledThemes = themes;
|
||||||
|
|
||||||
if ( m_showAll )
|
if ( showAll )
|
||||||
{
|
{
|
||||||
auto plasmaThemes = plasma_themes();
|
auto plasmaThemes = plasma_themes();
|
||||||
for ( auto& installed_theme : plasmaThemes )
|
for ( auto& installed_theme : plasmaThemes )
|
||||||
@ -102,7 +102,9 @@ PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes)
|
|||||||
void
|
void
|
||||||
PlasmaLnfPage::setEnabledThemesAll()
|
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
|
void
|
||||||
@ -113,13 +115,6 @@ PlasmaLnfPage::setPreselect( const QString& id )
|
|||||||
fillUi();
|
fillUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
PlasmaLnfPage::setShowAll(bool b)
|
|
||||||
{
|
|
||||||
m_showAll = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PlasmaLnfPage::updateThemeNames()
|
void PlasmaLnfPage::updateThemeNames()
|
||||||
{
|
{
|
||||||
auto plasmaThemes = plasma_themes();
|
auto plasmaThemes = plasma_themes();
|
||||||
|
@ -46,14 +46,17 @@ public:
|
|||||||
explicit PlasmaLnfPage( QWidget* parent = nullptr );
|
explicit PlasmaLnfPage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
void setLnfPath( const QString& path );
|
void setLnfPath( const QString& path );
|
||||||
/** @brief enable only the listed themes. */
|
/** @brief enable only the listed themes.
|
||||||
void setEnabledThemes( const ThemeInfoList& 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. */
|
/** @brief enable all installed plasma themes. */
|
||||||
void setEnabledThemesAll();
|
void setEnabledThemesAll();
|
||||||
/** @brief set which theme is to be preselected. */
|
/** @brief set which theme is to be preselected. */
|
||||||
void setPreselect( const QString& id );
|
void setPreselect( const QString& id );
|
||||||
/** @brief set whether to show all themes, not just the listed ones. */
|
|
||||||
void setShowAll( bool b );
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void plasmaThemeSelected( const QString& id );
|
void plasmaThemeSelected( const QString& id );
|
||||||
|
@ -165,12 +165,11 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
bool showAll( false );
|
bool showAll( false );
|
||||||
if ( configurationMap.contains( "showAll" ) && configurationMap.value( "showAll" ).type() == QVariant::Bool )
|
if ( configurationMap.contains( "showAll" ) && configurationMap.value( "showAll" ).type() == QVariant::Bool )
|
||||||
showAll = configurationMap.value( "showAll" ).toBool();
|
showAll = configurationMap.value( "showAll" ).toBool();
|
||||||
m_widget->setShowAll( showAll );
|
|
||||||
|
|
||||||
if ( configurationMap.contains( "themes" ) &&
|
if ( configurationMap.contains( "themes" ) &&
|
||||||
configurationMap.value( "themes" ).type() == QVariant::List )
|
configurationMap.value( "themes" ).type() == QVariant::List )
|
||||||
{
|
{
|
||||||
ThemeInfoList allThemes;
|
ThemeInfoList listedThemes;
|
||||||
auto themeList = configurationMap.value( "themes" ).toList();
|
auto themeList = configurationMap.value( "themes" ).toList();
|
||||||
// Create the ThemInfo objects for the listed themes; information
|
// Create the ThemInfo objects for the listed themes; information
|
||||||
// about the themes from Plasma (e.g. human-readable name and description)
|
// 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 )
|
if ( i.type() == QVariant::Map )
|
||||||
{
|
{
|
||||||
auto iv = i.toMap();
|
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 )
|
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";
|
cDebug() << "WARNING: only one theme enabled in plasmalnf";
|
||||||
m_widget->setEnabledThemes( allThemes );
|
m_widget->setEnabledThemes( listedThemes, showAll );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_widget->setEnabledThemesAll(); // All of them
|
m_widget->setEnabledThemesAll(); // All of them
|
||||||
|
Loading…
Reference in New Issue
Block a user