Skip to content

Commit cca10ca

Browse files
Move show msgbox to view
1 parent bfb29e3 commit cca10ca

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
3030
private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
3131
{
3232
var status = ViewModel.AddOrUpdate();
33-
if (status == null)
33+
bool modified = status.Item1;
34+
string msg = status.Item2;
35+
if (modified == false && msg != null)
3436
{
35-
return; // Invalid
36-
}
37-
else
38-
{
39-
DialogResult = status ?? false;
40-
Close();
37+
MessageBox.Show(msg); // Invalid
38+
return;
4139
}
40+
DialogResult = modified;
41+
Close();
4242
}
4343
}
4444
}

Plugins/Flow.Launcher.Plugin.Program/ViewModels/AddProgramSourceViewModel.cs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,42 +80,37 @@ public void Browse()
8080
}
8181
}
8282

83-
public bool? AddProgramSource()
83+
public (bool, string) AddProgramSource()
8484
{
8585
if (!Directory.Exists(Location))
8686
{
87-
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
88-
return null;
87+
return (false, API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
8988
}
9089
else if (DuplicateSource(Location))
9190
{
92-
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
93-
return null;
91+
return (false, API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
9492
}
9593
else
9694
{
9795
var source = new ProgramSource(Location, Enabled);
9896
Settings.ProgramSources.Insert(0, source);
9997
ProgramSetting.ProgramSettingDisplayList.Add(source);
100-
return true;
98+
return (true, null);
10199
}
102100
}
103101

104-
public bool? UpdateProgramSource()
102+
public (bool, string) UpdateProgramSource()
105103
{
106104
// Separate checks to avoid changing UniqueIdentifier of UWP when changing Enabled
107105
if (LocationModified)
108106
{
109107
if (!Directory.Exists(Location))
110108
{
111-
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
112-
return null;
109+
return (false, API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
113110
}
114111
else if (DuplicateSource(Location))
115112
{
116-
// No need to check win32 or uwp, just override them
117-
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
118-
return null;
113+
return (false, API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
119114
}
120115
else
121116
{
@@ -126,10 +121,10 @@ public void Browse()
126121
{
127122
Source.Enabled = Enabled;
128123
}
129-
return StatusModified || LocationModified;
124+
return (StatusModified || LocationModified, null);
130125
}
131126

132-
public bool? AddOrUpdate()
127+
public (bool, string) AddOrUpdate()
133128
{
134129
if (Source == null)
135130
{

0 commit comments

Comments
 (0)