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
20QT_BEGIN_NAMESPACE
21
22class QQuickToolTipPrivate;
23class QQuickToolTipAttached;
24class QQuickToolTipAttachedPrivate;
25
26class Q_QUICKTEMPLATES2_PRIVATE_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
36public:
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
52Q_SIGNALS:
53 void textChanged();
54 void delayChanged();
55 void timeoutChanged();
56
57public Q_SLOTS:
58 Q_REVISION(2, 5) void show(const QString &text, int ms = -1);
59 Q_REVISION(2, 5) void hide();
60
61protected:
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
72private:
73 Q_DISABLE_COPY(QQuickToolTip)
74 Q_DECLARE_PRIVATE(QQuickToolTip)
75};
76
77class Q_QUICKTEMPLATES2_PRIVATE_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
86public:
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
103Q_SIGNALS:
104 void textChanged();
105 void delayChanged();
106 void timeoutChanged();
107 void visibleChanged();
108
109public Q_SLOTS:
110 void show(const QString &text, int ms = -1);
111 void hide();
112
113private:
114 Q_DISABLE_COPY(QQuickToolTipAttached)
115 Q_DECLARE_PRIVATE(QQuickToolTipAttached)
116};
117
118QT_END_NAMESPACE
119
120QML_DECLARE_TYPE(QQuickToolTip)
121
122#endif // QQUICKTOOLTIP_P_H
123

source code of qtdeclarative/src/quicktemplates/qquicktooltip_p.h