|
@@ -41,12 +41,10 @@ internal class SettingsPage : ObservableObject
|
|
internal partial class SettingsWindowViewModel : ViewModelBase
|
|
internal partial class SettingsWindowViewModel : ViewModelBase
|
|
{
|
|
{
|
|
private string searchTerm;
|
|
private string searchTerm;
|
|
-
|
|
|
|
- [ObservableProperty]
|
|
|
|
- private int visibleGroups;
|
|
|
|
-
|
|
|
|
- [ObservableProperty]
|
|
|
|
- private int currentPage;
|
|
|
|
|
|
+
|
|
|
|
+ [ObservableProperty] private int visibleGroups;
|
|
|
|
+
|
|
|
|
+ [ObservableProperty] private int currentPage;
|
|
|
|
|
|
public bool ShowUpdateTab
|
|
public bool ShowUpdateTab
|
|
{
|
|
{
|
|
@@ -85,7 +83,8 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
[Command.Internal("PixiEditor.Shortcuts.Reset")]
|
|
[Command.Internal("PixiEditor.Shortcuts.Reset")]
|
|
public static async Task ResetCommand()
|
|
public static async Task ResetCommand()
|
|
{
|
|
{
|
|
- await new OptionsDialog<string>("ARE_YOU_SURE", new LocalizedString("WARNING_RESET_SHORTCUTS_DEFAULT"), MainWindow.Current!)
|
|
|
|
|
|
+ await new OptionsDialog<string>("ARE_YOU_SURE", new LocalizedString("WARNING_RESET_SHORTCUTS_DEFAULT"),
|
|
|
|
+ MainWindow.Current!)
|
|
{
|
|
{
|
|
{ new LocalizedString("YES"), x => CommandController.Current.ResetShortcuts() },
|
|
{ new LocalizedString("YES"), x => CommandController.Current.ResetShortcuts() },
|
|
new LocalizedString("CANCEL"),
|
|
new LocalizedString("CANCEL"),
|
|
@@ -112,31 +111,13 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
SuggestedStartLocation = suggestedStartLocation,
|
|
SuggestedStartLocation = suggestedStartLocation,
|
|
FileTypeChoices = new List<FilePickerFileType>()
|
|
FileTypeChoices = new List<FilePickerFileType>()
|
|
{
|
|
{
|
|
- new FilePickerFileType("PixiShorts (*.pixisc)")
|
|
|
|
- {
|
|
|
|
- Patterns = new List<string>
|
|
|
|
- {
|
|
|
|
- "*.pixisc"
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- new FilePickerFileType("json (*.json)")
|
|
|
|
- {
|
|
|
|
- Patterns = new List<string>
|
|
|
|
- {
|
|
|
|
- "*.json"
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- new FilePickerFileType("All files (*.*)")
|
|
|
|
- {
|
|
|
|
- Patterns = new List<string>
|
|
|
|
- {
|
|
|
|
- "*.*"
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ new FilePickerFileType("PixiShorts (*.pixisc)") { Patterns = new List<string> { "*.pixisc" }, },
|
|
|
|
+ new FilePickerFileType("json (*.json)") { Patterns = new List<string> { "*.json" }, },
|
|
|
|
+ new FilePickerFileType("All files (*.*)") { Patterns = new List<string> { "*.*" }, },
|
|
},
|
|
},
|
|
});
|
|
});
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
if (file is not null)
|
|
if (file is not null)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -146,10 +127,11 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
string errMessageTrimmed = ex.Message.Length > 100 ? ex.Message[..100] + "..." : ex.Message;
|
|
string errMessageTrimmed = ex.Message.Length > 100 ? ex.Message[..100] + "..." : ex.Message;
|
|
- NoticeDialog.Show(title: "ERROR", message: new LocalizedString("UNKNOWN_ERROR_SAVING").Value + $" {errMessageTrimmed}");
|
|
|
|
|
|
+ NoticeDialog.Show(title: "ERROR",
|
|
|
|
+ message: new LocalizedString("UNKNOWN_ERROR_SAVING").Value + $" {errMessageTrimmed}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Sometimes, focus was brought back to the last edited shortcut
|
|
// Sometimes, focus was brought back to the last edited shortcut
|
|
// TODO: Keyboard.ClearFocus(); should be there but I can't find an equivalent from avalonia
|
|
// TODO: Keyboard.ClearFocus(); should be there but I can't find an equivalent from avalonia
|
|
}
|
|
}
|
|
@@ -159,37 +141,20 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
{
|
|
{
|
|
List<FilePickerFileType> fileTypes = new List<FilePickerFileType>
|
|
List<FilePickerFileType> fileTypes = new List<FilePickerFileType>
|
|
{
|
|
{
|
|
- new("PixiShorts (*.pixisc)")
|
|
|
|
- {
|
|
|
|
- Patterns = new List<string>
|
|
|
|
- {
|
|
|
|
- "*.pixisc"
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- new("json (*.json)")
|
|
|
|
- {
|
|
|
|
- Patterns = new List<string>
|
|
|
|
- {
|
|
|
|
- "*.json"
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
|
|
+ new("PixiShorts (*.pixisc)") { Patterns = new List<string> { "*.pixisc" }, },
|
|
|
|
+ new("json (*.json)") { Patterns = new List<string> { "*.json" }, },
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
customShortcutFormats ??= ShortcutProvider.GetProviders().OfType<ICustomShortcutFormat>().ToList();
|
|
customShortcutFormats ??= ShortcutProvider.GetProviders().OfType<ICustomShortcutFormat>().ToList();
|
|
AddCustomParsersFormat(customShortcutFormats, fileTypes);
|
|
AddCustomParsersFormat(customShortcutFormats, fileTypes);
|
|
-
|
|
|
|
- fileTypes.Add(new FilePickerFileType("All files (*.*)")
|
|
|
|
- {
|
|
|
|
- Patterns = new List<string>
|
|
|
|
|
|
+
|
|
|
|
+ fileTypes.Add(new FilePickerFileType("All files (*.*)") { Patterns = new List<string> { "*.*" }, });
|
|
|
|
+
|
|
|
|
+ fileTypes.Insert(0,
|
|
|
|
+ new FilePickerFileType($"All Shortcut files {string.Join(",", fileTypes.SelectMany(a => a.Patterns))}")
|
|
{
|
|
{
|
|
- "*.*"
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- fileTypes.Insert(0, new FilePickerFileType($"All Shortcut files {string.Join(",", fileTypes.SelectMany(a => a.Patterns))}")
|
|
|
|
- {
|
|
|
|
- Patterns = fileTypes.SelectMany(a => a.Patterns).ToList(),
|
|
|
|
- });
|
|
|
|
|
|
+ Patterns = fileTypes.SelectMany(a => a.Patterns).ToList(),
|
|
|
|
+ });
|
|
|
|
|
|
IStorageFolder? suggestedLocation = null;
|
|
IStorageFolder? suggestedLocation = null;
|
|
try
|
|
try
|
|
@@ -205,34 +170,35 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
|
|
|
|
IReadOnlyList<IStorageFile> files = await MainWindow.Current!.StorageProvider.OpenFilePickerAsync(new()
|
|
IReadOnlyList<IStorageFile> files = await MainWindow.Current!.StorageProvider.OpenFilePickerAsync(new()
|
|
{
|
|
{
|
|
- AllowMultiple = false,
|
|
|
|
- SuggestedStartLocation = suggestedLocation,
|
|
|
|
- FileTypeFilter = fileTypes,
|
|
|
|
|
|
+ AllowMultiple = false, SuggestedStartLocation = suggestedLocation, FileTypeFilter = fileTypes,
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
if (files.Count > 0)
|
|
if (files.Count > 0)
|
|
{
|
|
{
|
|
List<Shortcut> shortcuts = new List<Shortcut>();
|
|
List<Shortcut> shortcuts = new List<Shortcut>();
|
|
- if (!TryImport(files[0], ref shortcuts))
|
|
|
|
|
|
+ if (!TryImport(files[0], ref shortcuts, out var errors))
|
|
return;
|
|
return;
|
|
-
|
|
|
|
|
|
+
|
|
CommandController.Current.ResetShortcuts();
|
|
CommandController.Current.ResetShortcuts();
|
|
CommandController.Current.Import(shortcuts, false);
|
|
CommandController.Current.Import(shortcuts, false);
|
|
File.Copy(files[0].Path.LocalPath, CommandController.ShortcutsPath, true);
|
|
File.Copy(files[0].Path.LocalPath, CommandController.ShortcutsPath, true);
|
|
- NoticeDialog.Show("SHORTCUTS_IMPORTED_SUCCESS", "SUCCESS");
|
|
|
|
|
|
+ ImportShortcutTemplatePopup.DisplayImportSuccessInfo(null, errors);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// Sometimes, focus was brought back to the last edited shortcut
|
|
// Sometimes, focus was brought back to the last edited shortcut
|
|
// TODO: Keyboard.ClearFocus(); should be there but I can't find an equivalent from avalonia
|
|
// TODO: Keyboard.ClearFocus(); should be there but I can't find an equivalent from avalonia
|
|
}
|
|
}
|
|
|
|
|
|
- private static bool TryImport(IStorageFile file, ref List<Shortcut> shortcuts)
|
|
|
|
|
|
+ private static bool TryImport(IStorageFile file, ref List<Shortcut> shortcuts, out List<string>? errors)
|
|
{
|
|
{
|
|
|
|
+ errors = null;
|
|
if (file.Name.EndsWith(".pixisc") || file.Name.EndsWith(".json"))
|
|
if (file.Name.EndsWith(".pixisc") || file.Name.EndsWith(".json"))
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- shortcuts = ShortcutFile.LoadTemplate(file.Path.LocalPath)?.Shortcuts.ToList();
|
|
|
|
|
|
+ var template = ShortcutFile.LoadTemplate(file.Path.LocalPath);
|
|
|
|
+ errors = template.Errors;
|
|
|
|
+ shortcuts = template.Shortcuts.ToList();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
catch (Exception)
|
|
{
|
|
{
|
|
@@ -258,7 +224,9 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- shortcuts = provider.KeysParser.Parse(file.Path.LocalPath, false)?.Shortcuts.ToList();
|
|
|
|
|
|
+ var template = provider.KeysParser.Parse(file.Path.LocalPath, false);
|
|
|
|
+ shortcuts = template?.Shortcuts.ToList();
|
|
|
|
+ errors = template?.Errors;
|
|
}
|
|
}
|
|
catch (RecoverableException e)
|
|
catch (RecoverableException e)
|
|
{
|
|
{
|
|
@@ -270,7 +238,8 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- private static void AddCustomParsersFormat(IList<ICustomShortcutFormat>? customFormats, List<FilePickerFileType> listToAddTo)
|
|
|
|
|
|
+ private static void AddCustomParsersFormat(IList<ICustomShortcutFormat>? customFormats,
|
|
|
|
+ List<FilePickerFileType> listToAddTo)
|
|
{
|
|
{
|
|
if (customFormats is null || customFormats.Count == 0)
|
|
if (customFormats is null || customFormats.Count == 0)
|
|
return;
|
|
return;
|
|
@@ -355,6 +324,7 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
|
|
|
|
group.IsVisible = visibleCommands > 0;
|
|
group.IsVisible = visibleCommands > 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -381,8 +351,7 @@ internal partial class SettingsWindowViewModel : ViewModelBase
|
|
|
|
|
|
internal partial class GroupSearchResult : ObservableObject
|
|
internal partial class GroupSearchResult : ObservableObject
|
|
{
|
|
{
|
|
- [ObservableProperty]
|
|
|
|
- private bool isVisible;
|
|
|
|
|
|
+ [ObservableProperty] private bool isVisible;
|
|
|
|
|
|
public LocalizedString DisplayName { get; set; }
|
|
public LocalizedString DisplayName { get; set; }
|
|
|
|
|
|
@@ -397,8 +366,7 @@ internal partial class GroupSearchResult : ObservableObject
|
|
|
|
|
|
internal partial class CommandSearchResult : ObservableObject
|
|
internal partial class CommandSearchResult : ObservableObject
|
|
{
|
|
{
|
|
- [ObservableProperty]
|
|
|
|
- private bool isVisible;
|
|
|
|
|
|
+ [ObservableProperty] private bool isVisible;
|
|
|
|
|
|
public Models.Commands.Commands.Command Command { get; set; }
|
|
public Models.Commands.Commands.Command Command { get; set; }
|
|
|
|
|