Skip to content

Commit bb5173a

Browse files
committed
Improve plugins pane performance in settings
1 parent 3ae438a commit bb5173a

File tree

6 files changed

+159
-105
lines changed

6 files changed

+159
-105
lines changed

Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml

Lines changed: 2 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -93,42 +93,7 @@
9393
</Expander.Header>
9494

9595
<StackPanel>
96-
<Border
97-
Width="Auto"
98-
Height="52"
99-
Margin="0"
100-
Padding="0"
101-
BorderThickness="0 1 0 0"
102-
CornerRadius="0"
103-
Style="{DynamicResource SettingGroupBox}"
104-
Visibility="{Binding ActionKeywordsVisibility}">
105-
<DockPanel Margin="22 0 18 0" VerticalAlignment="Center">
106-
<TextBlock
107-
Margin="48 0 10 0"
108-
DockPanel.Dock="Left"
109-
Style="{StaticResource Glyph}">
110-
&#xe819;
111-
</TextBlock>
112-
<TextBlock
113-
HorizontalAlignment="Left"
114-
VerticalAlignment="Center"
115-
DockPanel.Dock="Left"
116-
Style="{DynamicResource SettingTitleLabel}"
117-
Text="{DynamicResource actionKeywords}" />
118-
<Button
119-
Width="100"
120-
Height="34"
121-
Margin="5 0 0 0"
122-
HorizontalAlignment="Right"
123-
Command="{Binding SetActionKeywordsCommand}"
124-
Content="{Binding ActionKeywordsText}"
125-
Cursor="Hand"
126-
DockPanel.Dock="Right"
127-
FontWeight="Bold"
128-
ToolTip="{DynamicResource actionKeywordsTooltip}"
129-
Visibility="{Binding ActionKeywordsVisibility}" />
130-
</DockPanel>
131-
</Border>
96+
<ContentControl Content="{Binding BottomPart1}" />
13297

13398
<Border
13499
BorderThickness="0 1 0 0"
@@ -150,75 +115,7 @@
150115
Content="{Binding SettingControl}" />
151116
</Border>
152117

153-
<Border
154-
Margin="0"
155-
Padding="15 10"
156-
VerticalAlignment="Center"
157-
BorderThickness="0 1 0 0"
158-
CornerRadius="0 0 5 5"
159-
Style="{DynamicResource SettingGroupBox}">
160-
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
161-
<TextBlock
162-
Margin="10 0 0 0"
163-
VerticalAlignment="center"
164-
FontSize="11"
165-
Foreground="{DynamicResource PluginInfoColor}"
166-
Text="{DynamicResource author}" />
167-
<TextBlock
168-
Margin="5 0 0 0"
169-
VerticalAlignment="center"
170-
FontSize="11"
171-
Foreground="{DynamicResource PluginInfoColor}"
172-
Text="{Binding PluginPair.Metadata.Author}" />
173-
<TextBlock
174-
Margin="10 0 0 0"
175-
VerticalAlignment="Center"
176-
FontSize="11"
177-
Foreground="{DynamicResource PluginInfoColor}"
178-
Text="|" />
179-
<TextBlock
180-
Margin="10 0 5 0"
181-
VerticalAlignment="Center"
182-
FontSize="11"
183-
Foreground="{DynamicResource PluginInfoColor}"
184-
Text="{Binding Version}"
185-
ToolTip="{Binding InitAndQueryTime}"
186-
ToolTipService.InitialShowDelay="500" />
187-
<TextBlock
188-
Margin="5 0"
189-
VerticalAlignment="Center"
190-
FontSize="11"
191-
Foreground="{DynamicResource PluginInfoColor}"
192-
Text="|" />
193-
<TextBlock
194-
Margin="5 0 0 0"
195-
Style="{DynamicResource LinkBtnStyle}"
196-
Text="&#xe80f;"
197-
ToolTip="{DynamicResource plugin_query_web}">
198-
<TextBlock.InputBindings>
199-
<MouseBinding Command="{Binding OpenSourceCodeLinkCommand}" MouseAction="LeftClick" />
200-
</TextBlock.InputBindings>
201-
</TextBlock>
202-
<TextBlock
203-
Margin="10 0 0 0"
204-
Style="{DynamicResource LinkBtnStyle}"
205-
Text="&#xe74d;"
206-
ToolTip="{DynamicResource plugin_uninstall}">
207-
<TextBlock.InputBindings>
208-
<MouseBinding Command="{Binding OpenDeletePluginWindowCommand}" MouseAction="LeftClick" />
209-
</TextBlock.InputBindings>
210-
</TextBlock>
211-
<TextBlock
212-
Margin="10 0 5 0"
213-
Style="{DynamicResource LinkBtnStyle}"
214-
Text="&#xe8b7;"
215-
ToolTip="{DynamicResource pluginDirectory}">
216-
<TextBlock.InputBindings>
217-
<MouseBinding Command="{Binding OpenPluginDirectoryCommand}" MouseAction="LeftClick" />
218-
</TextBlock.InputBindings>
219-
</TextBlock>
220-
</StackPanel>
221-
</Border>
118+
<ContentControl Content="{Binding BottomPart2}" />
222119
</StackPanel>
223120
</Expander>
224121
</UserControl>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<UserControl
2+
x:Class="Flow.Launcher.Resources.Controls.InstalledPluginDisplayBottomData"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:viewModel="clr-namespace:Flow.Launcher.ViewModel"
8+
d:DataContext="{d:DesignInstance viewModel:PluginViewModel}"
9+
d:DesignHeight="300"
10+
d:DesignWidth="300"
11+
mc:Ignorable="d">
12+
<Border
13+
Margin="0"
14+
Padding="15 10"
15+
VerticalAlignment="Center"
16+
BorderThickness="0 1 0 0"
17+
CornerRadius="0 0 5 5"
18+
Style="{DynamicResource SettingGroupBox}">
19+
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
20+
<TextBlock
21+
Margin="10 0 0 0"
22+
VerticalAlignment="center"
23+
FontSize="11"
24+
Foreground="{DynamicResource PluginInfoColor}"
25+
Text="{DynamicResource author}" />
26+
<TextBlock
27+
Margin="5 0 0 0"
28+
VerticalAlignment="center"
29+
FontSize="11"
30+
Foreground="{DynamicResource PluginInfoColor}"
31+
Text="{Binding PluginPair.Metadata.Author}" />
32+
<TextBlock
33+
Margin="10 0 0 0"
34+
VerticalAlignment="Center"
35+
FontSize="11"
36+
Foreground="{DynamicResource PluginInfoColor}"
37+
Text="|" />
38+
<TextBlock
39+
Margin="10 0 5 0"
40+
VerticalAlignment="Center"
41+
FontSize="11"
42+
Foreground="{DynamicResource PluginInfoColor}"
43+
Text="{Binding Version}"
44+
ToolTip="{Binding InitAndQueryTime}"
45+
ToolTipService.InitialShowDelay="500" />
46+
<TextBlock
47+
Margin="5 0"
48+
VerticalAlignment="Center"
49+
FontSize="11"
50+
Foreground="{DynamicResource PluginInfoColor}"
51+
Text="|" />
52+
<TextBlock
53+
Margin="5 0 0 0"
54+
Style="{DynamicResource LinkBtnStyle}"
55+
Text="&#xe80f;"
56+
ToolTip="{DynamicResource plugin_query_web}">
57+
<TextBlock.InputBindings>
58+
<MouseBinding Command="{Binding OpenSourceCodeLinkCommand}" MouseAction="LeftClick" />
59+
</TextBlock.InputBindings>
60+
</TextBlock>
61+
<TextBlock
62+
Margin="10 0 0 0"
63+
Style="{DynamicResource LinkBtnStyle}"
64+
Text="&#xe74d;"
65+
ToolTip="{DynamicResource plugin_uninstall}">
66+
<TextBlock.InputBindings>
67+
<MouseBinding Command="{Binding OpenDeletePluginWindowCommand}" MouseAction="LeftClick" />
68+
</TextBlock.InputBindings>
69+
</TextBlock>
70+
<TextBlock
71+
Margin="10 0 5 0"
72+
Style="{DynamicResource LinkBtnStyle}"
73+
Text="&#xe8b7;"
74+
ToolTip="{DynamicResource pluginDirectory}">
75+
<TextBlock.InputBindings>
76+
<MouseBinding Command="{Binding OpenPluginDirectoryCommand}" MouseAction="LeftClick" />
77+
</TextBlock.InputBindings>
78+
</TextBlock>
79+
</StackPanel>
80+
</Border>
81+
</UserControl>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Windows.Controls;
2+
3+
namespace Flow.Launcher.Resources.Controls;
4+
5+
public partial class InstalledPluginDisplayBottomData : UserControl
6+
{
7+
public InstalledPluginDisplayBottomData()
8+
{
9+
InitializeComponent();
10+
}
11+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<UserControl
2+
x:Class="Flow.Launcher.Resources.Controls.InstalledPluginDisplayKeyword"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:viewModel="clr-namespace:Flow.Launcher.ViewModel"
8+
d:DataContext="{d:DesignInstance viewModel:PluginViewModel}"
9+
d:DesignHeight="300"
10+
d:DesignWidth="300"
11+
mc:Ignorable="d">
12+
<Border
13+
Width="Auto"
14+
Height="52"
15+
Margin="0"
16+
Padding="0"
17+
BorderThickness="0 1 0 0"
18+
CornerRadius="0"
19+
Style="{DynamicResource SettingGroupBox}"
20+
Visibility="{Binding ActionKeywordsVisibility}">
21+
<DockPanel Margin="22 0 18 0" VerticalAlignment="Center">
22+
<TextBlock
23+
Margin="48 0 10 0"
24+
DockPanel.Dock="Left"
25+
Style="{StaticResource Glyph}">
26+
&#xe819;
27+
</TextBlock>
28+
<TextBlock
29+
HorizontalAlignment="Left"
30+
VerticalAlignment="Center"
31+
DockPanel.Dock="Left"
32+
Style="{DynamicResource SettingTitleLabel}"
33+
Text="{DynamicResource actionKeywords}" />
34+
<Button
35+
Width="100"
36+
Height="34"
37+
Margin="5 0 0 0"
38+
HorizontalAlignment="Right"
39+
Command="{Binding SetActionKeywordsCommand}"
40+
Content="{Binding ActionKeywordsText}"
41+
Cursor="Hand"
42+
DockPanel.Dock="Right"
43+
FontWeight="Bold"
44+
ToolTip="{DynamicResource actionKeywordsTooltip}" />
45+
</DockPanel>
46+
</Border>
47+
</UserControl>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Windows.Controls;
2+
3+
namespace Flow.Launcher.Resources.Controls;
4+
5+
public partial class InstalledPluginDisplayKeyword : UserControl
6+
{
7+
public InstalledPluginDisplayKeyword()
8+
{
9+
InitializeComponent();
10+
}
11+
}

Flow.Launcher/ViewModel/PluginViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Windows.Controls;
88
using CommunityToolkit.Mvvm.Input;
99
using Flow.Launcher.Core.Resource;
10+
using Flow.Launcher.Resources.Controls;
1011

1112
namespace Flow.Launcher.ViewModel
1213
{
@@ -83,6 +84,12 @@ public bool IsExpanded
8384
private Control _settingControl;
8485
private bool _isExpanded;
8586

87+
private Control _bottomPart1;
88+
public Control BottomPart1 => IsExpanded ? _bottomPart1 ??= new InstalledPluginDisplayKeyword() : null;
89+
90+
private Control _bottomPart2;
91+
public Control BottomPart2 => IsExpanded ? _bottomPart2 ??= new InstalledPluginDisplayBottomData() : null;
92+
8693
public bool HasSettingControl => PluginPair.Plugin is ISettingProvider;
8794
public Control SettingControl
8895
=> IsExpanded

0 commit comments

Comments
 (0)