Browse Source

Open autosave folder

Krzysztof Krysiński 3 months ago
parent
commit
52a375423a

+ 2 - 2
src/PixiEditor.Windows/WindowsOperatingSystem.cs

@@ -37,7 +37,7 @@ public sealed class WindowsOperatingSystem : IOperatingSystem
     public void OpenFolder(string path)
     public void OpenFolder(string path)
     {
     {
         string dirName = Path.GetDirectoryName(path);
         string dirName = Path.GetDirectoryName(path);
-        string fileName = Path.GetFileName(path);
+        string fileName = !string.IsNullOrEmpty(Path.GetExtension(path)) ? Path.GetFileName(path) : null;
 
 
         if (dirName == null)
         if (dirName == null)
         {
         {
@@ -50,7 +50,7 @@ public sealed class WindowsOperatingSystem : IOperatingSystem
             return;
             return;
         }
         }
 
 
-        WindowsProcessUtility.ShellExecuteEV(dirName);
+        WindowsProcessUtility.ShellExecuteEV(path);
     }
     }
 
 
     public bool HandleNewInstance(Dispatcher? dispatcher, Action<string, bool> openInExistingAction, IApplicationLifetime lifetime)
     public bool HandleNewInstance(Dispatcher? dispatcher, Action<string, bool> openInExistingAction, IApplicationLifetime lifetime)

+ 4 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -1032,5 +1032,8 @@
   "CUSTOM_BACKGROUND_SCALE": "Custom background scale",
   "CUSTOM_BACKGROUND_SCALE": "Custom background scale",
   "PRIMARY_BG_COLOR": "Primary background color",
   "PRIMARY_BG_COLOR": "Primary background color",
   "SECONDARY_BG_COLOR": "Secondary background color",
   "SECONDARY_BG_COLOR": "Secondary background color",
-  "RESET": "Reset"
+  "RESET": "Reset",
+  "AUTOSAVE_OPEN_FOLDER": "Open autosave folder",
+   "AUTOSAVE_OPEN_FOLDER_DESCRIPTIVE": "Open the folder where autosaves are stored",
+  "AUTOSAVE_TOGGLE_DESCRIPTIVE": "Enable/disable autosave"
 }
 }

+ 13 - 1
src/PixiEditor/ViewModels/SubViewModels/AutosaveViewModel.cs

@@ -5,6 +5,8 @@ using PixiEditor.Models.Commands.Attributes.Commands;
 using PixiEditor.Models.Commands.Attributes.Evaluators;
 using PixiEditor.Models.Commands.Attributes.Evaluators;
 using PixiEditor.Models.DocumentModels.Autosave;
 using PixiEditor.Models.DocumentModels.Autosave;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.IO;
+using PixiEditor.OperatingSystem;
+using PixiEditor.UI.Common.Fonts;
 using PixiEditor.ViewModels.Document;
 using PixiEditor.ViewModels.Document;
 
 
 namespace PixiEditor.ViewModels.SubViewModels;
 namespace PixiEditor.ViewModels.SubViewModels;
@@ -13,7 +15,17 @@ internal class AutosaveViewModel(ViewModelMain owner, DocumentManagerViewModel d
 {
 {
     public static bool SaveSessionStateEnabled => IPreferences.Current!.GetPreference(PreferencesConstants.SaveSessionStateEnabled, PreferencesConstants.SaveSessionStateDefault);
     public static bool SaveSessionStateEnabled => IPreferences.Current!.GetPreference(PreferencesConstants.SaveSessionStateEnabled, PreferencesConstants.SaveSessionStateDefault);
 
 
-    [Command.Basic("PixiEditor.Autosave.ToggleAutosave", "AUTOSAVE_TOGGLE", "AUTOSAVE_TOGGLE_DESCRIPTION",
+    [Command.Basic("PixiEditor.Autosave.OpenAutosaveFolder", "AUTOSAVE_OPEN_FOLDER", "AUTOSAVE_OPEN_FOLDER_DESCRIPTIVE",
+        Icon = PixiPerfectIcons.Folder)]
+    public void OpenAutosaveFolder()
+    {
+        if (Directory.Exists(Paths.PathToUnsavedFilesFolder))
+        {
+            IOperatingSystem.Current.OpenFolder(Paths.PathToUnsavedFilesFolder);
+        }
+    }
+
+    [Command.Basic("PixiEditor.Autosave.ToggleAutosave", "AUTOSAVE_TOGGLE", "AUTOSAVE_TOGGLE_DESCRIPTIVE",
         CanExecute = "PixiEditor.Autosave.HasDocumentAndAutosaveEnabled")]
         CanExecute = "PixiEditor.Autosave.HasDocumentAndAutosaveEnabled")]
     public void ToggleAutosave()
     public void ToggleAutosave()
     {
     {