mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-24 02:00:55 +08:00
Improve hotkey logic: do not close window when typing
This commit is contained in:
@@ -44,16 +44,16 @@ namespace QuickLook.Helpers
|
||||
internal static bool IsFocusedControlExplorerItem()
|
||||
{
|
||||
if (NativeMethods.QuickLook.GetFocusedWindowType() == 0)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
var focusedWindowClass = GetWindowClassName(GetFocusedWindow());
|
||||
var focusedWindowParentClass =
|
||||
GetWindowClassName(GetParentWindow(GetFocusedWindow()));
|
||||
|
||||
if (focusedWindowParentClass != "SHELLDLL_DefView")
|
||||
if (focusedWindowClass != "SysListView32" && focusedWindowClass != "DirectUIHWND")
|
||||
return false;
|
||||
|
||||
if (focusedWindowClass != "SysListView32" && focusedWindowClass != "DirectUIHWND")
|
||||
if (focusedWindowParentClass != "SHELLDLL_DefView")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
WindowStartupLocation="CenterScreen"
|
||||
x:ClassModifier="internal" Focusable="False"
|
||||
ShowActivated="False" ShowInTaskbar="False" WindowStyle="None"
|
||||
FontFamily="Segoe UI,Microsoft Yahei UI"
|
||||
ResizeMode="CanResizeWithGrip" AllowsTransparency="True">
|
||||
<Window.Background>
|
||||
<SolidColorBrush Color="#E5FAFAFA" />
|
||||
@@ -30,8 +31,8 @@
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity"
|
||||
From="0"
|
||||
To="1"
|
||||
BeginTime="0:0:0.1"
|
||||
Duration="0:0:0.2" />
|
||||
BeginTime="0:0:0"
|
||||
Duration="0:0:0.1" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
@@ -43,9 +44,12 @@
|
||||
<fa:ImageAwesome DockPanel.Dock="Right" x:Name="buttonCloseWindow" Icon="TimesCircle"
|
||||
Height="15" Margin="10,0" Foreground="Gray"
|
||||
Cursor="Hand" />
|
||||
<Label x:Name="titlebarTitleArea" Content="{Binding ContextObject.Title, ElementName=mainWindow}"
|
||||
FontSize="14" HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center" />
|
||||
<!-- set grid.background colour makes it clickable -->
|
||||
<Grid x:Name="titleBarArea" Background="Transparent">
|
||||
<TextBlock Text="{Binding ContextObject.Title, ElementName=mainWindow}" FontSize="14"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
<Grid>
|
||||
<local:ViewContentContainer x:Name="viewContentContainer" />
|
||||
@@ -63,11 +67,11 @@
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity"
|
||||
From="1"
|
||||
To="0"
|
||||
BeginTime="0:0:0.1"
|
||||
Duration="0:0:0.2" />
|
||||
BeginTime="0:0:0"
|
||||
Duration="0:0:0.1" />
|
||||
<ObjectAnimationUsingKeyFrames
|
||||
Storyboard.TargetProperty="(UIElement.Visibility)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0:0:0.4"
|
||||
<DiscreteObjectKeyFrame KeyTime="0:0:0.1"
|
||||
Value="{x:Static Visibility.Collapsed}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</ParallelTimeline>
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace QuickLook
|
||||
Loaded += (sender, e) => AeroGlassHelper.EnableBlur(this);
|
||||
|
||||
buttonCloseWindow.MouseLeftButtonUp += (sender, e) => Close();
|
||||
titlebarTitleArea.MouseLeftButtonDown += DragMoveCurrentWindow;
|
||||
titleBarArea.PreviewMouseLeftButtonDown += DragMoveCurrentWindow;
|
||||
}
|
||||
|
||||
public ContextObject ContextObject { get; }
|
||||
@@ -75,7 +75,8 @@ namespace QuickLook
|
||||
|
||||
base.Show();
|
||||
|
||||
WindowHelper.SetNoactivate(new WindowInteropHelper(this));
|
||||
if (!ContextObject.Focusable)
|
||||
WindowHelper.SetNoactivate(new WindowInteropHelper(this));
|
||||
}
|
||||
|
||||
internal void BeginShow(IViewer matchedPlugin, string path)
|
||||
@@ -84,7 +85,7 @@ namespace QuickLook
|
||||
ContextObject.ViewerPlugin = matchedPlugin;
|
||||
|
||||
// get window size before showing it
|
||||
matchedPlugin.BoundViewSize(path, ContextObject);
|
||||
matchedPlugin.Prepare(path, ContextObject);
|
||||
|
||||
Show();
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ namespace QuickLook
|
||||
|
||||
internal void InvokeRoutine()
|
||||
{
|
||||
if (CloseCurrentWindow())
|
||||
if (!WindowHelper.IsFocusedControlExplorerItem())
|
||||
return;
|
||||
|
||||
if (!WindowHelper.IsFocusedControlExplorerItem())
|
||||
if (CloseCurrentWindow())
|
||||
return;
|
||||
|
||||
var path = GetCurrentSelection();
|
||||
|
||||
Reference in New Issue
Block a user