Changeset View
Changeset View
Standalone View
Standalone View
kcms/colors/colors.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #pragma once | ||||
22 | | ||||
23 | #include <KSharedConfig> | ||||
24 | | ||||
25 | #include <KNewStuff3/KNS3/DownloadDialog> | ||||
26 | | ||||
27 | #include <KQuickAddons/ConfigModule> | ||||
28 | | ||||
29 | class QStandardItemModel; | ||||
30 | | ||||
31 | class KCMColors : public KQuickAddons::ConfigModule | ||||
32 | { | ||||
33 | Q_OBJECT | ||||
34 | | ||||
35 | Q_PROPERTY(QStandardItemModel *colorsModel READ colorsModel CONSTANT) | ||||
36 | Q_PROPERTY(QString selectedScheme READ selectedScheme WRITE setSelectedScheme NOTIFY selectedSchemeChanged) | ||||
37 | Q_PROPERTY(int selectedSchemeIndex READ selectedSchemeIndex NOTIFY selectedSchemeIndexChanged) | ||||
38 | | ||||
39 | public: | ||||
40 | KCMColors(QObject *parent, const QVariantList &args); | ||||
41 | ~KCMColors() override; | ||||
42 | | ||||
43 | enum Roles { | ||||
44 | SchemeNameRole = Qt::UserRole + 1, | ||||
45 | PaletteRole, | ||||
46 | EditableRole, | ||||
47 | RemovableRole, | ||||
48 | PendingDeletionRole | ||||
49 | }; | ||||
50 | | ||||
51 | QStandardItemModel *colorsModel() const; | ||||
52 | | ||||
53 | QString selectedScheme() const; | ||||
54 | void setSelectedScheme(const QString &scheme); | ||||
55 | | ||||
56 | int selectedSchemeIndex() const; | ||||
57 | | ||||
58 | Q_INVOKABLE void getNewStuff(QQuickItem *ctx); | ||||
59 | Q_INVOKABLE void installSchemeFromFile(const QUrl &url); | ||||
60 | | ||||
61 | Q_INVOKABLE void setPendingDeletion(int index, bool pending); | ||||
62 | | ||||
63 | Q_INVOKABLE void editScheme(const QString &scheme); | ||||
64 | | ||||
65 | public Q_SLOTS: | ||||
66 | void load(); | ||||
67 | void save(); | ||||
68 | void defaults(); | ||||
69 | | ||||
70 | Q_SIGNALS: | ||||
71 | void selectedSchemeChanged(); | ||||
72 | void selectedSchemeIndexChanged(); | ||||
73 | | ||||
74 | void showSuccessMessage(const QString &message); | ||||
75 | void showErrorMessage(const QString &message); | ||||
76 | | ||||
77 | private: | ||||
78 | void loadModel(); | ||||
79 | | ||||
80 | void saveColors(); | ||||
81 | void processPendingDeletions(); | ||||
82 | | ||||
83 | QStandardItemModel *m_model; | ||||
84 | | ||||
85 | QString m_selectedScheme; | ||||
86 | // so we avoid launching changeicon process when theme didn't change (but only e.g. pending deletions) | ||||
87 | bool m_selectedSchemeDirty = false; | ||||
88 | | ||||
89 | bool m_applyToAlien; | ||||
90 | | ||||
91 | QPointer<KNS3::DownloadDialog> m_newStuffDialog; | ||||
92 | | ||||
93 | KSharedConfigPtr m_config; | ||||
94 | | ||||
95 | }; |