mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-26 03:58:36 +00:00
Add "Focusable" property to plugins
This commit is contained in:
@@ -30,7 +30,7 @@ namespace QuickLook.Plugin.ArchiveViewer
|
||||
return true;
|
||||
}
|
||||
|
||||
public void BoundViewSize(string path, ContextObject context)
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
context.PreferredSize = new Size {Width = 800, Height = 600};
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
}
|
||||
}
|
||||
|
||||
public void BoundViewSize(string path, ContextObject context)
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
_imageSize = ImageFileHelper.GetImageSize(path);
|
||||
|
||||
|
@@ -31,7 +31,7 @@ namespace QuickLook.Plugin.OfficeViewer
|
||||
return false;
|
||||
}
|
||||
|
||||
public void BoundViewSize(string path, ContextObject context)
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
context.SetPreferredSizeFit(new Size {Width = 800, Height = 600}, 0.8);
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
}
|
||||
}
|
||||
|
||||
public void BoundViewSize(string path, ContextObject context)
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
_pdfControl = new PdfViewerControl();
|
||||
|
||||
|
@@ -40,9 +40,10 @@ namespace QuickLook.Plugin.TextViewer
|
||||
}
|
||||
}
|
||||
|
||||
public void BoundViewSize(string path, ContextObject context)
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
context.PreferredSize = new Size {Width = 800, Height = 600};
|
||||
context.Focusable = true;
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
|
@@ -62,6 +62,11 @@ namespace QuickLook.Plugin
|
||||
/// </summary>
|
||||
public bool CanResize { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Set whether user are allowed to set focus at the viewer window.
|
||||
/// </summary>
|
||||
public bool Focusable { get; set; } = false;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
@@ -18,11 +18,11 @@
|
||||
bool CanHandle(string path);
|
||||
|
||||
/// <summary>
|
||||
/// Tell QuickLook the desired window size. Please not do any work that costs a lot of time.
|
||||
/// Do some preparation stuff before the window is showing. Please not do any work that costs a lot of time.
|
||||
/// </summary>
|
||||
/// <param name="path">The full path of the target file.</param>
|
||||
/// <param name="context">A runtime object which allows interaction between this plugin and QuickLook.</param>
|
||||
void BoundViewSize(string path, ContextObject context);
|
||||
void Prepare(string path, ContextObject context);
|
||||
|
||||
/// <summary>
|
||||
/// Start the loading process. During the process a busy indicator will be shown. Finish by setting context.IsBusy to
|
||||
|
@@ -14,7 +14,7 @@ namespace QuickLook.Plugin.InfoPanel
|
||||
return true;
|
||||
}
|
||||
|
||||
public void BoundViewSize(string path, ContextObject context)
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
_ip = new InfoPanel();
|
||||
|
||||
|
@@ -33,7 +33,19 @@ namespace QuickLook
|
||||
return null;
|
||||
|
||||
var matched = GetInstance()
|
||||
.LoadedPlugins.FirstOrDefault(plugin => plugin.CreateInstance<IViewer>().CanHandle(path))
|
||||
.LoadedPlugins.FirstOrDefault(plugin =>
|
||||
{
|
||||
bool can = false;
|
||||
try
|
||||
{
|
||||
can = plugin.CreateInstance<IViewer>().CanHandle(path);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
return can;
|
||||
})
|
||||
?.CreateInstance<IViewer>();
|
||||
|
||||
return matched ?? DefaultPlugin.CreateInstance<IViewer>();
|
||||
|
Reference in New Issue
Block a user