This commit is contained in:
Vic 2022-10-14 00:42:05 +08:00
parent 334d58df29
commit d394d86201
6 changed files with 11 additions and 10 deletions

View file

@ -46,7 +46,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public void Deconstruct(out string key, out string value)
{
key = Key;
value = Expand();
value = Value;
}
public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut)

View file

@ -8,6 +8,7 @@ using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedModels;
using Flow.Launcher;
using Flow.Launcher.ViewModel;
namespace Flow.Launcher.Infrastructure.UserSettings
{
public class Settings : BaseModel

View file

@ -20,9 +20,10 @@ namespace Flow.Launcher
InitializeComponent();
}
public CustomShortcutSetting((string, string) shortcut, Settings settings)
public CustomShortcutSetting(CustomShortcutModel shortcut, Settings settings)
{
(Key, Value) = shortcut;
Key = shortcut.Key;
Value = shortcut.Value;
_settings = settings;
update = true;
InitializeComponent();

View file

@ -2131,7 +2131,8 @@
<GridView>
<GridViewColumn Width="180" Header="{DynamicResource hotkey}">
<GridViewColumn.CellTemplate>
<DataTemplate DataType="userSettings:CustomPluginHotkey">
<DataTemplate
="userSettings:CustomPluginHotkey">
<TextBlock Text="{Binding Hotkey}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
@ -2184,7 +2185,6 @@
BorderThickness="1"
ItemsSource="{Binding ShortCuts}"
SelectedItem="{Binding SelectedCustomShortcut}"
SelectedIndex="{Binding SelectCustomShortcutIndex}"
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}">
<ListView.View>
<GridView>

View file

@ -411,7 +411,7 @@ namespace Flow.Launcher
var shortcutSettingWindow = new CustomShortcutSetting(item, settings);
if (shortcutSettingWindow.ShowDialog() == true)
{
viewModel.EditShortcut(item);
viewModel.EditShortcut(item, shortcutSettingWindow.ShortCut);
}
}
else

View file

@ -543,7 +543,6 @@ namespace Flow.Launcher.ViewModel
public CustomPluginHotkey SelectedCustomPluginHotkey { get; set; }
public CustomShortcutModel? SelectedCustomShortcut { get; set; }
public int? SelectCustomShortcutIndex { get; set; }
public void AddShortcut(CustomShortcutModel shortcut)
{
@ -551,10 +550,10 @@ namespace Flow.Launcher.ViewModel
ShortCuts.Add(shortcut);
}
public void EditShortcut(CustomShortcutModel shortcut)
public void EditShortcut(CustomShortcutModel oldShortcut, CustomShortcutModel newShortcut)
{
Settings.CustomShortcuts[ShortCuts.IndexOf(shortcut)] = shortcut;
ShortCuts[ShortCuts.IndexOf(shortcut)] = shortcut;
RemoveShortcut(oldShortcut);
AddShortcut(newShortcut);
}
public void RemoveShortcut(CustomShortcutModel shortcut)