mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-05-08 03:06:29 +08:00
Merge pull request #1 from JSuttHoops/codex/add-reload-button-with-preserved-window-properties
Summary Introduced a new “Reload” button in the viewer window toolbar for quickly refreshing the current preview without closing the window Added the “MW_Reload” string to the translations so the Reload button text can be localized Implemented a ReloadPreview method in ViewWindowManager to refresh the plugin content in-place Hooked the Reload button and added optional file monitoring for auto-reload in ViewerWindow code-behind Allowed custom window background colors via the WindowBackgroundColor setting
This commit is contained in:
@@ -175,6 +175,7 @@
|
||||
<MW_OpenWithMenu>Öffnen mit ...</MW_OpenWithMenu>
|
||||
<MW_Run>{0} ausführen</MW_Run>
|
||||
<MW_Share>Freigeben</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>Beim Systemstart &ausführen</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>Nach &Updates suchen</Icon_CheckUpdate>
|
||||
@@ -208,6 +209,7 @@
|
||||
<MW_OpenWithMenu>Open With Menu</MW_OpenWithMenu>
|
||||
<MW_Run>Run {0}</MW_Run>
|
||||
<MW_Share>Share</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>Run at &Startup</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>Check for &Updates...</Icon_CheckUpdate>
|
||||
@@ -241,6 +243,7 @@
|
||||
<MW_OpenWithMenu>Abrir Con Menu</MW_OpenWithMenu>
|
||||
<MW_Run>Iniciar {0}</MW_Run>
|
||||
<MW_Share>Compartir</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>Iniciar con el &sistema</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>Buscar &Actualizaciones...</Icon_CheckUpdate>
|
||||
@@ -328,6 +331,7 @@
|
||||
<MW_OpenWithMenu>メニューから選択して開く</MW_OpenWithMenu>
|
||||
<MW_Run>{0} を起動</MW_Run>
|
||||
<MW_Share>シェア</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>スタートアップ時に起動</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>更新を確認する... (&U)</Icon_CheckUpdate>
|
||||
@@ -411,6 +415,7 @@
|
||||
<MW_OpenWith>Otwórz w {0}</MW_OpenWith>
|
||||
<MW_Run>Uruchom {0}</MW_Run>
|
||||
<MW_Share>Udostępnij</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>Uruchamiaj automatycznie z systemem</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>Sprawdź &aktualizacje...</Icon_CheckUpdate>
|
||||
@@ -443,6 +448,7 @@
|
||||
<MW_OpenWithMenu>Menu abrir com</MW_OpenWithMenu>
|
||||
<MW_Run>Executar {0}</MW_Run>
|
||||
<MW_Share>Compartilhar</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>Executar na &Inicialização</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>Procurar por &Atualizações...</Icon_CheckUpdate>
|
||||
@@ -499,6 +505,7 @@
|
||||
<MW_StayTop>Поверх всех окон</MW_StayTop>
|
||||
<MW_PreventClosing>Закрепить</MW_PreventClosing>
|
||||
<MW_Share>Поделиться</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>Автозапуск</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>Проверить &обновления…</Icon_CheckUpdate>
|
||||
@@ -558,6 +565,7 @@
|
||||
<MW_OpenWithMenu>Відкрити за допомогою меню</MW_OpenWithMenu>
|
||||
<MW_Run>Запустити {0}</MW_Run>
|
||||
<MW_Share>Поширити</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>Запускати під час &старту</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>Перевірити наявність &оновлення…</Icon_CheckUpdate>
|
||||
@@ -616,6 +624,7 @@
|
||||
<MW_OpenWithMenu>从菜单选择打开</MW_OpenWithMenu>
|
||||
<MW_Run>运行 {0}</MW_Run>
|
||||
<MW_Share>分享</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>启动时自动运行 (&S)</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>检查更新... (&U)</Icon_CheckUpdate>
|
||||
@@ -649,6 +658,7 @@
|
||||
<MW_OpenWithMenu>從選單選擇開啟</MW_OpenWithMenu>
|
||||
<MW_Run>執行 {0}</MW_Run>
|
||||
<MW_Share>分享</MW_Share>
|
||||
<MW_Reload>Reload</MW_Reload>
|
||||
<Icon_RunAtStartup>系統啟動時自動執行 (&S)</Icon_RunAtStartup>
|
||||
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
|
||||
<Icon_CheckUpdate>檢查更新... (&U)</Icon_CheckUpdate>
|
||||
|
||||
@@ -189,6 +189,16 @@ internal class ViewWindowManager : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadPreview()
|
||||
{
|
||||
if (!_viewerWindow.IsVisible || string.IsNullOrEmpty(_invokedPath))
|
||||
return;
|
||||
|
||||
var matchedPlugin = PluginManager.GetInstance().FindMatch(_invokedPath);
|
||||
|
||||
BeginShowNewWindow(_invokedPath, matchedPlugin);
|
||||
}
|
||||
|
||||
private void BeginShowNewWindow(string path, IViewer matchedPlugin)
|
||||
{
|
||||
_viewerWindow.UnloadPlugin();
|
||||
|
||||
@@ -160,6 +160,12 @@ public partial class ViewerWindow
|
||||
Debug.WriteLine(e);
|
||||
}
|
||||
|
||||
if (_autoReloadWatcher != null)
|
||||
{
|
||||
_autoReloadWatcher.Dispose();
|
||||
_autoReloadWatcher = null;
|
||||
}
|
||||
|
||||
Plugin = null;
|
||||
|
||||
_path = string.Empty;
|
||||
@@ -211,6 +217,17 @@ public partial class ViewerWindow
|
||||
Show();
|
||||
}
|
||||
|
||||
if (_autoReload && File.Exists(path))
|
||||
{
|
||||
_autoReloadWatcher?.Dispose();
|
||||
_autoReloadWatcher = new FileSystemWatcher(Path.GetDirectoryName(path)!, Path.GetFileName(path)!)
|
||||
{
|
||||
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size
|
||||
};
|
||||
_autoReloadWatcher.Changed += (_, _) => Dispatcher.Invoke(() => ViewWindowManager.GetInstance().ReloadPreview());
|
||||
_autoReloadWatcher.EnableRaisingEvents = true;
|
||||
}
|
||||
|
||||
//ShowWindowCaptionContainer(null, null);
|
||||
//WindowHelper.SetActivate(new WindowInteropHelper(this), ContextObject.CanFocus);
|
||||
|
||||
|
||||
@@ -117,6 +117,11 @@
|
||||
DockPanel.Dock="Right"
|
||||
Style="{StaticResource CaptionButtonStyle}"
|
||||
ToolTip="Open with XXX" />
|
||||
<Button x:Name="buttonReload"
|
||||
Content=""
|
||||
DockPanel.Dock="Right"
|
||||
Style="{StaticResource CaptionButtonStyle}"
|
||||
ToolTip="Reload" />
|
||||
<!--<Button x:Name="buttonOpen" DockPanel.Dock="Right"
|
||||
Style="{StaticResource CaptionTextButtonStyle}"
|
||||
Visibility="{Binding ActualWidth, ElementName=windowCaptionContainer, Converter={StaticResource WidthToVisibilityCollapsedConverter}}">
|
||||
|
||||
@@ -24,6 +24,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.IO;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
using Brush = System.Windows.Media.Brush;
|
||||
using FontFamily = System.Windows.Media.FontFamily;
|
||||
@@ -36,6 +37,8 @@ public partial class ViewerWindow : Window
|
||||
private Size _customWindowSize = Size.Empty;
|
||||
private bool _ignoreNextWindowSizeChange;
|
||||
private string _path = string.Empty;
|
||||
private FileSystemWatcher? _autoReloadWatcher;
|
||||
private readonly bool _autoReload;
|
||||
|
||||
internal ViewerWindow()
|
||||
{
|
||||
@@ -46,6 +49,8 @@ public partial class ViewerWindow : Window
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
_autoReload = SettingHelper.Get("AutoReload", false);
|
||||
|
||||
Icon = (App.IsWin10 ? Properties.Resources.app_white_png : Properties.Resources.app_png).ToBitmapSource();
|
||||
|
||||
FontFamily = new FontFamily(TranslationHelper.Get("UI_FontFamily", failsafe: "Segoe UI"));
|
||||
@@ -93,6 +98,11 @@ public partial class ViewerWindow : Window
|
||||
ViewWindowManager.GetInstance().RunAndClosePreview();
|
||||
};
|
||||
|
||||
buttonReload.Click += (_, _) =>
|
||||
{
|
||||
ViewWindowManager.GetInstance().ReloadPreview();
|
||||
};
|
||||
|
||||
buttonWindowStatus.Click += (_, _) =>
|
||||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
|
||||
@@ -104,6 +114,7 @@ public partial class ViewerWindow : Window
|
||||
buttonPin.ToolTip = TranslationHelper.Get("MW_PreventClosing");
|
||||
buttonOpenWith.ToolTip = TranslationHelper.Get("MW_OpenWithMenu");
|
||||
buttonShare.ToolTip = TranslationHelper.Get("MW_Share");
|
||||
buttonReload.ToolTip = TranslationHelper.Get("MW_Reload", failsafe: "Reload");
|
||||
}
|
||||
|
||||
public new void Close()
|
||||
@@ -149,6 +160,19 @@ public partial class ViewerWindow : Window
|
||||
{
|
||||
Background = (Brush)FindResource("MainWindowBackgroundNoTransparent");
|
||||
}
|
||||
|
||||
var customColor = SettingHelper.Get("WindowBackgroundColor", string.Empty, "QuickLook");
|
||||
if (!string.IsNullOrEmpty(customColor))
|
||||
{
|
||||
try
|
||||
{
|
||||
Background = (Brush)new System.Windows.Media.BrushConverter().ConvertFromString(customColor);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore invalid color
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveWindowSizeOnSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user