mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix switching preview logic
This commit is contained in:
parent
10d1410c5e
commit
ba8bb3a3b8
1 changed files with 43 additions and 16 deletions
|
|
@ -579,18 +579,24 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
if (Settings.AlwaysPreview == true && PreviewVisible)
|
||||
{
|
||||
// Only hit this line at first preview toggle after toggle on Flow
|
||||
HideInternalPreview(); // When Always preview, toggle off rather than open external
|
||||
}
|
||||
else if (!ExternalPreviewOpen)
|
||||
{
|
||||
_ = OpenQuickLookPreviewAsync(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = CloseQuickLookPreviewAsync();
|
||||
ToggleExternalPreview(path);
|
||||
}
|
||||
}
|
||||
else if (!PreviewVisible)
|
||||
else
|
||||
{
|
||||
// Fallback
|
||||
ToggleInternalPreview();
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleInternalPreview()
|
||||
{
|
||||
if (!PreviewVisible)
|
||||
{
|
||||
ShowInternalPreview();
|
||||
}
|
||||
|
|
@ -600,6 +606,18 @@ namespace Flow.Launcher.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
private void ToggleExternalPreview(string path)
|
||||
{
|
||||
if (!ExternalPreviewOpen)
|
||||
{
|
||||
_ = OpenQuickLookPreviewAsync(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ = CloseQuickLookPreviewAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowInternalPreview()
|
||||
{
|
||||
ResultAreaColumn = 1;
|
||||
|
|
@ -629,21 +647,30 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
if (Settings.UseQuickLook && CanExternalPreviewSelectedResult(out var path))
|
||||
{
|
||||
_ = ToggleQuickLookPreviewAsync(path, ExternalPreviewOpen);
|
||||
if (PreviewVisible)
|
||||
// Should use external preview for selected result
|
||||
if (ExternalPreviewOpen)
|
||||
{
|
||||
_ = ToggleQuickLookPreviewAsync(path, true);
|
||||
}
|
||||
else if(PreviewVisible)
|
||||
{
|
||||
// When internal is open and select a result that should use external preview
|
||||
_ = OpenQuickLookPreviewAsync(path);
|
||||
HideInternalPreview();
|
||||
}
|
||||
}
|
||||
else if (PreviewVisible)
|
||||
{
|
||||
Results.SelectedItem?.LoadPreviewImage();
|
||||
}
|
||||
else
|
||||
{
|
||||
// When external is open and select a result that can't be previewed by external program
|
||||
_ = CloseQuickLookPreviewAsync();
|
||||
ShowInternalPreview();
|
||||
if (PreviewVisible)
|
||||
{
|
||||
Results.SelectedItem?.LoadPreviewImage();
|
||||
}
|
||||
else if (ExternalPreviewOpen)
|
||||
{
|
||||
// When external is open and select a result that can't use external preview
|
||||
_ = CloseQuickLookPreviewAsync();
|
||||
ShowInternalPreview();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -677,7 +704,7 @@ namespace Flow.Launcher.ViewModel
|
|||
private bool CanExternalPreviewSelectedResult(out string path)
|
||||
{
|
||||
path = Results.SelectedItem?.Result?.Preview.FilePath;
|
||||
return string.IsNullOrEmpty(path);
|
||||
return !string.IsNullOrEmpty(path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
Loading…
Reference in a new issue