From 244919d6feb8344c76364a7e0ad31089d8a7ded1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 14 Dec 2017 17:01:59 -0500 Subject: [PATCH] [plasmalnf] Add description to theme widget --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 11 +++++++++-- src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 7 +++++-- src/modules/plasmalnf/ThemeInfo.h | 14 ++++++++++++-- src/modules/plasmalnf/ThemeWidget.cpp | 1 + src/modules/plasmalnf/ThemeWidget.h | 3 ++- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index e93002855..501827003 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -19,7 +19,6 @@ #include "PlasmaLnfPage.h" #include "ui_page_plasmalnf.h" -#include "ThemeWidget.h" #include "utils/Logger.h" #include "utils/Retranslator.h" @@ -27,6 +26,13 @@ #include #include +ThemeInfo::ThemeInfo( const KPluginMetaData& data ) + : id( data.pluginId() ) + , name( data.name() ) + , description( data.description() ) +{ +} + static ThemeInfoList plasma_themes() { ThemeInfoList packages; @@ -37,7 +43,7 @@ static ThemeInfoList plasma_themes() { if ( data.isValid() && !data.isHidden() && !data.name().isEmpty() ) { - packages << ThemeInfo{ data.pluginId(), data.name() }; + packages << ThemeInfo{ data }; } } @@ -89,6 +95,7 @@ void PlasmaLnfPage::updateThemeNames() if ( t != nullptr ) { enabled_theme.name = t->name; + enabled_theme.description = t->description; } } } diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index ad4e531b5..4dcfd2f47 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -142,14 +142,17 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { ThemeInfoList allThemes; 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) + // are filled in by update_names() in PlasmaLnfPage. for ( const auto& i : themeList ) if ( i.type() == QVariant::Map ) { auto iv = i.toMap(); - allThemes.append( ThemeInfo( iv.value( "theme" ).toString(), QString(), iv.value( "image" ).toString() ) ); + allThemes.append( ThemeInfo( iv.value( "theme" ).toString(), iv.value( "image" ).toString() ) ); } else if ( i.type() == QVariant::String ) - allThemes.append( ThemeInfo( i.toString(), QString() ) ); + allThemes.append( ThemeInfo( i.toString() ) ); if ( allThemes.length() == 1 ) cDebug() << "WARNING: only one theme enabled in plasmalnf"; diff --git a/src/modules/plasmalnf/ThemeInfo.h b/src/modules/plasmalnf/ThemeInfo.h index 863043969..f11083485 100644 --- a/src/modules/plasmalnf/ThemeInfo.h +++ b/src/modules/plasmalnf/ThemeInfo.h @@ -22,6 +22,8 @@ #include #include +class KPluginMetaData; + /** @brief describes a single plasma LnF theme. * * A theme description has an id, which is really the name of the desktop @@ -33,17 +35,25 @@ struct ThemeInfo { QString id; QString name; + QString description; QString imagePath; ThemeInfo() {} - ThemeInfo( const QString& _id, const QString& _name, const QString& image = QString() ) + explicit ThemeInfo( const QString& _id ) + : id( _id ) + { + } + + explicit ThemeInfo( const QString& _id, const QString& image ) : id( _id ) - , name( _name ) , imagePath( image ) {} + // Defined in PlasmaLnfPage.cpp + explicit ThemeInfo( const KPluginMetaData& ); + bool isValid() const { return !id.isEmpty(); } } ; diff --git a/src/modules/plasmalnf/ThemeWidget.cpp b/src/modules/plasmalnf/ThemeWidget.cpp index 2261c2c4f..b2f8143bc 100644 --- a/src/modules/plasmalnf/ThemeWidget.cpp +++ b/src/modules/plasmalnf/ThemeWidget.cpp @@ -34,6 +34,7 @@ ThemeWidget::ThemeWidget(const ThemeInfo& info, QWidget* parent) layout->addWidget( m_check ); layout->addWidget( new QLabel( "Image", this ) ); + layout->addWidget( new QLabel( info.description, this ) ); connect( m_check, &QRadioButton::clicked, this, &ThemeWidget::clicked ); } diff --git a/src/modules/plasmalnf/ThemeWidget.h b/src/modules/plasmalnf/ThemeWidget.h index 837d362f4..42f064039 100644 --- a/src/modules/plasmalnf/ThemeWidget.h +++ b/src/modules/plasmalnf/ThemeWidget.h @@ -23,7 +23,8 @@ class QAbstractButton; class QRadioButton; -class ThemeInfo; + +struct ThemeInfo; class ThemeWidget : public QWidget {