mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-03-21 01:08:08 +08:00
Add F11 fullscreen toggle support
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
@@ -46,7 +46,7 @@ internal class KeystrokeDispatcher : IDisposable
|
||||
_validKeys =
|
||||
[
|
||||
Keys.Up, Keys.Down, Keys.Left, Keys.Right,
|
||||
Keys.Enter, Keys.Space, Keys.Escape
|
||||
Keys.Enter, Keys.Space, Keys.Escape, Keys.F11
|
||||
];
|
||||
}
|
||||
|
||||
@@ -135,6 +135,10 @@ internal class KeystrokeDispatcher : IDisposable
|
||||
case Keys.Space:
|
||||
PipeServerManager.SendMessage(PipeMessages.Toggle);
|
||||
break;
|
||||
|
||||
case Keys.F11:
|
||||
PipeServerManager.SendMessage(PipeMessages.Fullscreen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -36,6 +36,7 @@ public static class PipeMessages
|
||||
public const string Forget = "QuickLook.App.PipeMessages.Forget";
|
||||
public const string Close = "QuickLook.App.PipeMessages.Close";
|
||||
public const string Quit = "QuickLook.App.PipeMessages.Quit";
|
||||
public const string Fullscreen = "QuickLook.App.PipeMessages.Fullscreen";
|
||||
}
|
||||
|
||||
public class PipeServerManager : IDisposable
|
||||
@@ -161,6 +162,12 @@ public class PipeServerManager : IDisposable
|
||||
DispatcherPriority.ApplicationIdle);
|
||||
return false;
|
||||
|
||||
case PipeMessages.Fullscreen:
|
||||
Application.Current.Dispatcher.BeginInvoke(
|
||||
new Action(() => ViewWindowManager.GetInstance().ToggleFullscreen()),
|
||||
DispatcherPriority.ApplicationIdle);
|
||||
return false;
|
||||
|
||||
case PipeMessages.Quit:
|
||||
return true;
|
||||
|
||||
|
||||
@@ -198,6 +198,14 @@ public class ViewWindowManager : IDisposable
|
||||
BeginShowNewWindow(_invokedPath, matchedPlugin);
|
||||
}
|
||||
|
||||
public void ToggleFullscreen()
|
||||
{
|
||||
if (!_viewerWindow.IsVisible)
|
||||
return;
|
||||
|
||||
_viewerWindow.ToggleFullscreen();
|
||||
}
|
||||
|
||||
private void BeginShowNewWindow(string path, IViewer matchedPlugin)
|
||||
{
|
||||
_viewerWindow.UnloadPlugin();
|
||||
|
||||
@@ -62,6 +62,11 @@ public partial class ViewerWindow
|
||||
Close();
|
||||
}
|
||||
|
||||
internal void ToggleFullscreen()
|
||||
{
|
||||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
}
|
||||
|
||||
private void PositionWindow(Size size)
|
||||
{
|
||||
// If the window is now maximized, do not move it
|
||||
|
||||
Reference in New Issue
Block a user