-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1476 from LeLocTai/dev
[Program Plugin] Support .url file and Steam/Epic shortcuts
- Loading branch information
Showing
8 changed files
with
336 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 44 additions & 12 deletions
56
Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Windows; | ||
|
||
namespace Flow.Launcher.Plugin.Program | ||
{ | ||
/// <summary> | ||
/// ProgramSuffixes.xaml 的交互逻辑 | ||
/// </summary> | ||
public partial class ProgramSuffixes | ||
{ | ||
private PluginInitContext context; | ||
private Settings _settings; | ||
public Dictionary<string, bool> SuffixesStatus { get; set; } | ||
public Dictionary<string, bool> ProtocolsStatus { get; set; } | ||
public bool UseCustomSuffixes { get; set; } | ||
public bool UseCustomProtocols { get; set; } | ||
|
||
public ProgramSuffixes(PluginInitContext context, Settings settings) | ||
{ | ||
this.context = context; | ||
InitializeComponent(); | ||
_settings = settings; | ||
tbSuffixes.Text = string.Join(Settings.SuffixSeperator.ToString(), _settings.ProgramSuffixes); | ||
SuffixesStatus = new Dictionary<string, bool>(_settings.BuiltinSuffixesStatus); | ||
ProtocolsStatus = new Dictionary<string, bool>(_settings.BuiltinProtocolsStatus); | ||
UseCustomSuffixes = _settings.UseCustomSuffixes; | ||
UseCustomProtocols = _settings.UseCustomProtocols; | ||
InitializeComponent(); | ||
tbSuffixes.Text = string.Join(Settings.SuffixSeparator, _settings.CustomSuffixes); | ||
tbProtocols.Text = string.Join(Settings.SuffixSeparator, _settings.CustomProtocols); | ||
} | ||
|
||
private void BtnCancel_OnClick(object sender, RoutedEventArgs e) | ||
{ | ||
Close(); | ||
} | ||
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) | ||
|
||
private void BtnAdd_OnClick(object sender, RoutedEventArgs e) | ||
{ | ||
var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries); | ||
var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeparator, StringSplitOptions.RemoveEmptyEntries); | ||
var protocols = tbProtocols.Text.Split(Settings.SuffixSeparator, StringSplitOptions.RemoveEmptyEntries); | ||
|
||
if (suffixes.Length == 0) | ||
if (suffixes.Length == 0 && UseCustomSuffixes) | ||
{ | ||
string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty"); | ||
MessageBox.Show(warning); | ||
return; | ||
} | ||
|
||
_settings.ProgramSuffixes = suffixes; | ||
if (protocols.Length == 0 && UseCustomProtocols) | ||
{ | ||
string warning = context.API.GetTranslation("flowlauncher_plugin_protocols_cannot_empty"); | ||
MessageBox.Show(warning); | ||
return; | ||
} | ||
|
||
string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes"); | ||
MessageBox.Show(msg); | ||
_settings.CustomSuffixes = suffixes; | ||
_settings.CustomProtocols = protocols; | ||
_settings.BuiltinSuffixesStatus = new Dictionary<string, bool>(SuffixesStatus); | ||
_settings.BuiltinProtocolsStatus = new Dictionary<string, bool>(ProtocolsStatus); | ||
_settings.UseCustomSuffixes = UseCustomSuffixes; | ||
_settings.UseCustomProtocols = UseCustomProtocols; | ||
|
||
DialogResult = true; | ||
} | ||
|
||
private void BtnReset_OnClick(object sender, RoutedEventArgs e) | ||
{ | ||
apprefMS.IsChecked = true; | ||
exe.IsChecked = true; | ||
lnk.IsChecked = true; | ||
CustomFiles.IsChecked = false; | ||
|
||
steam.IsChecked = true; | ||
epic.IsChecked = true; | ||
http.IsChecked = false; | ||
CustomProtocol.IsChecked = false; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.