22// Licensed under the MIT License.
33
44using CommunityToolkit . WinUI ;
5- using Files . App . Actions ;
65using Files . App . Controls ;
76using Files . Shared . Helpers ;
87using Microsoft . UI . Dispatching ;
@@ -151,7 +150,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
151150
152151 private bool _IsDynamicOverflowEnabled ;
153152 public bool IsDynamicOverflowEnabled { get => _IsDynamicOverflowEnabled ; set => SetProperty ( ref _IsDynamicOverflowEnabled , value ) ; }
154-
153+
155154 private bool _IsUpdating ;
156155 public bool IsUpdating { get => _IsUpdating ; set => SetProperty ( ref _IsUpdating , value ) ; }
157156
@@ -224,7 +223,7 @@ public string? PathText
224223 public string ? OmnibarCommandPaletteModeText { get => _OmnibarCommandPaletteModeText ; set => SetProperty ( ref _OmnibarCommandPaletteModeText , value ) ; }
225224
226225 private bool _IsOmnibarFocused ;
227- public bool IsOmnibarFocused
226+ public bool IsOmnibarFocused
228227 {
229228 get => _IsOmnibarFocused ;
230229 set
@@ -233,7 +232,7 @@ public bool IsOmnibarFocused
233232 {
234233 if ( value )
235234 {
236- switch ( OmnibarCurrentSelectedMode . Name )
235+ switch ( OmnibarCurrentSelectedMode . Name )
237236 {
238237 case OmnibarPathModeName :
239238 PathText =
@@ -725,59 +724,79 @@ public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
725724 switch ( e . Key )
726725 {
727726 case Windows . System . VirtualKey . Down :
728- {
729- var item = e . OriginalSource as ListViewItem ;
730- var button = item ? . FindDescendant < Button > ( ) ;
731- button ? . Flyout . ShowAt ( button ) ;
732- e . Handled = true ;
733- break ;
734- }
735- case Windows . System . VirtualKey . Space :
727+ {
728+ var item = e . OriginalSource as ListViewItem ;
729+ var button = item ? . FindDescendant < Button > ( ) ;
730+ button ? . Flyout . ShowAt ( button ) ;
731+ e . Handled = true ;
732+ break ;
733+ }
734+ case Windows . System . VirtualKey . Space :
736735 case Windows . System . VirtualKey . Enter :
737- {
738- var item = e . OriginalSource as ListViewItem ;
739- var path = ( item ? . Content as PathBoxItem ) ? . Path ;
740- if ( path == PathControlDisplayText )
741- return ;
742- ToolbarPathItemInvoked ? . Invoke ( this , new PathNavigationEventArgs ( )
743736 {
744- ItemPath = path
745- } ) ;
746- e . Handled = true ;
747- break ;
748- }
737+ var item = e . OriginalSource as ListViewItem ;
738+ var path = ( item ? . Content as PathBoxItem ) ? . Path ;
739+ if ( path == PathControlDisplayText )
740+ return ;
741+ ToolbarPathItemInvoked ? . Invoke ( this , new PathNavigationEventArgs ( )
742+ {
743+ ItemPath = path
744+ } ) ;
745+ e . Handled = true ;
746+ break ;
747+ }
749748 }
750749 }
751750
752- public void OpenCommandPalette ( )
751+ public void SwitchToCommandPaletteMode ( )
753752 {
754- PathText = ">" ;
755- IsCommandPaletteOpen = true ;
756- ManualEntryBoxLoaded = true ;
757- ClickablePathLoaded = false ;
753+ if ( EnableOmnibar )
754+ {
755+ OmnibarCurrentSelectedMode . Name = OmnibarPaletteModeName ;
756+ IsOmnibarFocused = true ;
757+ }
758+ else
759+ {
760+ PathText = ">" ;
761+ IsCommandPaletteOpen = true ;
762+ ManualEntryBoxLoaded = true ;
763+ ClickablePathLoaded = false ;
758764
759- var visiblePath = AddressToolbar ? . FindDescendant < AutoSuggestBox > ( x => x . Name == "VisiblePath" ) ;
760- AddressBarTextEntered ? . Invoke ( this , new AddressBarTextEnteredEventArgs ( ) { AddressBarTextField = visiblePath } ) ;
765+ var visiblePath = AddressToolbar ? . FindDescendant < AutoSuggestBox > ( x => x . Name == "VisiblePath" ) ;
766+ AddressBarTextEntered ? . Invoke ( this , new AddressBarTextEnteredEventArgs ( ) { AddressBarTextField = visiblePath } ) ;
767+ }
761768 }
762769
763- public void SwitchSearchBoxVisibility ( )
770+ public void SwitchToSearchMode ( )
764771 {
765- if ( IsSearchBoxVisible )
772+ if ( EnableOmnibar )
766773 {
767- CloseSearchBox ( true ) ;
774+ OmnibarCurrentSelectedMode . Name = OmnibarSearchModeName ;
775+ IsOmnibarFocused = true ;
768776 }
769777 else
770778 {
771- IsSearchBoxVisible = true ;
779+ if ( IsSearchBoxVisible )
780+ CloseSearchBox ( true ) ;
781+ else
782+ {
783+ IsSearchBoxVisible = true ;
772784
773- // Given that binding and layouting might take a few cycles, when calling UpdateLayout
774- // we can guarantee that the focus call will be able to find an open ASB
775- var searchbox = AddressToolbar ? . FindDescendant ( "SearchRegion" ) as SearchBox ;
776- searchbox ? . UpdateLayout ( ) ;
777- searchbox ? . Focus ( FocusState . Programmatic ) ;
785+ // Given that binding and layouting might take a few cycles, when calling UpdateLayout
786+ // we can guarantee that the focus call will be able to find an open ASB
787+ var searchbox = AddressToolbar ? . FindDescendant ( "SearchRegion" ) as SearchBox ;
788+ searchbox ? . UpdateLayout ( ) ;
789+ searchbox ? . Focus ( FocusState . Programmatic ) ;
790+ }
778791 }
779792 }
780793
794+ public void SwitchToPathhMode ( )
795+ {
796+ OmnibarCurrentSelectedMode . Name = OmnibarPathModeName ;
797+ IsOmnibarFocused = true ;
798+ }
799+
781800 public void UpdateAdditionalActions ( )
782801 {
783802 OnPropertyChanged ( nameof ( HasAdditionalAction ) ) ;
0 commit comments