Skip to content

Commit 2fba709

Browse files
committed
Remove badges
1 parent e2c4021 commit 2fba709

File tree

7 files changed

+3
-153
lines changed

7 files changed

+3
-153
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ public string Theme
128128
public string ResultSubFontWeight { get; set; }
129129
public string ResultSubFontStretch { get; set; }
130130
public bool UseGlyphIcons { get; set; } = true;
131-
public bool ShowBadges { get; set; } = false;
132-
public bool ShowBadgesGlobalOnly { get; set; } = false;
133131

134132
public bool FirstLaunch { get; set; } = true;
135133

Flow.Launcher.Plugin/Result.cs

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public class Result
2323

2424
private string _copyText = string.Empty;
2525

26-
private string _badgeIcoPath;
27-
2826
/// <summary>
2927
/// The title of the result. This is always required.
3028
/// </summary>
@@ -87,33 +85,6 @@ public string IcoPath
8785
}
8886
}
8987

90-
/// <summary>
91-
/// The image to be displayed for the badge of the result.
92-
/// </summary>
93-
/// <value>Can be a local file path or a URL.</value>
94-
/// <remarks>If null or empty, will use plugin icon</remarks>
95-
public string BadgeIcoPath
96-
{
97-
get => _badgeIcoPath;
98-
set
99-
{
100-
// As a standard this property will handle prepping and converting to absolute local path for icon image processing
101-
if (!string.IsNullOrEmpty(value)
102-
&& !string.IsNullOrEmpty(PluginDirectory)
103-
&& !Path.IsPathRooted(value)
104-
&& !value.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
105-
&& !value.StartsWith("https://", StringComparison.OrdinalIgnoreCase)
106-
&& !value.StartsWith("data:image", StringComparison.OrdinalIgnoreCase))
107-
{
108-
_badgeIcoPath = Path.Combine(PluginDirectory, value);
109-
}
110-
else
111-
{
112-
_badgeIcoPath = value;
113-
}
114-
}
115-
}
116-
11788
/// <summary>
11889
/// Determines if Icon has a border radius
11990
/// </summary>
@@ -130,11 +101,6 @@ public string BadgeIcoPath
130101
/// </summary>
131102
public IconDelegate Icon = null;
132103

133-
/// <summary>
134-
/// Delegate to load an icon for the badge of this result.
135-
/// </summary>
136-
public IconDelegate BadgeIcon = null;
137-
138104
/// <summary>
139105
/// Information for Glyph Icon (Prioritized than IcoPath/Icon if user enable Glyph Icons)
140106
/// </summary>
@@ -188,9 +154,8 @@ public string PluginDirectory
188154

189155
// When the Result object is returned from the query call, PluginDirectory is not provided until
190156
// UpdatePluginMetadata call is made at PluginManager.cs L196. Once the PluginDirectory becomes available
191-
// we need to update (only if not Uri path) the IcoPath and BadgeIcoPath with the full absolute path so the image can be loaded.
157+
// we need to update (only if not Uri path) the IcoPath with the full absolute path so the image can be loaded.
192158
IcoPath = _icoPath;
193-
BadgeIcoPath = _badgeIcoPath;
194159
}
195160
}
196161

@@ -251,12 +216,6 @@ public string PluginDirectory
251216
/// </summary>
252217
public string RecordKey { get; set; } = null;
253218

254-
/// <summary>
255-
/// Determines if the badge icon should be shown.
256-
/// If users want to show the result badges and here you set this to true, the results will show the badge icon.
257-
/// </summary>
258-
public bool ShowBadge { get; set; } = false;
259-
260219
/// <summary>
261220
/// Run this result, asynchronously
262221
/// </summary>
@@ -286,10 +245,8 @@ public Result Clone()
286245
CopyText = CopyText,
287246
AutoCompleteText = AutoCompleteText,
288247
IcoPath = IcoPath,
289-
BadgeIcoPath = BadgeIcoPath,
290248
RoundedIcon = RoundedIcon,
291249
Icon = Icon,
292-
BadgeIcon = BadgeIcon,
293250
Glyph = Glyph,
294251
Action = Action,
295252
AsyncAction = AsyncAction,
@@ -307,7 +264,6 @@ public Result Clone()
307264
Preview = Preview,
308265
AddSelectedCount = AddSelectedCount,
309266
RecordKey = RecordKey,
310-
ShowBadge = ShowBadge,
311267
};
312268
}
313269

Flow.Launcher/Languages/en.xaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,6 @@
239239
<system:String x:Key="useGlyphUI">Use Segoe Fluent Icons</system:String>
240240
<system:String x:Key="useGlyphUIEffect">Use Segoe Fluent Icons for query results where supported</system:String>
241241
<system:String x:Key="flowlauncherPressHotkey">Press Key</system:String>
242-
<system:String x:Key="showBadges">Show Result Badges</system:String>
243-
<system:String x:Key="showBadgesToolTip">For supported plugins, badges are displayed to help distinguish them more easily.</system:String>
244-
<system:String x:Key="showBadgesGlobalOnly">Show Result Badges for Global Query Only</system:String>
245242

246243
<!-- Setting About -->
247244
<system:String x:Key="about">About</system:String>

Flow.Launcher/ResultListBox.xaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
<ListBox.Resources>
3535
<converter:SizeRatioConverter x:Key="SizeRatioConverter" />
36-
<converter:BadgePositionConverter x:Key="BadgePositionConverter" />
3736
<converter:IconRadiusConverter x:Key="IconRadiusConverter" />
3837
<converter:DiameterToCenterPointConverter x:Key="DiameterToCenterPointConverter" />
3938
<converter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
@@ -136,18 +135,6 @@
136135
Style="{DynamicResource ItemGlyph}"
137136
Text="{Binding Glyph.Glyph}"
138137
Visibility="{Binding ShowGlyph}" />
139-
140-
<Image
141-
x:Name="BadgeIcon"
142-
Width="{Binding ElementName=ImageIcon, Path=ActualWidth, Converter={StaticResource SizeRatioConverter}, ConverterParameter=0.6}"
143-
Height="{Binding ElementName=ImageIcon, Path=ActualWidth, Converter={StaticResource SizeRatioConverter}, ConverterParameter=0.6}"
144-
RenderOptions.BitmapScalingMode="HighQuality"
145-
Source="{Binding BadgeImage, TargetNullValue={x:Null}}"
146-
Visibility="{Binding ShowBadge}">
147-
<Image.RenderTransform>
148-
<TranslateTransform X="{Binding ElementName=ImageIcon, Path=ActualWidth, Converter={StaticResource BadgePositionConverter}, ConverterParameter=1}" Y="{Binding ElementName=ImageIcon, Path=ActualWidth, Converter={StaticResource BadgePositionConverter}, ConverterParameter=2}" />
149-
</Image.RenderTransform>
150-
</Image>
151138
</Grid>
152139
</Border>
153140

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -494,26 +494,6 @@
494494
OnContent="{DynamicResource enable}" />
495495
</cc:Card>
496496

497-
<!-- Badges -->
498-
<cc:ExCard
499-
Title="{DynamicResource showBadges}"
500-
Margin="0 4 0 0"
501-
Icon="&#xEC1B;"
502-
Sub="{DynamicResource showBadgesToolTip}">
503-
<cc:ExCard.SideContent>
504-
<ui:ToggleSwitch
505-
IsOn="{Binding Settings.ShowBadges}"
506-
OffContent="{DynamicResource disable}"
507-
OnContent="{DynamicResource enable}" />
508-
</cc:ExCard.SideContent>
509-
<cc:Card Title="{DynamicResource showBadgesGlobalOnly}" Type="InsideFit">
510-
<ui:ToggleSwitch
511-
IsOn="{Binding Settings.ShowBadgesGlobalOnly}"
512-
OffContent="{DynamicResource disable}"
513-
OnContent="{DynamicResource enable}" />
514-
</cc:Card>
515-
</cc:ExCard>
516-
517497
<!-- Settings color scheme -->
518498
<cc:Card
519499
Title="{DynamicResource ColorScheme}"

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,6 @@ public void RegisterResultsUpdatedEvent()
246246
// make a clone to avoid possible issue that plugin will also change the list and items when updating view model
247247
var resultsCopy = DeepCloneResults(e.Results, token);
248248

249-
foreach (var result in resultsCopy)
250-
{
251-
if (string.IsNullOrEmpty(result.BadgeIcoPath))
252-
{
253-
result.BadgeIcoPath = pair.Metadata.IcoPath;
254-
}
255-
}
256-
257249
PluginManager.UpdatePluginMetadata(resultsCopy, pair.Metadata, e.Query);
258250

259251
if (token.IsCancellationRequested) return;
@@ -1238,14 +1230,6 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) :
12381230
resultsCopy = DeepCloneResults(results, token);
12391231
}
12401232

1241-
foreach (var result in resultsCopy)
1242-
{
1243-
if (string.IsNullOrEmpty(result.BadgeIcoPath))
1244-
{
1245-
result.BadgeIcoPath = plugin.Metadata.IcoPath;
1246-
}
1247-
}
1248-
12491233
if (token.IsCancellationRequested) return;
12501234

12511235
App.API.LogDebug(ClassName, $"Update results for plugin <{plugin.Metadata.Name}>");

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public Visibility ShowPreviewImage
9191
{
9292
if (PreviewImageAvailable)
9393
return Visibility.Visible;
94-
94+
9595
// Fall back to icon
9696
return ShowIcon;
9797
}
@@ -103,7 +103,7 @@ public double IconRadius
103103
{
104104
if (Result.RoundedIcon)
105105
return IconXY / 2;
106-
106+
107107
return IconXY;
108108
}
109109
}
@@ -121,32 +121,12 @@ public Visibility ShowGlyph
121121
}
122122
}
123123

124-
public Visibility ShowBadge
125-
{
126-
get
127-
{
128-
// If results do not allow badges, or user has disabled badges in settings,
129-
// or badge icon is not available, then do not show badge
130-
if (!Result.ShowBadge || !Settings.ShowBadges || !BadgeIconAvailable)
131-
return Visibility.Collapsed;
132-
133-
// If user has set to show badges only for global results, and this is not a global result,
134-
// then do not show badge
135-
if (Settings.ShowBadgesGlobalOnly && !IsGlobalQuery)
136-
return Visibility.Collapsed;
137-
138-
return Visibility.Visible;
139-
}
140-
}
141-
142124
public bool IsGlobalQuery => string.IsNullOrEmpty(Result.OriginQuery.ActionKeyword);
143125

144126
private bool GlyphAvailable => Glyph is not null;
145127

146128
private bool ImgIconAvailable => !string.IsNullOrEmpty(Result.IcoPath) || Result.Icon is not null;
147129

148-
private bool BadgeIconAvailable => !string.IsNullOrEmpty(Result.BadgeIcoPath) || Result.BadgeIcon is not null;
149-
150130
private bool PreviewImageAvailable => !string.IsNullOrEmpty(Result.Preview.PreviewImagePath) || Result.Preview.PreviewDelegate != null;
151131

152132
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)
@@ -158,11 +138,9 @@ public Visibility ShowBadge
158138
: Result.SubTitleToolTip;
159139

160140
private volatile bool _imageLoaded;
161-
private volatile bool _badgeImageLoaded;
162141
private volatile bool _previewImageLoaded;
163142

164143
private ImageSource _image = ImageLoader.LoadingImage;
165-
private ImageSource _badgeImage = ImageLoader.LoadingImage;
166144
private ImageSource _previewImage = ImageLoader.LoadingImage;
167145

168146
public ImageSource Image
@@ -180,21 +158,6 @@ public ImageSource Image
180158
private set => _image = value;
181159
}
182160

183-
public ImageSource BadgeImage
184-
{
185-
get
186-
{
187-
if (!_badgeImageLoaded)
188-
{
189-
_badgeImageLoaded = true;
190-
_ = LoadBadgeImageAsync();
191-
}
192-
193-
return _badgeImage;
194-
}
195-
private set => _badgeImage = value;
196-
}
197-
198161
public ImageSource PreviewImage
199162
{
200163
get
@@ -251,21 +214,6 @@ private async Task LoadImageAsync()
251214
}
252215
}
253216

254-
private async Task LoadBadgeImageAsync()
255-
{
256-
var badgeImagePath = Result.BadgeIcoPath;
257-
var badgeIconDelegate = Result.BadgeIcon;
258-
if (ImageLoader.TryGetValue(badgeImagePath, false, out var img))
259-
{
260-
_badgeImage = img;
261-
}
262-
else
263-
{
264-
// We need to modify the property not field here to trigger the OnPropertyChanged event
265-
BadgeImage = await LoadImageInternalAsync(badgeImagePath, badgeIconDelegate, false).ConfigureAwait(false);
266-
}
267-
}
268-
269217
private async Task LoadPreviewImageAsync()
270218
{
271219
var imagePath = Result.Preview.PreviewImagePath ?? Result.IcoPath;

0 commit comments

Comments
 (0)