Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
tooltipattached.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include <QtCore/qobject.h>
7#include <QtCore/qpointer.h>
8#include <QtCore/qstring.h>
9#include <QtQml/qqmlregistration.h>
10
11QT_FORWARD_DECLARE_CLASS(QQuickItem)
12
13namespace Fluid {
14
15class PlainToolTipManager;
16
17class PlainToolTipAttached : public QObject
18{
19 Q_OBJECT
20
21 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
22 Q_PROPERTY(int delay READ delay WRITE setDelay NOTIFY delayChanged FINAL)
23 Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL)
24 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
25 Q_PROPERTY(QObject *toolTip READ toolTip CONSTANT FINAL)
26
27public:
28 explicit PlainToolTipAttached(QObject *parent = nullptr);
29 ~PlainToolTipAttached() override;
30
31 QString text() const;
32 void setText(const QString &text);
33
34 int delay() const;
35 void setDelay(int delay);
36
37 int timeout() const;
38 void setTimeout(int timeout);
39
40 bool isVisible() const;
41 void setVisible(bool visible);
42
43 QObject *toolTip() const;
44
45 Q_INVOKABLE void show(const QString &text, int timeout = -1);
46 Q_INVOKABLE void hide();
47
48Q_SIGNALS:
53
54private:
55 friend class PlainToolTipManager;
56
57 PlainToolTipManager *manager(bool create) const;
58 QQuickItem *target() const;
59 void notifyVisibleChanged();
60
61 QString m_text;
62 int m_delay = 0;
63 int m_timeout = -1;
64};
65
83class AttachedToolTip : public QObject
84{
85 Q_OBJECT
86 QML_NAMED_ELEMENT(ToolTip)
87 QML_UNCREATABLE("ToolTip is only available as an attached property")
88 QML_ATTACHED(PlainToolTipAttached)
89
90public:
91 explicit AttachedToolTip(QObject *parent = nullptr);
92
93 static PlainToolTipAttached *qmlAttachedProperties(QObject *object);
94};
95
96} // namespace Fluid
97
98QML_DECLARE_TYPEINFO(Fluid::AttachedToolTip, QML_HAS_ATTACHED_PROPERTIES)
Provides the Material plain-tooltip attached API.
void setText(const QString &text)
Q_INVOKABLE void show(const QString &text, int timeout=-1)
Material Design 3 tokens for plain and rich tooltips.
Definition tooltip.h:29