mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-12 02:00:27 +08:00
Compare commits
2 Commits
latest
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4742908983 | ||
|
|
ccbe1c297a |
@@ -220,6 +220,9 @@ public partial class App : Application
|
|||||||
ThemeManager.Apply(OSThemeHelper.AppsUseDarkTheme() ? ApplicationTheme.Dark : ApplicationTheme.Light);
|
ThemeManager.Apply(OSThemeHelper.AppsUseDarkTheme() ? ApplicationTheme.Dark : ApplicationTheme.Light);
|
||||||
UxTheme.ApplyPreferredAppMode();
|
UxTheme.ApplyPreferredAppMode();
|
||||||
|
|
||||||
|
// Handle power management events to prevent crashes after sleep/wake
|
||||||
|
SystemEvents.PowerModeChanged += OnPowerModeChanged;
|
||||||
|
|
||||||
// Initialize TrayIcon
|
// Initialize TrayIcon
|
||||||
_ = TrayIconManager.GetInstance();
|
_ = TrayIconManager.GetInstance();
|
||||||
|
|
||||||
@@ -303,6 +306,9 @@ public partial class App : Application
|
|||||||
if (!_cleanExit)
|
if (!_cleanExit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Unsubscribe from power management events
|
||||||
|
SystemEvents.PowerModeChanged -= OnPowerModeChanged;
|
||||||
|
|
||||||
_isRunning.ReleaseMutex();
|
_isRunning.ReleaseMutex();
|
||||||
|
|
||||||
PipeServerManager.GetInstance().Dispose();
|
PipeServerManager.GetInstance().Dispose();
|
||||||
@@ -330,4 +336,28 @@ public partial class App : Application
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (e.Mode)
|
||||||
|
{
|
||||||
|
case PowerModes.Suspend:
|
||||||
|
// System is going to sleep - close any open preview windows to prevent graphics issues
|
||||||
|
ProcessHelper.WriteLog("System entering sleep mode - closing preview windows");
|
||||||
|
ViewWindowManager.GetInstance().ClosePreview();
|
||||||
|
break;
|
||||||
|
case PowerModes.Resume:
|
||||||
|
// System waking up - log for debugging
|
||||||
|
ProcessHelper.WriteLog("System resumed from sleep mode");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Don't let power management exceptions crash the app
|
||||||
|
ProcessHelper.WriteLog($"Error handling power mode change: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user