| 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 QQUICKTOOLTIP_P_H |
| 5 | #define QQUICKTOOLTIP_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/qquickpopup_p.h> |
| 19 | |
| 20 | QT_BEGIN_NAMESPACE |
| 21 | |
| 22 | class QQuickToolTipPrivate; |
| 23 | class QQuickToolTipAttached; |
| 24 | class QQuickToolTipAttachedPrivate; |
| 25 | |
| 26 | class Q_QUICKTEMPLATES2_EXPORT QQuickToolTip : public QQuickPopup |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | Q_PROPERTY(int delay READ delay WRITE setDelay NOTIFY delayChanged FINAL) |
| 30 | Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL) |
| 31 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) |
| 32 | QML_NAMED_ELEMENT(ToolTip) |
| 33 | QML_ATTACHED(QQuickToolTipAttached) |
| 34 | QML_ADDED_IN_VERSION(2, 0) |
| 35 | |
| 36 | public: |
| 37 | explicit QQuickToolTip(QQuickItem *parent = nullptr); |
| 38 | |
| 39 | QString text() const; |
| 40 | void setText(const QString &text); |
| 41 | |
| 42 | int delay() const; |
| 43 | void setDelay(int delay); |
| 44 | |
| 45 | int timeout() const; |
| 46 | void setTimeout(int timeout); |
| 47 | |
| 48 | void setVisible(bool visible) override; |
| 49 | |
| 50 | static QQuickToolTipAttached *qmlAttachedProperties(QObject *object); |
| 51 | |
| 52 | Q_SIGNALS: |
| 53 | void textChanged(); |
| 54 | void delayChanged(); |
| 55 | void timeoutChanged(); |
| 56 | |
| 57 | public Q_SLOTS: |
| 58 | Q_REVISION(2, 5) void show(const QString &text, int ms = -1); |
| 59 | Q_REVISION(2, 5) void hide(); |
| 60 | |
| 61 | protected: |
| 62 | QFont defaultFont() const override; |
| 63 | |
| 64 | void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override; |
| 65 | void timerEvent(QTimerEvent *event) override; |
| 66 | |
| 67 | #if QT_CONFIG(accessibility) |
| 68 | QAccessible::Role accessibleRole() const override; |
| 69 | void accessibilityActiveChanged(bool active) override; |
| 70 | #endif |
| 71 | |
| 72 | private: |
| 73 | Q_DISABLE_COPY(QQuickToolTip) |
| 74 | Q_DECLARE_PRIVATE(QQuickToolTip) |
| 75 | }; |
| 76 | |
| 77 | class Q_QUICKTEMPLATES2_EXPORT QQuickToolTipAttached : public QObject |
| 78 | { |
| 79 | Q_OBJECT |
| 80 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL) |
| 81 | Q_PROPERTY(int delay READ delay WRITE setDelay NOTIFY delayChanged FINAL) |
| 82 | Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL) |
| 83 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) |
| 84 | Q_PROPERTY(QQuickToolTip *toolTip READ toolTip CONSTANT FINAL) |
| 85 | |
| 86 | public: |
| 87 | explicit QQuickToolTipAttached(QObject *parent = nullptr); |
| 88 | |
| 89 | QString text() const; |
| 90 | void setText(const QString &text); |
| 91 | |
| 92 | int delay() const; |
| 93 | void setDelay(int delay); |
| 94 | |
| 95 | int timeout() const; |
| 96 | void setTimeout(int timeout); |
| 97 | |
| 98 | bool isVisible() const; |
| 99 | void setVisible(bool visible); |
| 100 | |
| 101 | QQuickToolTip *toolTip() const; |
| 102 | |
| 103 | Q_SIGNALS: |
| 104 | void textChanged(); |
| 105 | void delayChanged(); |
| 106 | void timeoutChanged(); |
| 107 | void visibleChanged(); |
| 108 | |
| 109 | public Q_SLOTS: |
| 110 | void show(const QString &text, int ms = -1); |
| 111 | void hide(); |
| 112 | |
| 113 | private: |
| 114 | Q_DISABLE_COPY(QQuickToolTipAttached) |
| 115 | Q_DECLARE_PRIVATE(QQuickToolTipAttached) |
| 116 | }; |
| 117 | |
| 118 | QT_END_NAMESPACE |
| 119 | |
| 120 | #endif // QQUICKTOOLTIP_P_H |
| 121 | |