فهرست منبع

Minor macOS adjustments

Ruben 5 ماه پیش
والد
کامیت
e9c139a95c

+ 10 - 0
src/PicView.Avalonia.MacOS/Views/MacMainWindow.axaml

@@ -309,6 +309,16 @@
                 </NativeMenu>
             </NativeMenuItem>
 
+            <!--  Window  -->
+            <NativeMenuItem Header="{CompiledBinding Translation.Window}">
+                <NativeMenu>
+                    <NativeMenuItem Command="{CompiledBinding NewWindowCommand}" Header="{CompiledBinding Translation.NewWindow, Mode=OneWay}" />
+                    <NativeMenuItemSeparator />
+                    <NativeMenuItem Command="{CompiledBinding MaximizeCommand}" Header="{CompiledBinding Translation.Maximize, Mode=OneWay}" />
+                    <NativeMenuItem Command="{CompiledBinding ToggleFullscreenCommand}" Header="{CompiledBinding Translation.Fullscreen, Mode=OneWay}" />
+                </NativeMenu>
+            </NativeMenuItem>
+
         </NativeMenu>
     </NativeMenu.Menu>
 

+ 2 - 2
src/PicView.Avalonia.MacOS/WindowImpl/MacOSWindow.cs

@@ -56,7 +56,7 @@ public static class MacOSWindow
         {
             vm.SizeToContent = SizeToContent.WidthAndHeight;
             vm.CanResize = false;
-            WindowResizing.SetSize(vm);
+            await WindowResizing.SetSizeAsync(vm);
         }
         else
         {
@@ -84,7 +84,7 @@ public static class MacOSWindow
         vm.IsFullscreen = true;
         vm.IsMaximized = false;
         vm.CanResize = false;
-        WindowResizing.SetSize(vm);
+        await WindowResizing.SetSizeAsync(vm);
         
         if (saveSettings)
         {

+ 2 - 1
src/PicView.Avalonia/Views/MainView.axaml

@@ -85,7 +85,8 @@
                 Header="{CompiledBinding Translation.Print,
                                          Mode=OneWay}"
                 IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                            Converter={x:Static ObjectConverters.IsNotNull}}">
+                                            Converter={x:Static ObjectConverters.IsNotNull}}"
+                x:Name="PrintMenuItem">
                 <MenuItem.Icon>
                     <Path
                         Data="{StaticResource PrintGeometry}"

+ 9 - 10
src/PicView.Avalonia/Views/MainView.axaml.cs

@@ -28,11 +28,20 @@ public partial class MainView : UserControl
 
         if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
         {
+            // TODO: Add macOS support
+            WallpaperMenuItem.IsVisible = false;
+            OpenWithMenuItem.IsVisible = false;
+            PrintMenuItem.IsVisible = false;
+            
             // Move alt hover to left side on macOS and switch button order
             AltButtonsPanel.HorizontalAlignment = HorizontalAlignment.Left; 
             AltButtonsPanel.Children.Move(AltButtonsPanel.Children.IndexOf(AltClose),0);
             AltButtonsPanel.Children.Move(AltButtonsPanel.Children.IndexOf(AltMinimize),2);
         }
+        else
+        {
+            MacOSWallpaperMenuItem.IsVisible = false;
+        }
 
         if (!Settings.Theme.Dark && !Settings.Theme.GlassTheme)
         {
@@ -83,16 +92,6 @@ public partial class MainView : UserControl
             PointerPressed += PointerPressedBehavior;
 
             MainContextMenu.Opened += async (sender, args) =>  await OnMainContextMenuOpened(sender, args);
-
-            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
-            {
-                WallpaperMenuItem.IsVisible = false;
-                OpenWithMenuItem.IsVisible = false;
-            }
-            else
-            {
-                MacOSWallpaperMenuItem.IsVisible = false;
-            }
             
             if (!FileHistoryManager.IsSortingDescending)
             {

+ 5 - 0
src/PicView.Avalonia/Views/SettingsView.axaml.cs

@@ -1,3 +1,4 @@
+using System.Runtime.InteropServices;
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Controls.ApplicationLifetimes;
@@ -19,6 +20,10 @@ public partial class SettingsView : UserControl
     public SettingsView()
     {
         InitializeComponent();
+        if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+        {
+            FileAssociationsTabItem.IsEnabled = false;
+        }
         Loaded += OnLoaded;
     }
 

+ 2 - 1
src/PicView.Avalonia/Views/UC/Menus/FileMenu.axaml

@@ -172,7 +172,8 @@
                     Height="46"
                     IsEnabled="{CompiledBinding PicViewer.FileInfo,
                                                 Converter={x:Static ObjectConverters.IsNotNull}}"
-                    ToolTip.Tip="{CompiledBinding Translation.OpenWith}">
+                    ToolTip.Tip="{CompiledBinding Translation.OpenWith}"
+                    x:Name="OpenWithButton">
                     <StackPanel Orientation="Horizontal">
                         <Path
                             Data="M0 0l20 10L0 20V0zm0 8v4l10-2L0 8z"

+ 6 - 0
src/PicView.Avalonia/Views/UC/Menus/FileMenu.axaml.cs

@@ -1,3 +1,4 @@
+using System.Runtime.InteropServices;
 using Avalonia.Media;
 using PicView.Avalonia.CustomControls;
 
@@ -17,6 +18,11 @@ public partial class FileMenu : AnimatedMenu
             {
                 TopBorder.Background = Brushes.White;
             }
+
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+            {
+                OpenWithButton.IsEnabled = false;
+            }
         };
     }
 }