mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Display plugin hotkey setting
This commit is contained in:
parent
94f3746ddc
commit
5f49c436e7
2 changed files with 75 additions and 11 deletions
|
|
@ -204,19 +204,18 @@
|
|||
<cc:HotkeyDisplay Margin="4 0 0 0" Keys="Ctrl+Minus" />
|
||||
</StackPanel>
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
Title="{DynamicResource RenameFileHotkey}"
|
||||
Icon=""
|
||||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="F2"
|
||||
Type="RenameFileHotkey"
|
||||
ValidateKeyGesture="True"/>
|
||||
</cc:Card>
|
||||
<cc:Card
|
||||
Title="{DynamicResource RenameFileHotkey}"
|
||||
Icon=""
|
||||
Type="Inside">
|
||||
<flowlauncher:HotkeyControl
|
||||
DefaultHotkey="F2"
|
||||
Type="RenameFileHotkey"
|
||||
ValidateKeyGesture="True" />
|
||||
</cc:Card>
|
||||
</StackPanel>
|
||||
</cc:ExCard>
|
||||
|
||||
|
||||
<cc:ExCard
|
||||
Title="{DynamicResource autoCompleteHotkey}"
|
||||
Margin="0 14 0 0"
|
||||
|
|
@ -281,6 +280,12 @@
|
|||
</cc:Card>
|
||||
</cc:ExCard>
|
||||
|
||||
<StackPanel
|
||||
x:Name="PluginHotkeySettings"
|
||||
Margin="0 20 0 0"
|
||||
Loaded="PluginHotkeySettings_Loaded"
|
||||
Orientation="Vertical" />
|
||||
|
||||
<cc:ExCard
|
||||
Title="{DynamicResource customQueryHotkey}"
|
||||
Margin="0 20 0 0"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
using System.Windows.Navigation;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
using Flow.Launcher.Core.Plugin;
|
||||
using Flow.Launcher.Resources.Controls;
|
||||
using Flow.Launcher.SettingPages.ViewModels;
|
||||
using Flow.Launcher.ViewModel;
|
||||
|
||||
|
|
@ -28,4 +32,59 @@ public partial class SettingsPaneHotkey
|
|||
}
|
||||
base.OnNavigatedTo(e);
|
||||
}
|
||||
|
||||
private void PluginHotkeySettings_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var pluginHotkeyInfos = PluginManager.GetPluginHotkeyInfo();
|
||||
foreach (var info in pluginHotkeyInfos)
|
||||
{
|
||||
var pluginPair = info.Key;
|
||||
var hotkeyInfo = info.Value;
|
||||
var metadata = pluginPair.Metadata;
|
||||
var excard = new ExCard()
|
||||
{
|
||||
Title = metadata.Name
|
||||
// TODO: Support displaying plugin icon here
|
||||
};
|
||||
var hotkeyStackPanel = new StackPanel
|
||||
{
|
||||
Orientation = Orientation.Vertical
|
||||
};
|
||||
foreach (var hotkey in hotkeyInfo)
|
||||
{
|
||||
var card = new Card()
|
||||
{
|
||||
Title = hotkey.Name,
|
||||
Sub = hotkey.Description,
|
||||
Icon = hotkey.Glyph.Glyph,
|
||||
Type = Card.CardType.Inside
|
||||
};
|
||||
var hotkeySetting = metadata.PluginHotkeys.Find(h => h.Id == hotkey.Id)?.Hotkey ?? hotkey.DefaultHotkey;
|
||||
if (hotkey.Editable)
|
||||
{
|
||||
// TODO: Check if this can use
|
||||
var hotkeyControl = new HotkeyControl
|
||||
{
|
||||
DefaultHotkey = hotkey.DefaultHotkey,
|
||||
Hotkey = hotkeySetting,
|
||||
Type = HotkeyControl.HotkeyType.CustomQueryHotkey,
|
||||
ValidateKeyGesture = true
|
||||
};
|
||||
card.Content = hotkeyControl;
|
||||
// TODO: Update metadata & plugin setting hotkey
|
||||
}
|
||||
else
|
||||
{
|
||||
var hotkeyDisplay = new HotkeyDisplay
|
||||
{
|
||||
Keys = hotkeySetting
|
||||
};
|
||||
card.Content = hotkeyDisplay;
|
||||
}
|
||||
hotkeyStackPanel.Children.Add(card);
|
||||
}
|
||||
excard.Content = hotkeyStackPanel;
|
||||
PluginHotkeySettings.Children.Add(excard);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue