Add default icons for the default profiles (#934)

This commit introduces a handful of default icons whose paths will be
emitted into the default profiles.

Icons are named after the profile GUIDs, which for the default profiles
are stable v5 UUIDs based on the name of the profile. The plan is that
we'll never have a duplicate default profile, and if the user wants to
duplicate it they'll need to issue it a new GUID.

Eventually, when icons can be inserted through the settings UI, we can
keep the GUID name (to unique them among all icons for all profiles) and
move them into ms-appdata:///roaming/.

The currently included icons are named for the following profiles:

"cmd" `{0caa0dad-35be-5f56-a8ff-afceeeaa6101}`
"PowerShell Core" `{574e775e-4f2a-5b96-ac1e-a2962a402336}`
"Windows PowerShell" `{61c54bbd-c2c6-5271-96e7-009a87ff44bf}`
"WSL" `{9acb9455-ca41-5af7-950f-6bca1bc9722f}`

The PowerShell profile names aren't being used yet, but this is in
preparation for #918 merging.

Fixes #933.
This commit is contained in:
Dustin L. Howett (MSFT) 2019-05-22 13:03:10 -07:00 committed by GitHub
parent e9a3d16286
commit 8c3af2d066
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 38 additions and 14 deletions

View file

@ -99,6 +99,14 @@
<Content Include="Images\Wide310x150Logo.scale-150.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
<Content Include="Images\Wide310x150Logo.scale-400.png" />
<Content Include="ProfileIcons\{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.scale-100.png" />
<Content Include="ProfileIcons\{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.scale-200.png" />
<Content Include="ProfileIcons\{574e775e-4f2a-5b96-ac1e-a2962a402336}.scale-100.png" />
<Content Include="ProfileIcons\{574e775e-4f2a-5b96-ac1e-a2962a402336}.scale-200.png" />
<Content Include="ProfileIcons\{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.scale-100.png" />
<Content Include="ProfileIcons\{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.scale-200.png" />
<Content Include="ProfileIcons\{9acb9455-ca41-5af7-950f-6bca1bc9722f}.scale-100.png" />
<Content Include="ProfileIcons\{9acb9455-ca41-5af7-950f-6bca1bc9722f}.scale-200.png" />
<PRIResource Include="Resources\en-US\Resources.resw" />
</ItemGroup>

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -12,12 +12,16 @@ using namespace winrt::Microsoft::Terminal::Settings;
using namespace ::TerminalApp;
using namespace winrt::Microsoft::Terminal::TerminalControl;
using namespace winrt::TerminalApp;
using namespace Microsoft::Console;
// {2bde4a90-d05f-401c-9492-e40884ead1d8}
// uuidv5 properties: name format is UTF-16LE bytes
static constexpr GUID TERMINAL_PROFILE_NAMESPACE_GUID =
{ 0x2bde4a90, 0xd05f, 0x401c, { 0x94, 0x92, 0xe4, 0x8, 0x84, 0xea, 0xd1, 0xd8 } };
static constexpr std::wstring_view PACKAGED_PROFILE_ICON_PATH{ L"ms-appx:///ProfileIcons/" };
static constexpr std::wstring_view PACKAGED_PROFILE_ICON_EXTENSION{ L".png" };
CascadiaSettings::CascadiaSettings() :
_globals{},
_profiles{}
@ -37,8 +41,8 @@ ColorScheme _CreateCampbellScheme()
RGB(12, 12, 12) };
auto& campbellTable = campbellScheme.GetTable();
auto campbellSpan = gsl::span<COLORREF>(&campbellTable[0], gsl::narrow<ptrdiff_t>(COLOR_TABLE_SIZE));
Microsoft::Console::Utils::InitializeCampbellColorTable(campbellSpan);
Microsoft::Console::Utils::SetColorTableAlpha(campbellSpan, 0xff);
Utils::InitializeCampbellColorTable(campbellSpan);
Utils::SetColorTableAlpha(campbellSpan, 0xff);
return campbellScheme;
}
@ -69,7 +73,7 @@ ColorScheme _CreateOneHalfDarkScheme()
oneHalfDarkTable[13] = RGB(198, 120, 221); // magenta
oneHalfDarkTable[14] = RGB( 86, 182, 194); // cyan
oneHalfDarkTable[15] = RGB(220, 223, 228); // white
Microsoft::Console::Utils::SetColorTableAlpha(oneHalfDarkSpan, 0xff);
Utils::SetColorTableAlpha(oneHalfDarkSpan, 0xff);
return oneHalfDarkScheme;
}
@ -99,7 +103,7 @@ ColorScheme _CreateOneHalfLightScheme()
oneHalfLightTable[13] = RGB(197, 119, 221); // magenta
oneHalfLightTable[14] = RGB( 86, 181, 193); // cyan
oneHalfLightTable[15] = RGB(255, 255, 255); // white
Microsoft::Console::Utils::SetColorTableAlpha(oneHalfLightSpan, 0xff);
Utils::SetColorTableAlpha(oneHalfLightSpan, 0xff);
return oneHalfLightScheme;
}
@ -127,7 +131,7 @@ ColorScheme _CreateSolarizedDarkScheme()
solarizedDarkTable[13] = RGB(108, 113, 196);
solarizedDarkTable[14] = RGB(147, 161, 161);
solarizedDarkTable[15] = RGB(253, 246, 227);
Microsoft::Console::Utils::SetColorTableAlpha(solarizedDarkSpan, 0xff);
Utils::SetColorTableAlpha(solarizedDarkSpan, 0xff);
return solarizedDarkScheme;
}
@ -155,7 +159,7 @@ ColorScheme _CreateSolarizedLightScheme()
solarizedLightTable[13] = RGB(108, 113, 196);
solarizedLightTable[14] = RGB(147, 161, 161);
solarizedLightTable[15] = RGB(253, 246, 227);
Microsoft::Console::Utils::SetColorTableAlpha(solarizedLightSpan, 0xff);
Utils::SetColorTableAlpha(solarizedLightSpan, 0xff);
return solarizedLightScheme;
}
@ -473,16 +477,18 @@ std::wstring CascadiaSettings::ExpandEnvironmentVariableString(std::wstring_view
// - name: the name of the new profile.
// Return Value:
// - A Profile, ready to be filled in
Profile CascadiaSettings::_CreateDefaultProfile(const std::wstring_view& name)
Profile CascadiaSettings::_CreateDefaultProfile(const std::wstring_view name)
{
Profile newProfile{
Microsoft::Console::Utils::CreateV5Uuid(
TERMINAL_PROFILE_NAMESPACE_GUID,
gsl::as_bytes(gsl::make_span(name))
)
};
auto profileGuid{ Utils::CreateV5Uuid(TERMINAL_PROFILE_NAMESPACE_GUID, gsl::as_bytes(gsl::make_span(name))) };
Profile newProfile{ profileGuid };
newProfile.SetName(static_cast<std::wstring>(name));
std::wstring iconPath{ PACKAGED_PROFILE_ICON_PATH };
iconPath.append(Utils::GuidToString(profileGuid));
iconPath.append(PACKAGED_PROFILE_ICON_EXTENSION);
newProfile.SetIconPath(iconPath);
return newProfile;
}

View file

@ -69,5 +69,5 @@ private:
static std::optional<winrt::hstring> _LoadAsUnpackagedApp();
static bool _IsPowerShellCoreInstalled(std::wstring_view programFileEnv, std::filesystem::path& cmdline);
static std::wstring ExpandEnvironmentVariableString(std::wstring_view source);
static Profile _CreateDefaultProfile(const std::wstring_view& name);
static Profile _CreateDefaultProfile(const std::wstring_view name);
};

View file

@ -461,6 +461,15 @@ bool Profile::HasIcon() const noexcept
return _icon.has_value();
}
// Method Description:
// - Sets this profile's icon path.
// Arguments:
// - path: the path
void Profile::SetIconPath(std::wstring_view path) noexcept
{
_icon.emplace(path);
}
// Method Description:
// - Returns this profile's icon path, if one is set. Otherwise returns the empty string.
// Return Value:

View file

@ -50,6 +50,7 @@ public:
bool HasIcon() const noexcept;
std::wstring_view GetIconPath() const noexcept;
void SetIconPath(std::wstring_view path) noexcept;
bool GetCloseOnExit() const noexcept;