From 315a245868683819031bdefc2e5c8f117b62028d Mon Sep 17 00:00:00 2001 From: Grace Karanja Date: Thu, 4 Jun 2015 13:36:36 +0300 Subject: Link QMLManager to the main.qml file Add a link between the C++ and QML parts of the app using the qmlRegisterType function. [Dirk Hohndel: changed the name to org.subsurfacedivelog.mobile] Signed-off-by: Grace Karanja Signed-off-by: Dirk Hohndel --- qt-gui.cpp | 5 +++++ qt-mobile/main.qml | 9 +++++++++ qt-mobile/qmlmanager.cpp | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/qt-gui.cpp b/qt-gui.cpp index 6bc2e1e30..ed893c12e 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -15,6 +15,10 @@ #include "qt-gui.h" +#ifdef SUBSURFACE_MOBILE + #include "qt-mobile/qmlmanager.h" +#endif + static MainWindow *window = NULL; void init_ui() @@ -32,6 +36,7 @@ void run_ui() { #ifdef SUBSURFACE_MOBILE window->hide(); + qmlRegisterType("org.subsurfacedivelog.mobile", 1, 0, "QMLManager"); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); QObject *mainWindow = engine.rootObjects().value(0); diff --git a/qt-mobile/main.qml b/qt-mobile/main.qml index a98fb14d6..c6ee4bb09 100644 --- a/qt-mobile/main.qml +++ b/qt-mobile/main.qml @@ -2,6 +2,7 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 +import org.subsurfacedivelog.mobile 1.0 ApplicationWindow { title: qsTr("Subsurface") @@ -12,6 +13,14 @@ ApplicationWindow { id: fileOpen selectExisting: true selectMultiple: true + + onAccepted: { + manager.setFilename(fileUrl) + } + } + + QMLManager { + id: manager } menuBar: MenuBar { diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index 2de94e82d..6a770b256 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -1,5 +1,5 @@ #include "qmlmanager.h" - +#include QMLManager::QMLManager() { -- cgit v1.2.3-70-g09d2