Changeset View
Changeset View
Standalone View
Standalone View
kcms/desktoptheme/kcm.h
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #ifndef _KCM_DESKTOPTHEME_H | 22 | #ifndef _KCM_DESKTOPTHEME_H | ||
23 | #define _KCM_DESKTOPTHEME_H | 23 | #define _KCM_DESKTOPTHEME_H | ||
24 | 24 | | |||
25 | #include <KQuickAddons/ConfigModule> | 25 | #include <KQuickAddons/ConfigModule> | ||
26 | 26 | | |||
27 | #include <KNewStuff3/KNS3/DownloadDialog> | 27 | #include <KNewStuff3/KNS3/DownloadDialog> | ||
28 | 28 | | |||
29 | class QTemporaryFile; | ||||
30 | | ||||
29 | namespace Plasma { | 31 | namespace Plasma { | ||
30 | class Svg; | 32 | class Svg; | ||
31 | class Theme; | 33 | class Theme; | ||
32 | } | 34 | } | ||
33 | 35 | | |||
36 | namespace KIO | ||||
37 | { | ||||
38 | class FileCopyJob; | ||||
39 | } | ||||
40 | | ||||
34 | class QQuickItem; | 41 | class QQuickItem; | ||
35 | class QStandardItemModel; | 42 | class QStandardItemModel; | ||
36 | 43 | | |||
37 | class KCMDesktopTheme : public KQuickAddons::ConfigModule | 44 | class KCMDesktopTheme : public KQuickAddons::ConfigModule | ||
38 | { | 45 | { | ||
39 | Q_OBJECT | 46 | Q_OBJECT | ||
40 | Q_PROPERTY(QStandardItemModel *desktopThemeModel READ desktopThemeModel CONSTANT) | 47 | Q_PROPERTY(QStandardItemModel *desktopThemeModel READ desktopThemeModel CONSTANT) | ||
41 | Q_PROPERTY(QString selectedPlugin READ selectedPlugin WRITE setSelectedPlugin NOTIFY selectedPluginChanged) | 48 | Q_PROPERTY(QString selectedPlugin READ selectedPlugin WRITE setSelectedPlugin NOTIFY selectedPluginChanged) | ||
42 | Q_PROPERTY(int selectedPluginIndex READ selectedPluginIndex NOTIFY selectedPluginIndexChanged) | 49 | Q_PROPERTY(int selectedPluginIndex READ selectedPluginIndex NOTIFY selectedPluginIndexChanged) | ||
50 | Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged) | ||||
43 | Q_PROPERTY(bool canEditThemes READ canEditThemes CONSTANT) | 51 | Q_PROPERTY(bool canEditThemes READ canEditThemes CONSTANT) | ||
44 | 52 | | |||
45 | public: | 53 | public: | ||
46 | enum Roles { | 54 | enum Roles { | ||
47 | PluginNameRole = Qt::UserRole + 1, | 55 | PluginNameRole = Qt::UserRole + 1, | ||
48 | ThemeNameRole, | 56 | ThemeNameRole, | ||
49 | DescriptionRole, | 57 | DescriptionRole, | ||
50 | IsLocalRole, | 58 | IsLocalRole, | ||
51 | PendingDeletionRole | 59 | PendingDeletionRole | ||
52 | }; | 60 | }; | ||
53 | Q_ENUM(Roles) | 61 | Q_ENUM(Roles) | ||
54 | 62 | | |||
55 | KCMDesktopTheme(QObject *parent, const QVariantList &args); | 63 | KCMDesktopTheme(QObject *parent, const QVariantList &args); | ||
56 | ~KCMDesktopTheme() override; | 64 | ~KCMDesktopTheme() override; | ||
57 | 65 | | |||
58 | QStandardItemModel *desktopThemeModel() const; | 66 | QStandardItemModel *desktopThemeModel() const; | ||
59 | 67 | | |||
60 | QString selectedPlugin() const; | 68 | QString selectedPlugin() const; | ||
61 | void setSelectedPlugin(const QString &plugin); | 69 | void setSelectedPlugin(const QString &plugin); | ||
62 | int selectedPluginIndex() const; | 70 | int selectedPluginIndex() const; | ||
63 | 71 | | |||
72 | bool downloadingFile() const; | ||||
73 | | ||||
64 | bool canEditThemes() const; | 74 | bool canEditThemes() const; | ||
65 | 75 | | |||
66 | Q_INVOKABLE void getNewStuff(QQuickItem *ctx); | 76 | Q_INVOKABLE void getNewStuff(QQuickItem *ctx); | ||
67 | Q_INVOKABLE void installThemeFromFile(const QUrl &file); | 77 | Q_INVOKABLE void installThemeFromFile(const QUrl &url); | ||
68 | 78 | | |||
69 | Q_INVOKABLE void setPendingDeletion(int index, bool pending); | 79 | Q_INVOKABLE void setPendingDeletion(int index, bool pending); | ||
70 | 80 | | |||
71 | Q_INVOKABLE void applyPlasmaTheme(QQuickItem *item, const QString &themeName); | 81 | Q_INVOKABLE void applyPlasmaTheme(QQuickItem *item, const QString &themeName); | ||
72 | 82 | | |||
73 | Q_INVOKABLE void editTheme(const QString &themeName); | 83 | Q_INVOKABLE void editTheme(const QString &themeName); | ||
74 | 84 | | |||
75 | Q_SIGNALS: | 85 | Q_SIGNALS: | ||
76 | void selectedPluginChanged(const QString &plugin); | 86 | void selectedPluginChanged(const QString &plugin); | ||
77 | void selectedPluginIndexChanged(); | 87 | void selectedPluginIndexChanged(); | ||
88 | void downloadingFileChanged(); | ||||
89 | | ||||
78 | void showSuccessMessage(const QString &message); | 90 | void showSuccessMessage(const QString &message); | ||
79 | void showErrorMessage(const QString &message); | 91 | void showErrorMessage(const QString &message); | ||
80 | 92 | | |||
81 | public Q_SLOTS: | 93 | public Q_SLOTS: | ||
82 | void load() override; | 94 | void load() override; | ||
83 | void save() override; | 95 | void save() override; | ||
84 | void defaults() override; | 96 | void defaults() override; | ||
85 | 97 | | |||
86 | private: | 98 | private: | ||
87 | void updateNeedsSave(); | 99 | void updateNeedsSave(); | ||
88 | 100 | | |||
89 | void processPendingDeletions(); | 101 | void processPendingDeletions(); | ||
90 | 102 | | |||
103 | void installTheme(const QString &path); | ||||
104 | | ||||
91 | QStandardItemModel *m_model; | 105 | QStandardItemModel *m_model; | ||
92 | QString m_selectedPlugin; | 106 | QString m_selectedPlugin; | ||
93 | QStringList m_pendingRemoval; | 107 | QStringList m_pendingRemoval; | ||
94 | Plasma::Theme *m_defaultTheme; | 108 | Plasma::Theme *m_defaultTheme; | ||
95 | QHash<QString, Plasma::Theme*> m_themes; | 109 | QHash<QString, Plasma::Theme*> m_themes; | ||
96 | bool m_haveThemeExplorerInstalled; | 110 | bool m_haveThemeExplorerInstalled; | ||
97 | 111 | | |||
98 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | 112 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | ||
113 | | ||||
114 | QScopedPointer<QTemporaryFile> m_tempInstallFile; | ||||
115 | QPointer<KIO::FileCopyJob> m_tempCopyJob; | ||||
99 | }; | 116 | }; | ||
100 | 117 | | |||
101 | Q_DECLARE_LOGGING_CATEGORY(KCM_DESKTOP_THEME) | 118 | Q_DECLARE_LOGGING_CATEGORY(KCM_DESKTOP_THEME) | ||
102 | 119 | | |||
103 | #endif // _KCM_DESKTOPTHEME_H | 120 | #endif // _KCM_DESKTOPTHEME_H |