From 2172e18298b96d02908690f20c5a126f7d72db3e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 30 Mar 2024 21:39:08 +0100 Subject: [PATCH] mobile: pull undo/redo notification text up When changes need saving, the notification text was set quite deep in the calltree in "saveChangesLocal()". I don't know why this was put so deep in the call tree. In any case, it prevents asynchronous saving of the data. Therefore, pull it up to chnagesNeedSaving(). Signed-off-by: Berthold Stoeger --- mobile-widgets/qmlmanager.cpp | 29 +++++++++++++++-------------- mobile-widgets/qmlmanager.h | 4 ++-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 0ec2f2112..bd62cbd26 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1452,11 +1452,21 @@ void QMLManager::changesNeedSaving(bool fromUndo) mark_divelist_changed(true); emit syncStateChanged(); #if defined(Q_OS_IOS) - saveChangesLocal(fromUndo); + saveChangesLocal(); #else - saveChangesCloud(false, fromUndo); + saveChangesCloud(false); #endif updateAllGlobalLists(); + + // 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())); } void QMLManager::openNoCloudRepo() @@ -1482,7 +1492,7 @@ void QMLManager::openNoCloudRepo() openLocalThenRemote(filename); } -void QMLManager::saveChangesLocal(bool fromUndo) +void QMLManager::saveChangesLocal() { if (unsavedChanges()) { if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NOCLOUD) { @@ -1512,21 +1522,12 @@ void QMLManager::saveChangesLocal(bool fromUndo) 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, bool fromUndo) +void QMLManager::saveChangesCloud(bool forceRemoteSync) { if (!unsavedChanges() && !forceRemoteSync) { appendTextToLog("asked to save changes but no unsaved changes"); @@ -1534,7 +1535,7 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync, bool fromUndo) } // first we need to store any unsaved changes to the local repo gitProgressCB("Save changes to local cache"); - saveChangesLocal(fromUndo); + saveChangesLocal(); // if the user asked not to push to the cloud we are done if (git_local_only && !forceRemoteSync) return; diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 89e072670..7f3b75137 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -179,7 +179,7 @@ public slots: void addDiveToTrip(int id, int tripId); void changesNeedSaving(bool fromUndo = false); void openNoCloudRepo(); - void saveChangesCloud(bool forceRemoteSync, bool fromUndo = false); + void saveChangesCloud(bool forceRemoteSync); void selectDive(int id); void deleteDive(int id); void deleteAccount(); @@ -262,7 +262,7 @@ private: void consumeFinishedLoad(); void mergeLocalRepo(); void openLocalThenRemote(QString url); - void saveChangesLocal(bool fromUndo = false); + void saveChangesLocal(); #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) QString appLogFileName;