Skip to content

Commit 8942e55

Browse files
authored
Merge pull request #767 from onesounds/SettingWidth
Add width in setting and fix max result displayed not reflected in real-time
2 parents ad5f34f + 8ca8461 commit 8942e55

File tree

10 files changed

+974
-650
lines changed

10 files changed

+974
-650
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,11 @@ public ResourceDictionary GetResourceDictionary()
189189
new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
190190
=> Array.ForEach(setters, p => o.Setters.Add(p)));
191191
}
192-
192+
/* Ignore Theme Window Width and use setting */
193193
var windowStyle = dict["WindowStyle"] as Style;
194-
195-
var width = windowStyle?.Setters.OfType<Setter>().Where(x => x.Property.Name == "Width")
196-
.Select(x => x.Value).FirstOrDefault();
197-
198-
if (width == null)
199-
{
200-
windowStyle = dict["BaseWindowStyle"] as Style;
201-
202-
width = windowStyle?.Setters.OfType<Setter>().Where(x => x.Property.Name == "Width")
203-
.Select(x => x.Value).FirstOrDefault();
204-
}
205-
194+
var width = Settings.WindowSize;
195+
windowStyle.Setters.Add(new Setter(Window.WidthProperty, width));
206196
mainWindowWidth = (double)width;
207-
208197
return dict;
209198
}
210199

@@ -375,8 +364,6 @@ private void SetWindowAccent(Window w, AccentState state)
375364
{
376365
var windowHelper = new WindowInteropHelper(w);
377366

378-
// this determines the width of the main query window
379-
w.Width = mainWindowWidth;
380367
windowHelper.EnsureHandle();
381368

382369
var accent = new AccentPolicy { AccentState = state };

Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@
5050

5151
<ItemGroup>
5252
<PackageReference Include="Ben.Demystifier" Version="0.4.1" />
53+
<PackageReference Include="Fody" Version="6.5.5">
54+
<PrivateAssets>all</PrivateAssets>
55+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
56+
</PackageReference>
5357
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="16.10.56" />
5458
<PackageReference Include="NLog" Version="4.7.10" />
5559
<PackageReference Include="NLog.Schema" Version="4.7.10" />
5660
<PackageReference Include="NLog.Web.AspNetCore" Version="4.13.0" />
61+
<PackageReference Include="PropertyChanged.Fody" Version="3.4.0" />
5762
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
5863
<!--ToolGood.Words.Pinyin v3.0.2.6 results in high memory usage when search with pinyin is enabled-->
5964
<!--Bumping to it or higher needs to test and ensure this is no longer a problem-->

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
using System.Text.Json.Serialization;
55
using Flow.Launcher.Plugin;
66
using Flow.Launcher.Plugin.SharedModels;
7+
using Flow.Launcher;
78

89
namespace Flow.Launcher.Infrastructure.UserSettings
910
{
1011
public class Settings : BaseModel
1112
{
1213
private string language = "en";
13-
1414
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
1515
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
1616
public bool ShowOpenResultHotkey { get; set; } = true;
17+
public double WindowSize { get; set; } = 580;
18+
1719
public string Language
1820
{
19-
get => language; set
21+
get => language;
22+
set
2023
{
2124
language = value;
2225
OnPropertyChanged();
@@ -52,7 +55,7 @@ public string QuerySearchPrecisionString
5255
try
5356
{
5457
var precisionScore = (SearchPrecisionScore)Enum
55-
.Parse(typeof(SearchPrecisionScore), value);
58+
.Parse(typeof(SearchPrecisionScore), value);
5659

5760
QuerySearchPrecision = precisionScore;
5861
StringMatcher.Instance.UserSettingSearchPrecision = precisionScore;

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
9999
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
100100
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU. Not recommended if your computer performance is limited.</system:String>
101+
<system:String x:Key="windowWidthSize">Window Width Size</system:String>
101102
<system:String x:Key="useGlyphUI">Use Segoe Fluent Icons</system:String>
102103
<system:String x:Key="useGlyphUIEffect">Use Segoe Fluent Icons for query results where supported</system:String>
103104

Flow.Launcher/MainWindow.xaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
LocationChanged="OnLocationChanged"
2727
Deactivated="OnDeactivated"
2828
PreviewKeyDown="OnKeyDown"
29+
MinWidth="{Binding MainWindowWidth, Mode=OneWay}"
30+
MaxWidth="{Binding MainWindowWidth, Mode=OneWay}"
2931
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
3032
d:DataContext="{d:DesignInstance vm:MainViewModel}">
3133
<Window.Resources>
@@ -102,7 +104,25 @@
102104
</Grid>
103105

104106
<Grid ClipToBounds="True">
105-
<Rectangle Width="Auto" HorizontalAlignment="Stretch" Style="{DynamicResource SeparatorStyle}" />
107+
<ContentControl>
108+
<ContentControl.Style>
109+
<Style TargetType="ContentControl">
110+
<Setter Property="Visibility" Value="Collapsed" />
111+
<Style.Triggers>
112+
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Visible">
113+
<Setter Property="Visibility" Value="Visible" />
114+
</DataTrigger>
115+
<DataTrigger Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Visible">
116+
<Setter Property="Visibility" Value="Visible" />
117+
</DataTrigger>
118+
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}" Value="Visible">
119+
<Setter Property="Visibility" Value="Visible" />
120+
</DataTrigger>
121+
</Style.Triggers>
122+
</Style>
123+
</ContentControl.Style>
124+
<Rectangle Width="Auto" HorizontalAlignment="Stretch" Style="{DynamicResource SeparatorStyle}"/>
125+
</ContentControl>
106126
<Line x:Name="ProgressBar" HorizontalAlignment="Right"
107127
Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
108128
Y1="0" Y2="0" X1="-150" X2="-50" Height="2" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}},Path=ActualWidth}" StrokeThickness="1">

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
2121
using MessageBox = System.Windows.MessageBox;
2222
using NotifyIcon = System.Windows.Forms.NotifyIcon;
23+
using System.Windows.Interop;
2324

2425
namespace Flow.Launcher
2526
{

0 commit comments

Comments
 (0)