diff options
Diffstat (limited to 'mobile-widgets/qmlmanager.cpp')
| -rw-r--r-- | mobile-widgets/qmlmanager.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index a40eb7f6c..fddc61d3a 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -128,7 +128,12 @@ static void showProgress(QString msg) // show the git progress in the passive notification area extern "C" int gitProgressCB(const char *text) { - showProgress(QString(text)); + // regular users, during regular operation, likely really don't + // care at all about the git progress + if (verbose) { + showProgress(QString(text)); + appendTextToLogStandalone(text); + } // return 0 so that we don't end the download return 0; } @@ -328,6 +333,9 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false), // we start out with clean data updateHaveLocalChanges(false); + + // setup Command infrastructure + Command::init(); } void QMLManager::applicationStateChanged(Qt::ApplicationState state) @@ -1324,7 +1332,7 @@ void QMLManager::addDiveToTrip(int id, int tripId) changesNeedSaving(); } -void QMLManager::changesNeedSaving() +void QMLManager::changesNeedSaving(bool fromUndo) { // we no longer save right away on iOS because file access is so slow; on the other hand, // on Android the save as the user switches away doesn't seem to work... drat. @@ -1335,9 +1343,9 @@ void QMLManager::changesNeedSaving() mark_divelist_changed(true); emit syncStateChanged(); #if defined(Q_OS_IOS) - saveChangesLocal(); + saveChangesLocal(fromUndo); #else - saveChangesCloud(false); + saveChangesCloud(false, fromUndo); #endif updateAllGlobalLists(); } @@ -1368,7 +1376,7 @@ void QMLManager::openNoCloudRepo() openLocalThenRemote(filename); } -void QMLManager::saveChangesLocal() +void QMLManager::saveChangesLocal(bool fromUndo) { if (unsavedChanges()) { if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NOCLOUD) { @@ -1398,12 +1406,21 @@ void QMLManager::saveChangesLocal() mark_divelist_changed(false); Command::setClean(); updateHaveLocalChanges(true); + // provide a useful undo/redo notification + // NOTE: the QML UI interprets a leading '[action]' (where only the two brackets are checked for) + // as an indication to use the text between those two brackets as the label of a button that + // can be used to open the context menu + QString msgFormat = tr("[%1]Changes saved:'%2'.\n%1 possible via context menu"); + if (fromUndo) + setNotificationText(msgFormat.arg(tr("Redo")).arg(tr("Undo: %1").arg(getRedoText()))); + else + setNotificationText(msgFormat.arg(tr("Undo")).arg(getUndoText())); } else { appendTextToLog("local save requested with no unsaved changes"); } } -void QMLManager::saveChangesCloud(bool forceRemoteSync) +void QMLManager::saveChangesCloud(bool forceRemoteSync, bool fromUndo) { if (!unsavedChanges() && !forceRemoteSync) { appendTextToLog("asked to save changes but no unsaved changes"); @@ -1411,7 +1428,7 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync) } // first we need to store any unsaved changes to the local repo gitProgressCB("Save changes to local cache"); - saveChangesLocal(); + saveChangesLocal(fromUndo); // if the user asked not to push to the cloud we are done if (git_local_only && !forceRemoteSync) return; @@ -1431,7 +1448,7 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync) void QMLManager::undo() { Command::getUndoStack()->undo(); - changesNeedSaving(); + changesNeedSaving(true); } void QMLManager::redo() |