瀏覽代碼

Theme updates and fixes

Ruben 1 年之前
父節點
當前提交
f25c2e975f

+ 0 - 1
src/PicView.Avalonia/PicViewTheme/Controls/Menu.axaml

@@ -151,7 +151,6 @@
 
         <Style Selector="^:selected /template/ ContentPresenter#PART_HeaderPresenter">
             <Setter Property="Foreground" Value="{StaticResource SecondaryTextColor}" />
-            <Setter Property="Effect" Value="{StaticResource TextShadow}" />
         </Style>
 
         <Style Selector="^:nth-child(1) /template/ Border#root">

+ 16 - 0
src/PicView.Avalonia/UI/FunctionsHelper.cs

@@ -1061,6 +1061,22 @@ public static class FunctionsHelper
         ProcessHelper.RestartApp(args);
         await Quit();
     }
+    
+    public static async Task Restart()
+    {
+        ProcessHelper.RestartApp(Environment.GetCommandLineArgs()?.ToString());
+
+        if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
+        {
+            Environment.Exit(0);
+            return;
+        }
+        await Dispatcher.UIThread.InvokeAsync(() =>
+        {
+            // TODO: Make it a setting to close the window
+            desktop.MainWindow?.Close();
+        });
+    }
 
     #endregion
     

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

@@ -523,6 +523,8 @@ public class MainViewModel : ViewModelBase
     public ReactiveCommand<Unit, Unit>? ResetSettingsCommand { get; }
     
     public ReactiveCommand<Unit, Unit>? ShowSideBySideCommand { get; }
+    
+    public ReactiveCommand<Unit, Unit>? RestartCommand { get; }
 
     #endregion Commands
 
@@ -1871,6 +1873,8 @@ public class MainViewModel : ViewModelBase
         ToggleLoopingCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ToggleLooping);
         
         ResetSettingsCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.ResetSettings);
+        
+        RestartCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.Restart);
 
         #endregion Settings commands
     }

+ 9 - 0
src/PicView.Avalonia/ViewModels/ViewModelBase.cs

@@ -225,10 +225,19 @@ public class ViewModelBase : ReactiveObject
         HighlightColor = TranslationHelper.Translation.HighlightColor;
         AllowZoomOut = TranslationHelper.Translation.AllowZoomOut;
         GlassTheme = TranslationHelper.Translation.GlassTheme;
+        ChangingThemeRequiresRestart = TranslationHelper.Translation.ChangingThemeRequiresRestart;
     }
 
     #region Strings
     
+    private string? _changingThemeRequiresRestart;
+    
+    public string? ChangingThemeRequiresRestart
+    {
+        get => _changingThemeRequiresRestart;
+        set => this.RaiseAndSetIfChanged(ref _changingThemeRequiresRestart, value);
+    }
+    
     private string? _glassTheme;
     
     public string? GlassTheme

+ 8 - 0
src/PicView.Avalonia/Views/AppearanceView.axaml

@@ -38,6 +38,14 @@
             <ComboBoxItem Content="{CompiledBinding GlassTheme, Mode=OneWay}" x:Name="GlassThemeBox" />
         </ComboBox>
 
+        <Button Command="{Binding RestartCommand}" Margin="0,5,0,20">
+            <TextBlock
+                Classes="txt hover"
+                Foreground="{StaticResource SecondaryTextColor}"
+                Text="{CompiledBinding ChangingThemeRequiresRestart,
+                                       Mode=OneWay}" />
+        </Button>
+
         <TextBlock
             Classes="txt"
             FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"

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

@@ -115,7 +115,8 @@
                     Height="45"
                     ToolTip.Tip="{CompiledBinding GoToImageAtSpecifiedIndex,
                                                   Mode=OneWay}"
-                    Width="90">
+                    Width="90"
+                    x:Name="GoToPicButton">
                     <StackPanel Margin="5,0" Orientation="Horizontal">
                         <Image Height="17" Width="17">
                             <DrawingImage>

+ 11 - 4
src/PicView.Avalonia/Views/UC/Menus/ImageMenu.axaml.cs

@@ -3,6 +3,7 @@ using Avalonia.Input;
 using PicView.Avalonia.CustomControls;
 using PicView.Avalonia.Navigation;
 using PicView.Avalonia.ViewModels;
+using PicView.Core.Config;
 using ReactiveUI;
 
 namespace PicView.Avalonia.Views.UC.Menus;
@@ -12,10 +13,16 @@ public partial class ImageMenu  : AnimatedMenu
     public ImageMenu()
     {
         InitializeComponent();
-        GoToPicBox.KeyDown += async (_, e) => await GoToPicBox_OnKeyDown(e);
-        this.WhenAnyValue(x => x.IsVisible)
-            .Where(isVisible => !isVisible)
-            .Subscribe(_ => SlideShowButton.Flyout.Hide());
+        Loaded += delegate
+        {
+            if (SettingsHelper.Settings.Theme.GlassTheme || !SettingsHelper.Settings.Theme.Dark)
+            {
+                // TODO fix when not using dark theme
+            }
+            GoToPicBox.KeyDown += async (_, e) => await GoToPicBox_OnKeyDown(e);
+            this.WhenAnyValue(x => x.IsVisible)
+                .Where(isVisible => !isVisible).Subscribe(_ => SlideShowButton.Flyout.Hide());
+        };
     }
 
     private async Task GoToPicBox_OnKeyDown(KeyEventArgs e)

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

@@ -34,7 +34,7 @@
                     Background="Transparent"
                     BorderBrush="{DynamicResource MainBorderColor}"
                     BorderThickness="0,0,1,0"
-                    Classes="noBorderHover"
+                    Classes="hover"
                     Command="{Binding ShowSettingsWindowCommand}"
                     CornerRadius="8,0,0,0"
                     Height="46"
@@ -66,7 +66,7 @@
                     BorderBrush="{DynamicResource MainBorderColor}"
                     BorderThickness="0,0,1,0"
                     Canvas.Left="179"
-                    Classes="noBorderHover"
+                    Classes="hover"
                     Command="{CompiledBinding ShowAboutWindowCommand}"
                     Height="46"
                     ToolTip.Tip="{CompiledBinding AboutWindow,