Skip to content

Commit 2b171f5

Browse files
committed
Merge Dev
2 parents f24d385 + 8942e55 commit 2b171f5

File tree

10 files changed

+100
-53
lines changed

10 files changed

+100
-53
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
{

Flow.Launcher/SettingWindow.xaml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,16 +1388,12 @@
13881388
TextAlignment="left" />
13891389
</Border>
13901390

1391-
<StackPanel
1392-
Grid.Row="1"
1393-
Margin="0"
1394-
Background="{Binding PreviewBackground}">
1395-
<StackPanel
1396-
Margin="0,30,0,0"
1397-
HorizontalAlignment="Center"
1398-
VerticalAlignment="Center"
1399-
Orientation="Horizontal">
1400-
<Border Width="500" Style="{DynamicResource WindowBorderStyle}">
1391+
<StackPanel Grid.Row="1" Margin="0" Background="{Binding PreviewBackground}">
1392+
<StackPanel Margin="0,30,0,0"
1393+
HorizontalAlignment="Center"
1394+
VerticalAlignment="Center"
1395+
Orientation="Horizontal">
1396+
<Border Width="{Binding WindowWidthSize}" Style="{DynamicResource WindowBorderStyle}">
14011397
<Border Style="{DynamicResource WindowRadius}">
14021398
<Border.Clip>
14031399
<MultiBinding Converter="{StaticResource BorderClipConverter}">
@@ -1468,6 +1464,36 @@
14681464
</TextBlock>
14691465
</ItemsControl>
14701466
</Border>
1467+
<Border Margin="0,12,0,0" Style="{DynamicResource SettingGroupBox}">
1468+
<ItemsControl Style="{StaticResource SettingGrid}">
1469+
<StackPanel Style="{StaticResource TextPanel}">
1470+
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource windowWidthSize}" />
1471+
</StackPanel>
1472+
<StackPanel Grid.Column="2" Orientation="Horizontal">
1473+
<TextBlock Width="100"
1474+
Margin="0,0,8,2"
1475+
VerticalAlignment="Center"
1476+
Text="{Binding ElementName=WindowWidthValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
1477+
TextAlignment="Right" />
1478+
<Slider Name="WindowWidthValue"
1479+
Width="300"
1480+
Margin="0,0,18,0"
1481+
IsMoveToPointEnabled="True"
1482+
IsSnapToTickEnabled="True"
1483+
Maximum="900"
1484+
Minimum="400"
1485+
TickFrequency="10"
1486+
Value="{Binding WindowWidthSize, Mode=TwoWay}" />
1487+
</StackPanel>
1488+
<TextBlock Grid.Column="0"
1489+
Margin="24,0,16,0"
1490+
VerticalAlignment="Center"
1491+
FontFamily="/Resources/#Segoe Fluent Icons"
1492+
FontSize="20">
1493+
&#xe740;
1494+
</TextBlock>
1495+
</ItemsControl>
1496+
</Border>
14711497
</StackPanel>
14721498

14731499
<StackPanel Grid.Row="3">

Flow.Launcher/Themes/Base.xaml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:system="clr-namespace:System;assembly=mscorlib">
3+
xmlns:system="clr-namespace:System;assembly=mscorlib"
4+
xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure">
45

56
<!-- Further font customisations are dynamically loaded in Theme.cs -->
67
<Style x:Key="BaseQueryBoxStyle" TargetType="{x:Type TextBox}">
@@ -54,7 +55,7 @@
5455
<Setter Property="CornerRadius" Value="5" />
5556
</Style>
5657
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
57-
<Setter Property="Width" Value="750" />
58+
<Setter Property="Width" Value="600" />
5859
<Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
5960
</Style>
6061

@@ -222,31 +223,16 @@
222223
</ControlTemplate>
223224
</Setter.Value>
224225
</Setter>
225-
226226
</Style>
227227
<Style x:Key="BaseSeparatorStyle" TargetType="Rectangle">
228-
<Setter Property="Visibility" Value="Collapsed" />
229-
<Style.Triggers>
230-
<DataTrigger Binding="{Binding ElementName=ResultListBox, Path=Visibility}" Value="Visible">
231-
<Setter Property="Visibility" Value="Visible" />
232-
</DataTrigger>
233-
<DataTrigger Binding="{Binding ElementName=ContextMenu, Path=Visibility}" Value="Visible">
234-
<Setter Property="Visibility" Value="Visible" />
235-
</DataTrigger>
236-
<DataTrigger Binding="{Binding ElementName=History, Path=Visibility}" Value="Visible">
237-
<Setter Property="Visibility" Value="Visible" />
238-
</DataTrigger>
239-
</Style.Triggers>
240228
</Style>
241229
<Style x:Key="HighlightStyle">
242230
<Setter Property="Inline.FontWeight" Value="Bold" />
243231
</Style>
244-
245232
<Style x:Key="BaseItemHotkeyStyle" TargetType="{x:Type TextBlock}">
246233
<Setter Property="FontSize" Value="15" />
247234
<Setter Property="Foreground" Value="#8f8f8f" />
248235
</Style>
249-
250236
<Style x:Key="BaseItemHotkeySelecetedStyle" TargetType="{x:Type TextBlock}">
251237
<Setter Property="FontSize" Value="15" />
252238
<Setter Property="Foreground" Value="#8f8f8f" />

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using ISavable = Flow.Launcher.Plugin.ISavable;
2323
using System.Windows.Threading;
2424
using NHotkey;
25+
using Windows.Web.Syndication;
2526

2627

2728
namespace Flow.Launcher.ViewModel
@@ -63,6 +64,13 @@ public MainViewModel(Settings settings)
6364
_lastQuery = new Query();
6465

6566
_settings = settings;
67+
_settings.PropertyChanged += (_, args) =>
68+
{
69+
if (args.PropertyName == nameof(Settings.WindowSize))
70+
{
71+
OnPropertyChanged(nameof(MainWindowWidth));
72+
}
73+
};
6674

6775
_historyItemsStorage = new FlowLauncherJsonStorage<History>();
6876
_userSelectedRecordStorage = new FlowLauncherJsonStorage<UserSelectedRecord>();
@@ -373,6 +381,8 @@ private ResultsViewModel SelectedResults
373381
public Visibility ProgressBarVisibility { get; set; }
374382
public Visibility MainWindowVisibility { get; set; }
375383

384+
public double MainWindowWidth => _settings.WindowSize;
385+
376386
public ICommand EscCommand { get; set; }
377387
public ICommand SelectNextItemCommand { get; set; }
378388
public ICommand SelectPrevItemCommand { get; set; }

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
3737
Settings = _storage.Load();
3838
Settings.PropertyChanged += (s, e) =>
3939
{
40-
if (e.PropertyName == nameof(Settings.ActivateTimes))
40+
switch (e.PropertyName)
4141
{
42-
OnPropertyChanged(nameof(ActivatedTimes));
42+
case nameof(Settings.ActivateTimes):
43+
OnPropertyChanged(nameof(ActivatedTimes));
44+
break;
4345
}
4446
};
4547
}
@@ -53,7 +55,7 @@ public async void UpdateApp()
5355

5456
public bool AutoUpdates
5557
{
56-
get { return Settings.AutoUpdates; }
58+
get => Settings.AutoUpdates;
5759
set
5860
{
5961
Settings.AutoUpdates = value;
@@ -67,7 +69,7 @@ public bool AutoUpdates
6769
private bool _portableMode = DataLocation.PortableDataLocationInUse();
6870
public bool PortableMode
6971
{
70-
get { return _portableMode; }
72+
get => _portableMode;
7173
set
7274
{
7375
if (!_portable.CanUpdatePortability())
@@ -314,10 +316,16 @@ public bool DropShadowEffect
314316
}
315317
}
316318

319+
public double WindowWidthSize
320+
{
321+
get => Settings.WindowSize;
322+
set => Settings.WindowSize = value;
323+
}
324+
317325
public bool UseGlyphIcons
318326
{
319-
get { return Settings.UseGlyphIcons; }
320-
set { Settings.UseGlyphIcons = value; }
327+
get => Settings.UseGlyphIcons;
328+
set => Settings.UseGlyphIcons = value;
321329
}
322330

323331
public Brush PreviewBackground

0 commit comments

Comments
 (0)