1
- using Flow . Launcher . Plugin . Explorer . ViewModels ;
1
+ using Flow . Launcher . Plugin . Explorer . ViewModels ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using System . Windows ;
@@ -14,6 +14,8 @@ public partial class ActionKeywordSetting : Window
14
14
15
15
public ActionKeywordView CurrentActionKeyword { get ; set ; }
16
16
17
+ private string oldActionKeyword ;
18
+
17
19
private List < ActionKeywordView > actionKeywordListView ;
18
20
19
21
private Settings settings ;
@@ -30,32 +32,20 @@ public ActionKeywordSetting(SettingsViewModel settingsViewModel,
30
32
31
33
CurrentActionKeyword = selectedActionKeyword ;
32
34
35
+ oldActionKeyword = selectedActionKeyword . Keyword ;
36
+
33
37
this . actionKeywordListView = actionKeywordListView ;
34
38
35
39
InitializeComponent ( ) ;
36
40
37
41
}
38
42
39
- private void OnConfirmButtonClick ( object sender , RoutedEventArgs e )
43
+ private void OnDoneButtonClick ( object sender , RoutedEventArgs e )
40
44
{
41
- var newActionKeyword = TxtCurrentActionKeyword . Text ;
42
-
43
- if ( string . IsNullOrEmpty ( newActionKeyword ) )
45
+ if ( string . IsNullOrEmpty ( CurrentActionKeyword . Keyword ) )
44
46
return ;
45
47
46
- // reset to global so it does not take up an action keyword when disabled
47
- if ( ! CurrentActionKeyword . Enabled is not null && newActionKeyword != Query . GlobalPluginWildcardSign )
48
- settingsViewModel . UpdateActionKeyword ( CurrentActionKeyword . KeywordProperty ,
49
- Query . GlobalPluginWildcardSign , CurrentActionKeyword . Keyword ) ;
50
-
51
- if ( newActionKeyword == CurrentActionKeyword . Keyword )
52
- {
53
- Close ( ) ;
54
-
55
- return ;
56
- }
57
-
58
- if ( settingsViewModel . IsNewActionKeywordGlobal ( newActionKeyword )
48
+ if ( settingsViewModel . IsNewActionKeywordGlobal ( CurrentActionKeyword . Keyword )
59
49
&& CurrentActionKeyword . KeywordProperty == Settings . ActionKeyword . FileContentSearchActionKeyword )
60
50
{
61
51
MessageBox . Show (
@@ -64,13 +54,12 @@ private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
64
54
return ;
65
55
}
66
56
67
- if ( ! settingsViewModel . IsActionKeywordAlreadyAssigned ( newActionKeyword ) )
57
+ if ( ! settingsViewModel . IsActionKeywordAlreadyAssigned ( CurrentActionKeyword . Keyword , oldActionKeyword ) )
68
58
{
69
- settingsViewModel . UpdateActionKeyword ( CurrentActionKeyword . KeywordProperty , newActionKeyword ,
70
- CurrentActionKeyword . Keyword ) ;
59
+ settingsViewModel . UpdateActionKeyword ( CurrentActionKeyword . KeywordProperty , CurrentActionKeyword . Keyword , oldActionKeyword ) ;
71
60
72
61
actionKeywordListView . FirstOrDefault ( x => x . Description == CurrentActionKeyword . Description ) . Keyword =
73
- newActionKeyword ;
62
+ CurrentActionKeyword . Keyword ;
74
63
75
64
// automatically help users set this to enabled if an action keyword is set and currently disabled
76
65
if ( CurrentActionKeyword . KeywordProperty == Settings . ActionKeyword . IndexSearchActionKeyword
@@ -81,16 +70,19 @@ private void OnConfirmButtonClick(object sender, RoutedEventArgs e)
81
70
&& ! settings . EnabledPathSearchKeyword )
82
71
settings . EnabledPathSearchKeyword = true ;
83
72
73
+ if ( CurrentActionKeyword . KeywordProperty == Settings . ActionKeyword . SearchActionKeyword
74
+ && ! settings . EnableSearchActionKeyword )
75
+ settings . EnableSearchActionKeyword = true ;
76
+
84
77
Close ( ) ;
85
78
86
79
return ;
87
80
}
88
81
89
- MessageBox . Show ( settingsViewModel . Context . API . GetTranslation ( "newActionKeywordsHasBeenAssigned" ) ) ;
90
- }
82
+ // reset to global so it does not take up an action keyword when disabled
83
+ if ( CurrentActionKeyword . Enabled is not null && CurrentActionKeyword . Enabled == false && CurrentActionKeyword . Keyword != Query . GlobalPluginWildcardSign )
84
+ settingsViewModel . UpdateActionKeyword ( CurrentActionKeyword . KeywordProperty , Query . GlobalPluginWildcardSign , oldActionKeyword ) ;
91
85
92
- private void OnCancelButtonClick ( object sender , RoutedEventArgs e )
93
- {
94
86
Close ( ) ;
95
87
96
88
return ;
0 commit comments