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) public void Deconstruct(out string key, out string value)
{ {
key = Key; key = Key;
value = Expand(); value = Value;
} }
public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut) 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.Plugin.SharedModels;
using Flow.Launcher; using Flow.Launcher;
using Flow.Launcher.ViewModel; using Flow.Launcher.ViewModel;
namespace Flow.Launcher.Infrastructure.UserSettings namespace Flow.Launcher.Infrastructure.UserSettings
{ {
public class Settings : BaseModel public class Settings : BaseModel

View file

@ -20,9 +20,10 @@ namespace Flow.Launcher
InitializeComponent(); 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; _settings = settings;
update = true; update = true;
InitializeComponent(); InitializeComponent();

View file

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

View file

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

View file

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