QmlMaterial 0.1.0
Loading...
Searching...
No Matches
tool_tip_popup.hpp
1#pragma once
2
3#include "qml_material/control/popup.hpp"
4
5namespace qml_material
6{
7class QML_MATERIAL_API ToolTipPopup : public Popup {
8 Q_OBJECT
9 QML_NAMED_ELEMENT(ToolTipPopupBase)
10 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged FINAL)
11 Q_PROPERTY(int delay READ delay WRITE setDelay NOTIFY delayChanged FINAL)
12 Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged FINAL)
13public:
14 explicit ToolTipPopup(QObject* parent = nullptr);
15 QString text() const { return m_text; }
16 void setText(const QString&);
17 int delay() const { return m_delay; }
18 void setDelay(int);
19 int timeout() const { return m_timeout; }
20 void setTimeout(int);
21 void open() override;
22 void close() override;
23 void dismissImmediately() override;
24 Q_INVOKABLE void show(const QString& text, int timeout = -1);
25 Q_INVOKABLE void hide();
26 Q_SIGNAL void textChanged();
27 Q_SIGNAL void delayChanged();
28 Q_SIGNAL void timeoutChanged();
29
30protected:
31 bool inheritsHoverEnabled() const override { return false; }
32
33private:
34 void startTimeout();
35 QString m_text;
36 int m_delay = 0;
37 int m_timeout = -1;
38 QTimer m_delayTimer, m_timeoutTimer;
39 QMetaObject::Connection m_windowVisibility;
40};
41} // namespace qml_material