File indexing completed on 2025-02-02 05:26:32

0001 /*
0002     SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #ifndef SERVICEOPERATIONSTATUS_P
0007 #define SERVICEOPERATIONSTATUS_P
0008 
0009 #include <QObject>
0010 #include <QPointer>
0011 
0012 #include "plasma5support/service.h"
0013 
0014 namespace Plasma5Support
0015 {
0016 class Service;
0017 }
0018 
0019 /**
0020  * @class ServiceOperationStatus
0021  * @short Monitors services
0022  */
0023 class ServiceOperationStatus : public QObject
0024 {
0025     Q_OBJECT
0026 
0027     /**
0028      * The service instance we want to monitor
0029      */
0030     Q_PROPERTY(Plasma5Support::Service *service READ service WRITE setService NOTIFY serviceChanged)
0031 
0032     /**
0033      * the service operation we want to monitor for enabled or disabled status
0034      */
0035     Q_PROPERTY(QString operation READ operation WRITE setOperation NOTIFY operationChanged)
0036 
0037     /**
0038      * true if the service operation is enabled
0039      */
0040     Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
0041 
0042 public:
0043     explicit ServiceOperationStatus(QObject *parent = nullptr);
0044     ~ServiceOperationStatus() override;
0045 
0046     void setService(Plasma5Support::Service *service);
0047     Plasma5Support::Service *service() const;
0048 
0049     void setOperation(const QString &operation);
0050     QString operation() const;
0051 
0052     void setEnabled(bool enabled);
0053     bool isEnabled() const;
0054 
0055 Q_SIGNALS:
0056     void serviceChanged();
0057     void operationChanged();
0058     void enabledChanged();
0059 
0060 private Q_SLOTS:
0061     void updateStatus();
0062 
0063 private:
0064     QPointer<Plasma5Support::Service> m_service;
0065     QString m_operation;
0066     bool m_enabled;
0067 };
0068 
0069 #endif