/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/UserControls/TabBar/TabBar.xaml
272 строки
11 KB
Yair
Code Quality: Fixed keyboard shortcuts when refocusing window (#17502)
29 авг 2025, 03:58
Не верифицирован
29 авг 2025, 03:58
a1b843b
Код
Авторство
О чём код?
<!-- Copyright (c) Files Community. Licensed under the MIT License. --> <local:BaseTabBar x:Class="Files.App.UserControls.TabBar.TabBar" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="using:Files.App.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:helpers="using:Files.App.Helpers" xmlns:local="using:Files.App.UserControls.TabBar" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:root="using:Files.App" xmlns:uc="using:Files.App.UserControls" xmlns:wctconverters="using:CommunityToolkit.WinUI.Converters" mc:Ignorable="d"> <local:BaseTabBar.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ms-appx:///Styles/TabBarStyles.xaml" /> <ResourceDictionary> <MenuFlyout x:Key="TabFlyout" x:Name="TabItemContextMenu" Closing="TabItemContextMenu_Closing" Opening="TabItemContextMenu_Opening"> <MenuFlyoutItem Command="{x:Bind Commands.NewTab}" KeyboardAcceleratorTextOverride="{x:Bind Commands.NewTab.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.NewTab.Label}" /> <MenuFlyoutItem Command="{x:Bind Commands.DuplicateSelectedTab}" KeyboardAcceleratorTextOverride="{x:Bind Commands.DuplicateSelectedTab.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.DuplicateSelectedTab.Label}" /> <MenuFlyoutItem x:Name="MenuItemMoveTabToNewWindow" Click="MoveTabToNewWindowAsync" Text="{helpers:ResourceString Name=HorizontalMultitaskingControlMoveTabToNewWindow/Text}"> <MenuFlyoutItem.Icon> <FontIcon Glyph="" /> </MenuFlyoutItem.Icon> </MenuFlyoutItem> <MenuFlyoutItem Command="{x:Bind Commands.CloseTabsToTheLeftSelected}" KeyboardAcceleratorTextOverride="{x:Bind Commands.CloseTabsToTheLeftSelected.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.CloseTabsToTheLeftSelected.Label}" /> <MenuFlyoutItem Command="{x:Bind Commands.CloseTabsToTheRightSelected}" KeyboardAcceleratorTextOverride="{x:Bind Commands.CloseTabsToTheRightSelected.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.CloseTabsToTheRightSelected.Label}" /> <MenuFlyoutItem Command="{x:Bind Commands.CloseOtherTabsSelected}" KeyboardAcceleratorTextOverride="{x:Bind Commands.CloseOtherTabsSelected.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.CloseOtherTabsSelected.Label}" /> <MenuFlyoutItem Command="{x:Bind Commands.ReopenClosedTab}" KeyboardAcceleratorTextOverride="{x:Bind Commands.ReopenClosedTab.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.ReopenClosedTab.Label}" /> </MenuFlyout> </ResourceDictionary> </ResourceDictionary.MergedDictionaries> <wctconverters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" /> </ResourceDictionary> </local:BaseTabBar.Resources> <!-- TODO: Use TitleBar of WinAppSdk 1.6 when available --> <Border x:Name="TitlebarArea" HorizontalAlignment="Stretch" x:FieldModifier="public" Background="Transparent"> <!-- TabBar + Draggable Right Padding --> <TabView x:Name="HorizontalTabView" Margin="0,10,0,0" Padding="0" VerticalAlignment="Stretch" AllowDropTabs="True" CanDragTabs="{x:Bind AllowTabsDrag, Mode=OneWay}" CanReorderTabs="{x:Bind AllowTabsDrag, Mode=OneWay}" DragLeave="TabView_DragLeave" IsAddTabButtonVisible="False" PointerWheelChanged="TabView_PointerWheelChanged" SelectedIndex="{x:Bind root:App.AppModel.TabStripSelectedIndex, Mode=TwoWay}" SelectionChanged="TabView_SelectionChanged" TabCloseRequested="TabView_TabCloseRequested" TabDragCompleted="TabView_TabDragCompleted" TabDragStarting="TabView_TabDragStarting" TabDroppedOutside="TabView_TabDroppedOutside" TabItemsChanged="TabView_TabItemsChanged" TabItemsSource="{x:Bind Items, Mode=OneWay}" TabStripDragOver="TabView_TabStripDragOver" TabStripDrop="TabView_TabStripDrop"> <!-- Header --> <TabView.TabStripHeader> <Button Width="30" Height="30" Margin="4,0,-2,0" Padding="0" VerticalAlignment="Center" AutomationProperties.Name="{helpers:ResourceString Name=TabActions}" Background="Transparent" BorderThickness="0" ToolTipService.ToolTip="{helpers:ResourceString Name=TabActions}" Visibility="{x:Bind ShowTabActionsButton, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"> <controls:ThemedIcon Width="16" Height="16" Style="{StaticResource App.ThemedIcons.Panes.Single}" /> <Button.Flyout> <MenuFlyout Placement="BottomEdgeAlignedLeft"> <!-- New Window --> <uc:MenuFlyoutItemWithThemedIcon x:Name="OpenNewWindowTabActionButton" Command="{x:Bind Commands.NewWindow}" KeyboardAcceleratorTextOverride="{x:Bind Commands.NewWindow.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.NewWindow.Label}" ThemedIconStyle="{x:Bind Commands.NewWindow.ThemedIconStyle}" /> <!-- Enter Compact Overlay --> <uc:MenuFlyoutItemWithThemedIcon x:Name="EnterCompactOverlayTabActionButton" x:Load="{x:Bind Commands.EnterCompactOverlay.IsExecutable, Mode=OneWay}" Command="{x:Bind Commands.EnterCompactOverlay}" Text="{x:Bind Commands.EnterCompactOverlay.Label}" ThemedIconStyle="{x:Bind Commands.EnterCompactOverlay.ThemedIconStyle}" /> <!-- Exit Compact Overlay --> <uc:MenuFlyoutItemWithThemedIcon x:Name="ExitCompactOverlayTabActionButton" x:Load="{x:Bind Commands.ExitCompactOverlay.IsExecutable, Mode=OneWay}" Command="{x:Bind Commands.ExitCompactOverlay}" Text="{x:Bind Commands.ExitCompactOverlay.Label}" ThemedIconStyle="{x:Bind Commands.ExitCompactOverlay.ThemedIconStyle}" /> <!-- Add Pane --> <MenuFlyoutSubItem x:Name="SplitPaneMenuItem" x:Load="{x:Bind Commands.SplitPaneHorizontally.IsExecutable, Mode=OneWay}" Text="{helpers:ResourceString Name=SplitPane}"> <MenuFlyoutSubItem.Items> <!-- Vertical --> <uc:MenuFlyoutItemWithThemedIcon x:Name="AddVerticalPaneTabActionButton" Command="{x:Bind Commands.SplitPaneVertically, Mode=OneWay}" KeyboardAcceleratorTextOverride="{x:Bind Commands.SplitPaneVertically.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.SplitPaneVertically.Label}" ThemedIconStyle="{x:Bind Commands.SplitPaneVertically.ThemedIconStyle}" /> <!-- Horizontal --> <uc:MenuFlyoutItemWithThemedIcon x:Name="SplitPaneHorizontalTabActionButton" Command="{x:Bind Commands.SplitPaneHorizontally, Mode=OneWay}" KeyboardAcceleratorTextOverride="{x:Bind Commands.SplitPaneHorizontally.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.SplitPaneHorizontally.Label}" ThemedIconStyle="{x:Bind Commands.SplitPaneHorizontally.ThemedIconStyle}" /> </MenuFlyoutSubItem.Items> </MenuFlyoutSubItem> <!-- Arrange Panes --> <MenuFlyoutSubItem x:Name="ArrangePanesMenuItem" x:Load="{x:Bind Commands.CloseActivePane.IsExecutable, Mode=OneWay}" Text="{helpers:ResourceString Name=ArrangePanes}"> <MenuFlyoutSubItem.Items> <!-- Vertical --> <uc:ToggleMenuFlyoutItemWithThemedIcon x:Name="ArrangePanesVerticallyTabActionButton" Command="{x:Bind Commands.ArrangePanesVertically, Mode=OneWay}" IsChecked="{x:Bind Commands.ArrangePanesVertically.IsOn, Mode=OneWay}" KeyboardAcceleratorTextOverride="{x:Bind Commands.ArrangePanesVertically.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.ArrangePanesVertically.Label}" ThemedIconStyle="{x:Bind Commands.ArrangePanesVertically.ThemedIconStyle}" /> <!-- Horizontal --> <uc:ToggleMenuFlyoutItemWithThemedIcon x:Name="ArrangePanesHorizontallyTabActionButton" Command="{x:Bind Commands.ArrangePanesHorizontally, Mode=OneWay}" IsChecked="{x:Bind Commands.ArrangePanesHorizontally.IsOn, Mode=OneWay}" KeyboardAcceleratorTextOverride="{x:Bind Commands.ArrangePanesHorizontally.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.ArrangePanesHorizontally.Label}" ThemedIconStyle="{x:Bind Commands.ArrangePanesHorizontally.ThemedIconStyle}" /> </MenuFlyoutSubItem.Items> </MenuFlyoutSubItem> <!-- Close Active Pane --> <uc:MenuFlyoutItemWithThemedIcon x:Name="CloseActivePaneTabActionButton" x:Load="{x:Bind Commands.CloseActivePane.IsExecutable, Mode=OneWay}" Command="{x:Bind Commands.CloseActivePane}" KeyboardAcceleratorTextOverride="{x:Bind Commands.CloseActivePane.HotKeyText, Mode=OneWay}" Text="{x:Bind Commands.CloseActivePane.Label}" ThemedIconStyle="{x:Bind Commands.CloseActivePane.ThemedIconStyle}" /> </MenuFlyout> </Button.Flyout> </Button> </TabView.TabStripHeader> <!-- Item Template --> <TabView.TabItemTemplate> <DataTemplate x:DataType="local:TabBarItem"> <TabViewItem AllowDrop="{x:Bind AllowStorageItemDrop, Mode=OneWay}" ContextFlyout="{StaticResource TabFlyout}" DragEnter="TabViewItem_DragEnter" DragLeave="TabViewItem_DragLeave" Drop="TabViewItem_Drop" Header="{x:Bind Header, Mode=OneWay}" IconSource="{x:Bind IconSource, Mode=OneWay}" Loaded="TabViewItem_Loaded" Style="{StaticResource TabBarItemStyle}" ToolTipService.ToolTip="{x:Bind ToolTipText, Mode=OneWay}" /> </DataTemplate> </TabView.TabItemTemplate> <!-- Footer --> <TabView.TabStripFooter> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition x:Name="RightPaddingColumn" Width="0" /> </Grid.ColumnDefinitions> <!-- Height is not divisble by four in order to properly align the button --> <Button x:Name="TabBarAddNewTabButton" Grid.Column="0" Width="30" Height="30" Padding="8" HorizontalAlignment="Left" VerticalAlignment="Center" AllowDrop="True" AutomationProperties.Name="{x:Bind Commands.NewTab.AutomationName}" Background="Transparent" BorderThickness="0" Command="{x:Bind Commands.NewTab}" DragOver="TabBarAddNewTabButton_DragOver" Drop="TabBarAddNewTabButton_Drop" ToolTipService.ToolTip="{x:Bind Commands.NewTab.LabelWithHotKey, Mode=OneWay}"> <Button.Content> <FontIcon FontSize="12" Glyph="" /> </Button.Content> </Button> <!-- Left Side Drag Area --> <Rectangle x:Name="DragAreaRectangle" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="Transparent" Loaded="DragAreaRectangle_Loaded" /> </Grid> </TabView.TabStripFooter> </TabView> </Border> </local:BaseTabBar>