| 1 | // Copyright (C) 2020 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 | #ifndef QQUICKINDICATORBUTTON_H |
| 4 | #define QQUICKINDICATORBUTTON_H |
| 5 | |
| 6 | // |
| 7 | // W A R N I N G |
| 8 | // ------------- |
| 9 | // |
| 10 | // This file is not part of the Qt API. It exists purely as an |
| 11 | // implementation detail. This header file may change from version to |
| 12 | // version without notice, or even be removed. |
| 13 | // |
| 14 | // We mean it. |
| 15 | // |
| 16 | |
| 17 | #include <QtQuickTemplates2/private/qquickcontrol_p.h> |
| 18 | #include <QtQml/qjsvalue.h> |
| 19 | #include "qquickdeferredpointer_p_p.h" |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QQuickIndicatorButtonPrivate; |
| 24 | |
| 25 | class Q_QUICKTEMPLATES2_EXPORT QQuickIndicatorButton : public QObject |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) |
| 29 | Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) |
| 30 | // 2.1 (Qt 5.8) |
| 31 | Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION(2, 1)) |
| 32 | // 2.5 (Qt 5.12) |
| 33 | Q_PROPERTY(qreal implicitIndicatorWidth READ implicitIndicatorWidth NOTIFY implicitIndicatorWidthChanged FINAL REVISION(2, 5)) |
| 34 | Q_PROPERTY(qreal implicitIndicatorHeight READ implicitIndicatorHeight NOTIFY implicitIndicatorHeightChanged FINAL REVISION(2, 5)) |
| 35 | Q_CLASSINFO("DeferredPropertyNames" , "indicator" ) |
| 36 | QML_ANONYMOUS |
| 37 | QML_ADDED_IN_VERSION(2, 0) |
| 38 | |
| 39 | public: |
| 40 | explicit QQuickIndicatorButton(QObject *parent); |
| 41 | ~QQuickIndicatorButton() override; |
| 42 | |
| 43 | bool isPressed() const; |
| 44 | void setPressed(bool pressed); |
| 45 | |
| 46 | QQuickItem *indicator() const; |
| 47 | void setIndicator(QQuickItem *indicator); |
| 48 | |
| 49 | bool isHovered() const; |
| 50 | void setHovered(bool hovered); |
| 51 | |
| 52 | qreal implicitIndicatorWidth() const; |
| 53 | qreal implicitIndicatorHeight() const; |
| 54 | |
| 55 | Q_SIGNALS: |
| 56 | void pressedChanged(); |
| 57 | void indicatorChanged(); |
| 58 | // 2.1 (Qt 5.8) |
| 59 | Q_REVISION(2, 1) void hoveredChanged(); |
| 60 | // 2.5 (Qt 5.12) |
| 61 | Q_REVISION(2, 5) void implicitIndicatorWidthChanged(); |
| 62 | Q_REVISION(2, 5) void implicitIndicatorHeightChanged(); |
| 63 | |
| 64 | private: |
| 65 | Q_DISABLE_COPY(QQuickIndicatorButton) |
| 66 | Q_DECLARE_PRIVATE(QQuickIndicatorButton) |
| 67 | }; |
| 68 | |
| 69 | class QQuickIndicatorButtonPrivate : public QObjectPrivate |
| 70 | { |
| 71 | Q_DECLARE_PUBLIC(QQuickIndicatorButton) |
| 72 | |
| 73 | public: |
| 74 | static QQuickIndicatorButtonPrivate *get(QQuickIndicatorButton *button) |
| 75 | { |
| 76 | return button->d_func(); |
| 77 | } |
| 78 | |
| 79 | void cancelIndicator(); |
| 80 | void executeIndicator(bool complete = false); |
| 81 | |
| 82 | bool pressed = false; |
| 83 | bool hovered = false; |
| 84 | QQuickDeferredPointer<QQuickItem> indicator; |
| 85 | }; |
| 86 | |
| 87 | QT_END_NAMESPACE |
| 88 | |
| 89 | #endif // QQUICKINDICATORBUTTON_H |
| 90 | |