FlightGear next
GettingStartedTipsController.hxx
Go to the documentation of this file.
1#ifndef GETTINGSTARTEDTIPSCONTROLLER_HXX
2#define GETTINGSTARTEDTIPSCONTROLLER_HXX
3
4#include <QObject>
5#include <QVector>
6#include <QQuickItem>
7#include <QPointer>
8
9// forward decls
11
15class GettingStartedTipsController : public QObject
16{
17 Q_OBJECT
18
19 Q_PROPERTY(QString scopeId READ scopeId WRITE setScopeId NOTIFY scopeIdChanged)
20
21 Q_PROPERTY(GettingStartedTip* tip READ tip NOTIFY tipChanged)
22
23 Q_PROPERTY(int count READ count NOTIFY countChanged)
24 Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged)
25
26 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
27
30
31 Q_PROPERTY(QRectF tipGeometry READ tipGeometry NOTIFY tipGeometryChanged)
33 Q_PROPERTY(QRectF contentGeometry READ contentGeometry NOTIFY tipChanged)
34
35 Q_PROPERTY(QQuickItem* visualArea READ visualArea WRITE setVisualArea NOTIFY visualAreaChanged)
36
37public:
38 explicit GettingStartedTipsController(QObject *parent = nullptr);
40
41 int count() const;
42
43 int index() const;
44
45 GettingStartedTip* tip() const;
46
47 QString scopeId() const
48 {
49 return _scopeId;
50 }
51
52 bool isActive() const;
53
54 QPointF tipPositionInVisualArea() const;
55
56 QQuickItem* visualArea() const
57 {
58 return _visualArea;
59 }
60
61 QRectF tipGeometry() const;
62
63 bool tipPositionValid() const;
64
65 int activeTipHeight() const;
66
76 QRectF contentGeometry() const;
77
78public slots:
79
80 void close();
81
82 void setIndex(int index);
83
84 void setScopeId(QString scopeId);
85
86 void setVisualArea(QQuickItem* visualArea);
87
89
105
106 void tipsWereReset();
107signals:
108
112 void scopeChanged(QObject* scope);
113 void scopeIdChanged(QString scopeId);
116
118
119 void visualAreaChanged(QQuickItem* visualArea);
120
122
123private:
124 friend class GettingStartedTip;
125
126 bool shouldShowScope() const;
127
128 void currentTipUpdated();
129
130 bool addTip(GettingStartedTip* t);
131 void removeTip(GettingStartedTip* t);
132
133 void onOneShotDestroyed();
134private:
135
137
138 bool _scopeActive = false;
139 int _index = 0;
140 QString _scopeId;
141 ItemPositionObserver* _positionObserver = nullptr;
142 ItemPositionObserver* _viewAreaObserver = nullptr;
143
144 QPointer<GettingStartedTip> _oneShotTip;
145 QVector<GettingStartedTip*> _tips;
146 QQuickItem* _visualArea = nullptr;
147 int _activeTipHeight = 0;
148};
149
150#endif // GETTINGSTARTEDTIPSCONTROLLER_HXX
The GettingStartedTipsController::ItemPositionObserver class.
void scopeChanged(QObject *scope)
void indexChanged(int index)
GettingStartedTipsController(QObject *parent=nullptr)
void activeTipHeightChanged(int activeTipHeight)
void showOneShotTip(GettingStartedTip *tip)
showOneShotTip - show a single tip on its own, if it has not previously been shown before.
void scopeIdChanged(QString scopeId)
void countChanged(int count)
void visualAreaChanged(QQuickItem *visualArea)
void setVisualArea(QQuickItem *visualArea)