mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
update to use IcoAbsoluteLocalPath
This commit is contained in:
parent
7958b17968
commit
d78d313372
3 changed files with 33 additions and 25 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Security.Policy;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
@ -21,6 +22,8 @@ namespace Flow.Launcher.Plugin
|
||||||
|
|
||||||
private string _icoPath;
|
private string _icoPath;
|
||||||
|
|
||||||
|
private string _icoAbsoluteFullPath;
|
||||||
|
|
||||||
private string _copyText = string.Empty;
|
private string _copyText = string.Empty;
|
||||||
|
|
||||||
private string _badgeIcoPath;
|
private string _badgeIcoPath;
|
||||||
|
|
@ -67,12 +70,17 @@ namespace Flow.Launcher.Plugin
|
||||||
/// The image to be displayed for the result.
|
/// The image to be displayed for the result.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>Can be a local file path or a URL.</value>
|
/// <value>Can be a local file path or a URL.</value>
|
||||||
/// <remarks>GlyphInfo is prioritized if not null</remarks>
|
/// <remarks>
|
||||||
|
/// GlyphInfo is prioritized if not null.
|
||||||
|
/// Use IcoPathRelative for storage where it needs to be resistant to plugin location change.
|
||||||
|
/// </remarks>
|
||||||
public string IcoPath
|
public string IcoPath
|
||||||
{
|
{
|
||||||
get => _icoPath;
|
get => _icoPath;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
_icoPath = value;
|
||||||
|
|
||||||
// As a standard this property will handle prepping and converting to absolute local path for icon image processing
|
// As a standard this property will handle prepping and converting to absolute local path for icon image processing
|
||||||
if (!string.IsNullOrEmpty(value)
|
if (!string.IsNullOrEmpty(value)
|
||||||
&& !string.IsNullOrEmpty(PluginDirectory)
|
&& !string.IsNullOrEmpty(PluginDirectory)
|
||||||
|
|
@ -81,40 +89,40 @@ namespace Flow.Launcher.Plugin
|
||||||
&& !value.StartsWith("https://", StringComparison.OrdinalIgnoreCase)
|
&& !value.StartsWith("https://", StringComparison.OrdinalIgnoreCase)
|
||||||
&& !value.StartsWith("data:image", StringComparison.OrdinalIgnoreCase))
|
&& !value.StartsWith("data:image", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
_icoPath = Path.Combine(PluginDirectory, value);
|
_icoAbsoluteFullPath = Path.Combine(PluginDirectory, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_icoPath = value;
|
_icoAbsoluteFullPath = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the plugin directory relative IcoPath or URL. This path is useful for storage where the it needs
|
/// TODO COMMENT
|
||||||
/// to be resistant to changes in plugin location from update or portable mode change.
|
/// </summary>
|
||||||
|
public string IcoAbsoluteFullPath => _icoAbsoluteFullPath;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns IcoPath's relative path based on the plugin directory or original value if not file path.
|
||||||
|
/// This property is useful for storage where it needs to be resistant to changes in plugin location from update
|
||||||
|
/// or portable mode change.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>Must be a local file path.</value>
|
|
||||||
/// <remarks>This will be empty string if IcoPath is a URL, so must check for empty string during usage</remarks>
|
|
||||||
public string IcoPathRelative
|
public string IcoPathRelative
|
||||||
{
|
{
|
||||||
get => _icoPath;
|
get
|
||||||
set
|
|
||||||
{
|
{
|
||||||
// As a standard this property will handle prepping and converting to absolute local path for icon image processing
|
if (string.IsNullOrEmpty(IcoAbsoluteFullPath)
|
||||||
if (!string.IsNullOrEmpty(value)
|
|| string.IsNullOrEmpty(PluginDirectory)
|
||||||
&& !string.IsNullOrEmpty(PluginDirectory)
|
|| !Path.IsPathRooted(IcoAbsoluteFullPath)
|
||||||
&& !Path.IsPathRooted(value)
|
|| IcoAbsoluteFullPath.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
|
||||||
&& !value.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
|
|| IcoAbsoluteFullPath.StartsWith("https://", StringComparison.OrdinalIgnoreCase)
|
||||||
&& !value.StartsWith("https://", StringComparison.OrdinalIgnoreCase)
|
|| IcoAbsoluteFullPath.StartsWith("data:image", StringComparison.OrdinalIgnoreCase))
|
||||||
&& !value.StartsWith("data:image", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
_icoPath = Path.Combine(PluginDirectory, value);
|
return IcoAbsoluteFullPath;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_icoPath = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Path.GetRelativePath(PluginDirectory, IcoAbsoluteFullPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@
|
||||||
Margin="18 24 0 0"
|
Margin="18 24 0 0"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
RenderOptions.BitmapScalingMode="Fant"
|
RenderOptions.BitmapScalingMode="Fant"
|
||||||
Source="{Binding IcoPath, IsAsync=True}" />
|
Source="{Binding IcoAbsoluteFullPath, IsAsync=True}" />
|
||||||
<Border
|
<Border
|
||||||
x:Name="LabelUpdate"
|
x:Name="LabelUpdate"
|
||||||
Height="12"
|
Height="12"
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
private bool GlyphAvailable => Glyph is not null;
|
private bool GlyphAvailable => Glyph is not null;
|
||||||
|
|
||||||
private bool ImgIconAvailable => !string.IsNullOrEmpty(Result.IcoPath) || Result.Icon is not null;
|
private bool ImgIconAvailable => !string.IsNullOrEmpty(Result.IcoAbsoluteFullPath) || Result.Icon is not null;
|
||||||
|
|
||||||
private bool BadgeIconAvailable => !string.IsNullOrEmpty(Result.BadgeIcoPath) || Result.BadgeIcon is not null;
|
private bool BadgeIconAvailable => !string.IsNullOrEmpty(Result.BadgeIcoPath) || Result.BadgeIcon is not null;
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
private async Task LoadImageAsync()
|
private async Task LoadImageAsync()
|
||||||
{
|
{
|
||||||
var imagePath = Result.IcoPath;
|
var imagePath = Result.IcoAbsoluteFullPath;
|
||||||
var iconDelegate = Result.Icon;
|
var iconDelegate = Result.Icon;
|
||||||
if (ImageLoader.TryGetValue(imagePath, false, out var img))
|
if (ImageLoader.TryGetValue(imagePath, false, out var img))
|
||||||
{
|
{
|
||||||
|
|
@ -266,7 +266,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
private async Task LoadPreviewImageAsync()
|
private async Task LoadPreviewImageAsync()
|
||||||
{
|
{
|
||||||
var imagePath = Result.Preview.PreviewImagePath ?? Result.IcoPath;
|
var imagePath = Result.Preview.PreviewImagePath ?? Result.IcoAbsoluteFullPath;
|
||||||
var iconDelegate = Result.Preview.PreviewDelegate ?? Result.Icon;
|
var iconDelegate = Result.Preview.PreviewDelegate ?? Result.Icon;
|
||||||
if (ImageLoader.TryGetValue(imagePath, true, out var img))
|
if (ImageLoader.TryGetValue(imagePath, true, out var img))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue