diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj
index 49ae2656495..3fb0fa46f64 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj
@@ -95,6 +95,7 @@
+
diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml.cs
index 3182adfed65..1ee6b5c4551 100644
--- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/SettingsControl.xaml.cs
@@ -1,12 +1,13 @@
using System.Windows;
-using Flow.Launcher.Plugin.BrowserBookmark.Models;
using System.Windows.Input;
-using System.ComponentModel;
using System.Threading.Tasks;
+using CommunityToolkit.Mvvm.ComponentModel;
+using Flow.Launcher.Plugin.BrowserBookmark.Models;
namespace Flow.Launcher.Plugin.BrowserBookmark.Views;
-public partial class SettingsControl : INotifyPropertyChanged
+[INotifyPropertyChanged]
+public partial class SettingsControl
{
public Settings Settings { get; }
public CustomBrowser SelectedCustomBrowser { get; set; }
@@ -53,12 +54,10 @@ public bool OpenInNewBrowserWindow
set
{
Settings.OpenInNewBrowserWindow = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(OpenInNewBrowserWindow)));
+ OnPropertyChanged();
}
}
- public event PropertyChangedEventHandler PropertyChanged;
-
private void NewCustomBrowser(object sender, RoutedEventArgs e)
{
var newBrowser = new CustomBrowser();
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
index 7d0a553a486..2e0f6a67db3 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml
@@ -98,8 +98,11 @@
Delete
Permanently delete current file
Permanently delete current folder
- Path:
- Name:
+ Name
+ Type
+ Path
+ File
+ Folder
Delete the selected
Run as different user
Run the selected using a different user account
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs
index 745032d2c3d..2c4c4e54f9e 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs
@@ -1,16 +1,11 @@
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
+#nullable enable
-#nullable enable
-
-namespace Flow.Launcher.Plugin.Explorer.Views
+namespace Flow.Launcher.Plugin.Explorer.ViewModels
{
- public class ActionKeywordModel : INotifyPropertyChanged
+ public partial class ActionKeywordModel : BaseModel
{
private static Settings _settings = null!;
- public event PropertyChangedEventHandler? PropertyChanged;
-
public static void Init(Settings settings)
{
_settings = settings;
@@ -28,13 +23,7 @@ internal ActionKeywordModel(Settings.ActionKeyword actionKeyword, string descrip
internal Settings.ActionKeyword KeywordProperty { get; }
- private void OnPropertyChanged([CallerMemberName] string propertyName = "")
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
-
private string? keyword;
-
public string Keyword
{
get => keyword ??= _settings.GetActionKeyword(KeywordProperty);
@@ -45,8 +34,8 @@ public string Keyword
OnPropertyChanged();
}
}
- private bool? enabled;
+ private bool? enabled;
public bool Enabled
{
get => enabled ??= _settings.GetActionKeywordEnabled(KeywordProperty);
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
index 10ce28fe4ed..829a2feedd3 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
@@ -1,16 +1,13 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.CompilerServices;
+using System.Linq;
using System.Windows;
using System.Windows.Input;
+using CommunityToolkit.Mvvm.ComponentModel;
+using Flow.Launcher.Plugin.Explorer.ViewModels;
namespace Flow.Launcher.Plugin.Explorer.Views
{
- ///
- /// Interaction logic for ActionKeywordSetting.xaml
- ///
- public partial class ActionKeywordSetting : INotifyPropertyChanged
+ [INotifyPropertyChanged]
+ public partial class ActionKeywordSetting
{
private ActionKeywordModel CurrentActionKeyword { get; }
@@ -21,14 +18,14 @@ public string ActionKeyword
{
// Set Enable to be true if user change ActionKeyword
KeywordEnabled = true;
- _ = SetField(ref actionKeyword, value);
+ _ = SetProperty(ref actionKeyword, value);
}
}
public bool KeywordEnabled
{
get => _keywordEnabled;
- set => SetField(ref _keywordEnabled, value);
+ set => _ = SetProperty(ref _keywordEnabled, value);
}
private string actionKeyword;
@@ -116,20 +113,5 @@ private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e)
e.CancelCommand();
}
}
-
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
-
- private bool SetField(ref T field, T value, [CallerMemberName] string propertyName = null)
- {
- if (EqualityComparer.Default.Equals(field, value))
- return false;
- field = value;
- OnPropertyChanged(propertyName);
- return true;
- }
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
index 8f4b4d8623e..59373b4de3f 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml
@@ -8,7 +8,6 @@
xmlns:qa="clr-namespace:Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels"
- xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views"
d:DataContext="{d:DesignInstance viewModels:SettingsViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
@@ -18,7 +17,7 @@
-
+
-
-
-
+
+
+
+
@@ -58,55 +59,91 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
+ IsReadOnly="True"
+ Text="{Binding SelectedPath, Mode=TwoWay}" />
-
-
+ Click="SelectPath_OnClick"
+ Content="{DynamicResource select}" />
+
-
+
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs
index 36a00e9e59f..eb66e1efca5 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/QuickAccessLinkSettings.xaml.cs
@@ -2,15 +2,17 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
-using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Forms;
using Flow.Launcher.Plugin.Explorer.Helper;
+using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
+using CommunityToolkit.Mvvm.ComponentModel;
namespace Flow.Launcher.Plugin.Explorer.Views;
-public partial class QuickAccessLinkSettings : INotifyPropertyChanged
+[INotifyPropertyChanged]
+public partial class QuickAccessLinkSettings
{
private string _selectedPath;
public string SelectedPath
@@ -25,6 +27,7 @@ public string SelectedPath
if (string.IsNullOrEmpty(_selectedName))
{
SelectedName = _selectedPath.GetPathName();
+ _accessLinkType = GetResultType(_selectedPath);
}
}
}
@@ -47,11 +50,16 @@ public string SelectedName
}
}
+ public bool IsFileSelected { get; set; }
+ public bool IsFolderSelected { get; set; } = true; // Default to Folder
+
private bool IsEdit { get; }
private AccessLink SelectedAccessLink { get; }
-
+
public ObservableCollection QuickAccessLinks { get; }
-
+
+ private ResultType _accessLinkType = ResultType.Folder; // Default to Folder
+
public QuickAccessLinkSettings(ObservableCollection quickAccessLinks)
{
IsEdit = false;
@@ -64,6 +72,9 @@ public QuickAccessLinkSettings(ObservableCollection quickAccessLinks
IsEdit = true;
_selectedName = selectedAccessLink.Name;
_selectedPath = selectedAccessLink.Path;
+ _accessLinkType = GetResultType(_selectedPath); // Initialize link type
+ IsFileSelected = selectedAccessLink.Type == ResultType.File; // Initialize default selection
+ IsFolderSelected = !IsFileSelected;
SelectedAccessLink = selectedAccessLink;
QuickAccessLinks = quickAccessLinks;
InitializeComponent();
@@ -96,30 +107,42 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e)
}
// If editing, update the existing link
- if (IsEdit)
+ if (IsEdit)
{
- if (SelectedAccessLink == null) return;
-
- var index = QuickAccessLinks.IndexOf(SelectedAccessLink);
- if (index >= 0)
+ if (SelectedAccessLink != null)
{
- var updatedLink = new AccessLink
+ var index = QuickAccessLinks.IndexOf(SelectedAccessLink);
+ if (index >= 0)
{
- Name = SelectedName,
- Type = SelectedAccessLink.Type,
- Path = SelectedPath
- };
- QuickAccessLinks[index] = updatedLink;
+ var updatedLink = new AccessLink
+ {
+ Name = SelectedName,
+ Type = _accessLinkType,
+ Path = SelectedPath
+ };
+ QuickAccessLinks[index] = updatedLink;
+ }
+ DialogResult = true;
+ Close();
+ }
+ // Add a new one if the selected access link is null (should not happen in edit mode, but just in case)
+ else
+ {
+ AddNewAccessLink();
}
- DialogResult = true;
- Close();
}
// Otherwise, add a new one
else
+ {
+ AddNewAccessLink();
+ }
+
+ void AddNewAccessLink()
{
var newAccessLink = new AccessLink
{
Name = SelectedName,
+ Type = _accessLinkType,
Path = SelectedPath
};
QuickAccessLinks.Add(newAccessLink);
@@ -130,18 +153,59 @@ private void OnDoneButtonClick(object sender, RoutedEventArgs e)
private void SelectPath_OnClick(object commandParameter, RoutedEventArgs e)
{
- var folderBrowserDialog = new FolderBrowserDialog();
+ // Open file or folder selection dialog based on the selected radio button
+ if (IsFileSelected)
+ {
+ var openFileDialog = new OpenFileDialog
+ {
+ Multiselect = false,
+ CheckFileExists = true,
+ CheckPathExists = true
+ };
- if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
- return;
+ if (openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK ||
+ string.IsNullOrEmpty(openFileDialog.FileName))
+ return;
- SelectedPath = folderBrowserDialog.SelectedPath;
- }
+ SelectedPath = openFileDialog.FileName;
+ }
+ else // Folder selection
+ {
+ var folderBrowserDialog = new FolderBrowserDialog
+ {
+ ShowNewFolderButton = true
+ };
- public event PropertyChangedEventHandler PropertyChanged;
+ if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK ||
+ string.IsNullOrEmpty(folderBrowserDialog.SelectedPath))
+ return;
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ SelectedPath = folderBrowserDialog.SelectedPath;
+ }
+ }
+
+ private static ResultType GetResultType(string path)
{
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ // Check if the path is a file or folder
+ if (System.IO.File.Exists(path))
+ {
+ return ResultType.File;
+ }
+ else if (System.IO.Directory.Exists(path))
+ {
+ if (string.Equals(System.IO.Path.GetPathRoot(path), path, StringComparison.OrdinalIgnoreCase))
+ {
+ return ResultType.Volume;
+ }
+ else
+ {
+ return ResultType.Folder;
+ }
+ }
+ else
+ {
+ // This should not happen, but just in case, we assume it's a folder
+ return ResultType.Folder;
+ }
}
}