Switch to the new and beautiful VS Dev Shell icons (#17706)

We got some new icons for Developer Command Prompt and Developer
PowerShell from our friends over on Visual Studio!

This pull request includes them in the package, and fixes up the VS
dynamic profiles to reset any icons that matched the old paths.

This may be a minor breaking change for user settings, but we're making
the assumption that if they didn't change their VS profile icons from
the defaults, they probably want to follow us to the new defaults.

To prevent anything like this from happening again, we're going to stop
serializing icons for stub profiles.

I've also included a VS version of the PowerShell "black" icon which is
currently unused, but can be used in the future for PS7+-based VS Dev
Shell.

Closes #17627
This commit is contained in:
Dustin L. Howett 2024-08-13 18:21:09 -05:00 committed by GitHub
parent 0fd8dc575f
commit 06c07ab50d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 38 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 819 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -20,9 +20,6 @@
#include "SshHostGenerator.h"
#endif
// userDefault.h is like the above, but with a default template for the user's settings.json.
#include <LegacyProfileGeneratorNamespaces.h>
#include "ApplicationState.h"
#include "DefaultTerminal.h"
#include "FileUtils.h"
@ -465,6 +462,11 @@ bool SettingsLoader::FixupUserSettings()
CommandlinePatch{ DEFAULT_WINDOWS_POWERSHELL_GUID, L"powershell.exe", L"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" },
};
static constexpr std::array iconsToClearFromVisualStudioProfiles{
std::wstring_view{ L"ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png" },
std::wstring_view{ L"ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png" },
};
auto fixedUp = userSettings.fixupsAppliedDuringLoad;
fixedUp = userSettings.globals->FixupsAppliedDuringLoad() || fixedUp;
@ -473,28 +475,39 @@ bool SettingsLoader::FixupUserSettings()
{
fixedUp = RemapColorSchemeForProfile(profile) || fixedUp;
if (!profile->HasCommandline())
if (profile->HasCommandline())
{
continue;
for (const auto& patch : commandlinePatches)
{
if (profile->Guid() == patch.guid && til::equals_insensitive_ascii(profile->Commandline(), patch.before))
{
profile->ClearCommandline();
// GH#12842:
// With the commandline field on the user profile gone, it's actually unknown what
// commandline it'll inherit, since a user profile can have multiple parents. We have to
// make sure we restore the correct commandline in case we don't inherit the expected one.
if (profile->Commandline() != patch.after)
{
profile->Commandline(winrt::hstring{ patch.after });
}
fixedUp = true;
break;
}
}
}
for (const auto& patch : commandlinePatches)
if (profile->HasIcon() && profile->HasSource() && profile->Source() == VisualStudioGenerator::Namespace)
{
if (profile->Guid() == patch.guid && til::equals_insensitive_ascii(profile->Commandline(), patch.before))
for (auto&& icon : iconsToClearFromVisualStudioProfiles)
{
profile->ClearCommandline();
// GH#12842:
// With the commandline field on the user profile gone, it's actually unknown what
// commandline it'll inherit, since a user profile can have multiple parents. We have to
// make sure we restore the correct commandline in case we don't inherit the expected one.
if (profile->Commandline() != patch.after)
if (profile->Icon() == icon)
{
profile->Commandline(winrt::hstring{ patch.after });
profile->ClearIcon();
fixedUp = true;
break;
}
fixedUp = true;
break;
}
}
}

View File

@ -329,7 +329,7 @@ Json::Value Profile::ToJson() const
// Recall: Icon isn't actually a setting in the MTSM_PROFILE_SETTINGS. We
// defined it manually in Profile, so make sure we only serialize the Icon
// if the user actually changed it here.
JsonUtils::SetValueForKey(json, IconKey, (writeBasicSettings && HasIcon()) ? Icon() : _Icon);
JsonUtils::SetValueForKey(json, IconKey, _Icon);
// PermissiveStringConverter is unnecessary for serialization
JsonUtils::SetValueForKey(json, PaddingKey, _Padding);

View File

@ -9,9 +9,11 @@
using namespace winrt::Microsoft::Terminal::Settings::Model;
std::wstring_view VisualStudioGenerator::Namespace{ L"Windows.Terminal.VisualStudio" };
std::wstring_view VisualStudioGenerator::GetNamespace() const noexcept
{
return std::wstring_view{ L"Windows.Terminal.VisualStudio" };
return Namespace;
}
void VisualStudioGenerator::GenerateProfiles(std::vector<winrt::com_ptr<implementation::Profile>>& profiles) const

View File

@ -26,6 +26,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model
class VisualStudioGenerator : public IDynamicProfileGenerator
{
public:
static std::wstring_view Namespace;
std::wstring_view GetNamespace() const noexcept override;
void GenerateProfiles(std::vector<winrt::com_ptr<implementation::Profile>>& profiles) const override;

View File

@ -41,7 +41,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model
std::wstring GetProfileIconPath() const
{
return L"ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png";
return L"ms-appx:///ProfileIcons/vs-cmd.png";
}
std::wstring GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const;

View File

@ -38,7 +38,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model
std::wstring GetProfileIconPath() const
{
return L"ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png";
return L"ms-appx:///ProfileIcons/vs-powershell.png";
}
std::wstring GetProfileName(const VsSetupConfiguration::VsSetupInstance& instance) const;