Skip to content

Commit 99d1807

Browse files
Move CustomShortcutModel definition to a new file
1. Move CustomShortcutModel definition to a new file 2. Some other minor tweaks
1 parent 099b1d6 commit 99d1807

File tree

4 files changed

+58
-43
lines changed

4 files changed

+58
-43
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Flow.Launcher.Infrastructure.UserSettings
8+
{
9+
public class CustomShortcutModel
10+
{
11+
public string Key { get; set; }
12+
public string Value { get; set; }
13+
14+
public CustomShortcutModel(string key, string value)
15+
{
16+
Key = key;
17+
Value = value;
18+
}
19+
20+
public override bool Equals(object obj)
21+
{
22+
return obj is CustomShortcutModel other &&
23+
Key == other.Key &&
24+
Value == other.Value;
25+
}
26+
27+
public override int GetHashCode()
28+
{
29+
return HashCode.Combine(Key, Value);
30+
}
31+
32+
public void Deconstruct(out string key, out string value)
33+
{
34+
key = Key;
35+
value = Value;
36+
}
37+
38+
public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut)
39+
{
40+
return (shortcut.Key, shortcut.Value);
41+
}
42+
43+
public static implicit operator CustomShortcutModel((string Key, string Value) shortcut)
44+
{
45+
return new CustomShortcutModel(shortcut.Key, shortcut.Value);
46+
}
47+
}
48+
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -220,44 +220,4 @@ public enum ColorSchemes
220220
Light,
221221
Dark
222222
}
223-
224-
public struct CustomShortcutModel
225-
{
226-
public string Key { get; set; }
227-
public string Value { get; set; }
228-
229-
public CustomShortcutModel(string key, string value)
230-
{
231-
Key = key;
232-
Value = value;
233-
}
234-
235-
public override bool Equals(object obj)
236-
{
237-
return obj is CustomShortcutModel other &&
238-
Key == other.Key &&
239-
Value == other.Value;
240-
}
241-
242-
public override int GetHashCode()
243-
{
244-
return HashCode.Combine(Key, Value);
245-
}
246-
247-
public void Deconstruct(out string key, out string value)
248-
{
249-
key = Key;
250-
value = Value;
251-
}
252-
253-
public static implicit operator (string Key, string Value)(CustomShortcutModel value)
254-
{
255-
return (value.Key, value.Value);
256-
}
257-
258-
public static implicit operator CustomShortcutModel((string Key, string Value) value)
259-
{
260-
return new CustomShortcutModel(value.Key, value.Value);
261-
}
262-
}
263223
}

Flow.Launcher/CustomShortcutSetting.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public partial class CustomShortcutSetting : Window
1414
{
1515
private SettingWindow _settingWidow;
1616
private bool update;
17-
private CustomPluginHotkey updateCustomHotkey;
1817
private Settings _settings;
1918

2019
public string Key { get; set; }
2120
public string Value { get; set; }
2221
public CustomShortcutModel ShortCut => (Key, Value);
22+
2323
public CustomShortcutSetting()
2424
{
2525
InitializeComponent();

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,14 @@ private void RefreshMaximizeRestoreButton()
365365
restoreButton.Visibility = Visibility.Collapsed;
366366
}
367367
}
368+
368369
private void Window_StateChanged(object sender, EventArgs e)
369370
{
370371
RefreshMaximizeRestoreButton();
371372
}
372373

374+
#region Shortcut
375+
373376
private void OnDeleteCustomShortCutClick(object sender, RoutedEventArgs e)
374377
{
375378
var item = viewModel.SelectedCustomShortcut;
@@ -386,15 +389,16 @@ private void OnDeleteCustomShortCutClick(object sender, RoutedEventArgs e)
386389
MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"),
387390
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
388391
{
389-
settings.CustomShortcuts.Remove(item.Value);
392+
settings.CustomShortcuts.Remove(item);
390393
}
391394
}
395+
392396
private void OnEditCustomShortCutClick(object sender, RoutedEventArgs e)
393397
{
394398
var item = viewModel.SelectedCustomShortcut;
395399
if (item != null)
396400
{
397-
var shortcutSettingWindow = new CustomShortcutSetting(item.Value);
401+
var shortcutSettingWindow = new CustomShortcutSetting(item);
398402
if (shortcutSettingWindow.ShowDialog() == true)
399403
{
400404
settings.CustomShortcuts[viewModel.SelectCustomShortcutIndex.Value] = shortcutSettingWindow.ShortCut;
@@ -414,5 +418,8 @@ private void OnAddCustomeShortCutClick(object sender, RoutedEventArgs e)
414418
settings.CustomShortcuts.Add(shortcutSettingWindow.ShortCut);
415419
}
416420
}
421+
422+
#endregion
423+
417424
}
418425
}

0 commit comments

Comments
 (0)