Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="QuickLook.Plugin.ImageViewer.ImagePanel"
<UserControl x:Class="QuickLook.Plugin.ImageViewer.ImagePanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:animatedImage="clr-namespace:QuickLook.Plugin.ImageViewer.AnimatedImage"
Expand All @@ -24,7 +24,7 @@
<Rectangle.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=imagePanel, Path=Theme}" Value="{x:Static plugin:Themes.Dark}">
<DataTrigger Binding="{Binding ElementName=imagePanel, Path=CanvasTheme}" Value="{x:Static plugin:Themes.Dark}">
<Setter Property="Rectangle.Fill">
<Setter.Value>
<ImageBrush AlignmentY="Top"
Expand All @@ -38,7 +38,7 @@
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=imagePanel, Path=Theme}" Value="{x:Static plugin:Themes.Light}">
<DataTrigger Binding="{Binding ElementName=imagePanel, Path=CanvasTheme}" Value="{x:Static plugin:Themes.Light}">
<Setter Property="Rectangle.Fill">
<Setter.Value>
<ImageBrush AlignmentY="Top"
Expand Down
18 changes: 15 additions & 3 deletions QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2017-2026 QL-Win Contributors
// Copyright © 2017-2026 QL-Win Contributors
//
// This file is part of QuickLook program.
//
Expand Down Expand Up @@ -107,6 +107,7 @@ internal ImagePanel(ContextObject context, MetaProvider meta) : this()

ShowMeta();
Theme = ContextObject.Theme;
CanvasTheme = (Themes)SettingHelper.Get("LastCanvasTheme", (int)Theme, "QuickLook.Plugin.ImageViewer");
}

public bool ZoomWithControlKey
Expand Down Expand Up @@ -140,6 +141,17 @@ public Themes Theme
}
}

private Themes _canvasTheme = Themes.Dark;
public Themes CanvasTheme
{
get => _canvasTheme;
set
{
_canvasTheme = value;
OnPropertyChanged();
}
}

public BitmapScalingMode RenderMode
{
get => _renderMode;
Expand Down Expand Up @@ -381,9 +393,9 @@ private void OnReverseColorOnClick(object sender, RoutedEventArgs e)

private void OnBackgroundColourOnClick(object sender, RoutedEventArgs e)
{
Theme = Theme == Themes.Dark ? Themes.Light : Themes.Dark;
CanvasTheme = CanvasTheme == Themes.Dark ? Themes.Light : Themes.Dark;

SettingHelper.Set("LastTheme", (int)Theme, "QuickLook.Plugin.ImageViewer");
SettingHelper.Set("LastCanvasTheme", (int)CanvasTheme, "QuickLook.Plugin.ImageViewer");
}

private void ShowMeta()
Expand Down
21 changes: 19 additions & 2 deletions QuickLook/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ protected override void OnStartup(StartupEventArgs e)
// Therefore, the time-consuming initialization code can't be placed before `OnStartup`
base.OnStartup(e);

// Set initial theme based on system settings
ThemeManager.Apply(OSThemeHelper.AppsUseDarkTheme() ? ApplicationTheme.Dark : ApplicationTheme.Light);
// Set initial theme based on system or user settings
var appTheme = SettingHelper.Get("AppTheme", 0, "QuickLook");
SetTheme(appTheme);

// Initialize MessageBox patching
MessageBoxPatcher.Initialize();
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
Expand Down Expand Up @@ -346,4 +347,20 @@ private void RunListener(StartupEventArgs e)
KeystrokeDispatcher.GetInstance();
PipeServerManager.GetInstance();
}

public static void SetTheme(int theme)
{
switch (theme)
{
case 1:
ThemeManager.Apply(ApplicationTheme.Light);
break;
case 2:
ThemeManager.Apply(ApplicationTheme.Dark);
break;
default:
ThemeManager.Apply(OSThemeHelper.AppsUseDarkTheme() ? ApplicationTheme.Dark : ApplicationTheme.Light);
break;
}
}
}
14 changes: 14 additions & 0 deletions QuickLook/TrayIconManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal partial class TrayIconManager : IDisposable

private readonly TrayMenuItem _itemAutorun = null!;
private readonly TrayMenuItem _itemCloseOnLostFocus = null!;
private readonly TrayMenuItem _itemThemeCycle = null!;

private TrayIconManager()
{
Expand Down Expand Up @@ -70,6 +71,17 @@ private TrayIconManager()
Header = TranslationHelper.Get("Icon_OpenDataFolder"),
Command = new RelayCommand(() => Process.Start("explorer.exe", SettingHelper.LocalDataPath)),
},
_itemThemeCycle = new TrayMenuItem()
{
Header = "Theme: Auto",
Command = new RelayCommand(() =>
{
var current = SettingHelper.Get("AppTheme", 0, "QuickLook");
var next = (current + 1) % 3;
SettingHelper.Set("AppTheme", next, "QuickLook");
App.SetTheme(next);
Comment thread
EaZyStudiio marked this conversation as resolved.
}),
},
_itemAutorun = new TrayMenuItem()
{
Header = TranslationHelper.Get("Icon_RunAtStartup"),
Expand Down Expand Up @@ -109,6 +121,8 @@ private TrayIconManager()
{
_itemAutorun.IsChecked = AutoStartupHelper.IsAutorun();
_itemCloseOnLostFocus.IsChecked = SettingHelper.Get("CloseOnLostFocus", false);
var theme = SettingHelper.Get("AppTheme", 0, "QuickLook");
_itemThemeCycle.Header = theme == 1 ? "Theme: Light" : theme == 2 ? "Theme: Dark" : "Theme: Auto";
};
}

Expand Down