diff --git a/src/modules/plasmalnf/ThemeInfo.cpp b/src/modules/plasmalnf/ThemeInfo.cpp index 41bffd1f0..2cf389a7c 100644 --- a/src/modules/plasmalnf/ThemeInfo.cpp +++ b/src/modules/plasmalnf/ThemeInfo.cpp @@ -60,6 +60,45 @@ ThemesModel::roleNames() const return { { LabelRole, "label" }, { KeyRole, "key" } }; } +void +ThemesModel::setThemeImage( const QString& id, const QString& imagePath ) +{ + auto* theme = m_themes.findById( id ); + if ( theme ) + { + theme->imagePath = imagePath; + } +} + +void +ThemesModel::setThemeImage( const QMap< QString, QString >& images ) +{ + for ( const auto& k : images ) + { + setThemeImage( k, images[ k ] ); + } +} + +void +ThemesModel::showTheme( const QString& id, bool show ) +{ + auto* theme = m_themes.findById( id ); + if ( theme ) + { + theme->show = show; + } +} + +void +ThemesModel::showTheme( const QMap< QString, QString >& onlyThese ) +{ + for ( auto& t : m_themes ) + { + t.show = onlyThese.contains( t.id ); + } +} + + ThemeInfo::ThemeInfo( const KPluginMetaData& data ) : id( data.pluginId() ) , name( data.name() ) diff --git a/src/modules/plasmalnf/ThemeInfo.h b/src/modules/plasmalnf/ThemeInfo.h index a44c41858..3ac83c771 100644 --- a/src/modules/plasmalnf/ThemeInfo.h +++ b/src/modules/plasmalnf/ThemeInfo.h @@ -31,6 +31,7 @@ struct ThemeInfo QString description; QString imagePath; ThemeWidget* widget; + bool show = true; ThemeInfo() : widget( nullptr ) @@ -108,6 +109,18 @@ public: const ThemeInfo* findById( const QString& id ) const { return m_themes.findById( id ); } + /// @brief Set the screenshot to go with the given @p id + void setThemeImage( const QString& id, const QString& imagePath ); + + /// @brief Call setThemeImage( key, value ) for all keys in @p images + void setThemeImage( const QMap< QString, QString >& images ); + + /// @brief Set whether to show the given theme @p id (or not) + void showTheme( const QString& id, bool show = true ); + + /// @brief Shows the keys in the @p onlyThese map, and hides the rest + void showTheme( const QMap< QString, QString >& onlyThese ); + private: ThemeInfoList m_themes; };