Skip to content

Commit 4c81330

Browse files
committed
Add Type and Auto Size for context menu
1 parent ee64c25 commit 4c81330

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

Flow.Launcher.Plugin/Result.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ public ValueTask<bool> ExecuteAsync(ActionContext context)
246246
return AsyncAction?.Invoke(context) ?? ValueTask.FromResult(Action?.Invoke(context) ?? false);
247247
}
248248

249+
/// <summary>
250+
/// Item Height Style. Null, Small(for OS Context), Author
251+
/// </summary>
252+
public string ItemType { get; set; }
253+
254+
249255
/// <summary>
250256
/// Progress bar display. Providing an int value between 0-100 will trigger the progress bar to be displayed on the result
251257
/// </summary>

Flow.Launcher/ResultListBox.xaml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@
6262
<StackPanel
6363
x:Name="HotkeyArea"
6464
Grid.Column="2"
65-
Margin="0,0,10,0"
65+
Margin="0 0 10 0"
6666
VerticalAlignment="Center"
6767
Visibility="{Binding ShowOpenResultHotkey}">
6868
<TextBlock
6969
x:Name="Hotkey"
70-
Margin="12,0,12,0"
71-
Padding="0,0,0,0"
70+
Margin="12 0 12 0"
71+
Padding="0 0 0 0"
7272
HorizontalAlignment="Right"
7373
VerticalAlignment="Center"
7474
Style="{DynamicResource ItemHotkeyStyle}">
@@ -97,12 +97,12 @@
9797

9898
<Border
9999
Grid.Column="1"
100-
Margin="9,0,0,0"
100+
Margin="9 0 0 0"
101101
BorderBrush="Transparent"
102102
BorderThickness="1">
103103
<Image
104104
x:Name="ImageIcon"
105-
Margin="0,0,0,0"
105+
Margin="0 0 0 0"
106106
HorizontalAlignment="Center"
107107
IsHitTestVisible="False"
108108
RenderOptions.BitmapScalingMode="Fant"
@@ -131,7 +131,7 @@
131131
</Border>
132132
<Border
133133
Grid.Column="1"
134-
Margin="9,0,0,0"
134+
Margin="9 0 0 0"
135135
BorderBrush="Transparent"
136136
BorderThickness="0">
137137
<TextBlock
@@ -147,7 +147,7 @@
147147

148148
<Grid
149149
Grid.Column="1"
150-
Margin="6,0,10,0"
150+
Margin="6 0 10 0"
151151
HorizontalAlignment="Stretch"
152152
VerticalAlignment="Center">
153153
<Grid.RowDefinitions>
@@ -173,7 +173,7 @@
173173
<TextBlock
174174
x:Name="Title"
175175
Grid.Row="0"
176-
Margin="0,0,0,1"
176+
Margin="0 0 0 1"
177177
VerticalAlignment="Bottom"
178178
DockPanel.Dock="Left"
179179
FontSize="{Binding Settings.ResultItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
@@ -193,7 +193,7 @@
193193
<TextBlock
194194
x:Name="SubTitle"
195195
Grid.Row="1"
196-
Margin="0,1,0,0"
196+
Margin="0 1 0 0"
197197
VerticalAlignment="Top"
198198
FontSize="{Binding Settings.ResultSubItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
199199
IsEnabled="False"
@@ -222,9 +222,30 @@
222222
<!-- http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062 -->
223223
<ListBox.ItemContainerStyle>
224224
<Style TargetType="{x:Type ListBoxItem}">
225+
<Style.Triggers>
226+
<!-- Condition for Type being 'Small' -->
227+
<MultiDataTrigger>
228+
<MultiDataTrigger.Conditions>
229+
<Condition Binding="{Binding Result.ItemType}" Value="Small" />
230+
</MultiDataTrigger.Conditions>
231+
<MultiDataTrigger.Setters>
232+
<Setter Property="Height" Value="{Binding SmallSize}" />
233+
</MultiDataTrigger.Setters>
234+
</MultiDataTrigger>
235+
<!-- Default condition for Type being other values or not set -->
236+
<DataTrigger Binding="{Binding Result.ItemType}" Value="{x:Null}">
237+
<Setter Property="Height" Value="{Binding Settings.ItemHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
238+
</DataTrigger>
239+
<DataTrigger Binding="{Binding Result.ItemType}" Value="">
240+
<Setter Property="Height" Value="{Binding Settings.ItemHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
241+
</DataTrigger>
242+
<DataTrigger Binding="{Binding Result.ItemType}" Value="author">
243+
<Setter Property="Height" Value="{Binding Settings.ItemHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
244+
</DataTrigger>
245+
</Style.Triggers>
246+
<Setter Property="Visibility" Value="Visible" />
225247
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
226248
<EventSetter Event="MouseMove" Handler="OnMouseMove" />
227-
<Setter Property="Height" Value="{Binding Settings.ItemHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
228249
<Setter Property="Margin" Value="0" />
229250
<Setter Property="Padding" Value="0" />
230251
<Setter Property="BorderThickness" Value="0" />
@@ -256,5 +277,6 @@
256277
</Setter.Value>
257278
</Setter>
258279
</Style>
280+
259281
</ListBox.ItemContainerStyle>
260282
</ListBox>

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ public ImageSource PreviewImage
180180
/// </summary>
181181
public bool UseBigThumbnail => Result.Preview.IsMedia;
182182

183+
public double SmallSize
184+
{
185+
get { return Settings.ItemHeightSize * 0.6; }
186+
}
187+
183188
public GlyphInfo Glyph { get; set; }
184189

185190
private async Task<ImageSource> LoadImageInternalAsync(string imagePath, Result.IconDelegate icon, bool loadFullImage)

Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
301301
{
302302
Title = menuItem.Label,
303303
Icon = () => menuItem.Icon,
304+
ItemType = "Small",
304305
Action = _ =>
305306
{
306307
ShellContextMenuDisplayHelper.ExecuteContextMenuItem(record.FullPath, menuItem.CommandId);

0 commit comments

Comments
 (0)