68 _notMovingTimeout =
new QTimer(
this);
69 _notMovingTimeout->setSingleShot(
true);
70 _notMovingTimeout->setInterval(1000);
73 _notMovingTimeout, SLOT(start()));
75 connect(_notMovingTimeout, &QTimer::timeout,
81 if (obs == _observedItem)
85 for (
auto o = _observedItem; o; o = o->parentItem()) {
86 disconnect(o,
nullptr,
this,
nullptr);
92 startObserving(_observedItem);
98 return _notMovingTimeout->isActive();
105 void startObserving(QQuickItem* obs)
114 if (obs->parentItem()) {
115 startObserving(obs->parentItem());
119 QPointer<QQuickItem> _observedItem;
120 QTimer* _notMovingTimeout =
nullptr;
143 auto qqParent = qobject_cast<QQuickItem*>(parent);
180 if ((_index < 0) || (_index >= _tips.size()))
183 return _tips.at(_index);
192 _viewAreaObserver->setObservedItem(_visualArea);
219 settings.beginGroup(
"GettingStarted-DontShow");
220 if (settings.value(
tip->tipId()).toBool()) {
225 settings.setValue(
tip->tipId(),
true);
228 connect(_oneShotTip, &QObject::destroyed,
this, &GettingStartedTipsController::onOneShotDestroyed);
237 bool a = shouldShowScope();
238 if (a != _scopeActive) {
246void GettingStartedTipsController::currentTipUpdated()
258 if (_tips.contains(t)) {
259 qWarning() << Q_FUNC_INFO <<
"Duplicate tip" << t;
274 return a->nextTip() == b->tipId();
284 const bool removedActive = (
tip() == t);
285 if (!_tips.removeOne(t)) {
286 qWarning() << Q_FUNC_INFO <<
"tip not found";
290 _index = qMax(_index - 1, 0);
297void GettingStartedTipsController::onOneShotDestroyed()
299 if (_oneShotTip == sender()) {
310 return _scopeActive && !_tips.empty();
316 if (!_visualArea || !t) {
320 return _visualArea->mapFromItem(t, QPointF{0,0});
329 const auto arrow = t->
arrow();
333 return tg.arrow == arrow;
337 qWarning() << Q_FUNC_INFO <<
"Missing tip geometry" << arrow;
341 QRectF g = it->geometry;
347 g.setHeight(_activeTipHeight);
352 switch (it->verticalAlignment) {
353 case Qt::AlignBottom:
361 case Qt::AlignVCenter:
362 g.moveTop(_activeTipHeight * -0.5);
375 if (_positionObserver->hasRecentlyMoved() || _viewAreaObserver->hasRecentlyMoved()) {
382 return !_tips.empty();
387 return _activeTipHeight;
398 const auto arrow = t->
arrow();
423 disconnect(_oneShotTip,
nullptr,
this,
nullptr);
424 _oneShotTip =
nullptr;
432 settings.beginGroup(
"GettingStarted-DontShow");
433 settings.setValue(_scopeId,
true);
434 _scopeActive =
false;
450 _index = qBound(0,
index, _tips.size() - 1);
451 _positionObserver->setObservedItem(
tip());
463 _scopeActive = shouldShowScope();
471bool GettingStartedTipsController::shouldShowScope()
const
477 if (_scopeId.isEmpty())
481 settings.beginGroup(
"GettingStarted-DontShow");
482 return settings.value(_scopeId).toBool() ==
false;
486#include "GettingStartedTipsController.moc"
const double topHeightOffset
static std::initializer_list< TipGeometryByArrowLocation > static_tipGeometries
const double arrowSideOffset
const double halfBoxWidth
const double rightSideOffset
static QPointer< GettingStartedTipsController > static_activeController
The GettingStartedTipsController::ItemPositionObserver class.
void setObservedItem(QQuickItem *obs)
void itemPositionChanged()
ItemPositionObserver(QObject *pr)
bool hasRecentlyMoved() const
void tipGeometryChanged()
void indexChanged(int index)
GettingStartedTipsController(QObject *parent=nullptr)
void activeTipHeightChanged(int activeTipHeight)
~GettingStartedTipsController()
friend class GettingStartedTip
void showOneShotTip(GettingStartedTip *tip)
showOneShotTip - show a single tip on its own, if it has not previously been shown before.
QPointF tipPositionInVisualArea
void scopeIdChanged(QString scopeId)
void setScopeId(QString scopeId)
void tipPositionInVisualAreaChanged()
void setActiveTipHeight(int activeTipHeight)
void countChanged(int count)
void visualAreaChanged(QQuickItem *visualArea)
void setVisualArea(QQuickItem *visualArea)
static int arrowSideOffset()
TipGeometryByArrowLocation(GettingStartedTip::Arrow a, const QRectF &g, Qt::Alignment al)
GettingStartedTip::Arrow arrow
Qt::Alignment verticalAlignment