diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index eeb6b450e..439f3f87f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -327,18 +327,6 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels container.Add(link); } - [RelayCommand] - private void EditQuickAccessLink(object commandParameter) - { - if (SelectedQuickAccessLink is null) - { - ShowUnselectedMessage(); - return; - } - - var quickAccessLinkSettings = new QuickAccessLinkSettings(SelectedQuickAccessLink); - quickAccessLinkSettings.ShowDialog(); - } [RelayCommand] private void EditIndexSearchExcludePaths(object commandParameter) @@ -368,20 +356,6 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels }); } - private void ShowUnselectedMessage() - { - var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning"); - Context.API.ShowMsgBox(warning); - } - - [RelayCommand] - private void AddQuickAccessLink(object commandParameter) - { - var quickAccessLinkSettings = new QuickAccessLinkSettings(); - quickAccessLinkSettings.ShowDialog(); - } - - [RelayCommand] private void AddIndexSearchExcludePaths(object commandParameter) { @@ -400,6 +374,28 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels container.Add(newAccessLink); } + [RelayCommand] + private void EditQuickAccessLink(object commandParameter) + { + if (SelectedQuickAccessLink is null) + { + ShowUnselectedMessage(); + return; + } + + var quickAccessLinkSettings = new QuickAccessLinkSettings(SelectedQuickAccessLink); + quickAccessLinkSettings.ShowDialog(); + } + + [RelayCommand] + private void AddQuickAccessLink(object commandParameter) + { + var quickAccessLinkSettings = new QuickAccessLinkSettings(); + quickAccessLinkSettings.ShowDialog(); + } + + + [RelayCommand] private void RemoveLink(object obj) { @@ -418,6 +414,12 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels } Save(); } + + private void ShowUnselectedMessage() + { + var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning"); + Context.API.ShowMsgBox(warning); + } #endregion diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs index 7bd67b54e..454935bd4 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs @@ -14,9 +14,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views; public partial class QuickAccessLinkSettings : INotifyPropertyChanged { - - private bool IsEdit { get; set; } - [CanBeNull] private AccessLink SelectedAccessLink { get; set; } + private string _selectedPath; public string SelectedPath @@ -28,7 +26,7 @@ public partial class QuickAccessLinkSettings : INotifyPropertyChanged { _selectedPath = value; OnPropertyChanged(); - SelectedName = GetPathName(); + if (string.IsNullOrEmpty(_selectedName)) SelectedName = GetPathName(); } } } @@ -53,6 +51,8 @@ public partial class QuickAccessLinkSettings : INotifyPropertyChanged } } + private bool IsEdit { get; set; } + [CanBeNull] private AccessLink SelectedAccessLink { get; set; } public QuickAccessLinkSettings() { InitializeComponent(); @@ -78,7 +78,7 @@ public partial class QuickAccessLinkSettings : INotifyPropertyChanged private void OnDoneButtonClick(object sender, RoutedEventArgs e) { - if (string.IsNullOrEmpty(SelectedName) && string.IsNullOrEmpty(SelectedPath)) + if (string.IsNullOrEmpty(SelectedName) || string.IsNullOrEmpty(SelectedPath)) { var warning = Main.Context.API.GetTranslation("plugin_explorer_quick_access_link_no_folder_selected"); Main.Context.API.ShowMsgBox(warning); @@ -122,6 +122,9 @@ public partial class QuickAccessLinkSettings : INotifyPropertyChanged { if (SelectedAccessLink == null)throw new ArgumentException("Access Link object is null"); + + // Talvez nao seja preciso buscar pelo hash code, mas sim pelo nome ou path + // Uma possivel validação, se pode nomes e paths iguais var obj = Settings.QuickAccessLinks.FirstOrDefault(x => x.GetHashCode() == SelectedAccessLink.GetHashCode()); int index = Settings.QuickAccessLinks.IndexOf(obj); if (index >= 0)