File: actioninterface.h

package info (click to toggle)
plasma-workspace 4%3A6.3.6-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 104,900 kB
  • sloc: cpp: 125,434; xml: 31,579; python: 3,976; perl: 572; sh: 234; javascript: 74; ruby: 39; ansic: 13; makefile: 9
file content (78 lines) | stat: -rw-r--r-- 1,657 bytes parent folder | download | duplicates (2)
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)