1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/*
* SPDX-FileCopyrightText: 2024 Bohdan Onofriichuk <bogdan.onofriuchuk@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
/**
* Interface to add custom actions for devices
*/
class ActionInterface : public QObject
{
Q_OBJECT
public:
explicit ActionInterface(const QString &udi, QObject *parent = nullptr);
~ActionInterface() override;
/**
* Must return name of predicate which will be triggered in solid/actions/
* Can be not overridden if triggered is overridden
*/
virtual QString predicate() const;
/**
* Method which starts when action is triggered
* If not overridden then default implementation will start that triggers
* predicate() in solid/actions/
*/
virtual void triggered();
/**
* Name of action
*/
virtual QString name() const = 0;
/**
* Icon of action
*/
virtual QString icon() const = 0;
/**
* Text that describes action
*/
virtual QString text() const = 0;
/**
* Check if the action is valid. If not then action will be ignored
*/
virtual bool isValid() const;
Q_SIGNALS:
/**
* Emitted when text is changed
*/
void textChanged(const QString &text);
/**
* Emitted when icon is changed
*/
void iconChanged(const QString &icon);
/**
* Emitted when valid of action is changed
*/
void isValidChanged(const QString &name, bool status);
protected:
QString m_udi;
};
#define ActionInterface_iid "com.plasma.private.ActionInterface"
Q_DECLARE_INTERFACE(ActionInterface, ActionInterface_iid)
|