use the background from the control when we can
This commit is contained in:
parent
62fe8235dc
commit
5e9d0b8195
|
@ -15,6 +15,13 @@ namespace winrt::TerminalApp::implementation
|
|||
_Commandline{ cmdline }
|
||||
{
|
||||
InitializeComponent();
|
||||
// If the content we're hosting is a TermControl, then use the control's
|
||||
// BG as our BG, to give the impression that it's there, under the
|
||||
// dialog.
|
||||
if (const auto termControl{ control.try_as<winrt::Microsoft::Terminal::Control::TermControl>() })
|
||||
{
|
||||
RootGrid().Background(termControl.BackgroundBrush());
|
||||
}
|
||||
}
|
||||
void AdminWarningPlaceholder::_primaryButtonClick(winrt::Windows::Foundation::IInspectable const& /*sender*/,
|
||||
RoutedEventArgs const& e)
|
||||
|
|
|
@ -11,50 +11,63 @@
|
|||
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<Border Margin="8,8,8,8"
|
||||
Padding="16,8,16,8"
|
||||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2,2,2,2"
|
||||
CornerRadius="{ThemeResource OverlayCornerRadius}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningTitle"
|
||||
Padding="0,0,0,16"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="20"
|
||||
FontWeight="Normal"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<!--
|
||||
We have to use two grids to be tricky here:
|
||||
- The outer grid will get its background from the control it hosts, and
|
||||
expands to fit its container. This will make it look like the background
|
||||
fills the space available.
|
||||
- The inner grid is set to Center,Center, so that the "dialog" appears
|
||||
centered
|
||||
-->
|
||||
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningPrefixTextBlock"
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<Grid x:Name="RootGrid"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<Grid HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center">
|
||||
<Border Margin="8,8,8,8"
|
||||
Padding="16,8,16,8"
|
||||
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
|
||||
BorderBrush="{ThemeResource SystemAccentColor}"
|
||||
BorderThickness="2,2,2,2"
|
||||
CornerRadius="{ThemeResource OverlayCornerRadius}">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningTitle"
|
||||
Padding="0,0,0,16"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="20"
|
||||
FontWeight="Normal"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
|
||||
<TextBlock Margin="0,8,0,8"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="Cascadia Code"
|
||||
Text="{x:Bind Commandline, Mode=OneWay}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningPrefixTextBlock"
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningSuffixTextBlock"
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<StackPanel HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="PrimaryButton"
|
||||
x:Uid="ApproveCommandlineWarning_PrimaryButton"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Right"
|
||||
Click="_primaryButtonClick"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
<Button x:Name="CancelButton"
|
||||
x:Uid="ApproveCommandlineWarning_CancelButton"
|
||||
HorizontalAlignment="Right"
|
||||
Click="_cancelButtonClick" />
|
||||
<TextBlock Margin="0,8,0,8"
|
||||
HorizontalAlignment="Center"
|
||||
FontFamily="Cascadia Code"
|
||||
Text="{x:Bind Commandline, Mode=OneWay}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
|
||||
<TextBlock x:Uid="ApproveCommandlineWarningSuffixTextBlock"
|
||||
HorizontalAlignment="Left"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<StackPanel HorizontalAlignment="Right"
|
||||
Orientation="Horizontal">
|
||||
<Button x:Name="PrimaryButton"
|
||||
x:Uid="ApproveCommandlineWarning_PrimaryButton"
|
||||
Margin="8"
|
||||
HorizontalAlignment="Right"
|
||||
Click="_primaryButtonClick"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
<Button x:Name="CancelButton"
|
||||
x:Uid="ApproveCommandlineWarning_CancelButton"
|
||||
HorizontalAlignment="Right"
|
||||
Click="_cancelButtonClick" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
|
|
|
@ -1597,10 +1597,9 @@ namespace winrt::TerminalApp::implementation
|
|||
// - true if we should prompt the user for approval.
|
||||
bool TerminalPage::_shouldPromptForCommandline(const winrt::hstring& cmdline) const
|
||||
{
|
||||
// NOTE: For debugging purposes, changing this to `true ||
|
||||
// _isElevated()` is a handy way of forcing the elevation logic, even
|
||||
// when unelevated.
|
||||
if (_isElevated())
|
||||
// NOTE: For debugging purposes, changing this to `true || _isElevated()`
|
||||
// is a handy way of forcing the elevation logic, even when unelevated.
|
||||
if (true || _isElevated())
|
||||
{
|
||||
// If the cmdline is EXACTLY an executable in
|
||||
// `C:\WINDOWS\System32`, then ignore this check.
|
||||
|
|
|
@ -2590,4 +2590,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
{
|
||||
return _core.ReadEntireBuffer();
|
||||
}
|
||||
|
||||
Media::Brush TermControl::BackgroundBrush()
|
||||
{
|
||||
return RootGrid().Background();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
hstring ReadEntireBuffer() const;
|
||||
|
||||
Windows::UI::Xaml::Media::Brush BackgroundBrush();
|
||||
|
||||
// -------------------------------- WinRT Events ---------------------------------
|
||||
// clang-format off
|
||||
WINRT_CALLBACK(FontSizeChanged, Control::FontSizeChangedEventArgs);
|
||||
|
|
|
@ -71,5 +71,7 @@ namespace Microsoft.Terminal.Control
|
|||
void ToggleReadOnly();
|
||||
|
||||
String ReadEntireBuffer();
|
||||
|
||||
Windows.UI.Xaml.Media.Brush BackgroundBrush { get; };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ static winrt::com_ptr<implementation::Profile> makeProfile(const std::wstring& d
|
|||
wil::unique_cotaskmem_string systemPath;
|
||||
THROW_IF_FAILED(wil::GetSystemDirectoryW(systemPath));
|
||||
std::wstring command(systemPath.get());
|
||||
WSLDistro->Commandline(command + L"\\wsl.exe -d " + distName);
|
||||
WSLDistro->Commandline(winrt::hstring{ command + L"\\wsl.exe -d " + distName });
|
||||
WSLDistro->DefaultAppearance().ColorSchemeName(L"Campbell");
|
||||
WSLDistro->StartingDirectory(winrt::hstring{ DEFAULT_STARTING_DIRECTORY });
|
||||
WSLDistro->Icon(L"ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png");
|
||||
|
|
Loading…
Reference in a new issue