Changeset View
Changeset View
Standalone View
Standalone View
kcms/colors/colors.h
Show All 32 Lines | |||||
33 | class QProcess; | 33 | class QProcess; | ||
34 | class QTemporaryFile; | 34 | class QTemporaryFile; | ||
35 | 35 | | |||
36 | namespace KIO | 36 | namespace KIO | ||
37 | { | 37 | { | ||
38 | class FileCopyJob; | 38 | class FileCopyJob; | ||
39 | } | 39 | } | ||
40 | 40 | | |||
41 | class ColorsModel; | ||||
42 | class FilterProxyModel; | ||||
43 | | ||||
41 | class KCMColors : public KQuickAddons::ConfigModule | 44 | class KCMColors : public KQuickAddons::ConfigModule | ||
42 | { | 45 | { | ||
43 | Q_OBJECT | 46 | Q_OBJECT | ||
44 | 47 | | |||
45 | Q_PROPERTY(QStandardItemModel *colorsModel READ colorsModel CONSTANT) | 48 | Q_PROPERTY(ColorsModel *model READ model CONSTANT) | ||
46 | Q_PROPERTY(QString selectedScheme READ selectedScheme WRITE setSelectedScheme NOTIFY selectedSchemeChanged) | 49 | Q_PROPERTY(FilterProxyModel *filteredModel READ filteredModel CONSTANT) | ||
47 | Q_PROPERTY(int selectedSchemeIndex READ selectedSchemeIndex NOTIFY selectedSchemeIndexChanged) | | |||
48 | Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged) | 50 | Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged) | ||
49 | 51 | | |||
50 | public: | 52 | public: | ||
51 | KCMColors(QObject *parent, const QVariantList &args); | 53 | KCMColors(QObject *parent, const QVariantList &args); | ||
52 | ~KCMColors() override; | 54 | ~KCMColors() override; | ||
53 | 55 | | |||
54 | enum Roles { | 56 | enum Roles { | ||
55 | SchemeNameRole = Qt::UserRole + 1, | 57 | SchemeNameRole = Qt::UserRole + 1, | ||
56 | PaletteRole, | 58 | PaletteRole, | ||
57 | RemovableRole, | 59 | RemovableRole, | ||
58 | PendingDeletionRole | 60 | PendingDeletionRole | ||
59 | }; | 61 | }; | ||
60 | 62 | | |||
61 | QStandardItemModel *colorsModel() const; | 63 | enum SchemeFilter { | ||
62 | 64 | AllSchemes, | |||
63 | QString selectedScheme() const; | 65 | LightSchemes, | ||
64 | void setSelectedScheme(const QString &scheme); | 66 | DarkSchemes | ||
67 | }; | ||||
68 | Q_ENUM(SchemeFilter) | ||||
65 | 69 | | |||
66 | int selectedSchemeIndex() const; | 70 | ColorsModel *model() const; | ||
71 | FilterProxyModel *filteredModel() const; | ||||
67 | 72 | | |||
68 | bool downloadingFile() const; | 73 | bool downloadingFile() const; | ||
69 | 74 | | |||
70 | Q_INVOKABLE void getNewStuff(QQuickItem *ctx); | 75 | Q_INVOKABLE void getNewStuff(QQuickItem *ctx); | ||
71 | Q_INVOKABLE void installSchemeFromFile(const QUrl &url); | 76 | Q_INVOKABLE void installSchemeFromFile(const QUrl &url); | ||
72 | 77 | | |||
73 | Q_INVOKABLE void setPendingDeletion(int index, bool pending); | 78 | Q_INVOKABLE void editScheme(const QString &schemeName, QQuickItem *ctx); | ||
74 | | ||||
75 | Q_INVOKABLE void editScheme(int index, QQuickItem *ctx); | | |||
76 | 79 | | |||
77 | public Q_SLOTS: | 80 | public Q_SLOTS: | ||
78 | void load() override; | 81 | void load() override; | ||
79 | void save() override; | 82 | void save() override; | ||
80 | void defaults() override; | 83 | void defaults() override; | ||
81 | 84 | | |||
82 | Q_SIGNALS: | 85 | Q_SIGNALS: | ||
83 | void selectedSchemeChanged(); | 86 | void selectedSchemeChanged(); | ||
84 | void selectedSchemeIndexChanged(); | 87 | void selectedSchemeIndexChanged(); | ||
85 | void downloadingFileChanged(); | 88 | void downloadingFileChanged(); | ||
86 | 89 | | |||
87 | void showSuccessMessage(const QString &message); | 90 | void showSuccessMessage(const QString &message); | ||
88 | void showErrorMessage(const QString &message); | 91 | void showErrorMessage(const QString &message); | ||
89 | 92 | | |||
90 | void showSchemeNotInstalledWarning(const QString &schemeName); | 93 | void showSchemeNotInstalledWarning(const QString &schemeName); | ||
91 | 94 | | |||
92 | private: | 95 | private: | ||
93 | void loadModel(); | | |||
94 | | ||||
95 | void saveColors(); | 96 | void saveColors(); | ||
96 | void processPendingDeletions(); | 97 | void processPendingDeletions(); | ||
97 | 98 | | |||
98 | int indexOfScheme(const QString &schemeName) const; | | |||
99 | | ||||
100 | void installSchemeFile(const QString &path); | 99 | void installSchemeFile(const QString &path); | ||
101 | 100 | | |||
102 | QStandardItemModel *m_model; | 101 | ColorsModel *m_model; | ||
102 | FilterProxyModel *m_filteredModel; | ||||
103 | 103 | | |||
104 | QString m_selectedScheme; | | |||
105 | bool m_selectedSchemeDirty = false; | 104 | bool m_selectedSchemeDirty = false; | ||
106 | 105 | | |||
107 | bool m_applyToAlien = true; | 106 | bool m_applyToAlien = true; | ||
108 | 107 | | |||
109 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | 108 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | ||
110 | 109 | | |||
111 | QProcess *m_editDialogProcess = nullptr; | 110 | QProcess *m_editDialogProcess = nullptr; | ||
112 | 111 | | |||
113 | KSharedConfigPtr m_config; | 112 | KSharedConfigPtr m_config; | ||
114 | 113 | | |||
115 | QScopedPointer<QTemporaryFile> m_tempInstallFile; | 114 | QScopedPointer<QTemporaryFile> m_tempInstallFile; | ||
116 | QPointer<KIO::FileCopyJob> m_tempCopyJob; | 115 | QPointer<KIO::FileCopyJob> m_tempCopyJob; | ||
117 | 116 | | |||
118 | }; | 117 | }; |