Skip to content

Commit ff3688b

Browse files
committed
Add auto resize for list view in web search plugin
1 parent b637e21 commit ff3688b

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@
5151
ItemsSource="{Binding Settings.SearchSources}"
5252
MouseDoubleClick="MouseDoubleClickItem"
5353
SelectedItem="{Binding Settings.SelectedSearchSource}"
54+
SizeChanged="ListView_SizeChanged"
5455
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}">
5556
<ListView.View>
5657
<GridView>
57-
<GridViewColumn Width="50">
58+
<GridViewColumn Width="45">
5859
<GridViewColumn.CellTemplate>
5960
<DataTemplate>
6061
<Image
@@ -67,14 +68,14 @@
6768
</GridViewColumn>
6869

6970
<GridViewColumn
70-
Width="130"
71+
Width="112"
7172
DisplayMemberBinding="{Binding ActionKeyword}"
7273
Header="{DynamicResource flowlauncher_plugin_websearch_action_keyword}" />
7374
<GridViewColumn
74-
Width="239"
75+
Width="168"
7576
DisplayMemberBinding="{Binding Title}"
7677
Header="{DynamicResource flowlauncher_plugin_websearch_title}" />
77-
<GridViewColumn Width="140" Header="{DynamicResource flowlauncher_plugin_websearch_enable}">
78+
<GridViewColumn Width="112" Header="{DynamicResource flowlauncher_plugin_websearch_enable}">
7879
<GridViewColumn.CellTemplate>
7980
<DataTemplate>
8081
<TextBlock>
@@ -92,17 +93,14 @@
9293
</DataTemplate>
9394
</GridViewColumn.CellTemplate>
9495
</GridViewColumn>
95-
<GridViewColumn
96-
Width="120"
97-
Header="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}">
96+
<GridViewColumn Width="123" Header="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}">
9897
<GridViewColumn.CellTemplate>
9998
<DataTemplate>
10099
<CheckBox
101100
HorizontalAlignment="Center"
102101
VerticalAlignment="Center"
103102
IsChecked="{Binding IsPrivateMode}"
104-
IsEnabled="False"
105-
/>
103+
IsEnabled="False" />
106104
</DataTemplate>
107105
</GridViewColumn.CellTemplate>
108106
</GridViewColumn>

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,28 @@ private void MouseDoubleClickItem(object sender, System.Windows.Input.MouseButto
140140
webSearch.ShowDialog();
141141
}
142142
}
143+
144+
private void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
145+
{
146+
var listView = sender as ListView;
147+
var gView = listView.View as GridView;
148+
149+
var workingWidth =
150+
listView.ActualWidth - SystemParameters.VerticalScrollBarWidth; // take into account vertical scrollbar
151+
152+
if (workingWidth <= 0) return;
153+
154+
var col1 = 0.08;
155+
var col2 = 0.20;
156+
var col3 = 0.30;
157+
var col4 = 0.20;
158+
var col5 = 0.22;
159+
160+
gView.Columns[0].Width = workingWidth * col1;
161+
gView.Columns[1].Width = workingWidth * col2;
162+
gView.Columns[2].Width = workingWidth * col3;
163+
gView.Columns[3].Width = workingWidth * col4;
164+
gView.Columns[4].Width = workingWidth * col5;
165+
}
143166
}
144167
}

0 commit comments

Comments
 (0)