Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
516dd25
Initial
Garulf Dec 1, 2021
b520d66
add check for no history
jjw24 Dec 4, 2021
4f3ed19
Cycle through entire history
Garulf Dec 11, 2021
82baf1e
Merge branch 'dev' into Up-arrow-cycles-history
Garulf Dec 11, 2021
53f05f4
Fix condiitonal
Garulf Dec 11, 2021
76c410a
Explicitly that result is not history or context items
Garulf Dec 11, 2021
747abac
reset history index on hide
Garulf Dec 11, 2021
54821ff
shell like keybind
Garulf Dec 11, 2021
9a36c87
Better variable naming
Garulf Dec 12, 2021
cab0296
Dont reset history index when selection changes
Garulf Dec 12, 2021
0729899
cycle with alt modifer and empty query
Garulf Dec 13, 2021
387698b
Dont insert history if in history/context menus
Garulf Dec 13, 2021
8775dc8
Fix cycling
Garulf Dec 13, 2021
2ece980
Move history index
Garulf Dec 13, 2021
9141fbf
Remove unused function
Garulf Dec 13, 2021
d74878c
set to correct index
Garulf Dec 13, 2021
1ec7867
Add modifiers to settings
Garulf Dec 13, 2021
1312fda
Remove setings from general
Garulf Dec 14, 2021
70b0a54
Add modifiers to Hotkey Tab in settings
onesounds Dec 15, 2021
3578435
add check against empty history items
jjw24 Dec 21, 2021
aecb105
Update Flow.Launcher/ViewModel/MainViewModel.cs
Garulf Dec 21, 2021
302a8b8
Use more descriptive function name
Garulf Dec 22, 2021
7897d4a
Remove underscore from var name
Garulf Dec 22, 2021
a9878c9
Update changed function name
Garulf Dec 22, 2021
c8b1c31
Check history count before changing index
Garulf Dec 22, 2021
8b39a83
Increase index instead of explicitly defining
Garulf Dec 22, 2021
e67afcb
Reset index on cleared query
Garulf Dec 22, 2021
c6d5525
Use predefined function
Garulf Dec 22, 2021
47117a4
Merge branch 'dev' into Up-arrow-cycles-history
Garulf Jan 25, 2022
43b2272
Remove modifier option from settings GUI
Garulf Jan 25, 2022
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
1 change: 1 addition & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Settings : BaseModel
private string language = "en";
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
public string CycleHistoryModifiers { get; set; } = KeyConstant.Alt;
public string ColorScheme { get; set; } = "System";
public bool ShowOpenResultHotkey { get; set; } = true;
public double WindowSize { get; set; } = 580;
Expand Down
2 changes: 2 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
<system:String x:Key="openResultModifiersToolTip">Select a modifier key to open selected result via keyboard.</system:String>
<system:String x:Key="showOpenResultHotkey">Show Hotkey</system:String>
<system:String x:Key="showOpenResultHotkeyToolTip">Show result selection hotkey with results.</system:String>
<system:String x:Key="cycleHistoryModifierHotkey">Cycle History Modifiers</system:String>
<system:String x:Key="cycleHistoryModifierHotkeyTooltip">You can switch to the previously entered query using up, down + modifier.</system:String>
<system:String x:Key="customQueryHotkey">Custom Query Hotkey</system:String>
<system:String x:Key="customQuery">Query</system:String>
<system:String x:Key="delete">Delete</system:String>
Expand Down
6 changes: 6 additions & 0 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@
Modifiers="Ctrl" />
<KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}" />
<KeyBinding Key="Left" Command="{Binding EscCommand}" />
<KeyBinding Key="Up" Command="{Binding ReverseHistory}" Modifiers="{Binding CycleHistoryModifiers}" />
<KeyBinding Key="Down" Command="{Binding ForwardHistory}" Modifiers="{Binding CycleHistoryModifiers}" />
<KeyBinding
Key="H"
Command="{Binding LoadHistoryCommand}"
Modifiers="Ctrl" />
<KeyBinding
Key="R"
Command="{Binding LoadHistoryCommand}"
Modifiers="Ctrl" />
<KeyBinding
Key="Enter"
Command="{Binding OpenResultCommand}"
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ private void OnKeyDown(object sender, KeyEventArgs e)
e.Handled = true;
break;
case Key.Up:
_viewModel.SelectPrevItemCommand.Execute(null);
_viewModel.ReverseHistoryOnEmptyQuery.Execute(null);
e.Handled = true;
break;
case Key.PageDown:
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,6 @@
</ItemsControl>
</Border>


<Border Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
Expand Down Expand Up @@ -2097,6 +2096,7 @@
Style="{DynamicResource SideControlCheckBox}" />
</ItemsControl>
</Border>

</StackPanel>
</Border>

Expand Down
59 changes: 58 additions & 1 deletion Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class MainViewModel : BaseModel, ISavable
#region Private Fields

private const string DefaultOpenResultModifiers = "Alt";
private const string DefaultCycleHistoryModifiers = "Alt";

private bool _isQueryRunning;
private Query _lastQuery;
Expand All @@ -37,6 +38,7 @@ public class MainViewModel : BaseModel, ISavable
private readonly FlowLauncherJsonStorage<TopMostRecord> _topMostRecordStorage;
internal readonly Settings _settings;
private readonly History _history;
private int lasthistoryindex = 1;
private readonly UserSelectedRecord _userSelectedRecord;
private readonly TopMostRecord _topMostRecord;

Expand Down Expand Up @@ -84,6 +86,7 @@ public MainViewModel(Settings settings)
RegisterResultsUpdatedEvent();

SetOpenResultModifiers();
SetCycleHistoryModifiers();
}

private void RegisterViewUpdate()
Expand Down Expand Up @@ -187,6 +190,50 @@ private void InitializeKeyCommands()

SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult());

ReverseHistory = new RelayCommand(_ => {

if (_history.Items.Count > 0)
{
ChangeQueryText(_history.Items[_history.Items.Count - lasthistoryindex].Query.ToString());

if (lasthistoryindex < _history.Items.Count)
{
lasthistoryindex++;
}
}
});

ForwardHistory = new RelayCommand(_ => {

if (_history.Items.Count > 0)
{
ChangeQueryText(_history.Items[_history.Items.Count - lasthistoryindex].Query.ToString());

if (lasthistoryindex > 1)
{
lasthistoryindex--;
}
}

});

ReverseHistoryOnEmptyQuery = new RelayCommand(_ => {
var results = SelectedResults;

if (_history.Items.Count > 0
&& _queryText == String.Empty
&& !HistorySelected()
&& !ContextMenuSelected())
{
ReverseHistory.Execute(null);
}
else
{
SelectPrevItemCommand.Execute(null);
}

});

StartHelpCommand = new RelayCommand(_ =>
{
PluginManager.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/");
Expand Down Expand Up @@ -424,8 +471,12 @@ private ResultsViewModel SelectedResults
public ICommand ReloadPluginDataCommand { get; set; }
public ICommand ClearQueryCommand { get; private set; }
public ICommand AutocompleteQueryCommand { get; set; }
public ICommand ReverseHistory { get; set; }
public ICommand ForwardHistory { get; set; }
public ICommand ReverseHistoryOnEmptyQuery { get; set; }

public string OpenResultCommandModifiers { get; private set; }
public string CycleHistoryModifiers { get; private set; }

public string Image => Constant.QueryTextBoxIconImagePath;

Expand Down Expand Up @@ -543,6 +594,7 @@ private async void QueryResults()
{
Results.Clear();
Results.Visbility = Visibility.Collapsed;
lasthistoryindex = 1;
PluginIconPath = null;
SearchIconVisibility = Visibility.Visible;
return;
Expand Down Expand Up @@ -753,6 +805,11 @@ private void SetOpenResultModifiers()
OpenResultCommandModifiers = _settings.OpenResultModifiers ?? DefaultOpenResultModifiers;
}

private void SetCycleHistoryModifiers()
{
CycleHistoryModifiers = _settings.CycleHistoryModifiers ?? DefaultCycleHistoryModifiers;
}

public void ToggleFlowLauncher()
{
if (!MainWindowVisibilityStatus)
Expand Down Expand Up @@ -798,7 +855,7 @@ public async void Hide()
default:
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
}

lasthistoryindex = 1;
MainWindowVisibilityStatus = false;
MainWindowVisibility = Visibility.Collapsed;
}
Expand Down
1 change: 1 addition & 0 deletions Flow.Launcher/ViewModel/SettingWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public List<string> QuerySearchPrecisionStrings
}

public List<string> OpenResultModifiersList => new List<string> { KeyConstant.Alt, KeyConstant.Ctrl, $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" };
public List<string> CycleHistoryModifiersList => new List<string> { KeyConstant.Alt, KeyConstant.Ctrl, $"{KeyConstant.Ctrl}+{KeyConstant.Alt}" };
private Internationalization _translater => InternationalizationManager.Instance;
public List<Language> Languages => _translater.LoadAvailableLanguages();
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
Expand Down