mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e0a25289db
commit
315a245868
3 changed files with 15 additions and 1 deletions
|
@ -15,6 +15,10 @@
|
||||||
|
|
||||||
#include "qt-gui.h"
|
#include "qt-gui.h"
|
||||||
|
|
||||||
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
#include "qt-mobile/qmlmanager.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static MainWindow *window = NULL;
|
static MainWindow *window = NULL;
|
||||||
|
|
||||||
void init_ui()
|
void init_ui()
|
||||||
|
@ -32,6 +36,7 @@ void run_ui()
|
||||||
{
|
{
|
||||||
#ifdef SUBSURFACE_MOBILE
|
#ifdef SUBSURFACE_MOBILE
|
||||||
window->hide();
|
window->hide();
|
||||||
|
qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
||||||
QObject *mainWindow = engine.rootObjects().value(0);
|
QObject *mainWindow = engine.rootObjects().value(0);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import QtQuick 2.3
|
||||||
import QtQuick.Controls 1.2
|
import QtQuick.Controls 1.2
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
import QtQuick.Dialogs 1.2
|
import QtQuick.Dialogs 1.2
|
||||||
|
import org.subsurfacedivelog.mobile 1.0
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
title: qsTr("Subsurface")
|
title: qsTr("Subsurface")
|
||||||
|
@ -12,6 +13,14 @@ ApplicationWindow {
|
||||||
id: fileOpen
|
id: fileOpen
|
||||||
selectExisting: true
|
selectExisting: true
|
||||||
selectMultiple: true
|
selectMultiple: true
|
||||||
|
|
||||||
|
onAccepted: {
|
||||||
|
manager.setFilename(fileUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMLManager {
|
||||||
|
id: manager
|
||||||
}
|
}
|
||||||
|
|
||||||
menuBar: MenuBar {
|
menuBar: MenuBar {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "qmlmanager.h"
|
#include "qmlmanager.h"
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
QMLManager::QMLManager()
|
QMLManager::QMLManager()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue