diff --git a/src/QGCQmlWidgetHolder.cpp b/src/QGCQmlWidgetHolder.cpp index 5da881ce4b7891a57bc0eef367c52bf07ce3027c..844ac51328c963a011ef8c127ccd0a81d6c51327 100644 --- a/src/QGCQmlWidgetHolder.cpp +++ b/src/QGCQmlWidgetHolder.cpp @@ -25,7 +25,6 @@ /// @author Don Gagne #include "QGCQmlWidgetHolder.h" -#include "QGCMessageBox.h" QGCQmlWidgetHolder::QGCQmlWidgetHolder(QWidget *parent) : QWidget(parent) @@ -46,17 +45,5 @@ void QGCQmlWidgetHolder::setAutoPilot(AutoPilotPlugin* autoPilot) bool QGCQmlWidgetHolder::setSource(const QUrl& qmlUrl) { - _ui.qmlWidget->setSource(qmlUrl); - if (_ui.qmlWidget->status() != QQuickWidget::Ready) { - QString errorList; - - foreach (QQmlError error, _ui.qmlWidget->errors()) { - errorList += error.toString(); - errorList += "\n"; - } - QGCMessageBox::warning(tr("Qml Error"), tr("Source not ready: %1\nErrors:\n%2").arg(_ui.qmlWidget->status()).arg(errorList)); - return false; - } - - return true; + return _ui.qmlWidget->setSource(qmlUrl); } diff --git a/src/QGCQmlWidgetHolder.h b/src/QGCQmlWidgetHolder.h index 0cfb8a9996f17a4c685658bd3a388f6939c2ac1b..378e501994399ec0bc2953d2b95c0661bf075243 100644 --- a/src/QGCQmlWidgetHolder.h +++ b/src/QGCQmlWidgetHolder.h @@ -49,7 +49,8 @@ public: /// Sets the UAS into the widget which in turn will load facts into the context void setAutoPilot(AutoPilotPlugin* autoPilot); - /// Sets the QML into the control + /// Sets the QML into the control. Will display errors message box if error occurs loading source. + /// @return true: source loaded, false: source not loaded, errors occured bool setSource(const QUrl& qmlUrl); private: diff --git a/src/QGCQuickWidget.cc b/src/QGCQuickWidget.cc index f15b78530805880e08186b07bb33a9a1e517a9e4..14899edca663067c00271c3a927e2b2aaf6b263f 100644 --- a/src/QGCQuickWidget.cc +++ b/src/QGCQuickWidget.cc @@ -23,6 +23,7 @@ #include "QGCQuickWidget.h" #include "AutoPilotPluginManager.h" +#include "QGCMessageBox.h" #include #include @@ -43,3 +44,20 @@ void QGCQuickWidget::setAutoPilot(AutoPilotPlugin* autoPilot) { rootContext()->setContextProperty("autopilot", autoPilot); } + +bool QGCQuickWidget::setSource(const QUrl& qmlUrl) +{ + QQuickWidget::setSource(qmlUrl); + if (status() != Ready) { + QString errorList; + + foreach (QQmlError error, errors()) { + errorList += error.toString(); + errorList += "\n"; + } + QGCMessageBox::warning(tr("Qml Error"), tr("Source not ready: Status(%1)\nErrors:\n%2").arg(status()).arg(errorList)); + return false; + } + + return true; +} diff --git a/src/QGCQuickWidget.h b/src/QGCQuickWidget.h index 22a166ba5aa99e2d060ddf4d114c416efc815d2b..af0d7d90f76bb66b38b3e7ffa2ece34c0991250a 100644 --- a/src/QGCQuickWidget.h +++ b/src/QGCQuickWidget.h @@ -42,6 +42,10 @@ public: /// Sets the UAS into the widget which in turn will load facts into the context void setAutoPilot(AutoPilotPlugin* autoPilot); + + /// Sets the QML into the control. Will display errors message box if error occurs loading source. + /// @return true: source loaded, false: source not loaded, errors occured + bool setSource(const QUrl& qmlUrl); }; #endif