| 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 | |
| 4 | #ifndef QQUICKACTION_P_H |
| 5 | #define QQUICKACTION_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> |
| 19 | #include <QtQuickTemplates2/private/qquickicon_p.h> |
| 20 | #include <QtCore/qobject.h> |
| 21 | #include <QtQml/qqml.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QQuickIcon; |
| 26 | class QQuickActionPrivate; |
| 27 | |
| 28 | class Q_QUICKTEMPLATES2_EXPORT QQuickAction : public QObject |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) |
| 32 | Q_PROPERTY(QQuickIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL) |
| 33 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged RESET resetEnabled FINAL) |
| 34 | Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) |
| 35 | Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL) |
| 36 | #if QT_CONFIG(shortcut) |
| 37 | Q_PRIVATE_PROPERTY(QQuickAction::d_func(), QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged FINAL) |
| 38 | #endif |
| 39 | QML_NAMED_ELEMENT(Action) |
| 40 | QML_ADDED_IN_VERSION(2, 3) |
| 41 | |
| 42 | public: |
| 43 | explicit QQuickAction(QObject *parent = nullptr); |
| 44 | ~QQuickAction(); |
| 45 | |
| 46 | QString text() const; |
| 47 | void setText(const QString &text); |
| 48 | |
| 49 | QQuickIcon icon() const; |
| 50 | void setIcon(const QQuickIcon &icon); |
| 51 | |
| 52 | bool isEnabled() const; |
| 53 | void setEnabled(bool enabled); |
| 54 | void resetEnabled(); |
| 55 | |
| 56 | bool isChecked() const; |
| 57 | void setChecked(bool checked); |
| 58 | |
| 59 | bool isCheckable() const; |
| 60 | void setCheckable(bool checkable); |
| 61 | |
| 62 | #if QT_CONFIG(shortcut) |
| 63 | QKeySequence shortcut() const; |
| 64 | void setShortcut(const QKeySequence &shortcut); |
| 65 | #endif |
| 66 | |
| 67 | public Q_SLOTS: |
| 68 | void toggle(QObject *source = nullptr); |
| 69 | void trigger(QObject *source = nullptr); |
| 70 | |
| 71 | Q_SIGNALS: |
| 72 | void textChanged(const QString &text); |
| 73 | void iconChanged(const QQuickIcon &icon); |
| 74 | void enabledChanged(bool enabled); |
| 75 | void checkedChanged(bool checked); |
| 76 | void checkableChanged(bool checkable); |
| 77 | #if QT_CONFIG(shortcut) |
| 78 | void shortcutChanged(const QKeySequence &shortcut); |
| 79 | #endif |
| 80 | |
| 81 | void toggled(QObject *source = nullptr); |
| 82 | void triggered(QObject *source = nullptr); |
| 83 | |
| 84 | protected: |
| 85 | bool event(QEvent *event) override; |
| 86 | bool eventFilter(QObject *object, QEvent *event) override; |
| 87 | |
| 88 | private: |
| 89 | Q_DISABLE_COPY(QQuickAction) |
| 90 | Q_DECLARE_PRIVATE(QQuickAction) |
| 91 | }; |
| 92 | |
| 93 | QT_END_NAMESPACE |
| 94 | |
| 95 | #endif // QQUICKACTION_P_H |
| 96 | |