File indexing completed on 2024-04-28 09:22:03
0001 /* 0002 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 #pragma once 0007 0008 #include <KConfigPropertyMap> 0009 #include <KPackage/Package> 0010 #include <KSharedConfig> 0011 #include <QQuickItem> 0012 0013 class KConfigLoader; 0014 0015 namespace ScreenLocker 0016 { 0017 0018 class WallpaperIntegration : public QQuickItem 0019 { 0020 Q_OBJECT 0021 0022 Q_PROPERTY(QString pluginName READ pluginName NOTIFY packageChanged) 0023 Q_PROPERTY(KConfigPropertyMap *configuration READ configuration NOTIFY configurationChanged) 0024 Q_PROPERTY(QQmlListProperty<QAction> contextualActions READ qmlContextualActions NOTIFY contextualActionsChanged) 0025 Q_PROPERTY(bool loading MEMBER m_loading NOTIFY isLoadingChanged) 0026 Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged) 0027 0028 public: 0029 explicit WallpaperIntegration(QQuickItem *parent = nullptr); 0030 ~WallpaperIntegration() override; 0031 0032 void init(); 0033 0034 void setConfig(const KSharedConfig::Ptr &config) 0035 { 0036 m_config = config; 0037 } 0038 QString pluginName() const 0039 { 0040 return m_pluginName; 0041 } 0042 void setPluginName(const QString &name); 0043 0044 KPackage::Package package() const 0045 { 0046 return m_package; 0047 } 0048 0049 KConfigPropertyMap *configuration() const 0050 { 0051 return m_configuration; 0052 } 0053 0054 KConfigLoader *configScheme(); 0055 0056 QQmlListProperty<QAction> qmlContextualActions() 0057 { 0058 static QList<QAction *> list; 0059 return {this, &list}; 0060 } 0061 0062 QColor accentColor() const; 0063 void setAccentColor(const QColor &newColor); 0064 0065 Q_SIGNALS: 0066 void packageChanged(); 0067 void configurationChanged(); 0068 0069 /** 0070 * This is to keep compatible with WallpaperInterface in plasma-framework. 0071 * It doesn't have any practical use. 0072 */ 0073 void isLoadingChanged(); 0074 void accentColorChanged(); 0075 void openUrlRequested(const QUrl &url); 0076 void contextualActionsChanged(const QList<QAction *> &actions); 0077 0078 private: 0079 QString m_pluginName; 0080 KPackage::Package m_package; 0081 KSharedConfig::Ptr m_config; 0082 KConfigLoader *m_configLoader = nullptr; 0083 KConfigPropertyMap *m_configuration = nullptr; 0084 bool m_loading = false; 0085 }; 0086 0087 }