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
9 changes: 7 additions & 2 deletions QuickLook.Plugin.MIQ/MiqSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,15 @@ private static void WriteBreadcrumb(string? pluginDir, string settingsPath)
return;
try
{
File.WriteAllText(Path.Combine(pluginDir!, "MIQ settings location.txt"),
var breadcrumb = Path.Combine(pluginDir!, "MIQ settings location.txt");
var text =
"MIQ preview settings are stored outside this folder so they\r\n" +
"survive plugin updates. Edit this file:\r\n\r\n " +
settingsPath + "\r\n");
settingsPath + "\r\n";
// Load() runs on every preview; write only when missing or stale
// (wiped by an upgrade, or the settings path moved).
if (File.Exists(breadcrumb) && File.ReadAllText(breadcrumb) == text) return;
File.WriteAllText(breadcrumb, text);
}
catch { /* best-effort breadcrumb */ }
}
Expand Down
11 changes: 9 additions & 2 deletions QuickLook.Plugin.MIQ/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public sealed class Plugin : IViewer
private MiqVolume? _volume;
// Cancelled in Cleanup() so background tasks don't touch a recycled viewer.
private CancellationTokenSource? _cts;
// Loaded once per preview in Prepare() and reused by View(), so the ini is
// read (and its breadcrumb checked) once per Space, not twice.
private MiqSettings? _settings;

// Above QuickLook's generic ArchiveViewer, which otherwise grabs ".gz".
public int Priority => 100;
Expand Down Expand Up @@ -59,7 +62,9 @@ public bool CanHandle(string path)

public void Prepare(string path, ContextObject context)
{
// Re-read every preview so ini edits apply on the next Space.
var settings = MiqSettings.Load();
_settings = settings;
context.PreferredSize = new WpfSize(settings.PreviewWidth, settings.PreviewHeight);
context.Theme = Themes.Dark;
}
Expand All @@ -76,12 +81,14 @@ public void View(string path, ContextObject context)
context.ViewerContent = _control;

var control = _control;
// Frozen WPF resources only, so safe to hand to the background task.
// Load here only if the host skipped Prepare().
var loaded = _settings;
Task.Run(() =>
{
try
{
// Re-read every preview so ini edits apply on the next Space.
var settings = MiqSettings.Load();
var settings = loaded ?? MiqSettings.Load();
var options = settings.Options;
var kind = MiqFileKindExtensions.FromPath(path);

Expand Down
Loading