FlightGear next
GettingStartedTip.hxx
Go to the documentation of this file.
1#ifndef GETTINGSTARTEDTIP_HXX
2#define GETTINGSTARTEDTIP_HXX
3
4#include <QQuickItem>
5#include <QString>
6#include <QPointer>
7
9
10class GettingStartedTip : public QQuickItem
11{
12 Q_OBJECT
13
14 Q_PROPERTY(QString tipId MEMBER _id NOTIFY tipChanged)
15 Q_PROPERTY(QString text MEMBER _text NOTIFY tipChanged)
16 Q_PROPERTY(QString nextTip MEMBER _nextId NOTIFY tipChanged)
17
18 Q_PROPERTY(Arrow arrow MEMBER _arrow NOTIFY tipChanged)
19
20 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
21
23
26 Q_PROPERTY(bool standalone READ standalone WRITE setStandalone NOTIFY standaloneChanged)
27public:
28 enum class Arrow
29 {
30 TopCenter, // directly below the item, centered
37 LeftTop, // on the left side, at the top
39 };
40
41 Q_ENUM(Arrow)
42
43 explicit GettingStartedTip(QQuickItem *parent = nullptr);
44 ~GettingStartedTip() override;
45
46 QString tipId() const
47 {
48 return _id;
49 }
50
51 Arrow arrow() const
52 {
53 return _arrow;
54 }
55
56 bool isEnabled() const
57 {
58 return _enabled;
59 }
60
62
63 void componentComplete() override; // from QQmlParserStatus
64
65 bool standalone() const
66 {
67 return _standalone;
68 }
69
70 QString nextTip() const
71 {
72 return _nextId;
73 }
74
75 // allow disabling all tips progrmatically : this is a temporary
76 // measure to make life less annoying for our translators
77 static void setGlobalTipsEnabled(bool enable);
78public slots:
79 void setEnabled(bool enabled);
80
81 void showOneShot();
82 void setStandalone(bool standalone);
83
84signals:
85
86 void tipChanged();
89
91
92protected:
93 void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
94
95private:
96 void registerWithScope();
97 void unregisterFromScope();
98
99 GettingStartedTipsController* findController();
100
101 QString _id,
102 _text,
103 _nextId;
104
105 Arrow _arrow = Arrow::LeftCenter;
106 bool _enabled = true;
107 QPointer<GettingStartedTipsController> _controller;
108 bool _standalone = false;
109};
110
111#endif // GETTINGSTARTEDTIP_HXX
GettingStartedTipsController * controller
void standaloneChanged(bool standalone)
void setStandalone(bool standalone)
void componentComplete() override
QString nextTip() const
GettingStartedTip(QQuickItem *parent=nullptr)
void controllerChanged()
bool standalone
standalone tips are excluded from their scope when activated; instead they need to be activated manua...
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override
void setEnabled(bool enabled)
QString tipId() const
static void setGlobalTipsEnabled(bool enable)
Manage presentation of getting started tips on a screen/page.