From 7c92c7dc0ae658c088b8df83fcf97c3d3a8d8a16 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 28 Jul 2017 21:19:00 -0700 Subject: [PATCH] Map: try to wait for Map to load Signed-off-by: Dirk Hohndel --- desktop-widgets/mapwidget.cpp | 14 ++++++++++++-- desktop-widgets/mapwidget.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp index adda11c26..34f7ed217 100644 --- a/desktop-widgets/mapwidget.cpp +++ b/desktop-widgets/mapwidget.cpp @@ -22,15 +22,25 @@ MapWidget::MapWidget(QWidget *parent) : QQuickWidget(parent) qmlRegisterType("org.subsurfacedivelog.mobile", 1, 0, "MapLocationModel"); qmlRegisterType("org.subsurfacedivelog.mobile", 1, 0, "MapLocation"); + connect(this, &QQuickWidget::statusChanged, this, &MapWidget::doneLoading); setSource(QUrl(QStringLiteral("qrc:/MapWidget.qml"))); +} + +void MapWidget::doneLoading(QQuickWidget::Status status) +{ + if (status != QQuickWidget::Ready) { + qDebug() << "MapWidget status" << status; + return; + } + qDebug() << "MapWidget ready"; setResizeMode(QQuickWidget::SizeRootObjectToView); m_rootItem = qobject_cast(rootObject()); m_mapHelper = rootObject()->findChild(); connect(m_mapHelper, SIGNAL(selectedDivesChanged(QList)), - this, SLOT(selectedDivesChanged(QList))); + this, SLOT(selectedDivesChanged(QList))); connect(m_mapHelper, SIGNAL(coordinatesChanged()), - this, SLOT(coordinatesChangedLocal())); + this, SLOT(coordinatesChangedLocal())); } void MapWidget::centerOnDiveSite(struct dive_site *ds) diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h index d104da1a3..bb861d301 100644 --- a/desktop-widgets/mapwidget.h +++ b/desktop-widgets/mapwidget.h @@ -34,6 +34,7 @@ public slots: void prepareForGetDiveCoordinates(); void selectedDivesChanged(QList); void coordinatesChangedLocal(); + void doneLoading(QQuickWidget::Status status); private: void setEditMode(bool editMode);