Sfoglia il codice sorgente

Fix session ending window not being fully localized and save session state on shutdown/signout if enabled

CPKreuz 1 anno fa
parent
commit
81bf41cbae

+ 15 - 9
src/PixiEditor/App.xaml.cs

@@ -1,11 +1,9 @@
 using System.IO;
 using System.Text.RegularExpressions;
 using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Interop;
 using System.Windows.Media;
-using System.Windows.Threading;
 using PixiEditor.Extensions.Common.Localization;
+using PixiEditor.Extensions.Common.UserPreferences;
 using PixiEditor.Helpers;
 using PixiEditor.Models.AppExtensions;
 using PixiEditor.Helpers.UI;
@@ -16,7 +14,6 @@ using PixiEditor.Models.Enums;
 using PixiEditor.Platform;
 using PixiEditor.Views;
 using PixiEditor.Views.Dialogs;
-using Timer = System.Timers.Timer;
 
 namespace PixiEditor;
 
@@ -213,14 +210,23 @@ internal partial class App : Application
         var vm = ViewModelMain.Current;
         if (vm is null)
             return;
+        
+        if (IPreferences.Current != null)
+        {
+            vm.AutosaveAllForNextSession();
+        }
 
-        if (vm.DocumentManagerSubViewModel.Documents.Any(x => !x.AllChangesSaved))
+        if (vm.DocumentManagerSubViewModel.Documents.All(x => x.AllChangesSaved || x.AllChangesAutosaved))
         {
-            ConfirmationType confirmation = ConfirmationDialog.Show(
-                new LocalizedString("SESSION_UNSAVED_DATA", e.ReasonSessionEnding),
-                $"{e.ReasonSessionEnding}");
-            e.Cancel = confirmation != ConfirmationType.Yes;
+            return;
         }
+
+        string reason = e.ReasonSessionEnding.ToString().ToUpperInvariant();
+        
+        var confirmation = ConfirmationDialog.Show(
+            new LocalizedString(reason),
+            new LocalizedString($"{reason}_TITLE"));
+        e.Cancel = confirmation != ConfirmationType.Yes;
     }
 
     private bool ParseArgument(string pattern, string args, out Group[] groups)

+ 6 - 2
src/PixiEditor/Data/Localization/Languages/en.json

@@ -476,7 +476,6 @@
   "SHORTCUT_ALREADY_ASSIGNED_OVERWRITE": "This shortcut is already assigned to '{0}'\nDo you want to replace the existing shortcut?",
   "UNSAVED_CHANGES": "Unsaved changes",
   "DOCUMENT_MODIFIED_SAVE": "The document has been modified. Do you want to save changes?",
-  "SESSION_UNSAVED_DATA": "{0} with unsaved data. Are you sure?",
   "PROJECT_MAINTAINERS": "Project Maintainers",
   "OTHER_AWESOME_CONTRIBUTORS": "And other awesome contributors",
   "HELP": "Help",
@@ -618,5 +617,10 @@
   
   "MINUTE_SINGULAR": "minute",
   "MINUTE_PLURAL": "minutes",
-  "MINUTE_UNIVERSAL": "minute(s)"
+  "MINUTE_UNIVERSAL": "minute(s)",
+  
+  "LOGOFF": "Sign out with unsaved data. Are you sure?",
+  "SHUTDOWN": "Shut down with unsaved data. Are you sure?",
+  "LOGOFF_TITLE": "Sign out?",
+  "SHUTDOWN_TITLE": "Shut down?"
 }