Merge pull request #1369 from onesounds/QuickSizeAdjust

Shortcuts to adjust width size, number of results shown and game mode
This commit is contained in:
Jeremy Wu 2022-10-17 18:41:55 +11:00 committed by GitHub
commit 35a5aec3d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 151 additions and 36 deletions

View file

@ -83,6 +83,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Fody" Version="6.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -114,4 +115,14 @@
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="taskkill /f /fi &quot;IMAGENAME eq Flow.Launcher.exe&quot;" />
</Target>
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
<!-- Work around https://github.com/dotnet/wpf/issues/6792 -->
<ItemGroup>
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
<Analyzer Remove="@(Analyzer)" />
<Analyzer Include="@(FilteredAnalyzer)" />
</ItemGroup>
</Target>
</Project>

View file

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

View file

@ -32,7 +32,9 @@
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
WindowStartupLocation="Manual"
WindowStyle="None"
mc:Ignorable="d">
mc:Ignorable="d"
Left="{Binding Left, Mode=TwoWay}"
Top="{Binding Top, Mode=TwoWay}">
<Window.Resources>
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
<converters:BorderClipConverter x:Key="BorderClipConverter" />
@ -84,6 +86,22 @@
Modifiers="Ctrl" />
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
<KeyBinding
Key="OemCloseBrackets"
Modifiers="Control"
Command="{Binding IncreaseWidthCommand}"/>
<KeyBinding
Key="OemOpenBrackets"
Modifiers="Control"
Command="{Binding DecreaseWidthCommand}"/>
<KeyBinding
Key="OemPlus"
Modifiers="Control"
Command="{Binding IncreaseMaxResultCommand}"/>
<KeyBinding
Key="OemMinus"
Modifiers="Control"
Command="{Binding DecreaseMaxResultCommand}"/>
<KeyBinding
Key="H"
Command="{Binding LoadHistoryCommand}"

View file

@ -46,7 +46,6 @@ namespace Flow.Launcher
_viewModel = mainVM;
_settings = settings;
InitializeComponent();
InitializePosition();
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
}
@ -91,6 +90,7 @@ namespace Flow.Launcher
InitializeColorScheme();
WindowsInteropHelper.DisableControlBox(this);
InitProgressbarAnimation();
InitializePosition();
// since the default main window visibility is visible
// so we need set focus during startup
QueryTextBox.Focus();
@ -180,20 +180,6 @@ namespace Flow.Launcher
};
}
private void InitializePosition()
{
if (_settings.RememberLastLaunchLocation)
{
Top = _settings.WindowTop;
Left = _settings.WindowLeft;
}
else
{
Left = WindowLeft();
Top = WindowTop();
}
}
private void UpdateNotifyIconText()
{
var menu = contextMenu;
@ -454,6 +440,15 @@ namespace Flow.Launcher
}
}
private void InitializePosition()
{
if (!_settings.RememberLastLaunchLocation)
{
Left = WindowLeft();
Top = WindowTop();
}
}
public double WindowLeft()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
@ -478,6 +473,7 @@ namespace Flow.Launcher
/// </summary>
private void OnKeyDown(object sender, KeyEventArgs e)
{
var specialKeyState = GlobalHotkey.CheckModifiers();
switch (e.Key)
{
case Key.Down:
@ -512,8 +508,13 @@ namespace Flow.Launcher
e.Handled = true;
}
break;
case Key.F12:
if (specialKeyState.CtrlPressed)
{
ToggleGameMode();
}
break;
case Key.Back:
var specialKeyState = GlobalHotkey.CheckModifiers();
if (specialKeyState.CtrlPressed)
{
if (_viewModel.SelectedIsFromQueryResults()

View file

@ -818,11 +818,13 @@
BorderThickness="0"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Style="{DynamicResource SettingTitleLabel}"
Text="{DynamicResource maxShowResults}" />
<StackPanel Grid.Column="1">
<TextBlock
VerticalAlignment="Center"
Style="{DynamicResource SettingTitleLabel}"
Text="{DynamicResource maxShowResults}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource maxShowResultsToolTip}" />
</StackPanel>
<ComboBox
Grid.Column="2"
Width="100"
@ -1815,6 +1817,7 @@
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource windowWidthSize}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource windowWidthSizeToolTip}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<TextBlock
@ -1828,6 +1831,7 @@
Name="WindowWidthValue"
Width="300"
Margin="0,0,18,0"
VerticalAlignment="Center"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="1920"

View file

@ -21,10 +21,11 @@ using System.Threading.Channels;
using ISavable = Flow.Launcher.Plugin.ISavable;
using System.IO;
using System.Collections.Specialized;
using CommunityToolkit.Mvvm.Input;
namespace Flow.Launcher.ViewModel
{
public class MainViewModel : BaseModel, ISavable
public partial class MainViewModel : BaseModel, ISavable
{
#region Private Fields
@ -82,6 +83,7 @@ namespace Flow.Launcher.ViewModel
_selectedResults = Results;
InitializeKeyCommands();
RegisterViewUpdate();
RegisterResultsUpdatedEvent();
@ -154,6 +156,8 @@ namespace Flow.Launcher.ViewModel
}
}
private void InitializeKeyCommands()
{
EscCommand = new RelayCommand(_ =>
@ -307,7 +311,7 @@ namespace Flow.Launcher.ViewModel
Notification.Show(
InternationalizationManager.Instance.GetTranslation("success"),
InternationalizationManager.Instance.GetTranslation("completedSuccessfully")
);
);
}), TaskScheduler.Default)
.ConfigureAwait(false);
});
@ -318,9 +322,9 @@ namespace Flow.Launcher.ViewModel
#region ViewModel Properties
public ResultsViewModel Results { get; private set; }
public ResultsViewModel ContextMenu { get; private set; }
public ResultsViewModel History { get; private set; }
public bool GameModeStatus { get; set; }
@ -336,6 +340,74 @@ namespace Flow.Launcher.ViewModel
}
}
public double Top
{
get => _settings.WindowTop;
set
{
_settings.WindowTop = value;
OnPropertyChanged();
}
}
public double Left
{
get => _settings.WindowLeft;
set
{
_settings.WindowLeft = value;
OnPropertyChanged();
}
}
[RelayCommand]
private void IncreaseWidth()
{
if (MainWindowWidth + 100 > 1920 || _settings.WindowSize == 1920)
{
_settings.WindowSize = 1920;
}
else
{
_settings.WindowSize += 100;
Left -= 50;
}
OnPropertyChanged();
}
[RelayCommand]
private void DecreaseWidth()
{
if (MainWindowWidth - 100 < 400 || _settings.WindowSize == 400)
{
_settings.WindowSize = 400;
}
else
{
Left += 50;
_settings.WindowSize -= 100;
}
OnPropertyChanged();
}
[RelayCommand]
private void IncreaseMaxResult()
{
if (_settings.MaxResultsToShow == 17)
return;
_settings.MaxResultsToShow += 1;
}
[RelayCommand]
private void DecreaseMaxResult()
{
if (_settings.MaxResultsToShow == 2)
return;
_settings.MaxResultsToShow -= 1;
}
/// <summary>
/// we need move cursor to end when we manually changed query
/// but we don't want to move cursor to end when query is updated from TextBox
@ -411,7 +483,11 @@ namespace Flow.Launcher.ViewModel
public Visibility SearchIconVisibility { get; set; }
public double MainWindowWidth => _settings.WindowSize;
public double MainWindowWidth
{
get => _settings.WindowSize;
set => _settings.WindowSize = value;
}
public string PluginIconPath { get; set; } = null;
@ -592,7 +668,7 @@ namespace Flow.Launcher.ViewModel
PluginIconPath = null;
SearchIconVisibility = Visibility.Visible;
}
if (query.ActionKeyword == Plugin.Query.GlobalPluginWildcardSign)
{
@ -903,18 +979,18 @@ namespace Flow.Launcher.ViewModel
Clipboard.SetFileDropList(paths);
App.API.ShowMsg(
App.API.GetTranslation("copy")
+" "
+ (isFile? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle")),
App.API.GetTranslation("copy")
+ " "
+ (isFile ? App.API.GetTranslation("fileTitle") : App.API.GetTranslation("folderTitle")),
App.API.GetTranslation("completedSuccessfully"));
}
else
{
Clipboard.SetDataObject(copyText.ToString());
App.API.ShowMsg(
App.API.GetTranslation("copy")
+ " "
+ App.API.GetTranslation("textTitle"),
App.API.GetTranslation("copy")
+ " "
+ App.API.GetTranslation("textTitle"),
App.API.GetTranslation("completedSuccessfully"));
}
}

View file

@ -41,6 +41,9 @@ namespace Flow.Launcher.ViewModel
case nameof(Settings.ActivateTimes):
OnPropertyChanged(nameof(ActivatedTimes));
break;
case nameof(Settings.WindowSize):
OnPropertyChanged(nameof(WindowWidthSize));
break;
}
};
}

View file

@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"rollForward": "latestFeature"
"version": "6.0.*",
"rollForward": "latestPatch"
}
}