Skip to content

Commit

Permalink
Fix icon preview when targetting exe
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Oct 10, 2024
1 parent bb32896 commit 39059c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
else if (viewModelProperty == L"Icon")
{
_DeduceCurrentIconType();
_NotifyChanges(L"LocalizedIcon");
_NotifyChanges(L"LocalizedIcon", L"EvaluatedIcon", L"IconPreview");
}
else if (viewModelProperty == L"CurrentIconType")
{
Expand Down Expand Up @@ -418,6 +418,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return Icon();
}

Windows::UI::Xaml::Controls::IconElement ProfileViewModel::IconPreview() const
{
// IconWUX sets the icon width/height to 32 by default
auto icon = Microsoft::Terminal::UI::IconPathConverter::IconWUX(EvaluatedIcon());
icon.Width(16);
icon.Height(16);
return icon;
}

void ProfileViewModel::CurrentIconType(const Windows::Foundation::IInspectable& value)
{
if (_currentIconType != value)
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/ProfileViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
{
return _currentIconType;
}
Windows::UI::Xaml::Controls::IconElement IconPreview() const;
winrt::hstring LocalizedIcon() const;
void CurrentIconType(const Windows::Foundation::IInspectable& value);
bool UsingNoIcon() const;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/ProfileViewModel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace Microsoft.Terminal.Settings.Editor
Boolean AutoMarkPromptsAvailable { get; };
Boolean RepositionCursorWithMouseAvailable { get; };

Windows.UI.Xaml.Controls.IconElement IconPreview { get; };
String EvaluatedIcon { get; };
String LocalizedIcon { get; };
String CurrentEmojiIcon;
Expand Down
8 changes: 4 additions & 4 deletions src/cascadia/TerminalSettingsEditor/Profiles_Base.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@
<local:SettingContainer.CurrentValueTemplate>
<DataTemplate x:DataType="local:ProfileViewModel">
<Grid>
<IconSourceElement Width="16"
Height="16"
IconSource="{x:Bind mtu:IconPathConverter.IconSourceWUX(Icon), Mode=OneWay}"
Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(UsingNoIcon), Mode=OneWay}" />
<ContentControl Width="16"
Height="16"
Content="{x:Bind IconPreview, Mode=OneWay}"
Visibility="{x:Bind mtu:Converters.InvertedBooleanToVisibility(UsingNoIcon), Mode=OneWay}" />
<TextBlock Margin="0,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Expand Down

0 comments on commit 39059c4

Please sign in to comment.