Fix #521: wrong path copying when Enter key is pressed and QL is *not* showing

This commit is contained in:
Paddy Xu
2019-09-23 20:06:31 +03:00
parent 7505c40342
commit 1d83cd8dd0
2 changed files with 18 additions and 15 deletions
+6 -4
View File
@@ -75,33 +75,35 @@ namespace QuickLook
private void InvokeRoutine(Keys key, bool isKeyDown)
{
var path = NativeMethods.QuickLook.GetCurrentSelection();
Debug.WriteLine($"InvokeRoutine: key={key},down={isKeyDown}");
if (isKeyDown)
{
switch (key)
{
case Keys.Enter:
PipeServerManager.SendMessage(PipeMessages.RunAndClose);
break;
}
}
else
{
switch (key)
{
case Keys.Up:
case Keys.Down:
case Keys.Left:
case Keys.Right:
PipeServerManager.SendMessage(PipeMessages.Switch, path);
PipeServerManager.SendMessage(PipeMessages.Switch);
break;
case Keys.Space:
PipeServerManager.SendMessage(PipeMessages.Toggle, path);
PipeServerManager.SendMessage(PipeMessages.Toggle);
break;
case Keys.Escape:
PipeServerManager.SendMessage(PipeMessages.Close);
break;
}
}
}
private void InstallKeyHook(KeyEventHandler downHandler, KeyEventHandler upHandler)
+12 -11
View File
@@ -73,8 +73,11 @@ namespace QuickLook
_viewerWindow.BeginHide();
}
public void TogglePreview(string path)
public void TogglePreview(string path = null)
{
if (string.IsNullOrEmpty(path))
path = NativeMethods.QuickLook.GetCurrentSelection();
if (_viewerWindow.Visibility == Visibility.Visible && (string.IsNullOrEmpty(path) || path == _invokedPath))
ClosePreview();
else
@@ -99,19 +102,14 @@ namespace QuickLook
var newWindow = new ViewerWindow();
/*if (_viewerWindow.WindowState != WindowState.Maximized)
{
newWindow.Top = _viewerWindow.Top;
newWindow.Left = _viewerWindow.Left;
newWindow.Width = _viewerWindow.Width;
newWindow.Height = _viewerWindow.Height;
}*/
_viewerWindow = newWindow;
}
public void SwitchPreview(string path)
public void SwitchPreview(string path = null)
{
if (string.IsNullOrEmpty(path))
path = NativeMethods.QuickLook.GetCurrentSelection();
if (string.IsNullOrEmpty(path))
return;
@@ -121,8 +119,11 @@ namespace QuickLook
InvokePreview(path);
}
public void InvokePreview(string path)
public void InvokePreview(string path = null)
{
if (string.IsNullOrEmpty(path))
path = NativeMethods.QuickLook.GetCurrentSelection();
if (string.IsNullOrEmpty(path))
return;