From ec01106d569705bcff58710562bd4d8fd4721147 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 20 Jul 2025 23:45:47 -0400 Subject: [PATCH 1/4] Code Quality: Removed old address bar code --- .../PreviewPopup/LaunchPreviewPopupAction.cs | 1 - .../Content/Selection/ClearSelectionAction.cs | 4 +- .../Selection/InvertSelectionAction.cs | 5 +- .../Content/Selection/SelectAllAction.cs | 4 +- .../Actions/Global/EditPathAction.cs | 7 +- src/Files.App/Actions/Global/SearchAction.cs | 15 - .../ContentPage/ContentPageContext.cs | 3 - .../ContentPage/IContentPageContext.cs | 2 - .../Multitasking/MultitaskingContext.cs | 5 - .../Contracts/IAddressToolbarViewModel.cs | 12 - .../Data/Contracts/IGeneralSettingsService.cs | 5 - .../Data/Contracts/ISearchBoxViewModel.cs | 26 -- .../AddressBarTextEnteredEventArgs.cs | 14 - .../PathBreadcrumbItemSelector.cs | 35 -- .../Settings/GeneralSettingsService.cs | 6 - src/Files.App/Strings/en-US/Resources.resw | 3 - .../UserControls/NavigationToolbar.xaml | 149 +------- .../UserControls/NavigationToolbar.xaml.cs | 95 ----- .../UserControls/PathBreadcrumb.xaml | 173 --------- .../UserControls/PathBreadcrumb.xaml.cs | 74 ---- src/Files.App/UserControls/SearchBox.xaml | 110 ------ src/Files.App/UserControls/SearchBox.xaml.cs | 37 -- .../ViewModels/Settings/AdvancedViewModel.cs | 15 - .../NavigationToolbarViewModel.cs | 351 +----------------- .../UserControls/SearchBoxViewModel.cs | 140 ------- .../Views/Layouts/ColumnLayoutPage.xaml.cs | 9 +- .../Views/Layouts/DetailsLayoutPage.xaml.cs | 5 +- .../Views/Layouts/GridLayoutPage.xaml.cs | 3 +- src/Files.App/Views/MainPage.xaml | 17 - src/Files.App/Views/MainPage.xaml.cs | 2 +- .../Views/Settings/AdvancedPage.xaml | 8 - src/Files.App/Views/Shells/BaseShellPage.cs | 58 +-- .../Views/Shells/ColumnShellPage.xaml | 8 - .../Views/Shells/ColumnShellPage.xaml.cs | 31 +- .../Views/Shells/ModernShellPage.xaml | 8 - .../Views/Shells/ModernShellPage.xaml.cs | 28 +- 36 files changed, 26 insertions(+), 1442 deletions(-) delete mode 100644 src/Files.App/Data/Contracts/ISearchBoxViewModel.cs delete mode 100644 src/Files.App/Data/EventArguments/AddressBarTextEnteredEventArgs.cs delete mode 100644 src/Files.App/Data/TemplateSelectors/PathBreadcrumbItemSelector.cs delete mode 100644 src/Files.App/UserControls/PathBreadcrumb.xaml delete mode 100644 src/Files.App/UserControls/PathBreadcrumb.xaml.cs delete mode 100644 src/Files.App/UserControls/SearchBox.xaml delete mode 100644 src/Files.App/UserControls/SearchBox.xaml.cs delete mode 100644 src/Files.App/ViewModels/UserControls/SearchBoxViewModel.cs diff --git a/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs b/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs index fbf3b3407874..ece2f77c629f 100644 --- a/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs +++ b/src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs @@ -20,7 +20,6 @@ public HotKey HotKey public bool IsExecutable => context.SelectedItems.Count == 1 && - (!context.ShellPage?.ToolbarViewModel?.IsEditModeEnabled ?? false) && (!context.ShellPage?.SlimContentPage?.IsRenamingItem ?? false); public LaunchPreviewPopupAction() diff --git a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs index a7e44beb059c..30ad883f98f2 100644 --- a/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/ClearSelectionAction.cs @@ -30,11 +30,9 @@ public bool IsExecutable if (page is null) return false; - bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; bool isRenaming = page.SlimContentPage.IsRenamingItem; - return isCommandPaletteOpen || (!isEditing && !isRenaming); + return !isRenaming; } } diff --git a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs index 8054e9d0450e..d3bd0c95bfd2 100644 --- a/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs +++ b/src/Files.App/Actions/Content/Selection/InvertSelectionAction.cs @@ -30,11 +30,8 @@ public bool IsExecutable if (page is null) return false; - bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; bool isRenaming = page.SlimContentPage.IsRenamingItem; - - return isCommandPaletteOpen || (!isEditing && !isRenaming); + return !isRenaming; } } diff --git a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs index 5f3aae630853..0dac1beab3ad 100644 --- a/src/Files.App/Actions/Content/Selection/SelectAllAction.cs +++ b/src/Files.App/Actions/Content/Selection/SelectAllAction.cs @@ -35,11 +35,9 @@ public bool IsExecutable if (itemCount == selectedItemCount) return false; - bool isCommandPaletteOpen = page.ToolbarViewModel.IsCommandPaletteOpen; - bool isEditing = page.ToolbarViewModel.IsEditModeEnabled; bool isRenaming = page.SlimContentPage?.IsRenamingItem ?? false; - return isCommandPaletteOpen || (!isEditing && !isRenaming); + return !isRenaming; } } diff --git a/src/Files.App/Actions/Global/EditPathAction.cs b/src/Files.App/Actions/Global/EditPathAction.cs index f9ca51490d5e..302c9d0f9b30 100644 --- a/src/Files.App/Actions/Global/EditPathAction.cs +++ b/src/Files.App/Actions/Global/EditPathAction.cs @@ -31,12 +31,7 @@ public EditPathAction() public Task ExecuteAsync(object? parameter = null) { if (context.ShellPage is not null) - { - if (GeneralSettingsService.EnableOmnibarDesign) - context.ShellPage!.ToolbarViewModel.SwitchToPathMode(); - else - context.ShellPage.ToolbarViewModel.IsEditModeEnabled = true; - } + context.ShellPage!.ToolbarViewModel.SwitchToPathMode(); return Task.CompletedTask; } diff --git a/src/Files.App/Actions/Global/SearchAction.cs b/src/Files.App/Actions/Global/SearchAction.cs index 6e4b63a3cdcc..446a301695a4 100644 --- a/src/Files.App/Actions/Global/SearchAction.cs +++ b/src/Files.App/Actions/Global/SearchAction.cs @@ -22,14 +22,9 @@ public HotKey SecondHotKey public RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.Omnibar.Search"); - public bool IsExecutable - => !context.IsSearchBoxVisible; - public SearchAction() { context = Ioc.Default.GetRequiredService(); - - context.PropertyChanged += Context_PropertyChanged; } public Task ExecuteAsync(object? parameter = null) @@ -38,15 +33,5 @@ public Task ExecuteAsync(object? parameter = null) return Task.CompletedTask; } - - private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) - { - switch (e.PropertyName) - { - case nameof(IContentPageContext.IsSearchBoxVisible): - OnPropertyChanged(nameof(IsExecutable)); - break; - } - } } } diff --git a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs index d51bb9cd8058..da3cf6dc0b81 100644 --- a/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs +++ b/src/Files.App/Data/Contexts/ContentPage/ContentPageContext.cs @@ -39,8 +39,6 @@ internal sealed partial class ContentPageContext : ObservableObject, IContentPag public bool CanNavigateToParent => ShellPage is not null && ShellPage.ToolbarViewModel.CanNavigateToParent; - public bool IsSearchBoxVisible => ShellPage is not null && ShellPage.ToolbarViewModel.IsSearchBoxVisible; - public bool CanCreateItem => GetCanCreateItem(); public bool IsMultiPaneAvailable => ShellPage is not null && ShellPage.PaneHolder is not null && ShellPage.PaneHolder.IsMultiPaneAvailable; @@ -167,7 +165,6 @@ private void ToolbarViewModel_PropertyChanged(object? sender, PropertyChangedEve case nameof(NavigationToolbarViewModel.CanNavigateToParent): case nameof(NavigationToolbarViewModel.HasItem): case nameof(NavigationToolbarViewModel.CanRefresh): - case nameof(NavigationToolbarViewModel.IsSearchBoxVisible): OnPropertyChanged(e.PropertyName); break; case nameof(NavigationToolbarViewModel.SelectedItems): diff --git a/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs b/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs index f4a4a5c8a9aa..7a278b3a86b9 100644 --- a/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs +++ b/src/Files.App/Data/Contexts/ContentPage/IContentPageContext.cs @@ -23,8 +23,6 @@ public interface IContentPageContext : INotifyPropertyChanged bool CanGoForward { get; } bool CanNavigateToParent { get; } - bool IsSearchBoxVisible { get; } - bool CanCreateItem { get; } bool IsMultiPaneAvailable { get; } diff --git a/src/Files.App/Data/Contexts/Multitasking/MultitaskingContext.cs b/src/Files.App/Data/Contexts/Multitasking/MultitaskingContext.cs index be9e55cde60c..8219ded4f7ef 100644 --- a/src/Files.App/Data/Contexts/Multitasking/MultitaskingContext.cs +++ b/src/Files.App/Data/Contexts/Multitasking/MultitaskingContext.cs @@ -10,8 +10,6 @@ namespace Files.App.Data.Contexts { internal sealed partial class MultitaskingContext : ObservableObject, IMultitaskingContext { - private readonly MainPageViewModel MainPageViewModel = Ioc.Default.GetRequiredService(); - private bool isPopupOpen = false; private ITabBar? control; @@ -72,9 +70,6 @@ private void FocusManager_GotFocus(object? sender, FocusManagerGotFocusEventArgs { int newSelectedIndex = MainPageViewModel.AppInstances.IndexOf(tabItem); UpdateSelectedTabIndex(newSelectedIndex); - - // Focus the content of the selected tab item (needed for pointer navigation) - (MainPageViewModel.SelectedTabItem?.TabItemContent as Control)?.Focus(FocusState.Programmatic); } } diff --git a/src/Files.App/Data/Contracts/IAddressToolbarViewModel.cs b/src/Files.App/Data/Contracts/IAddressToolbarViewModel.cs index 42a5f0b7637c..f3345d435dc5 100644 --- a/src/Files.App/Data/Contracts/IAddressToolbarViewModel.cs +++ b/src/Files.App/Data/Contracts/IAddressToolbarViewModel.cs @@ -5,15 +5,6 @@ namespace Files.App.Data.Contracts { public interface IAddressToolbarViewModel { - public bool IsSearchBoxVisible { get; set; } - - public bool IsEditModeEnabled { get; set; } - - /// - /// Gets or sets the value that indicates whether the command palette is open. - /// - public bool IsCommandPaletteOpen { get; set; } - public bool CanRefresh { get; set; } public bool CanCopyPathInPage { get; set; } @@ -36,14 +27,11 @@ public interface IAddressToolbarViewModel public event ToolbarQuerySubmittedEventHandler PathBoxQuerySubmitted; - public event EventHandler EditModeEnabled; public event ItemDraggedOverPathItemEventHandler ItemDraggedOverPathItem; public event EventHandler RefreshWidgetsRequested; public void SwitchToSearchMode(); - - public ISearchBoxViewModel SearchBox { get; } } } diff --git a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs index 7b12ba1bbd0e..e473508791fe 100644 --- a/src/Files.App/Data/Contracts/IGeneralSettingsService.cs +++ b/src/Files.App/Data/Contracts/IGeneralSettingsService.cs @@ -304,10 +304,5 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty /// Gets or sets a value whether the filter header should be displayed. /// bool ShowFilterHeader { get; set; } - - /// - /// Gets or sets a value indicating whether or not to enable the Omnibar. - /// - bool EnableOmnibarDesign { get; set; } } } diff --git a/src/Files.App/Data/Contracts/ISearchBoxViewModel.cs b/src/Files.App/Data/Contracts/ISearchBoxViewModel.cs deleted file mode 100644 index b04cc5ff18b0..000000000000 --- a/src/Files.App/Data/Contracts/ISearchBoxViewModel.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Windows.Foundation; - -namespace Files.App.Data.Contracts -{ - public interface ISearchBoxViewModel - { - event TypedEventHandler TextChanged; - - event TypedEventHandler QuerySubmitted; - - event EventHandler Escaped; - - bool WasQuerySubmitted { get; set; } - - string Query { get; set; } - - void ClearSuggestions(); - - void SetSuggestions(IEnumerable suggestions); - - void AddRecentQueries(); - } -} diff --git a/src/Files.App/Data/EventArguments/AddressBarTextEnteredEventArgs.cs b/src/Files.App/Data/EventArguments/AddressBarTextEnteredEventArgs.cs deleted file mode 100644 index eb0f07fbd446..000000000000 --- a/src/Files.App/Data/EventArguments/AddressBarTextEnteredEventArgs.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Files.App.Views; -using Microsoft.UI.Xaml.Controls; -using Windows.ApplicationModel.DataTransfer; - -namespace Files.App.Data.EventArguments -{ - public sealed class AddressBarTextEnteredEventArgs - { - public AutoSuggestBox AddressBarTextField { get; set; } - } -} diff --git a/src/Files.App/Data/TemplateSelectors/PathBreadcrumbItemSelector.cs b/src/Files.App/Data/TemplateSelectors/PathBreadcrumbItemSelector.cs deleted file mode 100644 index a63112ba2723..000000000000 --- a/src/Files.App/Data/TemplateSelectors/PathBreadcrumbItemSelector.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; - -namespace Files.App.Data.TemplateSelectors -{ - /// - /// Provides template selector for Path Breadcrumb template items. - /// - internal sealed partial class PathBreadcrumbItemSelector : DataTemplateSelector - { - public DataTemplate? ParentItems { get; set; } - - public DataTemplate? CurrentItem { get; set; } - - protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) - { - var itemsControl = ItemsControl.ItemsControlFromItemContainer(container); - - if (itemsControl.ItemsSource is ObservableCollection items) - { - return - itemsControl.IndexFromContainer(container) == items.Count - 1 - ? CurrentItem! - : ParentItems!; - } - else - { - throw new ArgumentException($"Type of {nameof(itemsControl.ItemsSource)} doesn't match ObservableCollection<{nameof(PathBoxItem)}>"); - } - } - } -} diff --git a/src/Files.App/Services/Settings/GeneralSettingsService.cs b/src/Files.App/Services/Settings/GeneralSettingsService.cs index 889ac71779bb..addc268ce18a 100644 --- a/src/Files.App/Services/Settings/GeneralSettingsService.cs +++ b/src/Files.App/Services/Settings/GeneralSettingsService.cs @@ -375,12 +375,6 @@ public bool ShowFilterHeader set => Set(value); } - public bool EnableOmnibarDesign - { - get => Get(true); - set => Set(value); - } - protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e) { base.RaiseOnSettingChangedEvent(sender, e); diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index d1eb58490662..42ceb993838a 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -4223,9 +4223,6 @@ Decimal - - Enable Omnibar - You can add sections to the sidebar by right-clicking and selecting the sections you want to add diff --git a/src/Files.App/UserControls/NavigationToolbar.xaml b/src/Files.App/UserControls/NavigationToolbar.xaml index bb76747dc890..23a2969abf7b 100644 --- a/src/Files.App/UserControls/NavigationToolbar.xaml +++ b/src/Files.App/UserControls/NavigationToolbar.xaml @@ -221,126 +221,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Files.App/UserControls/NavigationToolbar.xaml.cs b/src/Files.App/UserControls/NavigationToolbar.xaml.cs index 7e5a335082e7..1d9228f75b0e 100644 --- a/src/Files.App/UserControls/NavigationToolbar.xaml.cs +++ b/src/Files.App/UserControls/NavigationToolbar.xaml.cs @@ -37,9 +37,6 @@ public sealed partial class NavigationToolbar : UserControl [GeneratedDependencyProperty] public partial bool ShowSettingsButton { get; set; } - [GeneratedDependencyProperty] - public partial bool ShowSearchBox { get; set; } - [GeneratedDependencyProperty] public partial NavigationToolbarViewModel ViewModel { get; set; } @@ -59,87 +56,6 @@ private void NavToolbar_Loading(FrameworkElement _, object e) OngoingTasksViewModel.NewItemAdded += OngoingTasksActions_ProgressBannerPosted; } - [Obsolete("Superseded by Omnibar.")] - private void VisiblePath_Loaded(object _, RoutedEventArgs e) - { - // AutoSuggestBox won't receive focus unless it's fully loaded - VisiblePath.Focus(FocusState.Programmatic); - - if (DependencyObjectHelpers.FindChild(VisiblePath) is TextBox textBox) - { - if (textBox.Text.StartsWith(">")) - textBox.Select(1, textBox.Text.Length - 1); - else - textBox.SelectAll(); - } - } - - [Obsolete("Superseded by Omnibar.")] - private void ManualPathEntryItem_Click(object _, PointerRoutedEventArgs e) - { - if (e.Pointer.PointerDeviceType is PointerDeviceType.Mouse) - { - var ptrPt = e.GetCurrentPoint(NavToolbar); - if (ptrPt.Properties.IsMiddleButtonPressed) - return; - } - ViewModel.IsEditModeEnabled = true; - } - - [Obsolete("Superseded by Omnibar.")] - private async void VisiblePath_KeyDown(object _, KeyRoutedEventArgs e) - { - if (e.Key is VirtualKey.Escape) - ViewModel.IsEditModeEnabled = false; - - if (e.Key is VirtualKey.Tab) - { - ViewModel.IsEditModeEnabled = false; - // Delay to ensure clickable path is ready to be focused - await Task.Delay(10); - ClickablePath.Focus(FocusState.Keyboard); - } - } - [Obsolete("Superseded by Omnibar.")] - private void VisiblePath_LostFocus(object _, RoutedEventArgs e) - { - if (App.AppModel.IsMainWindowClosed) - return; - - var element = Microsoft.UI.Xaml.Input.FocusManager.GetFocusedElement(MainWindow.Instance.Content.XamlRoot); - if (element is FlyoutBase or AppBarButton or Popup) - return; - - if (element is not Control control) - { - if (ViewModel.IsEditModeEnabled) - ViewModel.IsEditModeEnabled = false; - return; - } - - if (control.FocusState is not FocusState.Programmatic and not FocusState.Keyboard) - ViewModel.IsEditModeEnabled = false; - else if (ViewModel.IsEditModeEnabled) - VisiblePath.Focus(FocusState.Programmatic); - } - - [Obsolete("Superseded by Omnibar.")] - private void SearchRegion_OnGotFocus(object sender, RoutedEventArgs e) => ViewModel.SearchRegion_GotFocus(sender, e); - [Obsolete("Superseded by Omnibar.")] - private void SearchRegion_LostFocus(object sender, RoutedEventArgs e) => ViewModel.SearchRegion_LostFocus(sender, e); - [Obsolete("Superseded by Omnibar.")] - private void SearchRegion_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEventArgs args) - { - // Suppress access key invocation if any dialog is open - if (VisualTreeHelper.GetOpenPopupsForXamlRoot(MainWindow.Instance.Content.XamlRoot).Any()) - args.Handled = true; - else - sender.Focus(FocusState.Keyboard); - } - [Obsolete("Superseded by Omnibar.")] - private void VisiblePath_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) - => ViewModel.VisiblePath_QuerySubmitted(sender, args); - private void OngoingTasksActions_ProgressBannerPosted(object? _, StatusCenterItem e) { if (OngoingTasksViewModel is not null) @@ -254,17 +170,6 @@ void HistoryItemClicked(ToolbarHistoryItemModel? itemModel) } } - [Obsolete("Superseded by Omnibar.")] - private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs args) - { - if (args.InputDevice != FocusInputDeviceKind.Keyboard) - return; - - var previousControl = args.OldFocusedElement as FrameworkElement; - if (previousControl?.Name == nameof(Refresh)) - ViewModel.IsEditModeEnabled = true; - } - private async void Omnibar_QuerySubmitted(Omnibar sender, OmnibarQuerySubmittedEventArgs args) { var mode = Omnibar.CurrentSelectedMode; diff --git a/src/Files.App/UserControls/PathBreadcrumb.xaml b/src/Files.App/UserControls/PathBreadcrumb.xaml deleted file mode 100644 index 9913d9ea4c5d..000000000000 --- a/src/Files.App/UserControls/PathBreadcrumb.xaml +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Files.App/UserControls/PathBreadcrumb.xaml.cs b/src/Files.App/UserControls/PathBreadcrumb.xaml.cs deleted file mode 100644 index 66726ee9e82b..000000000000 --- a/src/Files.App/UserControls/PathBreadcrumb.xaml.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using CommunityToolkit.WinUI; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Input; - -namespace Files.App.UserControls -{ - public sealed partial class PathBreadcrumb : UserControl - { - [GeneratedDependencyProperty] - public partial NavigationToolbarViewModel ViewModel { get; set; } - - public PathBreadcrumb() - { - InitializeComponent(); - } - - private void PathItemSeparator_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) - { - ViewModel.PathItemSeparator_DataContextChanged(sender, args); - } - - private void PathBoxItemFlyout_Opening(object sender, object e) - { - ViewModel.PathboxItemFlyout_Opening(sender, e); - } - - private void PathBoxItemFlyout_Closed(object sender, object e) - { - ViewModel.PathBoxItemFlyout_Closed(sender, e) ; - } - - private void PathBoxItem_DragLeave(object sender, DragEventArgs e) - { - ViewModel.PathBoxItem_DragLeave(sender, e); - } - - private async void PathBoxItem_DragOver(object sender, DragEventArgs e) - { - await ViewModel.PathBoxItem_DragOver(sender, e); - } - - private async void PathBoxItem_Drop(object sender, DragEventArgs e) - { - await ViewModel.PathBoxItem_Drop(sender, e); - } - - private async void PathBoxItem_Tapped(object sender, TappedRoutedEventArgs e) - { - if (sender is not TextBlock textBlock || - textBlock.DataContext is not PathBoxItem item || - item.Path is not { } path) - return; - - // TODO: Implement middle click retrieving. - await ViewModel.HandleFolderNavigationAsync(path); - - e.Handled = true; - } - - private void PathBoxItem_PointerPressed(object sender, PointerRoutedEventArgs e) - { - ViewModel.PathBoxItem_PointerPressed(sender, e); - } - - private void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e) - { - ViewModel.PathBoxItem_PreviewKeyDown(sender, e); - } - } -} diff --git a/src/Files.App/UserControls/SearchBox.xaml b/src/Files.App/UserControls/SearchBox.xaml deleted file mode 100644 index a3a9f49cc0f6..000000000000 --- a/src/Files.App/UserControls/SearchBox.xaml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Files.App/UserControls/SearchBox.xaml.cs b/src/Files.App/UserControls/SearchBox.xaml.cs deleted file mode 100644 index 43fb5c13656d..000000000000 --- a/src/Files.App/UserControls/SearchBox.xaml.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Files.App.ViewModels; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Input; - -namespace Files.App.UserControls -{ - [Obsolete("Superseded by Omnibar.")] - public sealed partial class SearchBox : UserControl - { - public static readonly DependencyProperty SearchBoxViewModelProperty = - DependencyProperty.Register(nameof(SearchBoxViewModel), typeof(SearchBoxViewModel), typeof(SearchBox), new PropertyMetadata(null)); - - public SearchBoxViewModel SearchBoxViewModel - { - get => (SearchBoxViewModel)GetValue(SearchBoxViewModelProperty); - set => SetValue(SearchBoxViewModelProperty, value); - } - - public SearchBox() => InitializeComponent(); - - private void SearchRegion_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs e) - => SearchBoxViewModel.SearchRegion_TextChanged(sender, e); - - private void SearchRegion_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs e) - => SearchBoxViewModel.SearchRegion_QuerySubmitted(sender, e); - - private void SearchRegion_Escaped(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs e) - => SearchBoxViewModel.SearchRegion_Escaped(sender, e); - - private void SearchRegion_KeyDown(object sender, KeyRoutedEventArgs e) - => SearchBoxViewModel.SearchRegion_KeyDown(sender, e); - } -} diff --git a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs index 948d33fc5489..e8dd09d35b09 100644 --- a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs +++ b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs @@ -355,21 +355,6 @@ public bool ShowFlattenOptions OnPropertyChanged(); } } - - // TODO remove when feature is marked as stable - public bool EnableOmnibarDesign - { - get => UserSettingsService.GeneralSettingsService.EnableOmnibarDesign; - set - { - if (value == UserSettingsService.GeneralSettingsService.EnableOmnibarDesign) - return; - - UserSettingsService.GeneralSettingsService.EnableOmnibarDesign = value; - OnPropertyChanged(); - } - } - public async Task OpenFilesOnWindowsStartupAsync() { var stateMode = await ReadState(); diff --git a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs index bc245cee978d..7639fc3b98c4 100644 --- a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs @@ -33,7 +33,6 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr private readonly IUserSettingsService UserSettingsService = Ioc.Default.GetRequiredService(); private readonly IAppearanceSettingsService AppearanceSettingsService = Ioc.Default.GetRequiredService(); - private readonly IGeneralSettingsService GeneralSettingsService = Ioc.Default.GetRequiredService(); private readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService(); private readonly IUpdateService UpdateService = Ioc.Default.GetRequiredService(); private readonly ICommandManager Commands = Ioc.Default.GetRequiredService(); @@ -52,17 +51,21 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr // Events public delegate void ToolbarPathItemInvokedEventHandler(object sender, PathNavigationEventArgs e); + + [Obsolete("Superseded by Omnibar.")] public delegate void ToolbarFlyoutOpeningEventHandler(object sender, ToolbarFlyoutOpeningEventArgs e); public delegate void ToolbarPathItemLoadedEventHandler(object sender, ToolbarPathItemLoadedEventArgs e); - public delegate void AddressBarTextEnteredEventHandler(object sender, AddressBarTextEnteredEventArgs e); + public delegate void PathBoxItemDroppedEventHandler(object sender, PathBoxItemDroppedEventArgs e); public event ToolbarPathItemInvokedEventHandler? ToolbarPathItemInvoked; + + [Obsolete("Superseded by Omnibar.")] public event ToolbarFlyoutOpeningEventHandler? ToolbarFlyoutOpening; + public event ToolbarPathItemLoadedEventHandler? ToolbarPathItemLoaded; public event IAddressToolbarViewModel.ItemDraggedOverPathItemEventHandler? ItemDraggedOverPathItem; - public event EventHandler? EditModeEnabled; public event IAddressToolbarViewModel.ToolbarQuerySubmittedEventHandler? PathBoxQuerySubmitted; - public event AddressBarTextEnteredEventHandler? AddressBarTextEntered; + public event PathBoxItemDroppedEventHandler? PathBoxItemDropped; public event EventHandler? RefreshWidgetsRequested; @@ -82,10 +85,6 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr public bool IsSingleItemOverride { get; set; } - [Obsolete("Superseded by Omnibar.")] - public bool SearchHasFocus { get; private set; } - - public bool EnableOmnibarDesign => GeneralSettingsService.EnableOmnibarDesign; public bool ShowStatusCenterButton => AppearanceSettingsService.StatusCenterVisibility == StatusCenterVisibility.Always || (AppearanceSettingsService.StatusCenterVisibility == StatusCenterVisibility.DuringOngoingFileOperations && OngoingTasksViewModel.HasAnyItem); @@ -94,9 +93,6 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr private NavigationToolbar? AddressToolbar => (MainWindow.Instance.Content as Frame)?.FindDescendant(); - [Obsolete("Superseded by Omnibar.")] - public SearchBoxViewModel SearchBoxViewModel => (SearchBoxViewModel)SearchBox; - public bool HasAdditionalAction => InstanceViewModel.IsPageTypeRecycleBin || Commands.RunWithPowershell.IsExecutable || @@ -157,9 +153,6 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.ExtraLarge) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.ExtraLarge); - private bool _IsCommandPaletteOpen; - public bool IsCommandPaletteOpen { get => _IsCommandPaletteOpen; set => SetProperty(ref _IsCommandPaletteOpen, value); } - private bool _IsDynamicOverflowEnabled; public bool IsDynamicOverflowEnabled { get => _IsDynamicOverflowEnabled; set => SetProperty(ref _IsDynamicOverflowEnabled, value); } @@ -187,18 +180,6 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr private bool _CanRefresh; public bool CanRefresh { get => _CanRefresh; set => SetProperty(ref _CanRefresh, value); } - private string _SearchButtonGlyph = "\uE721"; - [Obsolete("Superseded by Omnibar.")] - public string SearchButtonGlyph { get => _SearchButtonGlyph; set => SetProperty(ref _SearchButtonGlyph, value); } - - private bool _ManualEntryBoxLoaded; - [Obsolete("Superseded by Omnibar.")] - public bool ManualEntryBoxLoaded { get => _ManualEntryBoxLoaded; set => SetProperty(ref _ManualEntryBoxLoaded, value); } - - private bool _ClickablePathLoaded = true; - [Obsolete("Superseded by Omnibar.")] - public bool ClickablePathLoaded { get => _ClickablePathLoaded; set => SetProperty(ref _ClickablePathLoaded, value); } - private string _PathControlDisplayText; [Obsolete("Superseded by Omnibar.")] public string PathControlDisplayText { get => _PathControlDisplayText; set => SetProperty(ref _PathControlDisplayText, value); } @@ -209,21 +190,6 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr private Style _LayoutThemedIcon; public Style LayoutThemedIcon { get => _LayoutThemedIcon; set => SetProperty(ref _LayoutThemedIcon, value); } - private ISearchBoxViewModel _SearchBox = new SearchBoxViewModel(); - public ISearchBoxViewModel SearchBox { get => _SearchBox; set => SetProperty(ref _SearchBox, value); } - - private bool _IsSearchBoxVisible; - [Obsolete("Superseded by Omnibar.")] - public bool IsSearchBoxVisible - { - get => _IsSearchBoxVisible; - set - { - if (SetProperty(ref _IsSearchBoxVisible, value)) - SearchButtonGlyph = value ? "\uE711" : "\uE721"; - } - } - // SetProperty doesn't seem to properly notify the binding in path bar private string? _PathText; public string? PathText @@ -236,6 +202,10 @@ public string? PathText } } + // Workaround to ensure Omnibar is only loaded after the ViewModel is initialized + public bool LoadOmnibar => + true; + private string? _OmnibarCommandPaletteModeText; public string? OmnibarCommandPaletteModeText { get => _OmnibarCommandPaletteModeText; set => SetProperty(ref _OmnibarCommandPaletteModeText, value); } @@ -262,31 +232,6 @@ public CurrentInstanceViewModel InstanceViewModel } } - [Obsolete("Superseded by Omnibar.")] - public bool IsEditModeEnabled - { - get => ManualEntryBoxLoaded; - set - { - if (value) - { - EditModeEnabled?.Invoke(this, EventArgs.Empty); - - var visiblePath = AddressToolbar?.FindDescendant(x => x.Name == "VisiblePath"); - visiblePath?.Focus(FocusState.Programmatic); - visiblePath?.FindDescendant()?.SelectAll(); - - AddressBarTextEntered?.Invoke(this, new AddressBarTextEnteredEventArgs() { AddressBarTextField = visiblePath }); - } - else - { - IsCommandPaletteOpen = false; - ManualEntryBoxLoaded = false; - ClickablePathLoaded = true; - } - } - } - private List? _SelectedItems; public List? SelectedItems { @@ -319,7 +264,6 @@ public NavigationToolbarViewModel() _dispatcherQueue = DispatcherQueue.GetForCurrentThread(); _dragOverTimer = _dispatcherQueue.CreateTimer(); - SearchBox.Escaped += SearchRegion_Escaped; UserSettingsService.OnSettingChangedEvent += UserSettingsService_OnSettingChangedEvent; UpdateService.PropertyChanged += UpdateService_OnPropertyChanged; @@ -359,15 +303,6 @@ public NavigationToolbarViewModel() break; } }; - GeneralSettingsService.PropertyChanged += (s, e) => - { - switch (e.PropertyName) - { - case nameof(GeneralSettingsService.EnableOmnibarDesign): - OnPropertyChanged(nameof(EnableOmnibarDesign)); - break; - } - }; OngoingTasksViewModel.PropertyChanged += (s, e) => { switch (e.PropertyName) @@ -560,18 +495,6 @@ public void PathItemSeparator_DataContextChanged(FrameworkElement sender, DataCo }); } - [Obsolete("Superseded by Omnibar.")] - public void PathboxItemFlyout_Opening(object sender, object e) - { - ToolbarFlyoutOpening?.Invoke(this, new ToolbarFlyoutOpeningEventArgs((MenuFlyout)sender)); - } - - [Obsolete("Superseded by Omnibar.")] - public void PathBoxItemFlyout_Closed(object sender, object e) - { - ((MenuFlyout)sender).Items.Clear(); - } - [Obsolete("Superseded by Omnibar.")] public void CurrentPathSetTextBox_TextChanged(object sender, TextChangedEventArgs args) { @@ -579,31 +502,6 @@ public void CurrentPathSetTextBox_TextChanged(object sender, TextChangedEventArg PathBoxQuerySubmitted?.Invoke(this, new ToolbarQuerySubmittedEventArgs() { QueryText = textBox.Text }); } - [Obsolete("Superseded by Omnibar.")] - public void VisiblePath_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) - { - if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput) - AddressBarTextEntered?.Invoke(this, new AddressBarTextEnteredEventArgs() { AddressBarTextField = sender }); - } - - [Obsolete("Superseded by Omnibar.")] - public void VisiblePath_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) - { - PathBoxQuerySubmitted?.Invoke(this, new ToolbarQuerySubmittedEventArgs() { QueryText = args.QueryText }); - - (this as IAddressToolbarViewModel).IsEditModeEnabled = false; - } - - [Obsolete("Superseded by Omnibar.")] - public void PathBoxItem_PointerPressed(object sender, PointerRoutedEventArgs e) - { - if (e.Pointer.PointerDeviceType != Microsoft.UI.Input.PointerDeviceType.Mouse) - return; - - var ptrPt = e.GetCurrentPoint(AddressToolbar); - _pointerRoutedEventArgs = ptrPt.Properties.IsMiddleButtonPressed ? e : null; - } - public async Task HandleFolderNavigationAsync(string path, bool openNewTab = false) { openNewTab |= _pointerRoutedEventArgs is not null; @@ -755,43 +653,12 @@ public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e) public void SwitchToCommandPaletteMode() { - if (EnableOmnibarDesign) - { - OmnibarCurrentSelectedModeName = OmnibarPaletteModeName; - } - else - { - PathText = ">"; - IsCommandPaletteOpen = true; - ManualEntryBoxLoaded = true; - ClickablePathLoaded = false; - - var visiblePath = AddressToolbar?.FindDescendant(x => x.Name == "VisiblePath"); - AddressBarTextEntered?.Invoke(this, new AddressBarTextEnteredEventArgs() { AddressBarTextField = visiblePath }); - } + OmnibarCurrentSelectedModeName = OmnibarPaletteModeName; } public void SwitchToSearchMode() { - if (EnableOmnibarDesign) - { - OmnibarCurrentSelectedModeName = OmnibarSearchModeName; - } - else - { - if (IsSearchBoxVisible) - CloseSearchBox(true); - else - { - IsSearchBoxVisible = true; - - // Given that binding and layouting might take a few cycles, when calling UpdateLayout - // we can guarantee that the focus call will be able to find an open ASB - var searchbox = AddressToolbar?.FindDescendant("SearchRegion") as SearchBox; - searchbox?.UpdateLayout(); - searchbox?.Focus(FocusState.Programmatic); - } - } + OmnibarCurrentSelectedModeName = OmnibarSearchModeName; } public void SwitchToPathMode() @@ -808,52 +675,6 @@ public void UpdateAdditionalActions() OnPropertyChanged(nameof(HasAdditionalAction)); } - [Obsolete("Superseded by Omnibar.")] - private void CloseSearchBox(bool doFocus = false) - { - if (_SearchBox.WasQuerySubmitted) - { - _SearchBox.WasQuerySubmitted = false; - } - else - { - IsSearchBoxVisible = false; - - if (doFocus) - { - SearchBox.Query = string.Empty; - - var page = Ioc.Default.GetRequiredService().ShellPage?.SlimContentPage; - - if (page is BaseGroupableLayoutPage svb && svb.IsLoaded) - page.ItemManipulationModel.FocusFileList(); - else - AddressToolbar?.Focus(FocusState.Programmatic); - } - } - } - - [Obsolete("Superseded by Omnibar.")] - public void SearchRegion_GotFocus(object sender, RoutedEventArgs e) - { - SearchHasFocus = true; - } - - [Obsolete("Superseded by Omnibar.")] - public void SearchRegion_LostFocus(object sender, RoutedEventArgs e) - { - var element = Microsoft.UI.Xaml.Input.FocusManager.GetFocusedElement(); - if (element is FlyoutBase or AppBarButton) - return; - - SearchHasFocus = false; - CloseSearchBox(); - } - - [Obsolete("Superseded by Omnibar.")] - private void SearchRegion_Escaped(object? sender, ISearchBoxViewModel _SearchBox) - => CloseSearchBox(true); - public async Task SetPathBoxDropDownFlyoutAsync(MenuFlyout flyout, PathBoxItem pathItem) { var nextPathItemTitle = PathComponents[PathComponents.IndexOf(pathItem) + 1].Title; @@ -1320,151 +1141,6 @@ public async Task PopulateOmnibarSuggestionsForSearchMode() OmnibarSearchModeSuggestionItems.Add(item); } - [Obsolete("Superseded by Omnibar.")] - public async Task SetAddressBarSuggestionsAsync(AutoSuggestBox sender, IShellPage shellpage) - { - if (sender.Text is not null && shellpage.ShellViewModel is not null) - { - if (!await SafetyExtensions.IgnoreExceptions(async () => - { - IList? suggestions = null; - - if (sender.Text.StartsWith(">")) - { - IsCommandPaletteOpen = true; - var searchText = sender.Text.Substring(1).Trim(); - suggestions = Commands.Where(command => - command.IsExecutable && - command.IsAccessibleGlobally && - (command.Description.Contains(searchText, StringComparison.OrdinalIgnoreCase) || - command.Code.ToString().Contains(searchText, StringComparison.OrdinalIgnoreCase))) - .Select(command => new NavigationBarSuggestionItem() - { - Text = ">" + command.Code, - PrimaryDisplay = command.Description, - HotKeys = command.HotKeys, - SearchText = searchText, - }).ToList(); - } - else - { - IsCommandPaletteOpen = false; - var currentInput = sender.Text; - - if (string.IsNullOrWhiteSpace(currentInput) || currentInput == "Home" || currentInput == "ReleaseNotes" || currentInput == "Settings") - { - // Load previously entered path - var pathHistoryList = UserSettingsService.GeneralSettingsService.PathHistoryList; - if (pathHistoryList is not null) - { - suggestions = pathHistoryList.Select(x => new NavigationBarSuggestionItem() - { - Text = x, - PrimaryDisplay = x - }).ToList(); - } - } - else - { - var isFtp = FtpHelpers.IsFtpPath(currentInput); - currentInput = NormalizePathInput(currentInput, isFtp); - var expandedPath = StorageFileExtensions.GetResolvedPath(currentInput, isFtp); - var folderPath = PathNormalization.GetParentDir(expandedPath) ?? expandedPath; - StorageFolderWithPath folder = await shellpage.ShellViewModel.GetFolderWithPathFromPathAsync(folderPath); - - if (folder is null) - return false; - - var currPath = await folder.GetFoldersWithPathAsync(Path.GetFileName(expandedPath), (uint)MaxSuggestionsCount); - if (currPath.Count >= MaxSuggestionsCount) - { - suggestions = currPath.Select(x => new NavigationBarSuggestionItem() - { - Text = x.Path, - PrimaryDisplay = x.Item.DisplayName - }).ToList(); - } - else if (currPath.Any()) - { - var subPath = await currPath.First().GetFoldersWithPathAsync((uint)(MaxSuggestionsCount - currPath.Count)); - suggestions = currPath.Select(x => new NavigationBarSuggestionItem() - { - Text = x.Path, - PrimaryDisplay = x.Item.DisplayName - }).Concat( - subPath.Select(x => new NavigationBarSuggestionItem() - { - Text = x.Path, - PrimaryDisplay = PathNormalization.Combine(currPath.First().Item.DisplayName, x.Item.DisplayName) - })).ToList(); - } - } - } - - if (suggestions is null || suggestions.Count == 0) - { - suggestions = new List() { new NavigationBarSuggestionItem() { - Text = shellpage.ShellViewModel.WorkingDirectory, - PrimaryDisplay = Strings.NavigationToolbarVisiblePathNoResults.GetLocalizedResource() } }; - } - - // NavigationBarSuggestions becoming empty causes flickering of the suggestion box - // Here we check whether at least an element is in common between old and new list - if (!NavigationBarSuggestions.IntersectBy(suggestions, x => x.PrimaryDisplay).Any()) - { - // No elements in common, update the list in-place - for (int index = 0; index < suggestions.Count; index++) - { - if (index < NavigationBarSuggestions.Count) - { - NavigationBarSuggestions[index].Text = suggestions[index].Text; - NavigationBarSuggestions[index].PrimaryDisplay = suggestions[index].PrimaryDisplay; - NavigationBarSuggestions[index].SearchText = suggestions[index].SearchText; - NavigationBarSuggestions[index].HotKeys = suggestions[index].HotKeys; - } - else - { - NavigationBarSuggestions.Add(suggestions[index]); - } - } - - while (NavigationBarSuggestions.Count > suggestions.Count) - NavigationBarSuggestions.RemoveAt(NavigationBarSuggestions.Count - 1); - } - else - { - // At least an element in common, show animation - foreach (var s in NavigationBarSuggestions.ExceptBy(suggestions, x => x.PrimaryDisplay).ToList()) - NavigationBarSuggestions.Remove(s); - - for (int index = 0; index < suggestions.Count; index++) - { - if (NavigationBarSuggestions.Count > index && NavigationBarSuggestions[index].PrimaryDisplay == suggestions[index].PrimaryDisplay) - { - NavigationBarSuggestions[index].SearchText = suggestions[index].SearchText; - NavigationBarSuggestions[index].HotKeys = suggestions[index].HotKeys; - } - else - NavigationBarSuggestions.Insert(index, suggestions[index]); - } - } - - return true; - })) - { - SafetyExtensions.IgnoreExceptions(() => - { - NavigationBarSuggestions.Clear(); - NavigationBarSuggestions.Add(new NavigationBarSuggestionItem() - { - Text = shellpage.ShellViewModel.WorkingDirectory, - PrimaryDisplay = Strings.NavigationToolbarVisiblePathNoResults.GetLocalizedResource() - }); - }); - } - } - } - private void FolderSettings_PropertyChanged(object? sender, PropertyChangedEventArgs e) { switch (e.PropertyName) @@ -1496,7 +1172,6 @@ private void FolderSettings_PropertyChanged(object? sender, PropertyChangedEvent public void Dispose() { - SearchBox.Escaped -= SearchRegion_Escaped; UserSettingsService.OnSettingChangedEvent -= UserSettingsService_OnSettingChangedEvent; } } diff --git a/src/Files.App/ViewModels/UserControls/SearchBoxViewModel.cs b/src/Files.App/ViewModels/UserControls/SearchBoxViewModel.cs deleted file mode 100644 index 00d679b291c2..000000000000 --- a/src/Files.App/ViewModels/UserControls/SearchBoxViewModel.cs +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Input; -using Windows.Foundation; -using Windows.System; - -namespace Files.App.ViewModels.UserControls -{ - [Obsolete("Superseded by Omnibar.")] - public sealed partial class SearchBoxViewModel : ObservableObject, ISearchBoxViewModel - { - private string query; - public string Query - { - get => query; - set => SetProperty(ref query, value); - } - - public bool WasQuerySubmitted { get; set; } = false; - - public event TypedEventHandler? TextChanged; - - public event TypedEventHandler? QuerySubmitted; - - public event EventHandler? Escaped; - - private readonly SuggestionComparer suggestionComparer = new SuggestionComparer(); - - public ObservableCollection Suggestions { get; } = []; - - private readonly List oldQueries = []; - - public void ClearSuggestions() - { - Suggestions.Clear(); - } - - public void SetSuggestions(IEnumerable suggestions) - { - ClearSuggestions(); - - var items = suggestions.OrderBy(suggestion => suggestion, suggestionComparer).ToList(); - - var oldSuggestions = Suggestions.Except(items, suggestionComparer).ToList(); - foreach (var oldSuggestion in oldSuggestions) - Suggestions.Remove(oldSuggestion); - - var newSuggestions = items.Except(Suggestions, suggestionComparer).ToList(); - foreach (var newSuggestion in newSuggestions) - { - var indexSuggestion = Suggestions.FirstOrDefault(suggestion => suggestionComparer.Compare(suggestion, newSuggestion) < 1); - if (!(indexSuggestion is null)) - { - int index = Suggestions.IndexOf(indexSuggestion); - Suggestions.Insert(index, newSuggestion); - } - else - { - Suggestions.Add(newSuggestion); - } - } - } - - public void SearchRegion_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs e) - { - TextChanged?.Invoke(this, new SearchBoxTextChangedEventArgs(e.Reason)); - } - - public void SearchRegion_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs e) - { - if (e.ChosenSuggestion is null && string.IsNullOrWhiteSpace(e.QueryText)) - return; - - WasQuerySubmitted = true; - - if (e.ChosenSuggestion is SuggestionModel chosen && chosen.ItemPath is null) - { - Query = chosen.Name; - QuerySubmitted?.Invoke(this, new SearchBoxQuerySubmittedEventArgs(null)); - } - else - { - QuerySubmitted?.Invoke(this, new SearchBoxQuerySubmittedEventArgs((SuggestionModel)e.ChosenSuggestion)); - } - - if (!string.IsNullOrWhiteSpace(e.QueryText)) - { - // If the element is already contained, update its position - if (oldQueries.FirstOrDefault(suggestion => suggestion.Name == e.QueryText) is SuggestionModel old) - oldQueries.Remove(old); - - oldQueries.Insert(0, new SuggestionModel(e.QueryText, true)); - - // Limit to last 10 queries to improve performance - if (oldQueries.Count > 10) - oldQueries.RemoveAt(10); - } - } - - public void SearchRegion_Escaped(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs e) - { - Escaped?.Invoke(this, this); - } - - public void SearchRegion_GotFocus(object sender, RoutedEventArgs e) - { - if (string.IsNullOrWhiteSpace(query)) - AddRecentQueries(); - } - - public void SearchRegion_KeyDown(object sender, KeyRoutedEventArgs e) - { - e.Handled = - e.Key is VirtualKey.Left || - e.Key is VirtualKey.Right || - ((e.Key is VirtualKey.Up || e.Key is VirtualKey.Down) && Suggestions.Count == 0); - } - - public void AddRecentQueries() - { - ClearSuggestions(); - oldQueries.ForEach(Suggestions.Add); - } - - private sealed class SuggestionComparer : IEqualityComparer, IComparer - { - public int Compare(SuggestionModel x, SuggestionModel y) - => y.ItemPath.CompareTo(x.ItemPath); - - public bool Equals(SuggestionModel x, SuggestionModel y) - => y.ItemPath.Equals(x.ItemPath); - - public int GetHashCode(SuggestionModel o) - => o.ItemPath.GetHashCode(); - } - } -} diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs index b483ef0a8e6b..90f0911877d6 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs @@ -401,8 +401,7 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) - e.Handled = true; + e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) { @@ -427,9 +426,6 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Left) // Left arrow: select parent folder (previous column) { - if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) - return; - var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0; this.FindAscendant()?.MoveFocusToPreviousBlade(currentBladeIndex); FileList.SelectedItem = null; @@ -438,9 +434,6 @@ ParentShellPageInstance is null || } else if (e.Key == VirtualKey.Right) // Right arrow: switch focus to next column { - if (ParentShellPageInstance is not null && ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) - return; - var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0; this.FindAscendant()?.MoveFocusToNextBlade(currentBladeIndex + 1); e.Handled = true; diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs index c09892fa4161..cfcce735fa10 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml.cs @@ -479,8 +479,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) - e.Handled = true; + e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) { @@ -494,7 +493,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Down) { - if (isHeaderFocused && !ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) + if (isHeaderFocused) { var selectIndex = FileList.SelectedIndex < 0 ? 0 : FileList.SelectedIndex; if (FileList.ContainerFromIndex(selectIndex) is ListViewItem item) diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index 22d07bf5e5d2..51feed73cacb 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -531,8 +531,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv } else if (e.Key == VirtualKey.Space) { - if (!ParentShellPageInstance.ToolbarViewModel.IsEditModeEnabled) - e.Handled = true; + e.Handled = true; } else if (e.KeyStatus.IsMenuKeyDown && (e.Key == VirtualKey.Left || e.Key == VirtualKey.Right || e.Key == VirtualKey.Up)) { diff --git a/src/Files.App/Views/MainPage.xaml b/src/Files.App/Views/MainPage.xaml index ab1bde83e9b5..73587546e8e5 100644 --- a/src/Files.App/Views/MainPage.xaml +++ b/src/Files.App/Views/MainPage.xaml @@ -169,7 +169,6 @@ x:Load="False" Loaded="NavToolbar_Loaded" ShowOngoingTasks="True" - ShowSearchBox="True" TabIndex="1" /> @@ -433,22 +432,6 @@ - - - - - - - - - - - - - - - - diff --git a/src/Files.App/Views/MainPage.xaml.cs b/src/Files.App/Views/MainPage.xaml.cs index d849eaf3ec80..96f7006a9798 100644 --- a/src/Files.App/Views/MainPage.xaml.cs +++ b/src/Files.App/Views/MainPage.xaml.cs @@ -216,7 +216,7 @@ private async Task OnPreviewKeyDownAsync(KeyRoutedEventArgs e) // Execute command for hotkey var command = Commands[hotKey]; - if (command.Code is CommandCodes.OpenItem && source?.FindAscendantOrSelf() is not null) + if (command.Code is CommandCodes.OpenItem && (source?.FindAscendantOrSelf() is not null || source?.FindAscendantOrSelf() is not null)) break; diff --git a/src/Files.App/Views/Settings/AdvancedPage.xaml b/src/Files.App/Views/Settings/AdvancedPage.xaml index 21e688925155..4a001c502182 100644 --- a/src/Files.App/Views/Settings/AdvancedPage.xaml +++ b/src/Files.App/Views/Settings/AdvancedPage.xaml @@ -168,14 +168,6 @@ - - - - - - - - diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 65a60d14d6e4..9d777c00733e 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -137,9 +137,6 @@ public bool IsCurrentInstance { _IsCurrentInstance = value; - if (!value && SlimContentPage is not ColumnsLayoutPage) - ToolbarViewModel.IsEditModeEnabled = false; - if (value) _IsCurrentInstanceTCS.TrySetResult(); else @@ -182,14 +179,10 @@ public BaseShellPage(CurrentInstanceViewModel instanceViewModel) ToolbarViewModel.ToolbarPathItemInvoked += ShellPage_NavigationRequested; ToolbarViewModel.ToolbarFlyoutOpening += ShellPage_ToolbarFlyoutOpening; ToolbarViewModel.ToolbarPathItemLoaded += ShellPage_ToolbarPathItemLoaded; - ToolbarViewModel.AddressBarTextEntered += ShellPage_AddressBarTextEntered; ToolbarViewModel.PathBoxItemDropped += ShellPage_PathBoxItemDropped; - ToolbarViewModel.EditModeEnabled += NavigationToolbar_EditModeEnabled; ToolbarViewModel.ItemDraggedOverPathItem += ShellPage_NavigationRequested; ToolbarViewModel.PathBoxQuerySubmitted += NavigationToolbar_QuerySubmitted; - ToolbarViewModel.SearchBox.TextChanged += ShellPage_TextChanged; - ToolbarViewModel.SearchBox.QuerySubmitted += ShellPage_QuerySubmitted; InstanceViewModel.FolderSettings.SortDirectionPreferenceUpdated += AppSettings_SortDirectionPreferenceUpdated; InstanceViewModel.FolderSettings.SortOptionPreferenceUpdated += AppSettings_SortOptionPreferenceUpdated; @@ -345,39 +338,6 @@ protected void ShellPage_PreviewKeyDown(object sender, KeyRoutedEventArgs args) } } - protected async void ShellPage_QuerySubmitted(ISearchBoxViewModel sender, SearchBoxQuerySubmittedEventArgs e) - { - if (e.ChosenSuggestion is SuggestionModel item && !string.IsNullOrWhiteSpace(item.ItemPath)) - await NavigationHelpers.OpenPath(item.ItemPath, this); - else if (e.ChosenSuggestion is null && !string.IsNullOrWhiteSpace(sender.Query)) - SubmitSearch(sender.Query); - } - - protected async void ShellPage_TextChanged(ISearchBoxViewModel sender, SearchBoxTextChangedEventArgs e) - { - if (e.Reason != SearchBoxTextChangeReason.UserInput) - return; - - ShellViewModel.FilesAndFoldersFilter = sender.Query; - await ShellViewModel.ApplyFilesAndFoldersChangesAsync(); - - if (!string.IsNullOrWhiteSpace(sender.Query)) - { - var search = new FolderSearch - { - Query = sender.Query, - Folder = ShellViewModel.WorkingDirectory, - MaxItemCount = 10, - }; - - sender.SetSuggestions((await search.SearchAsync()).Select(suggestion => new SuggestionModel(suggestion))); - } - else - { - sender.AddRecentQueries(); - } - } - protected void AppSettings_SortDirectionPreferenceUpdated(object sender, SortDirection e) { ShellViewModel?.UpdateSortDirectionStatusAsync(); @@ -415,16 +375,12 @@ protected async void ShellPage_PathBoxItemDropped(object sender, PathBoxItemDrop e.SignalEvent?.Set(); } - protected async void ShellPage_AddressBarTextEntered(object sender, AddressBarTextEnteredEventArgs e) - { - await ToolbarViewModel.SetAddressBarSuggestionsAsync(e.AddressBarTextField, this); - } - protected async void ShellPage_ToolbarPathItemLoaded(object sender, ToolbarPathItemLoadedEventArgs e) { await ToolbarViewModel.SetPathBoxDropDownFlyoutAsync(e.OpenedFlyout, e.Item); } + [Obsolete("Superseded by Omnibar.")] protected async void ShellPage_ToolbarFlyoutOpening(object sender, ToolbarFlyoutOpeningEventArgs e) { var pathBoxItem = ((Button)e.OpeningFlyout.Target).DataContext as PathBoxItem; @@ -438,15 +394,6 @@ protected async void NavigationToolbar_QuerySubmitted(object sender, ToolbarQuer await ToolbarViewModel.CheckPathInputAsync(e.QueryText, ToolbarViewModel.PathComponents.LastOrDefault()?.Path, this); } - protected void NavigationToolbar_EditModeEnabled(object sender, EventArgs e) - { - ToolbarViewModel.ManualEntryBoxLoaded = true; - ToolbarViewModel.ClickablePathLoaded = false; - ToolbarViewModel.PathText = string.IsNullOrEmpty(ShellViewModel?.WorkingDirectory) - ? Constants.UserEnvironmentPaths.HomePath - : ShellViewModel.WorkingDirectory; - } - protected async void DrivesManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "ShowUserConsentOnInit") @@ -835,12 +782,9 @@ public virtual void Dispose() ToolbarViewModel.ToolbarPathItemInvoked -= ShellPage_NavigationRequested; ToolbarViewModel.ToolbarFlyoutOpening -= ShellPage_ToolbarFlyoutOpening; ToolbarViewModel.ToolbarPathItemLoaded -= ShellPage_ToolbarPathItemLoaded; - ToolbarViewModel.AddressBarTextEntered -= ShellPage_AddressBarTextEntered; ToolbarViewModel.PathBoxItemDropped -= ShellPage_PathBoxItemDropped; - ToolbarViewModel.EditModeEnabled -= NavigationToolbar_EditModeEnabled; ToolbarViewModel.ItemDraggedOverPathItem -= ShellPage_NavigationRequested; ToolbarViewModel.PathBoxQuerySubmitted -= NavigationToolbar_QuerySubmitted; - ToolbarViewModel.SearchBox.TextChanged -= ShellPage_TextChanged; InstanceViewModel.FolderSettings.LayoutPreferencesUpdateRequired -= FolderSettings_LayoutPreferencesUpdateRequired; InstanceViewModel.FolderSettings.SortDirectionPreferenceUpdated -= AppSettings_SortDirectionPreferenceUpdated; diff --git a/src/Files.App/Views/Shells/ColumnShellPage.xaml b/src/Files.App/Views/Shells/ColumnShellPage.xaml index b186d79d18a1..3434b32878f4 100644 --- a/src/Files.App/Views/Shells/ColumnShellPage.xaml +++ b/src/Files.App/Views/Shells/ColumnShellPage.xaml @@ -19,14 +19,6 @@ - - - - diff --git a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs index 4c8accff8cf1..9aeba6830f10 100644 --- a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs +++ b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs @@ -105,13 +105,7 @@ protected override async void ViewModel_WorkingDirectoryModified(object sender, private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs e) { ContentPage = await GetContentOrNullAsync(); - - if (!ToolbarViewModel.SearchBox.WasQuerySubmitted) - { - ToolbarViewModel.SearchBox.Query = string.Empty; - ToolbarViewModel.IsSearchBoxVisible = false; - } - + if (ItemDisplayFrame.CurrentSourcePageType == typeof(ColumnLayoutPage)) { // Reset DataGrid Rows that may be in "cut" command mode @@ -126,29 +120,6 @@ private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs }; } - private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args) - { - args.Handled = true; - var tabInstance = - CurrentPageType == typeof(DetailsLayoutPage) || - CurrentPageType == typeof(GridLayoutPage) || - CurrentPageType == typeof(ColumnsLayoutPage) || - CurrentPageType == typeof(ColumnLayoutPage); - - var ctrl = args.KeyboardAccelerator.Modifiers.HasFlag(VirtualKeyModifiers.Control); - var shift = args.KeyboardAccelerator.Modifiers.HasFlag(VirtualKeyModifiers.Shift); - var alt = args.KeyboardAccelerator.Modifiers.HasFlag(VirtualKeyModifiers.Menu); - - switch (c: ctrl, s: shift, a: alt, t: tabInstance, k: args.KeyboardAccelerator.Key) - { - // Ctrl + V, Paste - case (true, false, false, true, VirtualKey.V): - if (!ToolbarViewModel.IsEditModeEnabled && !ContentPage.IsRenamingItem && !InstanceViewModel.IsPageTypeSearchResults && !ToolbarViewModel.SearchHasFocus) - await UIFilesystemHelpers.PasteItemAsync(ShellViewModel.WorkingDirectory, this); - break; - } - } - public override void Back_Click() { ToolbarViewModel.CanGoBack = false; diff --git a/src/Files.App/Views/Shells/ModernShellPage.xaml b/src/Files.App/Views/Shells/ModernShellPage.xaml index dd55215cda6d..186f94c75e5d 100644 --- a/src/Files.App/Views/Shells/ModernShellPage.xaml +++ b/src/Files.App/Views/Shells/ModernShellPage.xaml @@ -30,14 +30,6 @@ - - - - Date: Mon, 21 Jul 2025 11:32:05 -0400 Subject: [PATCH 2/4] Update NavigationToolbarViewModel.cs --- .../NavigationToolbarViewModel.cs | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs index 7639fc3b98c4..19b0ecef8555 100644 --- a/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs @@ -621,36 +621,6 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.InvalidItemDialogTitle.GetLoca PathControlDisplayText = ContentPageContext.ShellPage.ShellViewModel.WorkingDirectory; } - [Obsolete("Superseded by Omnibar.")] - public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e) - { - switch (e.Key) - { - case Windows.System.VirtualKey.Down: - { - var item = e.OriginalSource as ListViewItem; - var button = item?.FindDescendant