1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
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 http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QQUICKTOOLTIP_P_H
38#define QQUICKTOOLTIP_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include <QtQuickTemplates2/private/qquickpopup_p.h>
52
53QT_BEGIN_NAMESPACE
54
55class QQuickToolTipPrivate;
56class QQuickToolTipAttached;
57class QQuickToolTipAttachedPrivate;
58
59class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickToolTip : public QQuickPopup
60{
61 Q_OBJECT
62 Q_PROPERTY(int delay READ delay WRITE setDelay NOTIFY delayChanged FINAL)
63 Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL)
64 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
65
66public:
67 explicit QQuickToolTip(QQuickItem *parent = nullptr);
68
69 QString text() const;
70 void setText(const QString &text);
71
72 int delay() const;
73 void setDelay(int delay);
74
75 int timeout() const;
76 void setTimeout(int timeout);
77
78 void setVisible(bool visible) override;
79
80 static QQuickToolTipAttached *qmlAttachedProperties(QObject *object);
81
82Q_SIGNALS:
83 void textChanged();
84 void delayChanged();
85 void timeoutChanged();
86
87public Q_SLOTS:
88 Q_REVISION(5) void show(const QString &text, int ms = -1);
89 Q_REVISION(5) void hide();
90
91protected:
92 QFont defaultFont() const override;
93 QPalette defaultPalette() const override;
94
95 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) override;
96 void timerEvent(QTimerEvent *event) override;
97
98#if QT_CONFIG(accessibility)
99 QAccessible::Role accessibleRole() const override;
100 void accessibilityActiveChanged(bool active) override;
101#endif
102
103private:
104 Q_DISABLE_COPY(QQuickToolTip)
105 Q_DECLARE_PRIVATE(QQuickToolTip)
106};
107
108class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickToolTipAttached : public QObject
109{
110 Q_OBJECT
111 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
112 Q_PROPERTY(int delay READ delay WRITE setDelay NOTIFY delayChanged FINAL)
113 Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL)
114 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
115 Q_PROPERTY(QQuickToolTip *toolTip READ toolTip CONSTANT FINAL)
116
117public:
118 explicit QQuickToolTipAttached(QObject *parent = nullptr);
119
120 QString text() const;
121 void setText(const QString &text);
122
123 int delay() const;
124 void setDelay(int delay);
125
126 int timeout() const;
127 void setTimeout(int timeout);
128
129 bool isVisible() const;
130 void setVisible(bool visible);
131
132 QQuickToolTip *toolTip() const;
133
134Q_SIGNALS:
135 void textChanged();
136 void delayChanged();
137 void timeoutChanged();
138 void visibleChanged();
139
140public Q_SLOTS:
141 void show(const QString &text, int ms = -1);
142 void hide();
143
144private:
145 Q_DISABLE_COPY(QQuickToolTipAttached)
146 Q_DECLARE_PRIVATE(QQuickToolTipAttached)
147};
148
149QT_END_NAMESPACE
150
151QML_DECLARE_TYPE(QQuickToolTip)
152QML_DECLARE_TYPEINFO(QQuickToolTip, QML_HAS_ATTACHED_PROPERTIES)
153
154#endif // QQUICKTOOLTIP_P_H
155

source code of qtquickcontrols2/src/quicktemplates2/qquicktooltip_p.h