File indexing completed on 2024-05-12 17:07:11

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2002 Daniel Molkentin <molkentin@kde.org>
0004     SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 #pragma once
0009 
0010 #include <KQuickAddons/ConfigModule>
0011 
0012 class QDBusServiceWatcher;
0013 
0014 class KConfig;
0015 class KPluginMetaData;
0016 
0017 class ModulesModel;
0018 class FilterProxyModel;
0019 
0020 class OrgKdeKded5Interface;
0021 
0022 namespace org
0023 {
0024 namespace kde
0025 {
0026 using kded5 = ::OrgKdeKded5Interface;
0027 }
0028 }
0029 
0030 class KDEDConfig : public KQuickAddons::ConfigModule
0031 {
0032     Q_OBJECT
0033 
0034     Q_PROPERTY(ModulesModel *model READ model CONSTANT)
0035     Q_PROPERTY(FilterProxyModel *filteredModel READ filteredModel CONSTANT)
0036 
0037     Q_PROPERTY(bool kdedRunning READ kdedRunning NOTIFY kdedRunningChanged)
0038 
0039 public:
0040     explicit KDEDConfig(QObject *parent, const QVariantList &foo = QVariantList());
0041     ~KDEDConfig() override
0042     {
0043     }
0044 
0045     enum ModuleType {
0046         UnknownType = -1,
0047         AutostartType,
0048         OnDemandType,
0049     };
0050     Q_ENUM(ModuleType)
0051 
0052     enum ModuleStatus {
0053         UnknownStatus = -1,
0054         NotRunning,
0055         Running,
0056     };
0057     Q_ENUM(ModuleStatus)
0058 
0059     ModulesModel *model() const;
0060     FilterProxyModel *filteredModel() const;
0061 
0062     bool kdedRunning() const;
0063 
0064     Q_INVOKABLE void startModule(const QString &moduleName);
0065     Q_INVOKABLE void stopModule(const QString &moduleName);
0066 
0067     void load() override;
0068     void save() override;
0069     void defaults() override;
0070 
0071 Q_SIGNALS:
0072     void kdedRunningChanged();
0073 
0074     void errorMessage(const QString &errorString);
0075     void showSelfDisablingModulesHint();
0076     void showRunningModulesChangedAfterSaveHint();
0077 
0078 private:
0079     void setKdedRunning(bool kdedRunning);
0080 
0081     void getModuleStatus();
0082     void startOrStopModule(const QString &moduleName, ModuleStatus status /*better than a bool*/);
0083 
0084     ModulesModel *const m_model;
0085     FilterProxyModel *const m_filteredModel;
0086 
0087     org::kde::kded5 *const m_kdedInterface;
0088 
0089     QDBusServiceWatcher *const m_kdedWatcher;
0090     bool m_kdedRunning = false;
0091 
0092     QString m_lastStartedModule;
0093     QStringList m_runningModulesBeforeReconfigure;
0094 };