Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickaction_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKACTION_P_H
6#define QQUICKACTION_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
20#include <QtQuickTemplates2/private/qquickicon_p.h>
21#include <QtCore/qobject.h>
22#include <QtQml/qqml.h>
23
25
26class QQuickIcon;
28
29class Q_QUICKTEMPLATES2_EXPORT QQuickAction : public QObject
30{
31 Q_OBJECT
32 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
33 Q_PROPERTY(QQuickIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL)
34 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged RESET resetEnabled FINAL)
35 Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL)
36 Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
37#if QT_CONFIG(shortcut)
38 Q_PRIVATE_PROPERTY(QQuickAction::d_func(), QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged FINAL)
39#endif
40 QML_NAMED_ELEMENT(Action)
41 QML_ADDED_IN_VERSION(2, 3)
42
43public:
44 explicit QQuickAction(QObject *parent = nullptr);
45 ~QQuickAction();
46
47 QString text() const;
48 void setText(const QString &text);
49
50 QQuickIcon icon() const;
51 void setIcon(const QQuickIcon &icon);
52
53 bool isEnabled() const;
54 void setEnabled(bool enabled);
55 void resetEnabled();
56
57 bool isChecked() const;
58 void setChecked(bool checked);
59
60 bool isCheckable() const;
61 void setCheckable(bool checkable);
62
63#if QT_CONFIG(shortcut)
64 QKeySequence shortcut() const;
65 void setShortcut(const QKeySequence &shortcut);
66#endif
67
68public Q_SLOTS:
69 void toggle(QObject *source = nullptr);
70 void trigger(QObject *source = nullptr);
71
72Q_SIGNALS:
73 void textChanged(const QString &text);
74 void iconChanged(const QQuickIcon &icon);
75 void enabledChanged(bool enabled);
76 void checkedChanged(bool checked);
77 void checkableChanged(bool checkable);
78#if QT_CONFIG(shortcut)
79 void shortcutChanged(const QKeySequence &shortcut);
80#endif
81
82 void toggled(QObject *source = nullptr);
83 void triggered(QObject *source = nullptr);
84
85protected:
86 bool event(QEvent *event) override;
87 bool eventFilter(QObject *object, QEvent *event) override;
88
89private:
90 Q_DISABLE_COPY(QQuickAction)
91 Q_DECLARE_PRIVATE(QQuickAction)
92};
93
94QT_END_NAMESPACE
95
96#endif // QQUICKACTION_P_H
Groups actions together.
Mutually-exclusive group of checkable buttons.