Commit ea722c48 authored by Don Gagne's avatar Don Gagne

Better error handling

parent 1cf50225
......@@ -25,6 +25,7 @@
/// @author Don Gagne <don@thegagnes.com>
#include "QGCQmlWidgetHolder.h"
#include "QGCMessageBox.h"
QGCQmlWidgetHolder::QGCQmlWidgetHolder(QWidget *parent) :
QWidget(parent)
......@@ -43,8 +44,19 @@ void QGCQmlWidgetHolder::setAutoPilot(AutoPilotPlugin* autoPilot)
_ui.qmlWidget->rootContext()->setContextProperty("autopilot", autoPilot);
}
void QGCQmlWidgetHolder::setSource(const QUrl& qmlUrl)
bool QGCQmlWidgetHolder::setSource(const QUrl& qmlUrl)
{
_ui.qmlWidget->setSource(qmlUrl);
_ui.qmlWidget->setMinimumSize(_ui.qmlWidget->rootObject()->width(), _ui.qmlWidget->rootObject()->height());
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;
}
......@@ -50,7 +50,7 @@ public:
void setAutoPilot(AutoPilotPlugin* autoPilot);
/// Sets the QML into the control
void setSource(const QUrl& qmlUrl);
bool setSource(const QUrl& qmlUrl);
private:
Ui::QGCQmlWidgetHolder _ui;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment