mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Start working on handling duplicate hotkeys
This commit is contained in:
parent
4ce591fa20
commit
de8036bdba
3 changed files with 67 additions and 20 deletions
|
|
@ -82,7 +82,8 @@
|
||||||
<Border
|
<Border
|
||||||
x:Name="Alert"
|
x:Name="Alert"
|
||||||
Width="420"
|
Width="420"
|
||||||
Height="50"
|
Padding="0, 10"
|
||||||
|
VerticalAlignment="Center"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Background="{DynamicResource InfoBarWarningBG}"
|
Background="{DynamicResource InfoBarWarningBG}"
|
||||||
BorderBrush="{DynamicResource InfoBarBD}"
|
BorderBrush="{DynamicResource InfoBarBD}"
|
||||||
|
|
@ -90,21 +91,26 @@
|
||||||
CornerRadius="5"
|
CornerRadius="5"
|
||||||
Visibility="Collapsed">
|
Visibility="Collapsed">
|
||||||
<Grid VerticalAlignment="Center">
|
<Grid VerticalAlignment="Center">
|
||||||
<StackPanel Orientation="Horizontal">
|
<Grid.ColumnDefinitions>
|
||||||
<ui:FontIcon
|
<ColumnDefinition Width="Auto" />
|
||||||
Margin="20,0,14,0"
|
<ColumnDefinition Width="*" />
|
||||||
VerticalAlignment="Center"
|
</Grid.ColumnDefinitions>
|
||||||
FontSize="15"
|
<ui:FontIcon
|
||||||
Foreground="{DynamicResource InfoBarWarningIcon}"
|
Grid.Column="0"
|
||||||
Glyph="" />
|
Margin="20,0,14,0"
|
||||||
<TextBlock
|
VerticalAlignment="Center"
|
||||||
x:Name="tbMsg"
|
FontSize="15"
|
||||||
Margin="0,0,0,2"
|
Foreground="{DynamicResource InfoBarWarningIcon}"
|
||||||
HorizontalAlignment="Left"
|
Glyph="" />
|
||||||
FontSize="13"
|
<TextBlock
|
||||||
FontWeight="SemiBold"
|
Grid.Column="1"
|
||||||
Foreground="{DynamicResource Color05B}" />
|
x:Name="tbMsg"
|
||||||
</StackPanel>
|
Margin="0,0,0,2"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
FontSize="13"
|
||||||
|
FontWeight="SemiBold"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Foreground="{DynamicResource Color05B}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Flow.Launcher.Core.Resource;
|
using Flow.Launcher.Core.Resource;
|
||||||
|
|
@ -16,6 +17,28 @@ public partial class HotkeyControlDialog : ContentDialog
|
||||||
public HotkeyModel CurrentHotkey { get; private set; }
|
public HotkeyModel CurrentHotkey { get; private set; }
|
||||||
public ObservableCollection<string> KeysToDisplay { get; } = new();
|
public ObservableCollection<string> KeysToDisplay { get; } = new();
|
||||||
|
|
||||||
|
private readonly Dictionary<HotkeyModel, string> StaticHotkeys = new()
|
||||||
|
{
|
||||||
|
[new HotkeyModel("Escape")] = "", // TODO
|
||||||
|
[new HotkeyModel("F5")] = "ReloadPluginHotkey",
|
||||||
|
[new HotkeyModel("Alt+Home")] = "Select first result", // TODO
|
||||||
|
[new HotkeyModel("Alt+End")] = "Select last result", // TODO
|
||||||
|
[new HotkeyModel("Ctrl+R")] = "Requery", // TODO
|
||||||
|
[new HotkeyModel("Ctrl+H")] = "ToggleHistoryHotkey",
|
||||||
|
[new HotkeyModel("Ctrl+OemCloseBrackets")] = "QuickWidthHotkey",
|
||||||
|
[new HotkeyModel("Ctrl+OemOpenBrackets")] = "QuickWidthHotkey",
|
||||||
|
[new HotkeyModel("Ctrl+OemPlus")] = "QuickHeightHotkey",
|
||||||
|
[new HotkeyModel("Ctrl+OemMinus")] = "QuickHeightHotkey",
|
||||||
|
[new HotkeyModel("Ctrl+Shift+Enter")] = "HotkeyCtrlShiftEnterDesc",
|
||||||
|
[new HotkeyModel("Shift+Enter")] = "OpenContextMenuHotkey",
|
||||||
|
[new HotkeyModel("Enter")] = "HotkeyRunDesc",
|
||||||
|
[new HotkeyModel("Ctrl+Enter")] = "Open result", // TODO
|
||||||
|
[new HotkeyModel("Alt+Enter")] = "Open result", // TODO
|
||||||
|
// TODO D0-D9 But not here since they're not completely static, they can be Ctrl+D0-D9, Alt+D0-D9, or Ctrl+Alt+D0-D9
|
||||||
|
[new HotkeyModel("Ctrl+F12")] = "ToggleGameModeHotkey",
|
||||||
|
[new HotkeyModel("Ctrl+Shift+C")] = "Copy alternative", // TODO
|
||||||
|
};
|
||||||
|
|
||||||
public enum EResultType
|
public enum EResultType
|
||||||
{
|
{
|
||||||
Cancel,
|
Cancel,
|
||||||
|
|
@ -109,11 +132,20 @@ public partial class HotkeyControlDialog : ContentDialog
|
||||||
if (tbMsg == null)
|
if (tbMsg == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (StaticHotkeys.TryGetValue((HotkeyModel)hotkey, out var staticHotkey))
|
||||||
|
{
|
||||||
|
ShowWarningAndDisableSaveButton(
|
||||||
|
string.Format(
|
||||||
|
InternationalizationManager.Instance.GetTranslation("hotkeyUnavailableInUseStatic"),
|
||||||
|
InternationalizationManager.Instance.GetTranslation(staticHotkey)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!CheckHotkeyAvailability(hotkey.Value, true))
|
if (!CheckHotkeyAvailability(hotkey.Value, true))
|
||||||
{
|
{
|
||||||
tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable");
|
ShowWarningAndDisableSaveButton(InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable"));
|
||||||
Alert.Visibility = Visibility.Visible;
|
|
||||||
SaveBtn.IsEnabled = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -122,6 +154,13 @@ public partial class HotkeyControlDialog : ContentDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowWarningAndDisableSaveButton(string message)
|
||||||
|
{
|
||||||
|
tbMsg.Text = message;
|
||||||
|
Alert.Visibility = Visibility.Visible;
|
||||||
|
SaveBtn.IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) =>
|
private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) =>
|
||||||
hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey);
|
hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,8 @@
|
||||||
<system:String x:Key="update">Update</system:String>
|
<system:String x:Key="update">Update</system:String>
|
||||||
<system:String x:Key="hotkeyRegTitle">Binding Hotkey</system:String>
|
<system:String x:Key="hotkeyRegTitle">Binding Hotkey</system:String>
|
||||||
<system:String x:Key="hotkeyUnavailable">Current hotkey is unavailable.</system:String>
|
<system:String x:Key="hotkeyUnavailable">Current hotkey is unavailable.</system:String>
|
||||||
|
<system:String x:Key="hotkeyUnavailableInUseStatic">This hotkey is unavailable because it is reserved for Flow Launcher's functionality: {0}.</system:String>
|
||||||
|
<system:String x:Key="hotkeyUnavailableInUse">This hotkey is unavailable because it is already used for {0}.</system:String>
|
||||||
<system:String x:Key="hotkeyRegGuide">Press the keys you want to use for this function.</system:String>
|
<system:String x:Key="hotkeyRegGuide">Press the keys you want to use for this function.</system:String>
|
||||||
|
|
||||||
<!-- Custom Query Shortcut Dialog -->
|
<!-- Custom Query Shortcut Dialog -->
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue