summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-17 13:09:01 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-19 12:42:47 -0800
commite1cb36843742e3ad901c5eac8cdeb007f406ed66 (patch)
tree574871aa789bbce4c5d88e60686f0bc9fce7e1a1 /mobile-widgets
parentfa8ac5ceeb7cbd25f87467973f4e8bf74d3a6531 (diff)
downloadsubsurface-e1cb36843742e3ad901c5eac8cdeb007f406ed66.tar.gz
mobile/UI: show notification with changes made after save
Since we save after every operation in the mobile app, this allows us to tell the user what we actually saved - and we can remind the user that they can undo/redo the last operation. The code gets more complicated because in the case that the operation that triggered this change was an undo, we need to show the redo text to describe what we are saving, and must point the user to the redo operation. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp20
-rw-r--r--mobile-widgets/qmlmanager.h6
2 files changed, 16 insertions, 10 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 790be68a9..001edcb09 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1332,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.
@@ -1343,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();
}
@@ -1376,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) {
@@ -1406,12 +1406,18 @@ void QMLManager::saveChangesLocal()
mark_divelist_changed(false);
Command::setClean();
updateHaveLocalChanges(true);
+ // provide a useful undo/redo notification
+ QString msgFormat = tr("Changes saved:'%1'. %2 possible via context menu");
+ if (fromUndo)
+ setNotificationText(msgFormat.arg(tr("Undo: %1").arg(getRedoText())).arg(tr("Redo")));
+ else
+ setNotificationText(msgFormat.arg(getUndoText()).arg(tr("Undo")));
} 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");
@@ -1419,7 +1425,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;
@@ -1439,7 +1445,7 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync)
void QMLManager::undo()
{
Command::getUndoStack()->undo();
- changesNeedSaving();
+ changesNeedSaving(true);
}
void QMLManager::redo()
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 7a031a73a..9db2f991c 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -190,9 +190,9 @@ public slots:
void removeDiveFromTrip(int id);
void addTripForDive(int id);
void addDiveToTrip(int id, int tripId);
- void changesNeedSaving();
+ void changesNeedSaving(bool fromUndo = false);
void openNoCloudRepo();
- void saveChangesCloud(bool forceRemoteSync);
+ void saveChangesCloud(bool forceRemoteSync, bool fromUndo = false);
void selectDive(int id);
void deleteDive(int id);
void toggleDiveInvalid(int id);
@@ -283,7 +283,7 @@ private:
void consumeFinishedLoad();
void mergeLocalRepo();
void openLocalThenRemote(QString url);
- void saveChangesLocal();
+ void saveChangesLocal(bool fromUndo = false);
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
QString appLogFileName;