Browse Source

macOS updates

Ruben 6 months ago
parent
commit
e0797e9c71

+ 9 - 8
src/PicView.Avalonia.MacOS/App.axaml.cs

@@ -1,4 +1,5 @@
 using System.Diagnostics;
+using System.Runtime;
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Controls.ApplicationLifetimes;
@@ -20,9 +21,6 @@ using PicView.Core.MacOS.FileAssociation;
 using PicView.Core.MacOS.Wallpaper;
 using PicView.Core.ProcessHandling;
 using PicView.Core.ViewModels;
-#if DEBUG
-using System.Runtime;
-#endif
 
 namespace PicView.Avalonia.MacOS;
 
@@ -40,10 +38,8 @@ public class App : Application, IPlatformSpecificService
 
     public override void Initialize()
     {
-#if DEBUG
         ProfileOptimization.SetProfileRoot(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/"));
         ProfileOptimization.StartProfile("ProfileOptimization");
-#endif
         base.OnFrameworkInitializationCompleted();
     }
 
@@ -61,16 +57,21 @@ public class App : Application, IPlatformSpecificService
             var settingsExists = await LoadSettingsAsync().ConfigureAwait(false);
         
             TranslationManager.Init();
-            _vm = new MainViewModel(this);
-            
+        
             await Dispatcher.UIThread.InvokeAsync(() =>
             {
                 ThemeManager.DetermineTheme(Current, settingsExists);
             
                 _mainWindow = new MacMainWindow();
                 desktop.MainWindow = _mainWindow;
-                _mainWindow.DataContext = _vm;
+            },DispatcherPriority.Send);
+        
+            _vm = new MainViewModel(this);
+        
+            await Dispatcher.UIThread.InvokeAsync(() =>
+            {
                 
+                _mainWindow.DataContext = _vm;
                 StartUpHelper.Start(_vm, settingsExists, desktop, _mainWindow);
             },DispatcherPriority.Send);
         }

+ 6 - 1
src/PicView.Avalonia.MacOS/Views/KeybindingsWindow.axaml.cs

@@ -23,10 +23,15 @@ public partial class KeybindingsWindow : Window
             MinWidth = MaxWidth = Bounds.Width;
             Title = $"{TranslationManager.Translation.ApplicationShortcuts} - PicView";
         };
-        KeyDown += (_, e) =>
+        KeyUp += (_, e) =>
         {
             if (e.Key is Key.Escape)
             {
+                if (!MainKeyboardShortcuts.IsEscKeyEnabled)
+                {
+                    Focus();
+                    return;
+                }
                 e.Handled = true;
                 MainKeyboardShortcuts.IsEscKeyEnabled = false;
                 Close();

+ 9 - 15
src/PicView.Core.MacOS/MacOsKeybindings.cs

@@ -26,48 +26,42 @@ public static class MacOsKeybindings
                                                 "OemPlus": "ZoomIn",
                                                 "OemMinus": "ZoomOut",
                                                 "Subtract": "ZoomOut",
-                                                "Scroll": "ToggleScroll",
+                                                "Alt+X": "ToggleScroll",
                                                 "Home": "ScrollToTop",
                                                 "End": "ScrollToBottom",
                                                 "G": "ToggleGallery",
                                                 "F": "Flip",
-                                                "J": "ResizeImage",
                                                 "L": "ToggleLooping",
                                                 "C": "Crop",
                                                 "E": "GalleryClick",
-                                                "Enter": "GalleryClick",
+                                                "Return": "GalleryClick",
                                                 "I": "ImageInfoWindow",
                                                 "F6": "EffectsWindow",
                                                 "F1": "AboutWindow",
                                                 "F3": "OpenInExplorer",
-                                                "F4": "SettingsWindow",
+                                                "Alt+S": "SettingsWindow",
                                                 "F5": "Slideshow",
-                                                "F11": "Fullscreen",
+                                                "Ctrl+Cmd+F": "Fullscreen",
                                                 "F12": "Fullscreen",
                                                 "B": "ChangeBackground",
                                                 "Space": "Center",
                                                 "K": "KeybindingsWindow",
-                                                "D0": "Set0Star",
-                                                "D1": "Set1Star",
-                                                "D2": "Set2Star",
-                                                "D3": "Set3Star",
-                                                "D4": "Set4Star",
-                                                "D5": "Set5Star",
                                                 "Cmd+O": "Open",
                                                 "Cmd+E": "OpenWith",
                                                 "Cmd+R": "Reload",
                                                 "Cmd+S": "Save",
-                                                "Cmd+Shift+S": "SaveAs",
+                                                "Shift+Cmd+S": "SaveAs",
                                                 "F2": "Rename",
                                                 "Cmd+C": "CopyFile",
-                                                "Cmd+Alt+V": "CopyFilePath",
-                                                "Cmd+Shift+C": "CopyImage",
+                                                "Alt+Cmd+V": "CopyFilePath",
+                                                "Shift+Cmd+C": "CopyImage",
                                                 "Cmd+X": "CutFile",
                                                 "Cmd+V": "Paste",
                                                 "Cmd+P": "Print",
                                                 "Alt+Z": "ToggleInterface",
                                                 "Delete": "DeleteFile",
-                                                "Shift+Delete": "DeleteFilePermanently"
+                                                "Shift+Delete": "DeleteFilePermanently",
+                                                "Cmd+N": "NewWindow"
                                               }
                                               """;
 }