Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions QuickLook/Translations.config
Original file line number Diff line number Diff line change
Expand Up @@ -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 &amp;ausführen</Icon_RunAtStartup>
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
<Icon_CheckUpdate>Nach &amp;Updates suchen</Icon_CheckUpdate>
Expand Down Expand Up @@ -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 &amp;Startup</Icon_RunAtStartup>
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
<Icon_CheckUpdate>Check for &amp;Updates...</Icon_CheckUpdate>
Expand Down Expand Up @@ -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 &amp;sistema</Icon_RunAtStartup>
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
<Icon_CheckUpdate>Buscar &amp;Actualizaciones...</Icon_CheckUpdate>
Expand Down Expand Up @@ -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>更新を確認する... (&amp;U)</Icon_CheckUpdate>
Expand Down Expand Up @@ -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ź &amp;aktualizacje...</Icon_CheckUpdate>
Expand Down Expand Up @@ -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 &amp;Inicialização</Icon_RunAtStartup>
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
<Icon_CheckUpdate>Procurar por &amp;Atualizações...</Icon_CheckUpdate>
Expand Down Expand Up @@ -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>Проверить &amp;обновления…</Icon_CheckUpdate>
Expand Down Expand Up @@ -558,6 +565,7 @@
<MW_OpenWithMenu>Відкрити за допомогою меню</MW_OpenWithMenu>
<MW_Run>Запустити {0}</MW_Run>
<MW_Share>Поширити</MW_Share>
<MW_Reload>Reload</MW_Reload>
<Icon_RunAtStartup>Запускати під час &amp;старту</Icon_RunAtStartup>
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
<Icon_CheckUpdate>Перевірити наявність &amp;оновлення…</Icon_CheckUpdate>
Expand Down Expand Up @@ -616,6 +624,7 @@
<MW_OpenWithMenu>从菜单选择打开</MW_OpenWithMenu>
<MW_Run>运行 {0}</MW_Run>
<MW_Share>分享</MW_Share>
<MW_Reload>Reload</MW_Reload>
<Icon_RunAtStartup>启动时自动运行 (&amp;S)</Icon_RunAtStartup>
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
<Icon_CheckUpdate>检查更新... (&amp;U)</Icon_CheckUpdate>
Expand Down Expand Up @@ -649,6 +658,7 @@
<MW_OpenWithMenu>從選單選擇開啟</MW_OpenWithMenu>
<MW_Run>執行 {0}</MW_Run>
<MW_Share>分享</MW_Share>
<MW_Reload>Reload</MW_Reload>
<Icon_RunAtStartup>系統啟動時自動執行 (&amp;S)</Icon_RunAtStartup>
<Icon_ToolTip>QuickLook v{0}</Icon_ToolTip>
<Icon_CheckUpdate>檢查更新... (&amp;U)</Icon_CheckUpdate>
Expand Down
10 changes: 10 additions & 0 deletions QuickLook/ViewWindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ public void InvokePluginPreview(string plugin, string path = null)
}
}

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();
Expand Down
17 changes: 17 additions & 0 deletions QuickLook/ViewerWindow.Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ internal void UnloadPlugin()
Debug.WriteLine(e);
}

if (_autoReloadWatcher != null)
{
_autoReloadWatcher.Dispose();
_autoReloadWatcher = null;
}

Plugin = null;

_path = string.Empty;
Expand Down Expand Up @@ -211,6 +217,17 @@ internal void BeginShow(IViewer matchedPlugin, string path,
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);

Expand Down
5 changes: 5 additions & 0 deletions QuickLook/ViewerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@
DockPanel.Dock="Right"
Style="{StaticResource CaptionButtonStyle}"
ToolTip="Open with XXX" />
<Button x:Name="buttonReload"
Content="&#xE72C;"
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}}">
Expand Down
24 changes: 24 additions & 0 deletions QuickLook/ViewerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand All @@ -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()
{
Expand All @@ -46,6 +49,8 @@ internal ViewerWindow()

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"));
Expand Down Expand Up @@ -93,6 +98,11 @@ internal ViewerWindow()
ViewWindowManager.GetInstance().RunAndClosePreview();
};

buttonReload.Click += (_, _) =>
{
ViewWindowManager.GetInstance().ReloadPreview();
};

buttonWindowStatus.Click += (_, _) =>
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;

Expand All @@ -104,6 +114,7 @@ internal ViewerWindow()
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()
Expand Down Expand Up @@ -149,6 +160,19 @@ public override void OnApplyTemplate()
{
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)
Expand Down