diff --git a/QuickLook/App.xaml.cs b/QuickLook/App.xaml.cs
index 0c1a880..12f101b 100644
--- a/QuickLook/App.xaml.cs
+++ b/QuickLook/App.xaml.cs
@@ -15,7 +15,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-using Microsoft.Win32;
using QuickLook.Common.Helpers;
using QuickLook.Helpers;
using QuickLook.NativeMethods;
@@ -228,8 +227,6 @@ public partial class App : Application
// Set initial theme based on system settings
ThemeManager.Apply(OSThemeHelper.AppsUseDarkTheme() ? ApplicationTheme.Dark : ApplicationTheme.Light);
- UxTheme.ApplyPreferredAppMode(isTracked: true);
- SystemEvents.SessionEnding += OnSessionEnding;
// Initialize MessageBox patching
MessageBoxPatcher.Initialize();
@@ -239,21 +236,8 @@ public partial class App : Application
CheckAndRegisterPluginIcon();
}
- protected virtual void OnSessionEnding(object sender, SessionEndingEventArgs e)
- {
- SystemEvents.SessionEnding -= OnSessionEnding;
-
- // You must unsubscribe from SystemEvents events before your application exits, or the application may crash
- // https://github.com/QL-Win/QuickLook/issues/1782
- UxTheme.ApplyPreferredAppMode(isTracked: false);
- }
-
protected override void OnExit(ExitEventArgs e)
{
- // You must unsubscribe from SystemEvents events before your application exits, or the application may crash
- // https://github.com/QL-Win/QuickLook/issues/1782
- UxTheme.ApplyPreferredAppMode(isTracked: false);
-
base.OnExit(e);
if (!_cleanExit)
diff --git a/QuickLook/QuickLook.csproj b/QuickLook/QuickLook.csproj
index fcc73b6..3ae1f2e 100644
--- a/QuickLook/QuickLook.csproj
+++ b/QuickLook/QuickLook.csproj
@@ -101,10 +101,10 @@
all
-
+
all
-
+
all
diff --git a/QuickLook/TrayIconManager.cs b/QuickLook/TrayIconManager.cs
index 448ba9d..cfa926c 100644
--- a/QuickLook/TrayIconManager.cs
+++ b/QuickLook/TrayIconManager.cs
@@ -25,6 +25,7 @@ using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using Wpf.Ui.Violeta.Win32;
+using OSThemeHelper = QuickLook.Common.Helpers.OSThemeHelper;
using ToolTipIcon = Wpf.Ui.Violeta.Win32.ToolTipIcon;
namespace QuickLook;
@@ -44,6 +45,7 @@ internal partial class TrayIconManager : IDisposable
ToolTipText = string.Format(TranslationHelper.Get("Icon_ToolTip"),
Application.ProductVersion),
Icon = GetTrayIconByDPI(),
+ ThemeMode = TrayThemeMode.System,
Menu =
[
new TrayMenuItem()