1
1
Эх сурвалжийг харах

Simplify and refactor wallpaper context menu logic in `MainView` and `ImageInfoView`.

Ruben 3 сар өмнө
parent
commit
83e0015bef

+ 4 - 1
src/PicView.Avalonia/ViewModels/MainViewModel.cs

@@ -1133,10 +1133,13 @@ public class MainViewModel : ReactiveObject
         await FileManager.LocateOnDisk(path, this).ConfigureAwait(false);
 
     private async Task SetAsWallpaperTask(string path) =>
-        await SetAsWallpaperTask(path, WallpaperStyle.Fit).ConfigureAwait(false);
+        await SetAsWallpaperTask(path, WallpaperStyle.Fill).ConfigureAwait(false);
 
     private async Task SetAsWallpaperFilledTask(string path) =>
         await SetAsWallpaperTask(path, WallpaperStyle.Fill).ConfigureAwait(false);
+    
+    private async Task SetAsWallpaperFittedTask(string path) =>
+        await SetAsWallpaperTask(path, WallpaperStyle.Fit).ConfigureAwait(false);
 
     private async Task SetAsWallpaperTiledTask(string path) =>
         await SetAsWallpaperTask(path, WallpaperStyle.Tile).ConfigureAwait(false);

+ 1 - 1
src/PicView.Avalonia/Views/ImageInfoView.axaml

@@ -157,7 +157,7 @@
 
                 <!--  Set as wallpaper fit  -->
                 <MenuItem
-                    Command="{CompiledBinding SetAsWallpaperCommand}"
+                    Command="{CompiledBinding SetAsWallpaperFittedTask}"
                     CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,
                                                        FallbackValue=''}"
                     Header="{CompiledBinding Translation.Fit,

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

@@ -687,24 +687,7 @@
                 Header="{CompiledBinding Translation.SetAsWallpaper,
                                          Mode=OneWay}"
                 IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                            Converter={x:Static ObjectConverters.IsNotNull}}"
-                x:Name="MacOSWallpaperMenuItem">
-                <MenuItem.Icon>
-                    <Path
-                        Data="{StaticResource PanoramaGeometry}"
-                        Fill="{StaticResource Brush0}"
-                        Height="10.40"
-                        Stretch="Fill"
-                        Width="13" />
-                </MenuItem.Icon>
-            </MenuItem>
-
-            <MenuItem
-                Header="{CompiledBinding Translation.SetAsWallpaper,
-                                         Mode=OneWay}"
-                IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                            Converter={x:Static ObjectConverters.IsNotNull}}"
-                x:Name="WallpaperMenuItem">
+                                            Converter={x:Static ObjectConverters.IsNotNull}}">
                 <MenuItem.Icon>
                     <Path
                         Data="{StaticResource PanoramaGeometry}"
@@ -713,124 +696,6 @@
                         Stretch="Fill"
                         Width="13" />
                 </MenuItem.Icon>
-
-                <!--  Set as wallpaper filled  -->
-                <MenuItem
-                    Command="{CompiledBinding SetAsWallpaperFilledCommand}"
-                    CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,
-                                                       FallbackValue=''}"
-                    Header="{CompiledBinding Translation.Fill,
-                                             Mode=OneWay}"
-                    IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                                Converter={x:Static ObjectConverters.IsNotNull}}">
-                    <MenuItem.Icon>
-                        <Path
-                            Data="{StaticResource PanoramaGeometry}"
-                            Fill="{StaticResource Brush0}"
-                            Height="10.40"
-                            Stretch="Fill"
-                            Width="13" />
-                    </MenuItem.Icon>
-                </MenuItem>
-
-                <!--  Set as wallpaper fit  -->
-                <MenuItem
-                    Command="{CompiledBinding SetAsWallpaperCommand}"
-                    CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,
-                                                       FallbackValue=''}"
-                    Header="{CompiledBinding Translation.Fit,
-                                             Mode=OneWay}"
-                    IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                                Converter={x:Static ObjectConverters.IsNotNull}}">
-                    <MenuItem.Icon>
-                        <Path
-                            Data="{StaticResource PanoramaGeometry}"
-                            Fill="{StaticResource Brush0}"
-                            Height="10.40"
-                            Stretch="Fill"
-                            Width="13" />
-                    </MenuItem.Icon>
-                </MenuItem>
-
-                <!--  Set as wallpaper stretched  -->
-                <MenuItem
-                    Command="{CompiledBinding SetAsWallpaperStretchedCommand}"
-                    CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,
-                                                       FallbackValue=''}"
-                    Header="{CompiledBinding Translation.Stretch,
-                                             Mode=OneWay}"
-                    IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                                Converter={x:Static ObjectConverters.IsNotNull}}">
-                    <MenuItem.Icon>
-                        <Path
-                            Data="{StaticResource PanoramaGeometry}"
-                            Fill="{StaticResource Brush0}"
-                            Height="10.40"
-                            Stretch="Fill"
-                            Width="13" />
-                    </MenuItem.Icon>
-                </MenuItem>
-
-
-
-                <!--  Set as wallpaper centered  -->
-                <MenuItem
-                    Command="{CompiledBinding SetAsWallpaperCenteredCommand}"
-                    CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,
-                                                       FallbackValue=''}"
-                    Header="{CompiledBinding Translation.Center,
-                                             Mode=OneWay}"
-                    IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                                Converter={x:Static ObjectConverters.IsNotNull}}">
-                    <MenuItem.Icon>
-                        <Path
-                            Data="{StaticResource PanoramaGeometry}"
-                            Fill="{StaticResource Brush0}"
-                            Height="10.40"
-                            Stretch="Fill"
-                            Width="13" />
-                    </MenuItem.Icon>
-                </MenuItem>
-
-                <!--  Set as wallpaper tiled  -->
-                <MenuItem
-                    Command="{CompiledBinding SetAsWallpaperTiledCommand}"
-                    CommandParameter="{CompiledBinding PicViewer.FileInfo.FullName,
-                                                       FallbackValue=''}"
-                    Header="{CompiledBinding Translation.Tile,
-                                             Mode=OneWay}"
-                    IsEnabled="{CompiledBinding PicViewer.ImageSource,
-                                                Converter={x:Static ObjectConverters.IsNotNull}}">
-                    <MenuItem.Icon>
-                        <Path
-                            Data="{StaticResource PanoramaGeometry}"
-                            Fill="{StaticResource Brush0}"
-                            Height="10.40"
-                            Stretch="Fill"
-                            Width="13" />
-                    </MenuItem.Icon>
-                </MenuItem>
-
-                <!-- <Separator /> -->
-                <!--    -->
-                <!--  ~1~  Set as lock screen  @1@  -->
-                <!--  <MenuItem  -->
-                <!--  Command="{CompiledBinding SetAsLockScreenCommand}"  -->
-                <!--  CommandParameter="{CompiledBinding FileInfo.FullName,  -->
-                <!--  FallbackValue=''}"  -->
-                <!--  Header="{CompiledBinding SetAsLockScreenImage,  -->
-                <!--  Mode=OneWay}"  -->
-                <!--  IsEnabled="False">  -->
-                <!--     <MenuItem.Icon> -->
-                <!--  <Path  -->
-                <!--  Data="{StaticResource PanoramaGeometry}"  -->
-                <!--  Fill="{StaticResource Brush0}"  -->
-                <!--  Height="10.40"  -->
-                <!--  Stretch="Fill"  -->
-                <!--  Width="13" />  -->
-                <!--     </MenuItem.Icon> -->
-                <!-- </MenuItem> -->
-
             </MenuItem>
 
             <Separator />

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

@@ -29,7 +29,6 @@ public partial class MainView : UserControl
         if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
         {
             // TODO: Add macOS support
-            WallpaperMenuItem.IsVisible = false;
             PrintMenuItem.IsVisible = false;
             
             // Move alt hover to left side on macOS and switch button order
@@ -38,10 +37,6 @@ public partial class MainView : UserControl
             AltButtonsPanel.Children.Move(AltButtonsPanel.Children.IndexOf(AltMinimize),2);
             AltMinimize.RenderTransform = new ScaleTransform{ScaleX = -1};
         }
-        else
-        {
-            MacOSWallpaperMenuItem.IsVisible = false;
-        }
 
         if (!Settings.Theme.Dark && !Settings.Theme.GlassTheme)
         {