Commit 41b007fa authored by Volker Krause's avatar Volker Krause

Turn ApplicationController into a QML singleton

parent 2c6879f3
......@@ -81,7 +81,7 @@ Kirigami.ScrollablePage {
text: i18n("Delete")
icon.name: "edit-delete"
onClicked: {
_appController.removeDocument(controller.batchId, deleteWarningSheet.docId);
ApplicationController.removeDocument(controller.batchId, deleteWarningSheet.docId);
deleteWarningSheet.sheetOpen = false;
}
}
......@@ -93,7 +93,7 @@ Kirigami.ScrollablePage {
Kirigami.Action {
iconName: "list-add"
text: i18n("Add Document...")
onTriggered: _appController.addDocument(controller.batchId)
onTriggered: ApplicationController.addDocument(controller.batchId)
}
]
}
......
......@@ -214,6 +214,10 @@ int main(int argc, char **argv)
qmlRegisterSingletonType("org.kde.itinerary", 1, 0, "PublicTransport", [](QQmlEngine*, QJSEngine *engine) -> QJSValue {
return engine->toScriptValue(PublicTransport());
});
qmlRegisterSingletonType<DocumentManager>("org.kde.itinerary", 1, 0, "ApplicationController", [](QQmlEngine *engine, QJSEngine*) -> QObject* {
engine->setObjectOwnership(ApplicationController::instance(), QQmlEngine::CppOwnership);
return ApplicationController::instance();
});
qmlRegisterSingletonType("org.kde.itinerary", 1, 0, "NavigationController", [](QQmlEngine*, QJSEngine *engine) -> QJSValue {
return engine->toScriptValue(NavigationController());
});
......@@ -228,7 +232,6 @@ int main(int argc, char **argv)
engine.rootContext()->setContextProperty(QStringLiteral("_pkpassManager"), &passMgr);
engine.rootContext()->setContextProperty(QStringLiteral("_reservationManager"), &resMgr);
engine.rootContext()->setContextProperty(QStringLiteral("_timelineModel"), &tripGroupProxy);
engine.rootContext()->setContextProperty(QStringLiteral("_appController"), &appController);
engine.rootContext()->setContextProperty(QStringLiteral("_settings"), &settings);
engine.rootContext()->setContextProperty(QStringLiteral("_weatherForecastManager"), &weatherForecastMgr);
engine.rootContext()->setContextProperty(QStringLiteral("_brightnessManager"), &brightnessManager);
......
......@@ -19,6 +19,7 @@ import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.1 as QQC2
import org.kde.kirigami 2.0 as Kirigami
import org.kde.itinerary 1.0
import "." as App
Kirigami.ApplicationWindow {
......@@ -35,18 +36,18 @@ Kirigami.ApplicationWindow {
Kirigami.Action {
text: i18n("Import...")
iconName: "document-open"
onTriggered: _appController.showImportFileDialog();
onTriggered: ApplicationController.showImportFileDialog();
},
Kirigami.Action {
text: i18n("Paste")
iconName: "edit-paste"
onTriggered: _appController.importFromClipboard()
enabled: _appController.hasClipboardContent
onTriggered: ApplicationController.importFromClipboard()
enabled: ApplicationController.hasClipboardContent
},
Kirigami.Action {
text: i18n("Check Calendar")
iconName: "view-calendar-day"
onTriggered: _appController.checkCalendar()
onTriggered: ApplicationController.checkCalendar()
visible: Qt.platform.os == "android"
},
Kirigami.Action {
......@@ -65,7 +66,7 @@ Kirigami.ApplicationWindow {
Kirigami.Action {
text: i18n("Export...")
iconName: "export-symbolic"
onTriggered: _appController.exportData();
onTriggered: ApplicationController.exportData();
},
Kirigami.Action {
id: aboutAction
......
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