From ecf44bb2faccf080215ccb2f660b36316169ec60 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 15 Apr 2016 14:42:08 -0700 Subject: [PATCH] QML UI: quit on back key while showing dive list Make sure you save first, though. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveList.qml | 5 +++++ mobile-widgets/qmlmanager.cpp | 7 +++++++ mobile-widgets/qmlmanager.h | 1 + 3 files changed, 13 insertions(+) diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index 906eb9445..a89b05c8b 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -278,5 +278,10 @@ Kirigami.ScrollablePage { manager.credentialStatus = oldStatus event.accepted = true; } + if (!startPageWrapper.visible) { + manager.quit() + // we shouldn't come back from there, but just in case + event.accepted = true + } } } diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 05490ab42..3c2f8d311 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1198,3 +1198,10 @@ void QMLManager::screenChanged(QScreen *screen) m_lastDevicePixelRatio = screen->devicePixelRatio(); emit sendScreenChanged(screen); } + +void QMLManager::quit() +{ + if (unsaved_changes()) + saveChangesCloud(false); + QApplication::quit(); +} diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index af81368f3..7d1fc4a6b 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -132,6 +132,7 @@ public slots: void screenChanged(QScreen *screen); qreal lastDevicePixelRatio(); void appendTextToLog(const QString &newText); + void quit(); private: QString m_cloudUserName;