Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Flow.Launcher/Flow.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Comment on lines +118 to +127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taooceros What's this change for us specifically?

</Project>
2 changes: 2 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>

Expand Down
20 changes: 19 additions & 1 deletion Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down Expand Up @@ -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}"
Expand Down
33 changes: 17 additions & 16 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public MainWindow(Settings settings, MainViewModel mainVM)
_viewModel = mainVM;
_settings = settings;
InitializeComponent();
InitializePosition();
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
}

Expand Down Expand Up @@ -91,6 +90,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
InitializeColorScheme();
WindowsInteropHelper.DisableControlBox(this);
InitProgressbarAnimation();
InitializePosition();
// since the default main window visibility is visible
// so we need set focus during startup
QueryTextBox.Focus();
Expand Down Expand Up @@ -180,20 +180,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
};
}

private void InitializePosition()
{
if (_settings.RememberLastLaunchLocation)
{
Top = _settings.WindowTop;
Left = _settings.WindowLeft;
}
else
{
Left = WindowLeft();
Top = WindowTop();
}
}

private void UpdateNotifyIconText()
{
var menu = contextMenu;
Expand Down Expand Up @@ -454,6 +440,15 @@ public void HideStartup()
}
}

private void InitializePosition()
{
if (!_settings.RememberLastLaunchLocation)
{
Left = WindowLeft();
Top = WindowTop();
}
}

public double WindowLeft()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
Expand All @@ -478,6 +473,7 @@ public double WindowTop()
/// </summary>
private void OnKeyDown(object sender, KeyEventArgs e)
{
var specialKeyState = GlobalHotkey.CheckModifiers();
switch (e.Key)
{
case Key.Down:
Expand Down Expand Up @@ -512,8 +508,13 @@ private void OnKeyDown(object sender, KeyEventArgs e)
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()
Expand Down
14 changes: 9 additions & 5 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -1828,6 +1831,7 @@
Name="WindowWidthValue"
Width="300"
Margin="0,0,18,0"
VerticalAlignment="Center"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="1920"
Expand Down
100 changes: 88 additions & 12 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taooceros why is this changed to partial class?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I would like to use the mvvm toolkit to simplify the code of creating RelayCommand, which requires partial to generate additional code.

{
#region Private Fields

Expand Down Expand Up @@ -82,6 +83,7 @@ public MainViewModel(Settings settings)
_selectedResults = Results;

InitializeKeyCommands();

RegisterViewUpdate();
RegisterResultsUpdatedEvent();

Expand Down Expand Up @@ -154,6 +156,8 @@ private void RegisterResultsUpdatedEvent()
}
}



private void InitializeKeyCommands()
{
EscCommand = new RelayCommand(_ =>
Expand Down Expand Up @@ -307,7 +311,7 @@ private void InitializeKeyCommands()
Notification.Show(
InternationalizationManager.Instance.GetTranslation("success"),
InternationalizationManager.Instance.GetTranslation("completedSuccessfully")
);
);
}), TaskScheduler.Default)
.ConfigureAwait(false);
});
Expand All @@ -318,9 +322,9 @@ private void InitializeKeyCommands()
#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; }
Expand All @@ -336,6 +340,74 @@ public string QueryText
}
}


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
Expand Down Expand Up @@ -411,7 +483,11 @@ private ResultsViewModel SelectedResults

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;

Expand Down Expand Up @@ -592,7 +668,7 @@ private async void QueryResults()
PluginIconPath = null;
SearchIconVisibility = Visibility.Visible;
}


if (query.ActionKeyword == Plugin.Query.GlobalPluginWildcardSign)
{
Expand Down Expand Up @@ -903,18 +979,18 @@ public void ResultCopy(string stringToCopy)

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"));
}
}
Expand Down
3 changes: 3 additions & 0 deletions Flow.Launcher/ViewModel/SettingWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
case nameof(Settings.ActivateTimes):
OnPropertyChanged(nameof(ActivatedTimes));
break;
case nameof(Settings.WindowSize):
OnPropertyChanged(nameof(WindowWidthSize));
break;
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"rollForward": "latestFeature"
"version": "6.0.*",
"rollForward": "latestPatch"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taooceros what's this change for?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it shouldn't be there (I am testing different version of dotnet and see which one can help with the bug. However it is not needed because workaround is found)...Though it makes sense to apply the latest patch since that generally includes some security fixes.

}
}