File indexing completed on 2024-05-19 05:38:27

0001 #ifndef WALLPAPERMODULE_H
0002 #define WALLPAPERMODULE_H
0003 
0004 #include <KConfigGroup>
0005 #include <KQuickConfigModule>
0006 #include <KSharedConfig>
0007 #include <PlasmaQuick/ConfigModel>
0008 
0009 #include <QQmlPropertyMap>
0010 #include <QScreen>
0011 
0012 class KConfigLoader;
0013 class WallpaperConfigModel;
0014 class OutputOrderWatcher;
0015 class KConfigPropertyMap;
0016 
0017 namespace KActivities
0018 {
0019 class Consumer;
0020 }
0021 
0022 class WallpaperModule : public KQuickConfigModule
0023 {
0024     Q_OBJECT
0025 
0026     Q_PROPERTY(QQmlPropertyMap *configuration READ wallpaperConfiguration NOTIFY wallpaperConfigurationChanged)
0027 
0028     Q_PROPERTY(QString currentWallpaper READ currentWallpaperPlugin WRITE setCurrentWallpaperPlugin NOTIFY currentWallpaperPluginChanged)
0029     Q_PROPERTY(bool allScreens READ allScreens WRITE setAllScreens NOTIFY allScreensChanged)
0030     Q_PROPERTY(QString wallpaperPluginSource READ wallpaperPluginSource NOTIFY currentWallpaperPluginChanged)
0031     Q_PROPERTY(PlasmaQuick::ConfigModel *wallpaperConfigModel READ wallpaperConfigModel CONSTANT)
0032 
0033     Q_PROPERTY(QScreen *selectedScreen READ selectedScreen NOTIFY selectedScreenChanged)
0034     Q_PROPERTY(QList<QScreen *> screens READ screens NOTIFY screensChanged)
0035 
0036 public:
0037     explicit WallpaperModule(QObject *parent, const KPluginMetaData &data);
0038 
0039     PlasmaQuick::ConfigModel *wallpaperConfigModel();
0040 
0041     QQmlPropertyMap *wallpaperConfiguration() const;
0042     QString wallpaperPluginSource();
0043     QList<QScreen *> screens() const;
0044     QScreen *selectedScreen() const;
0045 
0046     Q_INVOKABLE void setSelectedScreen(const QString &screenName);
0047     int screenIdFromName(const QString &stringName) const;
0048 
0049     QString currentWallpaperPlugin() const;
0050     void setCurrentWallpaperPlugin(const QString &wallpaperPlugin);
0051 
0052     bool allScreens() const;
0053     void setAllScreens(const bool allScreens);
0054 
0055     void load() override;
0056     void save() override;
0057     void defaults() override;
0058 
0059 Q_SIGNALS:
0060     void wallpaperConfigurationChanged();
0061     void currentWallpaperPluginChanged();
0062     void selectedScreenChanged();
0063     void screensChanged();
0064     void allScreensChanged();
0065     void settingsSaved();
0066 
0067 public Q_SLOTS:
0068     void onScreenChanged();
0069     void onWallpaperChanged(uint screenIdx);
0070     void setCurrentActivity(const QString &activityId);
0071 
0072 private:
0073     void setWallpaperPluginConfiguration(const QString &wallpaperplugin, bool loadDefaults = false);
0074     void loadConfiguration();
0075     bool isDefault() const;
0076 
0077     KSharedConfig::Ptr m_config;
0078     KConfigLoader *m_configLoader;
0079     KActivities::Consumer *m_activityConsumer = nullptr;
0080     OutputOrderWatcher *m_outputOrderWatcher = nullptr;
0081     WallpaperConfigModel *m_wallpaperConfigModel = nullptr;
0082     KConfigPropertyMap *m_wallpaperConfiguration = nullptr;
0083     QString m_loadedWallpaperplugin;
0084     QString m_currentWallpaperPlugin;
0085     QScreen *m_selectedScreen = nullptr;
0086     KConfigGroup m_wallpaperConfigGeneral;
0087     QString m_activityId;
0088     QString m_containmentIdx;
0089     QString m_defaultWallpaper;
0090     QList<QScreen *> m_screens;
0091     bool m_allScreens = false;
0092 };
0093 
0094 #endif // WALLPAPERMODULE_H