Index: sources/gui/GuiGlobals.cpp =================================================================== diff -u -rd862dfcd402206e33b314c458e41c13b684a4565 -rf20fa155dca799c332189f8d3932e35b5c4ef84a --- sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision d862dfcd402206e33b314c458e41c13b684a4565) +++ sources/gui/GuiGlobals.cpp (.../GuiGlobals.cpp) (revision f20fa155dca799c332189f8d3932e35b5c4ef84a) @@ -206,7 +206,53 @@ _viewer->engine()->addImportPath("qrc:/plugins"); //DEBUG: qDebug() << _viewer->engine()->importPathList(); _viewer->setSource(QStringLiteral("qrc:/main.qml")); + + // if reload QML build arguement is set then set reloadable main.qml source + if ( gReloadQML) { + const QUrl mainQML(QUrl::fromLocalFile(QStringLiteral("%1/qml/main.qml").arg(QML_PATH))); + _viewer->setReloadSource(mainQML); + } + LOG_DEBUG("MainView started"); return true; } + + /*! + * \brief setReloadSource + * \param vUrl - local top level qml file to set as reloadble source + * \details Source code url used to reload the qml during developing without requiring an application restart + */ + void MainView::setReloadSource(QUrl vUrl) + { + _reloadSource = vUrl; + } + + /*! + * \brief reload + * \details Used to reload the qml during developing without requiring an application restart + */ + void MainView::reload() + { + engine()->clearComponentCache(); + setSource(_reloadSource.isEmpty() ? source() : _reloadSource); + qDebug() << "QML reloaded."; + } + + /*! + * \brief keyPressEvent + * \param vEvent - QKeyEvent user key input + * \details event handler for input key events + */ + void MainView::keyPressEvent(QKeyEvent *vEvent) + { + // Enable reloading of the QML files for quicker development + if ( gReloadQML ) { + if (vEvent->key() == Qt::Key_F5) + { + QMetaObject::invokeMethod(this, &MainView::reload, Qt::QueuedConnection); + } + } + + QQuickView::keyPressEvent(vEvent); + } }