Skip to content

Commit 35a5aec

Browse files
authored
Merge pull request #1369 from onesounds/QuickSizeAdjust
Shortcuts to adjust width size, number of results shown and game mode
2 parents caa2c75 + 6592de9 commit 35a5aec

File tree

8 files changed

+151
-36
lines changed

8 files changed

+151
-36
lines changed

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
</ItemGroup>
8484

8585
<ItemGroup>
86+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
8687
<PackageReference Include="Fody" Version="6.5.4">
8788
<PrivateAssets>all</PrivateAssets>
8889
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -114,4 +115,14 @@
114115
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
115116
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
116117
</Target>
118+
119+
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
120+
<!-- Work around https://github.com/dotnet/wpf/issues/6792 -->
121+
122+
<ItemGroup>
123+
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
124+
<Analyzer Remove="@(Analyzer)" />
125+
<Analyzer Include="@(FilteredAnalyzer)" />
126+
</ItemGroup>
127+
</Target>
117128
</Project>

Flow.Launcher/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<system:String x:Key="LastQuerySelected">Select last Query</system:String>
4242
<system:String x:Key="LastQueryEmpty">Empty last Query</system:String>
4343
<system:String x:Key="maxShowResults">Maximum results shown</system:String>
44+
<system:String x:Key="maxShowResultsToolTip">You can also quickly adjust this by using CTRL+Plus and CTRL+Minus.</system:String>
4445
<system:String x:Key="ignoreHotkeysOnFullscreen">Ignore hotkeys in fullscreen mode</system:String>
4546
<system:String x:Key="ignoreHotkeysOnFullscreenToolTip">Disable Flow Launcher activation when a full screen application is active (Recommended for games).</system:String>
4647
<system:String x:Key="defaultFileManager">Default File Manager</system:String>
@@ -131,6 +132,7 @@
131132
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
132133
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU. Not recommended if your computer performance is limited.</system:String>
133134
<system:String x:Key="windowWidthSize">Window Width Size</system:String>
135+
<system:String x:Key="windowWidthSizeToolTip">You can also quickly adjust this by using Ctrl+[ and Ctrl+].</system:String>
134136
<system:String x:Key="useGlyphUI">Use Segoe Fluent Icons</system:String>
135137
<system:String x:Key="useGlyphUIEffect">Use Segoe Fluent Icons for query results where supported</system:String>
136138

Flow.Launcher/MainWindow.xaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
3333
WindowStartupLocation="Manual"
3434
WindowStyle="None"
35-
mc:Ignorable="d">
35+
mc:Ignorable="d"
36+
Left="{Binding Left, Mode=TwoWay}"
37+
Top="{Binding Top, Mode=TwoWay}">
3638
<Window.Resources>
3739
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
3840
<converters:BorderClipConverter x:Key="BorderClipConverter" />
@@ -84,6 +86,22 @@
8486
Modifiers="Ctrl" />
8587
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
8688
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
89+
<KeyBinding
90+
Key="OemCloseBrackets"
91+
Modifiers="Control"
92+
Command="{Binding IncreaseWidthCommand}"/>
93+
<KeyBinding
94+
Key="OemOpenBrackets"
95+
Modifiers="Control"
96+
Command="{Binding DecreaseWidthCommand}"/>
97+
<KeyBinding
98+
Key="OemPlus"
99+
Modifiers="Control"
100+
Command="{Binding IncreaseMaxResultCommand}"/>
101+
<KeyBinding
102+
Key="OemMinus"
103+
Modifiers="Control"
104+
Command="{Binding DecreaseMaxResultCommand}"/>
87105
<KeyBinding
88106
Key="H"
89107
Command="{Binding LoadHistoryCommand}"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public MainWindow(Settings settings, MainViewModel mainVM)
4646
_viewModel = mainVM;
4747
_settings = settings;
4848
InitializeComponent();
49-
InitializePosition();
5049
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
5150
}
5251

@@ -91,6 +90,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
9190
InitializeColorScheme();
9291
WindowsInteropHelper.DisableControlBox(this);
9392
InitProgressbarAnimation();
93+
InitializePosition();
9494
// since the default main window visibility is visible
9595
// so we need set focus during startup
9696
QueryTextBox.Focus();
@@ -180,20 +180,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
180180
};
181181
}
182182

183-
private void InitializePosition()
184-
{
185-
if (_settings.RememberLastLaunchLocation)
186-
{
187-
Top = _settings.WindowTop;
188-
Left = _settings.WindowLeft;
189-
}
190-
else
191-
{
192-
Left = WindowLeft();
193-
Top = WindowTop();
194-
}
195-
}
196-
197183
private void UpdateNotifyIconText()
198184
{
199185
var menu = contextMenu;
@@ -454,6 +440,15 @@ public void HideStartup()
454440
}
455441
}
456442

443+
private void InitializePosition()
444+
{
445+
if (!_settings.RememberLastLaunchLocation)
446+
{
447+
Left = WindowLeft();
448+
Top = WindowTop();
449+
}
450+
}
451+
457452
public double WindowLeft()
458453
{
459454
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
@@ -478,6 +473,7 @@ public double WindowTop()
478473
/// </summary>
479474
private void OnKeyDown(object sender, KeyEventArgs e)
480475
{
476+
var specialKeyState = GlobalHotkey.CheckModifiers();
481477
switch (e.Key)
482478
{
483479
case Key.Down:
@@ -512,8 +508,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
512508
e.Handled = true;
513509
}
514510
break;
511+
case Key.F12:
512+
if (specialKeyState.CtrlPressed)
513+
{
514+
ToggleGameMode();
515+
}
516+
break;
515517
case Key.Back:
516-
var specialKeyState = GlobalHotkey.CheckModifiers();
517518
if (specialKeyState.CtrlPressed)
518519
{
519520
if (_viewModel.SelectedIsFromQueryResults()

Flow.Launcher/SettingWindow.xaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -818,11 +818,13 @@
818818
BorderThickness="0"
819819
Style="{DynamicResource SettingGroupBox}">
820820
<ItemsControl Style="{StaticResource SettingGrid}">
821-
<TextBlock
822-
Grid.Column="1"
823-
VerticalAlignment="Center"
824-
Style="{DynamicResource SettingTitleLabel}"
825-
Text="{DynamicResource maxShowResults}" />
821+
<StackPanel Grid.Column="1">
822+
<TextBlock
823+
VerticalAlignment="Center"
824+
Style="{DynamicResource SettingTitleLabel}"
825+
Text="{DynamicResource maxShowResults}" />
826+
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource maxShowResultsToolTip}" />
827+
</StackPanel>
826828
<ComboBox
827829
Grid.Column="2"
828830
Width="100"
@@ -1815,6 +1817,7 @@
18151817
<ItemsControl Style="{StaticResource SettingGrid}">
18161818
<StackPanel Style="{StaticResource TextPanel}">
18171819
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource windowWidthSize}" />
1820+
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource windowWidthSizeToolTip}" />
18181821
</StackPanel>
18191822
<StackPanel Grid.Column="2" Orientation="Horizontal">
18201823
<TextBlock
@@ -1828,6 +1831,7 @@
18281831
Name="WindowWidthValue"
18291832
Width="300"
18301833
Margin="0,0,18,0"
1834+
VerticalAlignment="Center"
18311835
IsMoveToPointEnabled="True"
18321836
IsSnapToTickEnabled="True"
18331837
Maximum="1920"

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
using ISavable = Flow.Launcher.Plugin.ISavable;
2222
using System.IO;
2323
using System.Collections.Specialized;
24+
using CommunityToolkit.Mvvm.Input;
2425

2526
namespace Flow.Launcher.ViewModel
2627
{
27-
public class MainViewModel : BaseModel, ISavable
28+
public partial class MainViewModel : BaseModel, ISavable
2829
{
2930
#region Private Fields
3031

@@ -82,6 +83,7 @@ public MainViewModel(Settings settings)
8283
_selectedResults = Results;
8384

8485
InitializeKeyCommands();
86+
8587
RegisterViewUpdate();
8688
RegisterResultsUpdatedEvent();
8789

@@ -154,6 +156,8 @@ private void RegisterResultsUpdatedEvent()
154156
}
155157
}
156158

159+
160+
157161
private void InitializeKeyCommands()
158162
{
159163
EscCommand = new RelayCommand(_ =>
@@ -307,7 +311,7 @@ private void InitializeKeyCommands()
307311
Notification.Show(
308312
InternationalizationManager.Instance.GetTranslation("success"),
309313
InternationalizationManager.Instance.GetTranslation("completedSuccessfully")
310-
);
314+
);
311315
}), TaskScheduler.Default)
312316
.ConfigureAwait(false);
313317
});
@@ -318,9 +322,9 @@ private void InitializeKeyCommands()
318322
#region ViewModel Properties
319323

320324
public ResultsViewModel Results { get; private set; }
321-
325+
322326
public ResultsViewModel ContextMenu { get; private set; }
323-
327+
324328
public ResultsViewModel History { get; private set; }
325329

326330
public bool GameModeStatus { get; set; }
@@ -336,6 +340,74 @@ public string QueryText
336340
}
337341
}
338342

343+
344+
public double Top
345+
{
346+
get => _settings.WindowTop;
347+
set
348+
{
349+
_settings.WindowTop = value;
350+
OnPropertyChanged();
351+
}
352+
}
353+
public double Left
354+
{
355+
get => _settings.WindowLeft;
356+
set
357+
{
358+
_settings.WindowLeft = value;
359+
OnPropertyChanged();
360+
}
361+
}
362+
363+
[RelayCommand]
364+
private void IncreaseWidth()
365+
{
366+
if (MainWindowWidth + 100 > 1920 || _settings.WindowSize == 1920)
367+
{
368+
_settings.WindowSize = 1920;
369+
}
370+
else
371+
{
372+
_settings.WindowSize += 100;
373+
Left -= 50;
374+
}
375+
OnPropertyChanged();
376+
}
377+
378+
[RelayCommand]
379+
private void DecreaseWidth()
380+
{
381+
if (MainWindowWidth - 100 < 400 || _settings.WindowSize == 400)
382+
{
383+
_settings.WindowSize = 400;
384+
}
385+
else
386+
{
387+
Left += 50;
388+
_settings.WindowSize -= 100;
389+
}
390+
OnPropertyChanged();
391+
}
392+
393+
[RelayCommand]
394+
private void IncreaseMaxResult()
395+
{
396+
if (_settings.MaxResultsToShow == 17)
397+
return;
398+
399+
_settings.MaxResultsToShow += 1;
400+
}
401+
402+
[RelayCommand]
403+
private void DecreaseMaxResult()
404+
{
405+
if (_settings.MaxResultsToShow == 2)
406+
return;
407+
408+
_settings.MaxResultsToShow -= 1;
409+
}
410+
339411
/// <summary>
340412
/// we need move cursor to end when we manually changed query
341413
/// but we don't want to move cursor to end when query is updated from TextBox
@@ -411,7 +483,11 @@ private ResultsViewModel SelectedResults
411483

412484
public Visibility SearchIconVisibility { get; set; }
413485

414-
public double MainWindowWidth => _settings.WindowSize;
486+
public double MainWindowWidth
487+
{
488+
get => _settings.WindowSize;
489+
set => _settings.WindowSize = value;
490+
}
415491

416492
public string PluginIconPath { get; set; } = null;
417493

@@ -592,7 +668,7 @@ private async void QueryResults()
592668
PluginIconPath = null;
593669
SearchIconVisibility = Visibility.Visible;
594670
}
595-
671+
596672

597673
if (query.ActionKeyword == Plugin.Query.GlobalPluginWildcardSign)
598674
{
@@ -903,18 +979,18 @@ public void ResultCopy(string stringToCopy)
903979

904980
Clipboard.SetFileDropList(paths);
905981
App.API.ShowMsg(
906-
App.API.GetTranslation("copy")
907-
+" "
908-
+ (isFile? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle")),
982+
App.API.GetTranslation("copy")
983+
+ " "
984+
+ (isFile ? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle")),
909985
App.API.GetTranslation("completedSuccessfully"));
910986
}
911987
else
912988
{
913989
Clipboard.SetDataObject(copyText.ToString());
914990
App.API.ShowMsg(
915-
App.API.GetTranslation("copy")
916-
+ " "
917-
+ App.API.GetTranslation("textTitle"),
991+
App.API.GetTranslation("copy")
992+
+ " "
993+
+ App.API.GetTranslation("textTitle"),
918994
App.API.GetTranslation("completedSuccessfully"));
919995
}
920996
}

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
4141
case nameof(Settings.ActivateTimes):
4242
OnPropertyChanged(nameof(ActivatedTimes));
4343
break;
44+
case nameof(Settings.WindowSize):
45+
OnPropertyChanged(nameof(WindowWidthSize));
46+
break;
4447
}
4548
};
4649
}

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.100",
4-
"rollForward": "latestFeature"
3+
"version": "6.0.*",
4+
"rollForward": "latestPatch"
55
}
66
}

0 commit comments

Comments
 (0)