Compare commits
1 commit
main
...
dev/lhecke
Author | SHA1 | Date | |
---|---|---|---|
6f73c41b91 |
|
@ -9,6 +9,7 @@
|
|||
|
||||
using namespace winrt::Windows::UI::Xaml::Navigation;
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Windows::Foundation::Collections;
|
||||
using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<local:SettingContainer x:Uid="Globals_DefaultProfile"
|
||||
Margin="0">
|
||||
<ComboBox x:Name="DefaultProfile"
|
||||
ItemsSource="{x:Bind State.Settings.AllProfiles, Mode=OneWay}"
|
||||
ItemsSource="{x:Bind State.Settings.ActiveProfiles, Mode=OneWay}"
|
||||
SelectedItem="{x:Bind CurrentDefaultProfile, Mode=TwoWay}"
|
||||
Style="{StaticResource ComboBoxSettingStyle}">
|
||||
<ComboBox.ItemTemplate>
|
||||
|
|
|
@ -387,14 +387,19 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
|
||||
void MainPage::_InitializeProfilesList()
|
||||
{
|
||||
const auto menuItems = SettingsNav().MenuItems();
|
||||
|
||||
// Manually create a NavigationViewItem for each profile
|
||||
// and keep a reference to them in a map so that we
|
||||
// can easily modify the correct one when the associated
|
||||
// profile changes.
|
||||
for (const auto& profile : _settingsClone.AllProfiles())
|
||||
{
|
||||
auto navItem = _CreateProfileNavViewItem(_viewModelForProfile(profile, _settingsClone));
|
||||
SettingsNav().MenuItems().Append(navItem);
|
||||
if (!profile.Deleted())
|
||||
{
|
||||
auto navItem = _CreateProfileNavViewItem(_viewModelForProfile(profile, _settingsClone));
|
||||
menuItems.Append(navItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Top off (the end of the nav view) with the Add Profile item
|
||||
|
@ -407,7 +412,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
icon.Glyph(L"\xE710");
|
||||
addProfileItem.Icon(icon);
|
||||
|
||||
SettingsNav().MenuItems().Append(addProfileItem);
|
||||
menuItems.Append(addProfileItem);
|
||||
}
|
||||
|
||||
void MainPage::_CreateAndNavigateToNewProfile(const uint32_t index, const Model::Profile& profile)
|
||||
|
|
|
@ -18,11 +18,6 @@ using namespace winrt::Windows::Foundation;
|
|||
using namespace winrt::Windows::Foundation::Collections;
|
||||
using namespace winrt::Microsoft::Terminal::Settings::Model;
|
||||
|
||||
static const std::array<winrt::guid, 2> InBoxProfileGuids{
|
||||
winrt::guid{ 0x61c54bbd, 0xc2c6, 0x5271, { 0x96, 0xe7, 0x00, 0x9a, 0x87, 0xff, 0x44, 0xbf } }, // Windows Powershell
|
||||
winrt::guid{ 0x0caa0dad, 0x35be, 0x5f56, { 0xa8, 0xff, 0xaf, 0xce, 0xee, 0xaa, 0x61, 0x01 } } // Command Prompt
|
||||
};
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
Windows::Foundation::Collections::IObservableVector<Editor::Font> ProfileViewModel::_MonospaceFontList{ nullptr };
|
||||
|
@ -219,29 +214,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
return _originalProfileGuid;
|
||||
}
|
||||
|
||||
bool ProfileViewModel::CanDeleteProfile() const
|
||||
{
|
||||
const auto guid{ Guid() };
|
||||
if (IsBaseLayer())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (std::find(std::begin(InBoxProfileGuids), std::end(InBoxProfileGuids), guid) != std::end(InBoxProfileGuids))
|
||||
{
|
||||
// in-box profile
|
||||
return false;
|
||||
}
|
||||
else if (!Source().empty())
|
||||
{
|
||||
// dynamic profile
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Editor::AppearanceViewModel ProfileViewModel::DefaultAppearance()
|
||||
{
|
||||
return _defaultAppearanceViewModel;
|
||||
|
@ -383,21 +355,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
ProfileViewModel::UpdateFontList();
|
||||
}
|
||||
|
||||
// Set the text disclaimer for the text box
|
||||
hstring disclaimer{};
|
||||
const auto guid{ _State.Profile().Guid() };
|
||||
if (std::find(std::begin(InBoxProfileGuids), std::end(InBoxProfileGuids), guid) != std::end(InBoxProfileGuids))
|
||||
{
|
||||
// load disclaimer for in-box profiles
|
||||
disclaimer = RS_(L"Profile_DeleteButtonDisclaimerInBox");
|
||||
}
|
||||
else if (!_State.Profile().Source().empty())
|
||||
{
|
||||
// load disclaimer for dynamic profiles
|
||||
disclaimer = RS_(L"Profile_DeleteButtonDisclaimerDynamic");
|
||||
}
|
||||
DeleteButtonDisclaimer().Text(disclaimer);
|
||||
|
||||
// Check the use parent directory box if the starting directory is empty
|
||||
if (_State.Profile().StartingDirectory().empty())
|
||||
{
|
||||
|
|
|
@ -42,7 +42,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
|
||||
// general profile knowledge
|
||||
winrt::guid OriginalProfileGuid() const noexcept;
|
||||
bool CanDeleteProfile() const;
|
||||
Editor::AppearanceViewModel DefaultAppearance();
|
||||
Editor::AppearanceViewModel UnfocusedAppearance();
|
||||
bool HasUnfocusedAppearance();
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace Microsoft.Terminal.Settings.Editor
|
|||
void SetAcrylicOpacityPercentageValue(Double value);
|
||||
void SetPadding(Double value);
|
||||
|
||||
Boolean CanDeleteProfile { get; };
|
||||
Boolean IsBaseLayer;
|
||||
Boolean UseParentProcessDirectory;
|
||||
Boolean UseCustomStartingDirectory { get; };
|
||||
|
|
|
@ -146,7 +146,6 @@
|
|||
<!-- Delete Button -->
|
||||
<StackPanel Margin="{StaticResource StandardControlMargin}">
|
||||
<Button x:Name="DeleteButton"
|
||||
IsEnabled="{x:Bind State.Profile.CanDeleteProfile}"
|
||||
Style="{StaticResource DeleteButtonStyle}">
|
||||
<Button.Resources>
|
||||
<ResourceDictionary>
|
||||
|
|
|
@ -986,14 +986,6 @@
|
|||
<value>Rename</value>
|
||||
<comment>Text label for a button that can be used to begin the renaming process.</comment>
|
||||
</data>
|
||||
<data name="Profile_DeleteButtonDisclaimerInBox" xml:space="preserve">
|
||||
<value>This profile cannot be deleted because it is included by default.</value>
|
||||
<comment>Disclaimer presented next to the delete button when it is disabled. Some profiles are included in the app by default and cannot be deleted.</comment>
|
||||
</data>
|
||||
<data name="Profile_DeleteButtonDisclaimerDynamic" xml:space="preserve">
|
||||
<value>This profile cannot be deleted because it is automatically generated.</value>
|
||||
<comment>Disclaimer presented next to the delete button when it is disabled. Some profiles are automatically generated by the app and cannot be deleted.</comment>
|
||||
</data>
|
||||
<data name="ColorScheme_DeleteButtonDisclaimerInBox" xml:space="preserve">
|
||||
<value>This color scheme cannot be deleted or renamed because it is included by default.</value>
|
||||
<comment>Disclaimer presented next to the delete button when it is disabled.</comment>
|
||||
|
|
|
@ -237,9 +237,17 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::CreateNew
|
|||
}
|
||||
}
|
||||
|
||||
// Technically there's Utils::CreateV5Uuid which we could use, but I wanted
|
||||
// truly globally unique UUIDs for profiles created through the settings UI.
|
||||
GUID guid{};
|
||||
LOG_IF_FAILED(CoCreateGuid(&guid));
|
||||
|
||||
auto newProfile{ _userDefaultProfileSettings->CreateChild() };
|
||||
newProfile->Guid(guid);
|
||||
newProfile->Name(newName);
|
||||
|
||||
_allProfiles.Append(*newProfile);
|
||||
_activeProfiles.Append(*newProfile);
|
||||
return *newProfile;
|
||||
}
|
||||
|
||||
|
@ -268,12 +276,6 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::Duplicate
|
|||
{
|
||||
duplicated = winrt::make_self<Profile>();
|
||||
}
|
||||
_allProfiles.Append(*duplicated);
|
||||
|
||||
if (!source.Hidden())
|
||||
{
|
||||
_activeProfiles.Append(*duplicated);
|
||||
}
|
||||
|
||||
winrt::hstring newName{ fmt::format(L"{} ({})", source.Name(), RS_(L"CopySuffix")) };
|
||||
|
||||
|
@ -289,11 +291,11 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::Duplicate
|
|||
}
|
||||
duplicated->Name(winrt::hstring(newName));
|
||||
|
||||
const auto isProfilesDefaultsOrigin = [](const auto& profile) -> bool {
|
||||
static constexpr auto isProfilesDefaultsOrigin = [](const auto& profile) -> bool {
|
||||
return profile && profile.Origin() != OriginTag::ProfilesDefaults;
|
||||
};
|
||||
|
||||
const auto isProfilesDefaultsOriginSub = [=](const auto& sub) -> bool {
|
||||
static constexpr auto isProfilesDefaultsOriginSub = [=](const auto& sub) -> bool {
|
||||
return sub && isProfilesDefaultsOrigin(sub.SourceProfile());
|
||||
};
|
||||
|
||||
|
@ -309,7 +311,9 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::Duplicate
|
|||
target.settingName(source.settingName()); \
|
||||
}
|
||||
|
||||
DUPLICATE_SETTING_MACRO(Hidden);
|
||||
// If the source is hidden and the Settings UI creates a
|
||||
// copy of it we don't want the copy to be hidden as well.
|
||||
duplicated->Hidden(false);
|
||||
DUPLICATE_SETTING_MACRO(Icon);
|
||||
DUPLICATE_SETTING_MACRO(CloseOnExit);
|
||||
DUPLICATE_SETTING_MACRO(TabTitle);
|
||||
|
@ -389,6 +393,8 @@ winrt::Microsoft::Terminal::Settings::Model::Profile CascadiaSettings::Duplicate
|
|||
duplicated->ConnectionType(source.ConnectionType());
|
||||
}
|
||||
|
||||
_allProfiles.Append(*duplicated);
|
||||
_activeProfiles.Append(*duplicated);
|
||||
return *duplicated;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,6 +222,7 @@ winrt::Microsoft::Terminal::Settings::Model::CascadiaSettings CascadiaSettings::
|
|||
}
|
||||
else if (profile.Origin() != OriginTag::User)
|
||||
{
|
||||
profile.Deleted(true);
|
||||
profile.Hidden(true);
|
||||
}
|
||||
}
|
||||
|
@ -781,7 +782,7 @@ bool CascadiaSettings::_AppendDynamicProfilesToUserSettings()
|
|||
// * in the user settings or the default settings
|
||||
// Because we don't want to add profiles which are already
|
||||
// in the settings.json (explicitly or implicitly).
|
||||
if (profile.Hidden() || isInJsonObj(profile, _userSettings) || isInJsonObj(profile, _defaultSettings))
|
||||
if (profile.Deleted() || isInJsonObj(profile, _userSettings) || isInJsonObj(profile, _defaultSettings))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1250,8 +1251,11 @@ Json::Value CascadiaSettings::ToJson() const
|
|||
Json::Value profilesList{ Json::ValueType::arrayValue };
|
||||
for (const auto& entry : _allProfiles)
|
||||
{
|
||||
const auto prof{ winrt::get_self<implementation::Profile>(entry) };
|
||||
profilesList.append(prof->ToJson());
|
||||
if (!entry.Deleted())
|
||||
{
|
||||
const auto prof{ winrt::get_self<implementation::Profile>(entry) };
|
||||
profilesList.append(prof->ToJson());
|
||||
}
|
||||
}
|
||||
profiles[JsonKey(ProfilesListKey)] = profilesList;
|
||||
json[JsonKey(ProfilesKey)] = profiles;
|
||||
|
|
|
@ -84,6 +84,7 @@ winrt::com_ptr<Profile> Profile::CopySettings(winrt::com_ptr<Profile> source)
|
|||
{
|
||||
auto profile{ winrt::make_self<Profile>() };
|
||||
|
||||
profile->_Deleted = source->_Deleted;
|
||||
profile->_Guid = source->_Guid;
|
||||
profile->_Name = source->_Name;
|
||||
profile->_Source = source->_Source;
|
||||
|
|
|
@ -106,6 +106,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
|
||||
void _FinalizeInheritance() override;
|
||||
|
||||
WINRT_PROPERTY(bool, Deleted, false);
|
||||
WINRT_PROPERTY(OriginTag, Origin, OriginTag::None);
|
||||
|
||||
INHERITABLE_SETTING(Model::Profile, guid, Guid, _GenerateGuidForProfile(Name(), Source()));
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace Microsoft.Terminal.Settings.Model
|
|||
void CreateUnfocusedAppearance();
|
||||
void DeleteUnfocusedAppearance();
|
||||
|
||||
// True if the user manually removed this Profile from settings.json.
|
||||
Boolean Deleted;
|
||||
OriginTag Origin { get; };
|
||||
|
||||
INHERITABLE_PROFILE_SETTING(String, Name);
|
||||
|
|
Loading…
Reference in a new issue