Skip to content

Commit ee6674e

Browse files
authored
Code Quality: Added setting to enable Omnibar (#17018)
1 parent ae5354d commit ee6674e

File tree

7 files changed

+165
-109
lines changed

7 files changed

+165
-109
lines changed

Diff for: src/Files.App/Data/Contracts/IGeneralSettingsService.cs

+5
Original file line numberDiff line numberDiff line change
@@ -294,5 +294,10 @@ public interface IGeneralSettingsService : IBaseSettingsService, INotifyProperty
294294
/// Gets or sets a value indicating whether or not to show the shelf pane.
295295
/// </summary>
296296
bool ShowShelfPane { get; set; }
297+
298+
/// <summary>
299+
/// Gets or sets a value indicating whether or not to enable the Omnibar.
300+
/// </summary>
301+
bool EnableOmnibar { get; set; }
297302
}
298303
}

Diff for: src/Files.App/Services/Settings/GeneralSettingsService.cs

+6
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ public bool ShowShelfPane
363363
set => Set(value);
364364
}
365365

366+
public bool EnableOmnibar
367+
{
368+
get => Get(false);
369+
set => Set(value);
370+
}
371+
366372
protected override void RaiseOnSettingChangedEvent(object sender, SettingChangedEventArgs e)
367373
{
368374
base.RaiseOnSettingChangedEvent(sender, e);

Diff for: src/Files.App/Strings/en-US/Resources.resw

+3
Original file line numberDiff line numberDiff line change
@@ -4187,4 +4187,7 @@
41874187
<data name="Decimal" xml:space="preserve">
41884188
<value>Decimal</value>
41894189
</data>
4190+
<data name="EnableOmnibar" xml:space="preserve">
4191+
<value>Enable Omnibar</value>
4192+
</data>
41904193
</root>

Diff for: src/Files.App/UserControls/NavigationToolbar.xaml

+114-100
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
xmlns:ucs="using:Files.App.UserControls.StatusCenter"
2020
xmlns:vm="using:Files.App.ViewModels.UserControls"
2121
x:Name="NavToolbar"
22-
Height="50"
2322
Loading="NavToolbar_Loading"
2423
mc:Ignorable="d">
2524

@@ -55,14 +54,14 @@
5554
</UserControl.Resources>
5655

5756
<Grid
58-
Padding="8"
57+
Height="48"
58+
Padding="4,0,4,0"
5959
Background="{ThemeResource App.Theme.AddressBar.BackgroundBrush}"
6060
ColumnSpacing="4">
6161
<Grid.ColumnDefinitions>
6262
<ColumnDefinition Width="Auto" />
6363
<ColumnDefinition Width="*" />
6464
<ColumnDefinition Width="Auto" />
65-
<ColumnDefinition Width="Auto" />
6665
</Grid.ColumnDefinitions>
6766

6867
<!-- Listary Integration -->
@@ -203,114 +202,129 @@
203202
</Button>
204203
</StackPanel>
205204

206-
<!-- Path Box -->
207-
<AutoSuggestBox
208-
x:Name="VisiblePath"
209-
Grid.Column="1"
210-
HorizontalAlignment="Stretch"
211-
VerticalAlignment="Center"
212-
x:Load="{x:Bind ViewModel.ManualEntryBoxLoaded, Mode=OneWay}"
213-
BorderBrush="{ThemeResource SystemBaseMediumLowColor}"
214-
BorderThickness="{ThemeResource TextControlBorderThemeThickness}"
215-
CornerRadius="{StaticResource ControlCornerRadius}"
216-
FocusDisengaged="VisiblePath_LostFocus"
217-
FontWeight="SemiBold"
218-
ItemsSource="{x:Bind ViewModel.NavigationBarSuggestions, Mode=OneWay}"
219-
Loaded="VisiblePath_Loaded"
220-
LostFocus="VisiblePath_LostFocus"
221-
PlaceholderText="{helpers:ResourceString Name=NavigationToolbarVisiblePath/PlaceholderText}"
222-
PreviewKeyDown="VisiblePath_KeyDown"
223-
QuerySubmitted="VisiblePath_QuerySubmitted"
224-
ScrollViewer.HorizontalScrollBarVisibility="Auto"
225-
ScrollViewer.VerticalScrollBarVisibility="Hidden"
226-
Text="{x:Bind ViewModel.PathText, Mode=OneWay}"
227-
TextChanged="{x:Bind ViewModel.VisiblePath_TextChanged, Mode=OneWay}"
228-
TextMemberPath="Text"
229-
Visibility="{x:Bind converters:MultiBooleanConverter.OrNotConvertToVisibility(ShowSearchBox, ViewModel.IsSearchBoxVisible), Mode=OneWay}">
230-
<AutoSuggestBox.ItemTemplate>
231-
<DataTemplate x:DataType="items:NavigationBarSuggestionItem">
232-
<StackPanel Margin="0,4">
233-
<Grid ColumnSpacing="8">
234-
<Grid.ColumnDefinitions>
235-
<ColumnDefinition Width="*" />
236-
<ColumnDefinition Width="Auto" />
237-
</Grid.ColumnDefinitions>
238-
239-
<!-- Primary Title -->
240-
<TextBlock
241-
x:Name="PrimaryDisplayBlock"
242-
Grid.Column="0"
243-
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
244-
MaxLines="1"
245-
TextTrimming="CharacterEllipsis"
246-
TextWrapping="NoWrap">
247-
<Run FontWeight="Normal" Text="{x:Bind PrimaryDisplayPreMatched, Mode=OneWay}" /><Run FontWeight="Bold" Text="{x:Bind PrimaryDisplayMatched, Mode=OneWay}" /><Run FontWeight="Normal" Text="{x:Bind PrimaryDisplayPostMatched, Mode=OneWay}" />
248-
</TextBlock>
249-
250-
<!-- Keyboard Shortcuts -->
251-
<keyboard:KeyboardShortcut
252-
x:Name="RightAlignedKeyboardShortcut"
253-
Grid.Column="1"
254-
HotKeys="{x:Bind HotKeys, Mode=OneWay}" />
255-
</Grid>
256-
</StackPanel>
257-
</DataTemplate>
258-
</AutoSuggestBox.ItemTemplate>
259-
</AutoSuggestBox>
260-
261-
<!-- Path Breadcrumb Bar -->
205+
<!-- Legacy breadcrumb bar -->
262206
<Grid
263-
x:Name="ClickablePath"
207+
x:Name="LegacyBreadcrumb"
264208
Grid.Column="1"
265-
MinHeight="33"
266-
HorizontalAlignment="Stretch"
267-
VerticalAlignment="Center"
268-
x:Load="{x:Bind ViewModel.ClickablePathLoaded, Mode=OneWay}"
269-
Background="{ThemeResource TextControlBackground}"
270-
BorderBrush="{ThemeResource ControlElevationBorderBrush}"
271-
BorderThickness="1"
272-
CornerRadius="{StaticResource ControlCornerRadius}"
273-
GettingFocus="ClickablePath_GettingFocus"
274-
PointerPressed="ManualPathEntryItem_Click"
275-
Visibility="{x:Bind converters:MultiBooleanConverter.OrNotConvertToVisibility(ShowSearchBox, ViewModel.IsSearchBoxVisible), Mode=OneWay}">
209+
x:Load="{x:Bind ViewModel.EnableOmnibar, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
210+
ColumnSpacing="4">
276211
<Grid.ColumnDefinitions>
277212
<ColumnDefinition Width="*" />
278213
<ColumnDefinition Width="Auto" />
279214
</Grid.ColumnDefinitions>
280-
<uc:PathBreadcrumb
281-
Grid.Column="0"
282-
VerticalAlignment="Stretch"
283-
HorizontalContentAlignment="Stretch"
284-
VerticalContentAlignment="Stretch"
285-
ViewModel="{x:Bind ViewModel, Mode=OneWay}" />
286-
<FontIcon
215+
<!-- Path Box -->
216+
<AutoSuggestBox
217+
x:Name="VisiblePath"
218+
HorizontalAlignment="Stretch"
219+
VerticalAlignment="Center"
220+
x:Load="{x:Bind ViewModel.ManualEntryBoxLoaded, Mode=OneWay}"
221+
BorderBrush="{ThemeResource SystemBaseMediumLowColor}"
222+
BorderThickness="{ThemeResource TextControlBorderThemeThickness}"
223+
CornerRadius="{StaticResource ControlCornerRadius}"
224+
FocusDisengaged="VisiblePath_LostFocus"
225+
FontWeight="SemiBold"
226+
ItemsSource="{x:Bind ViewModel.NavigationBarSuggestions, Mode=OneWay}"
227+
Loaded="VisiblePath_Loaded"
228+
LostFocus="VisiblePath_LostFocus"
229+
PlaceholderText="{helpers:ResourceString Name=NavigationToolbarVisiblePath/PlaceholderText}"
230+
PreviewKeyDown="VisiblePath_KeyDown"
231+
QuerySubmitted="VisiblePath_QuerySubmitted"
232+
ScrollViewer.HorizontalScrollBarVisibility="Auto"
233+
ScrollViewer.VerticalScrollBarVisibility="Hidden"
234+
Text="{x:Bind ViewModel.PathText, Mode=OneWay}"
235+
TextChanged="{x:Bind ViewModel.VisiblePath_TextChanged, Mode=OneWay}"
236+
TextMemberPath="Text"
237+
Visibility="{x:Bind converters:MultiBooleanConverter.OrNotConvertToVisibility(ShowSearchBox, ViewModel.IsSearchBoxVisible), Mode=OneWay}">
238+
<AutoSuggestBox.ItemTemplate>
239+
<DataTemplate x:DataType="items:NavigationBarSuggestionItem">
240+
<StackPanel Margin="0,4">
241+
<Grid ColumnSpacing="8">
242+
<Grid.ColumnDefinitions>
243+
<ColumnDefinition Width="*" />
244+
<ColumnDefinition Width="Auto" />
245+
</Grid.ColumnDefinitions>
246+
247+
<!-- Primary Title -->
248+
<TextBlock
249+
x:Name="PrimaryDisplayBlock"
250+
Grid.Column="0"
251+
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
252+
MaxLines="1"
253+
TextTrimming="CharacterEllipsis"
254+
TextWrapping="NoWrap">
255+
<Run FontWeight="Normal" Text="{x:Bind PrimaryDisplayPreMatched, Mode=OneWay}" /><Run FontWeight="Bold" Text="{x:Bind PrimaryDisplayMatched, Mode=OneWay}" /><Run FontWeight="Normal" Text="{x:Bind PrimaryDisplayPostMatched, Mode=OneWay}" />
256+
</TextBlock>
257+
258+
<!-- Keyboard Shortcuts -->
259+
<keyboard:KeyboardShortcut
260+
x:Name="RightAlignedKeyboardShortcut"
261+
Grid.Column="1"
262+
HotKeys="{x:Bind HotKeys, Mode=OneWay}" />
263+
</Grid>
264+
</StackPanel>
265+
</DataTemplate>
266+
</AutoSuggestBox.ItemTemplate>
267+
</AutoSuggestBox>
268+
269+
<!-- Path Breadcrumb Bar -->
270+
<Grid
271+
x:Name="ClickablePath"
272+
Height="34"
273+
HorizontalAlignment="Stretch"
274+
VerticalAlignment="Center"
275+
x:Load="{x:Bind ViewModel.ClickablePathLoaded, Mode=OneWay}"
276+
Background="{ThemeResource TextControlBackground}"
277+
BorderBrush="{ThemeResource ControlElevationBorderBrush}"
278+
BorderThickness="1"
279+
CornerRadius="{StaticResource ControlCornerRadius}"
280+
GettingFocus="ClickablePath_GettingFocus"
281+
PointerPressed="ManualPathEntryItem_Click"
282+
Visibility="{x:Bind converters:MultiBooleanConverter.OrNotConvertToVisibility(ShowSearchBox, ViewModel.IsSearchBoxVisible), Mode=OneWay}">
283+
<Grid.ColumnDefinitions>
284+
<ColumnDefinition Width="*" />
285+
<ColumnDefinition Width="Auto" />
286+
</Grid.ColumnDefinitions>
287+
<uc:PathBreadcrumb
288+
Grid.Column="0"
289+
VerticalAlignment="Stretch"
290+
HorizontalContentAlignment="Stretch"
291+
VerticalContentAlignment="Stretch"
292+
ViewModel="{x:Bind ViewModel, Mode=OneWay}" />
293+
<FontIcon
294+
Grid.Column="1"
295+
Margin="12"
296+
FontSize="16"
297+
Foreground="{ThemeResource App.Theme.IconBaseBrush}"
298+
Glyph="&#xE70D;" />
299+
</Grid>
300+
301+
<!-- Storage Search Box -->
302+
<uc:SearchBox
303+
x:Name="SearchRegion"
287304
Grid.Column="1"
288-
Margin="12"
289-
FontSize="16"
290-
Foreground="{ThemeResource App.Theme.IconBaseBrush}"
291-
Glyph="&#xE70D;" />
305+
Width="240"
306+
Height="34"
307+
HorizontalAlignment="Stretch"
308+
VerticalAlignment="Center"
309+
AccessKey="K"
310+
AccessKeyInvoked="SearchRegion_AccessKeyInvoked"
311+
Canvas.ZIndex="100"
312+
CornerRadius="{StaticResource ControlCornerRadius}"
313+
GotFocus="SearchRegion_OnGotFocus"
314+
LostFocus="SearchRegion_LostFocus"
315+
SearchBoxViewModel="{x:Bind ViewModel.SearchBoxViewModel, Mode=OneWay}"
316+
Visibility="{x:Bind converters:MultiBooleanConverter.OrConvertToVisibility(ShowSearchBox, ViewModel.IsSearchBoxVisible), Mode=OneWay}" />
292317
</Grid>
293318

294-
<!-- Storage Search Box -->
295-
<uc:SearchBox
296-
x:Name="SearchRegion"
297-
Grid.Column="2"
298-
Width="240"
299-
Height="34"
300-
HorizontalAlignment="Stretch"
301-
VerticalAlignment="Center"
302-
AccessKey="K"
303-
AccessKeyInvoked="SearchRegion_AccessKeyInvoked"
304-
Canvas.ZIndex="100"
305-
CornerRadius="{StaticResource ControlCornerRadius}"
306-
GotFocus="SearchRegion_OnGotFocus"
307-
LostFocus="SearchRegion_LostFocus"
308-
SearchBoxViewModel="{x:Bind ViewModel.SearchBoxViewModel, Mode=OneWay}"
309-
Visibility="{x:Bind converters:MultiBooleanConverter.OrConvertToVisibility(ShowSearchBox, ViewModel.IsSearchBoxVisible), Mode=OneWay}" />
319+
<!-- Omnibar -->
320+
<controls:Omnibar
321+
x:Name="Omnibar"
322+
Grid.Column="1"
323+
x:Load="{x:Bind ViewModel.EnableOmnibar, Mode=OneWay}" />
310324

311325
<!-- Right Side Action Buttons -->
312326
<StackPanel
313-
Grid.Column="3"
327+
Grid.Column="2"
314328
Orientation="Horizontal"
315329
Spacing="4">
316330

@@ -465,7 +479,7 @@
465479
</VisualState.StateTriggers>
466480
<VisualState.Setters>
467481
<Setter Target="ShowSearchButton.Visibility" Value="Visible" />
468-
<Setter Target="SearchRegion.(Grid.Column)" Value="1" />
482+
<Setter Target="SearchRegion.(Grid.Column)" Value="0" />
469483
<Setter Target="SearchRegion.Width" Value="NaN" />
470484
</VisualState.Setters>
471485
</VisualState>

Diff for: src/Files.App/ViewModels/Settings/AdvancedViewModel.cs

+14
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,20 @@ public bool ShowFlattenOptions
355355
OnPropertyChanged();
356356
}
357357
}
358+
359+
// TODO remove when feature is marked as stable
360+
public bool EnableOmnibar
361+
{
362+
get => UserSettingsService.GeneralSettingsService.EnableOmnibar;
363+
set
364+
{
365+
if (value == UserSettingsService.GeneralSettingsService.EnableOmnibar)
366+
return;
367+
368+
UserSettingsService.GeneralSettingsService.EnableOmnibar = value;
369+
OnPropertyChanged();
370+
}
371+
}
358372

359373
public async Task OpenFilesOnWindowsStartupAsync()
360374
{

Diff for: src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs

+11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
2525

2626
private readonly IUserSettingsService UserSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
2727
private readonly IAppearanceSettingsService AppearanceSettingsService = Ioc.Default.GetRequiredService<IAppearanceSettingsService>();
28+
private readonly IGeneralSettingsService GeneralSettingsService = Ioc.Default.GetRequiredService<IGeneralSettingsService>();
2829
private readonly DrivesViewModel drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>();
2930
private readonly IUpdateService UpdateService = Ioc.Default.GetRequiredService<IUpdateService>();
3031
private readonly ICommandManager Commands = Ioc.Default.GetRequiredService<ICommandManager>();
@@ -66,6 +67,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
6667
public bool SearchHasFocus { get; private set; }
6768

6869
public bool ShowHomeButton => AppearanceSettingsService.ShowHomeButton;
70+
public bool EnableOmnibar => GeneralSettingsService.EnableOmnibar;
6971

7072
public bool ShowShelfPaneToggleButton => AppearanceSettingsService.ShowShelfPaneToggleButton && AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev;
7173

@@ -306,6 +308,15 @@ public NavigationToolbarViewModel()
306308
break;
307309
}
308310
};
311+
GeneralSettingsService.PropertyChanged += (s, e) =>
312+
{
313+
switch (e.PropertyName)
314+
{
315+
case nameof(GeneralSettingsService.EnableOmnibar):
316+
OnPropertyChanged(nameof(EnableOmnibar));
317+
break;
318+
}
319+
};
309320
}
310321

311322
// Methods

0 commit comments

Comments
 (0)