Changeset View
Changeset View
Standalone View
Standalone View
kcms/kded/kcmkded.h
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project | ||
---|---|---|---|---|---|
2 | Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org> | 2 | Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org> | ||
3 | Copyright (C) 2020 Kai Uwe Broulik <kde@broulik.de> | ||||
3 | 4 | | |||
4 | This program is free software; you can redistribute it and/or | 5 | This program is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public | 6 | modify it under the terms of the GNU General Public | ||
6 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. | ||
8 | 9 | | |||
9 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | 13 | General Public License for more details. | ||
13 | 14 | | |||
14 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; see the file COPYING. If not, write to | 16 | along with this program; see the file COPYING. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 18 | Boston, MA 02110-1301, USA. | ||
18 | */ | 19 | */ | ||
19 | #ifndef KCMKDED_H | 20 | #ifndef KCMKDED_H | ||
20 | #define KCMKDED_H | 21 | #define KCMKDED_H | ||
21 | 22 | | |||
22 | #include <QLoggingCategory> | 23 | #include <KQuickAddons/ConfigModule> | ||
23 | 24 | | |||
24 | #include <KCModule> | 25 | class QDBusServiceWatcher; | ||
25 | 26 | | |||
26 | class QPushButton; | | |||
27 | class QTreeWidget; | | |||
28 | class QTreeWidgetItem; | | |||
29 | class KConfig; | 27 | class KConfig; | ||
30 | class KPluginMetaData; | 28 | class KPluginMetaData; | ||
31 | 29 | | |||
32 | Q_DECLARE_LOGGING_CATEGORY(KCM_KDED) | 30 | class ModulesModel; | ||
31 | class FilterProxyModel; | ||||
33 | 32 | | |||
34 | class KDEDConfig : public KCModule | 33 | class OrgKdeKded5Interface; | ||
34 | | ||||
35 | namespace org { | ||||
36 | namespace kde { | ||||
37 | using kded5 = ::OrgKdeKded5Interface; | ||||
38 | } | ||||
39 | } | ||||
40 | | ||||
41 | class KDEDConfig : public KQuickAddons::ConfigModule | ||||
35 | { | 42 | { | ||
36 | Q_OBJECT | 43 | Q_OBJECT | ||
44 | | ||||
45 | Q_PROPERTY(ModulesModel *model READ model CONSTANT) | ||||
46 | Q_PROPERTY(FilterProxyModel *filteredModel READ filteredModel CONSTANT) | ||||
47 | | ||||
48 | Q_PROPERTY(bool kdedRunning READ kdedRunning NOTIFY kdedRunningChanged) | ||||
49 | | ||||
37 | public: | 50 | public: | ||
38 | explicit KDEDConfig(QWidget* parent, const QVariantList& foo = QVariantList()); | 51 | explicit KDEDConfig(QObject* parent, const QVariantList& foo = QVariantList()); | ||
39 | ~KDEDConfig() override {} | 52 | ~KDEDConfig() override {} | ||
40 | 53 | | |||
54 | enum ModuleType { | ||||
55 | UnknownType = -1, | ||||
56 | AutostartType, | ||||
57 | OnDemandType | ||||
58 | }; | ||||
59 | Q_ENUM(ModuleType) | ||||
60 | | ||||
61 | enum ModuleStatus { | ||||
62 | UnknownStatus = -1, | ||||
63 | NotRunning, | ||||
64 | Running | ||||
65 | }; | ||||
66 | Q_ENUM(ModuleStatus) | ||||
67 | | ||||
68 | ModulesModel *model() const; | ||||
69 | FilterProxyModel *filteredModel() const; | ||||
70 | | ||||
71 | bool kdedRunning() const; | ||||
72 | | ||||
73 | Q_INVOKABLE void startModule(const QString &moduleName); | ||||
74 | Q_INVOKABLE void stopModule(const QString &moduleName); | ||||
75 | | ||||
41 | void load() override; | 76 | void load() override; | ||
42 | void save() override; | 77 | void save() override; | ||
43 | void defaults() override; | 78 | void defaults() override; | ||
44 | 79 | | |||
45 | protected Q_SLOTS: | 80 | signals: | ||
46 | void slotReload(); | 81 | void kdedRunningChanged(); | ||
47 | void slotStartService(); | | |||
48 | void slotStopService(); | | |||
49 | void slotServiceRunningToggled(); | | |||
50 | void slotStartupItemSelected(); | | |||
51 | void slotLodItemSelected(); | | |||
52 | void slotItemChecked(QTreeWidgetItem *item, int column); | | |||
53 | void getServiceStatus(); | | |||
54 | 82 | | |||
55 | bool autoloadEnabled(KConfig *config, const KPluginMetaData &filename); | 83 | void errorMessage(const QString &errorString); | ||
56 | void setAutoloadEnabled(KConfig *config, const KPluginMetaData &filename, bool b); | 84 | void showSelfDisablingModulesHint(); | ||
85 | void showRunningModulesChangedAfterSaveHint(); | ||||
57 | 86 | | |||
58 | private: | 87 | private: | ||
59 | QTreeWidget *_lvLoD; | 88 | void setKdedRunning(bool kdedRunning); | ||
60 | QTreeWidget *_lvStartup; | 89 | | ||
61 | QPushButton *_pbStart; | 90 | void getModuleStatus(); | ||
62 | QPushButton *_pbStop; | 91 | void startOrStopModule(const QString &moduleName, ModuleStatus status /*better than a bool*/); | ||
92 | | ||||
93 | ModulesModel *m_model; | ||||
94 | FilterProxyModel *m_filteredModel; | ||||
95 | | ||||
96 | org::kde::kded5 *m_kdedInterface; | ||||
97 | | ||||
98 | QDBusServiceWatcher *m_kdedWatcher; | ||||
99 | bool m_kdedRunning = false; | ||||
100 | | ||||
101 | QString m_lastStartedModule; | ||||
102 | QStringList m_runningModulesBeforeReconfigure; | ||||
63 | 103 | | |||
64 | QString RUNNING; | | |||
65 | QString NOT_RUNNING; | | |||
66 | }; | 104 | }; | ||
67 | 105 | | |||
68 | #endif // KCMKDED_H | 106 | #endif // KCMKDED_H | ||
69 | 107 | |