mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
fix icon & glyph display based on selected history style results
This commit is contained in:
parent
3745c44455
commit
e970bb4d4e
3 changed files with 39 additions and 37 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using Flow.Launcher.Infrastructure;
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
|
|
||||||
namespace Flow.Launcher.Storage;
|
namespace Flow.Launcher.Storage;
|
||||||
|
|
@ -56,24 +57,54 @@ public class LastOpenedHistoryResult : Result
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Selectively creates a deep copy of the required properties for <see cref="LastOpenedHistoryResult"/>.
|
/// Selectively creates a deep copy of the required properties for <see cref="LastOpenedHistoryResult"/>
|
||||||
|
/// based on the style of history- Last Opened or Query.
|
||||||
/// This copy should be independent of original and full isolated.
|
/// This copy should be independent of original and full isolated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A new <see cref="LastOpenedHistoryResult"/> containing the same required data.</returns>
|
/// <returns>A new <see cref="LastOpenedHistoryResult"/> containing the same required data.</returns>
|
||||||
public LastOpenedHistoryResult DeepCopy()
|
public LastOpenedHistoryResult DeepCopyForHistoryStyle(bool isHistoryStyleLastOpened)
|
||||||
{
|
{
|
||||||
// queryValue and glyphValue are captured to ensure they are correctly referenced in the Action delegate.
|
// queryValue and glyphValue are captured to ensure they are correctly referenced in the Action delegate.
|
||||||
var queryValue = Query;
|
var queryValue = Query;
|
||||||
var glyphValue = Glyph;
|
var glyphValue = Glyph;
|
||||||
|
|
||||||
|
var title = string.Empty;
|
||||||
|
var showBadge = false;
|
||||||
|
var badgeIcoPath = string.Empty;
|
||||||
|
var icoPath = string.Empty;
|
||||||
|
var glyph = null as GlyphInfo;
|
||||||
|
|
||||||
|
if (isHistoryStyleLastOpened)
|
||||||
|
{
|
||||||
|
title = Title;
|
||||||
|
icoPath = IcoPath;
|
||||||
|
glyph = glyphValue != null
|
||||||
|
? new GlyphInfo(glyphValue.FontFamily, glyphValue.Glyph)
|
||||||
|
: null;
|
||||||
|
showBadge = true;
|
||||||
|
badgeIcoPath = Constant.HistoryIcon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
title = Localize.executeQuery(Query);
|
||||||
|
icoPath = Constant.HistoryIcon;
|
||||||
|
glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C");
|
||||||
|
showBadge = false;
|
||||||
|
}
|
||||||
|
|
||||||
return new LastOpenedHistoryResult
|
return new LastOpenedHistoryResult
|
||||||
{
|
{
|
||||||
Title = Title,
|
Title = title,
|
||||||
SubTitle = SubTitle,
|
// Subtitle has datetime which can cause duplicates when saving.
|
||||||
PluginID = PluginID,
|
SubTitle = Localize.lastExecuteTime(ExecutedDateTime),
|
||||||
|
// Empty PluginID so the source of last opened history results won't be updated, this copy is meant to be temporary.
|
||||||
|
PluginID = string.Empty,
|
||||||
Query = Query,
|
Query = Query,
|
||||||
OriginQuery = new Query { TrimmedQuery = Query },
|
OriginQuery = new Query { TrimmedQuery = Query },
|
||||||
RecordKey = RecordKey,
|
RecordKey = RecordKey,
|
||||||
IcoPath = IcoPath,
|
IcoPath = icoPath,
|
||||||
|
ShowBadge = showBadge,
|
||||||
|
BadgeIcoPath = badgeIcoPath,
|
||||||
PluginDirectory = PluginDirectory,
|
PluginDirectory = PluginDirectory,
|
||||||
// Used for Query History style reopening
|
// Used for Query History style reopening
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
|
|
@ -84,9 +115,7 @@ public class LastOpenedHistoryResult : Result
|
||||||
},
|
},
|
||||||
// Used for Last Opened History style reopening, currently need to be assigned at MainViewModel.cs
|
// Used for Last Opened History style reopening, currently need to be assigned at MainViewModel.cs
|
||||||
AsyncAction = null,
|
AsyncAction = null,
|
||||||
Glyph = glyphValue != null
|
Glyph = glyph,
|
||||||
? new GlyphInfo(glyphValue.FontFamily, glyphValue.Glyph)
|
|
||||||
: null,
|
|
||||||
ExecutedDateTime = ExecutedDateTime
|
ExecutedDateTime = ExecutedDateTime
|
||||||
// Note: Other properties are left as default — copy if needed.
|
// Note: Other properties are left as default — copy if needed.
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Flow.Launcher.Core.Plugin;
|
using Flow.Launcher.Core.Plugin;
|
||||||
using Flow.Launcher.Infrastructure;
|
|
||||||
using Flow.Launcher.Plugin;
|
using Flow.Launcher.Plugin;
|
||||||
|
|
||||||
namespace Flow.Launcher.Storage
|
namespace Flow.Launcher.Storage
|
||||||
|
|
@ -35,9 +34,7 @@ namespace Flow.Launcher.Storage
|
||||||
LastOpenedHistoryItems.Add(new LastOpenedHistoryResult
|
LastOpenedHistoryItems.Add(new LastOpenedHistoryResult
|
||||||
{
|
{
|
||||||
Title = Localize.executeQuery(item.Query),
|
Title = Localize.executeQuery(item.Query),
|
||||||
IcoPath = null,
|
|
||||||
OriginQuery = new Query { TrimmedQuery = item.Query },
|
OriginQuery = new Query { TrimmedQuery = item.Query },
|
||||||
Glyph = null,
|
|
||||||
Query = item.Query,
|
Query = item.Query,
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
@ -1340,30 +1339,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
foreach (var item in historyItems)
|
foreach (var item in historyItems)
|
||||||
{
|
{
|
||||||
var copiedItem = item.DeepCopy();
|
var copiedItem = item.DeepCopyForHistoryStyle(Settings.HistoryStyle == HistoryStyle.LastOpened);
|
||||||
|
|
||||||
if (Settings.HistoryStyle == HistoryStyle.Query)
|
|
||||||
{
|
|
||||||
copiedItem.Title = Localize.executeQuery(copiedItem.Query);
|
|
||||||
copiedItem.IcoPath = Constant.HistoryIcon;
|
|
||||||
// TODO: Add Glyph here
|
|
||||||
// copiedItem.Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uE81C");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(copiedItem.IcoPath)) // Must manually set missing image icon here
|
|
||||||
{
|
|
||||||
copiedItem.IcoPath = Constant.MissingImgIcon;
|
|
||||||
}
|
|
||||||
copiedItem.ShowBadge = true;
|
|
||||||
copiedItem.BadgeIcoPath = Constant.HistoryIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subtitle has datetime which can cause duplicates when saving.
|
|
||||||
copiedItem.SubTitle = Localize.lastExecuteTime(copiedItem.ExecutedDateTime);
|
|
||||||
|
|
||||||
// Empty PluginID so the source of last opened history results won't be updated, these results are meant to be temporary copy.
|
|
||||||
copiedItem.PluginID = string.Empty;
|
|
||||||
|
|
||||||
if (Settings.HistoryStyle == HistoryStyle.LastOpened)
|
if (Settings.HistoryStyle == HistoryStyle.LastOpened)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue