Merge pull request #649 from QL-Win/no-focus

No focus
This commit is contained in:
Pengfei Xu
2020-05-13 22:13:56 +03:00
committed by GitHub
5 changed files with 45 additions and 4 deletions

View File

@@ -36,7 +36,7 @@ namespace QuickLook.Plugin.ImageViewer
".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".x3f",
// normal
".bmp", ".heic", ".heif", ".ico", ".icon", ".jpg", ".jpeg", ".psd", ".wdp", ".tif", ".tiff", ".tga",
".webp", ".pbm", ".pgm", ".ppm", ".pnm", ".svg",
".webp", ".pbm", ".pgm", ".ppm", ".pnm", ".svg", ".emf", ".wmf",
// animated
".png", ".apng", ".gif"
};

View File

@@ -19,6 +19,7 @@ using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
@@ -50,6 +51,12 @@ namespace QuickLook.Plugin.TextViewer
Options.EnableEmailHyperlinks = false;
Options.EnableHyperlinks = false;
ContextMenu = new ContextMenu();
ContextMenu.Items.Add(new MenuItem
{Header = TranslationHelper.Get("Editor_Copy"), Command = ApplicationCommands.Copy});
ContextMenu.Items.Add(new MenuItem
{Header = TranslationHelper.Get("Editor_SelectAll"), Command = ApplicationCommands.SelectAll});
ManipulationInertiaStarting += Viewer_ManipulationInertiaStarting;
ManipulationStarting += Viewer_ManipulationStarting;
ManipulationDelta += Viewer_ManipulationDelta;
@@ -124,7 +131,7 @@ namespace QuickLook.Plugin.TextViewer
{
Task.Run(() =>
{
const int maxLength = 50 * 1024 * 1024;
const int maxLength = 5 * 1024 * 1024;
var buffer = new MemoryStream();
bool tooLong;
@@ -146,7 +153,7 @@ namespace QuickLook.Plugin.TextViewer
return;
if (tooLong)
_context.Title += " (0 ~ 50MB)";
_context.Title += " (0 ~ 5MB)";
var bufferCopy = buffer.ToArray();
buffer.Dispose();

View File

@@ -9,6 +9,8 @@
</de-DE>
<en>
<Editor_FontFamily>Consolas</Editor_FontFamily>
<Editor_Copy>Copy</Editor_Copy>
<Editor_SelectAll>Select All</Editor_SelectAll>
</en>
<es-ES>
<Editor_FontFamily>Consolas</Editor_FontFamily>
@@ -21,6 +23,8 @@
</it>
<ja-JP>
<Editor_FontFamily>Consolas,Meiryo UI,MS UI Gothic,MS Gothic</Editor_FontFamily>
<Editor_Copy>コピー</Editor_Copy>
<Editor_SelectAll>すべて選択</Editor_SelectAll>
</ja-JP>
<ko-KR>
<Editor_FontFamily>Consolas,Malgun Gothic,Batang</Editor_FontFamily>
@@ -54,9 +58,13 @@
</vi>
<zh-CN>
<Editor_FontFamily>Consolas,Microsoft Yahei UI,Microsoft Yahei,SimSun</Editor_FontFamily>
<Editor_Copy>复制</Editor_Copy>
<Editor_SelectAll>全选</Editor_SelectAll>
</zh-CN>
<zh-TW>
<Editor_FontFamily>Consolas,Microsoft JhengHei UI,Microsoft JhengHei,MingLiU</Editor_FontFamily>
<Editor_Copy>複製</Editor_Copy>
<Editor_SelectAll>全選</Editor_SelectAll>
</zh-TW>
<mr>
<Editor_FontFamily>Consolas,Mangal,Nirmala UI</Editor_FontFamily>

View File

@@ -18,6 +18,7 @@
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media.Animation;
using QuickLook.Common.ExtensionMethods;
using QuickLook.Common.Helpers;
@@ -55,6 +56,10 @@ namespace QuickLook
StateChanged += (sender, e) => _ignoreNextWindowSizeChange = true;
// bring the window to top when users click in the client area.
// the non-client area is handled by the WndProc inside OnSourceInitialized().
PreviewMouseDown += (sender, e) => this.BringToFront(false);
windowFrameContainer.PreviewMouseMove += ShowWindowCaptionContainer;
Topmost = SettingHelper.Get("Topmost", false);
@@ -98,6 +103,27 @@ namespace QuickLook
buttonOpenWith.Click += (sender, e) => ShareHelper.Share(_path, this, true);
}
// bring the window to top when users click in the non-client area.
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
this.SetNoactivate();
HwndSource.FromHwnd(new WindowInteropHelper(this).Handle)?.AddHook(
(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
{
switch (msg)
{
case 0x0112: // WM_SYSCOMMAND
this.BringToFront(false);
break;
}
return IntPtr.Zero;
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();