| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Quick Controls module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QQUICKACTION_H |
| 41 | #define QQUICKACTION_H |
| 42 | |
| 43 | #include <QtCore/qobject.h> |
| 44 | #include <QtCore/qurl.h> |
| 45 | #include <QtCore/qvariant.h> |
| 46 | #include <QtGui/qicon.h> |
| 47 | #include <QtGui/qkeysequence.h> |
| 48 | #include <QtCore/qpointer.h> |
| 49 | |
| 50 | QT_BEGIN_NAMESPACE |
| 51 | |
| 52 | class QQuickExclusiveGroup1; |
| 53 | |
| 54 | class QQuickAction1 : public QObject |
| 55 | { |
| 56 | Q_OBJECT |
| 57 | |
| 58 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged RESET resetText) |
| 59 | Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged RESET resetIconSource) |
| 60 | Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) |
| 61 | Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY iconChanged) |
| 62 | Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged RESET resetTooltip) |
| 63 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) |
| 64 | Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged) |
| 65 | Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled) |
| 66 | |
| 67 | Q_PROPERTY(QQuickExclusiveGroup1 *exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup NOTIFY exclusiveGroupChanged) |
| 68 | #ifndef QT_NO_SHORTCUT |
| 69 | Q_PROPERTY(QVariant shortcut READ shortcut WRITE setShortcut NOTIFY shortcutChanged) |
| 70 | #endif |
| 71 | |
| 72 | public: |
| 73 | explicit QQuickAction1(QObject *parent = 0); |
| 74 | ~QQuickAction1(); |
| 75 | |
| 76 | QString text() const { return m_text; } |
| 77 | void resetText() { setText(QString()); } |
| 78 | void setText(const QString &text); |
| 79 | |
| 80 | QVariant shortcut() const; |
| 81 | void setShortcut(const QVariant &shortcut); |
| 82 | |
| 83 | void setMnemonicFromText(const QString &mnemonic); |
| 84 | |
| 85 | QString iconName() const; |
| 86 | void setIconName(const QString &iconName); |
| 87 | |
| 88 | QUrl iconSource() const { return m_iconSource; } |
| 89 | void resetIconSource() { setIconSource(QString()); } |
| 90 | void setIconSource(const QUrl &iconSource); |
| 91 | |
| 92 | QString tooltip() const { return m_tooltip; } |
| 93 | void resetTooltip() { setTooltip(QString()); } |
| 94 | void setTooltip(const QString &tooltip); |
| 95 | |
| 96 | bool isEnabled() const { return m_enabled; } |
| 97 | void setEnabled(bool e); |
| 98 | |
| 99 | bool isCheckable() const { return m_checkable; } |
| 100 | void setCheckable(bool c); |
| 101 | |
| 102 | bool isChecked() const { return m_checkable && m_checked; } |
| 103 | void setChecked(bool c); |
| 104 | |
| 105 | QQuickExclusiveGroup1 *exclusiveGroup() const; |
| 106 | void setExclusiveGroup(QQuickExclusiveGroup1 *arg); |
| 107 | |
| 108 | QIcon icon() const { return m_icon; } |
| 109 | QVariant iconVariant() const { return QVariant(m_icon); } |
| 110 | void setIcon(const QIcon &icon) { m_icon = icon; emit iconChanged(); } |
| 111 | |
| 112 | bool event(QEvent *e) override; |
| 113 | |
| 114 | public Q_SLOTS: |
| 115 | void trigger(QObject *source = 0); |
| 116 | |
| 117 | Q_SIGNALS: |
| 118 | void triggered(QObject *source = 0); |
| 119 | void toggled(bool checked); |
| 120 | |
| 121 | void textChanged(); |
| 122 | void shortcutChanged(const QVariant &shortcut); |
| 123 | |
| 124 | void iconChanged(); |
| 125 | void iconNameChanged(); |
| 126 | void iconSourceChanged(); |
| 127 | void tooltipChanged(const QString &arg); |
| 128 | void enabledChanged(); |
| 129 | void checkableChanged(); |
| 130 | |
| 131 | void exclusiveGroupChanged(); |
| 132 | |
| 133 | private: |
| 134 | QString m_text; |
| 135 | QUrl m_iconSource; |
| 136 | QString m_iconName; |
| 137 | QIcon m_icon; |
| 138 | bool m_enabled; |
| 139 | bool m_checkable; |
| 140 | bool m_checked; |
| 141 | QPointer<QQuickExclusiveGroup1> m_exclusiveGroup; |
| 142 | QKeySequence m_shortcut; |
| 143 | QKeySequence m_mnemonic; |
| 144 | QString m_tooltip; |
| 145 | }; |
| 146 | |
| 147 | QT_END_NAMESPACE |
| 148 | |
| 149 | #endif // QQUICKACTION_H |
| 150 | |