[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.
This commit is contained in:
Adriaan de Groot 2018-03-29 09:57:19 -04:00
parent c2efae765d
commit b0828faadb
4 changed files with 33 additions and 2 deletions

View File

@ -57,6 +57,7 @@ static ThemeInfoList plasma_themes()
PlasmaLnfPage::PlasmaLnfPage( QWidget* parent ) PlasmaLnfPage::PlasmaLnfPage( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::PlasmaLnfPage ) , ui( new Ui::PlasmaLnfPage )
, m_showAll( false )
, m_buttonGroup( nullptr ) , m_buttonGroup( nullptr )
{ {
ui->setupUi( this ); ui->setupUi( this );
@ -85,6 +86,14 @@ PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes)
{ {
m_enabledThemes = 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(); updateThemeNames();
winnowThemes(); winnowThemes();
fillUi(); fillUi();
@ -104,6 +113,12 @@ PlasmaLnfPage::setPreselect( const QString& id )
fillUi(); fillUi();
} }
void
PlasmaLnfPage::setShowAll(bool b)
{
m_showAll = b;
}
void PlasmaLnfPage::updateThemeNames() void PlasmaLnfPage::updateThemeNames()
{ {

View File

@ -52,6 +52,8 @@ public:
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 );
@ -67,6 +69,7 @@ private:
Ui::PlasmaLnfPage* ui; Ui::PlasmaLnfPage* ui;
QString m_lnfPath; QString m_lnfPath;
QString m_preselect; QString m_preselect;
bool m_showAll; // If true, don't winnow according to enabledThemes
ThemeInfoList m_enabledThemes; ThemeInfoList m_enabledThemes;
QButtonGroup *m_buttonGroup; QButtonGroup *m_buttonGroup;

View File

@ -162,6 +162,11 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
if ( !preselect.isEmpty() ) if ( !preselect.isEmpty() )
m_widget->setPreselect( preselect ); 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" ) && if ( configurationMap.contains( "themes" ) &&
configurationMap.value( "themes" ).type() == QVariant::List ) configurationMap.value( "themes" ).type() == QVariant::List )
{ {

View File

@ -13,8 +13,9 @@ lnftool: "/usr/bin/lookandfeeltool"
# You can limit the list of Plasma look-and-feel themes by listing ids # 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. # 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 # If the key is present, only installed themes that are **also** included
# in the list are shown (could be none!). # 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 # 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. # and an image (e.g. breeze) which will be used to show a screenshot.
@ -28,6 +29,13 @@ themes:
image: "breeze-dark.png" image: "breeze-dark.png"
- org.kde.fluffy-bunny.desktop - 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 # You can pre-select one of the themes; it is not applied
# immediately, but its radio-button is switched on to indicate # immediately, but its radio-button is switched on to indicate
# that that is the theme (that is most likely) currently in use. # that that is the theme (that is most likely) currently in use.