Libplasma

action.h
1/*
2 SPDX-FileCopyrightText: 2023 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef PLASMAACTION_H
8#define PLASMAACTION_H
9
10#include <QAction>
11#include <QActionGroup>
12#include <QObject>
13#include <qqml.h>
14#include <qtclasshelpermacros.h>
15#include <qtmetamacros.h>
16
17class QQuickItem;
18
19namespace PlasmaQuick
20{
21class SharedQmlEngine;
22}
23
24class ActionExtension;
25
26class IconGroup : public QObject
27{
29 QML_ANONYMOUS
30 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
31 Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged)
32public:
33 explicit IconGroup(ActionExtension *parent = nullptr);
34 ~IconGroup();
35
36 void setName(const QString &name);
37 QString name() const;
38
39 QIcon icon() const;
40 void setIcon(const QIcon &icon);
41
43 void nameChanged();
44 void iconChanged();
45
46private:
47 QAction *m_action;
48 QString m_name;
49};
50
51class ActionExtension : public QObject
52{
54 Q_PROPERTY(IconGroup *icon MEMBER m_iconGroup CONSTANT)
55 Q_PROPERTY(bool isSeparator READ isSeparator WRITE setSeparator NOTIFY isSeparatorChanged)
56 Q_PROPERTY(QActionGroup *actionGroup READ actionGroup WRITE setActionGroup NOTIFY actionGroupChanged)
57 Q_PROPERTY(QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged)
58 Q_PROPERTY(QMenu *menu READ menu WRITE setMenu NOTIFY menuChanged)
59
60public:
61 explicit ActionExtension(QObject *parent = nullptr);
62 ~ActionExtension() override;
63
64 bool isSeparator() const;
65 void setSeparator(bool setSeparator);
66
67 void setActionGroup(QActionGroup *group);
68 QActionGroup *actionGroup() const;
69
70 void setShortcut(const QVariant &var);
71 QVariant shortcut() const;
72
73 void setMenu(QMenu *menu);
74 QMenu *menu();
75
76 QAction *action() const;
77
79 void isSeparatorChanged();
80 void actionGroupChanged();
81 void shortcutChanged();
82 void menuChanged();
83
84private:
85 QAction *m_action;
86 IconGroup *m_iconGroup;
87 QString m_icon;
88};
89
90class ActionGroup : public QActionGroup
91{
93 QML_ELEMENT
94public:
95 ActionGroup(QObject *parent = nullptr)
97 {
98 }
99};
100
101#endif
An object that instantiates an entire QML context, with its own declarative engine.
The EdgeEventForwarder class This class forwards edge events to be replayed within the given margin T...
Definition action.h:20
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.