Rename IInheritable::InsertParent to improve clarity of intent
This commit is contained in:
parent
f2386de422
commit
c4efd9098b
|
@ -36,7 +36,7 @@ winrt::com_ptr<Profile> Model::implementation::CreateChild(const winrt::com_ptr<
|
||||||
profile->Name(parent->Name());
|
profile->Name(parent->Name());
|
||||||
profile->Guid(parent->Guid());
|
profile->Guid(parent->Guid());
|
||||||
profile->Hidden(parent->Hidden());
|
profile->Hidden(parent->Hidden());
|
||||||
profile->InsertParent(parent);
|
profile->AddLeastImportantParent(parent);
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ Model::Profile CascadiaSettings::DuplicateProfile(const Model::Profile& source)
|
||||||
// Make sure to add the default appearance of the duplicated profile as a parent to the duplicate's UnfocusedAppearance
|
// Make sure to add the default appearance of the duplicated profile as a parent to the duplicate's UnfocusedAppearance
|
||||||
winrt::com_ptr<AppearanceConfig> defaultAppearance;
|
winrt::com_ptr<AppearanceConfig> defaultAppearance;
|
||||||
defaultAppearance.copy_from(winrt::get_self<AppearanceConfig>(duplicated->DefaultAppearance()));
|
defaultAppearance.copy_from(winrt::get_self<AppearanceConfig>(duplicated->DefaultAppearance()));
|
||||||
unfocusedAppearance->InsertParent(defaultAppearance);
|
unfocusedAppearance->AddLeastImportantParent(defaultAppearance);
|
||||||
|
|
||||||
duplicated->UnfocusedAppearance(*unfocusedAppearance);
|
duplicated->UnfocusedAppearance(*unfocusedAppearance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,15 +284,15 @@ void SettingsLoader::MergeFragmentIntoUserSettings(const winrt::hstring& source,
|
||||||
void SettingsLoader::FinalizeLayering()
|
void SettingsLoader::FinalizeLayering()
|
||||||
{
|
{
|
||||||
// Layer default globals -> user globals
|
// Layer default globals -> user globals
|
||||||
userSettings.globals->InsertParent(inboxSettings.globals);
|
userSettings.globals->AddLeastImportantParent(inboxSettings.globals);
|
||||||
userSettings.globals->_FinalizeInheritance();
|
userSettings.globals->_FinalizeInheritance();
|
||||||
// Layer default profile defaults -> user profile defaults
|
// Layer default profile defaults -> user profile defaults
|
||||||
userSettings.baseLayerProfile->InsertParent(inboxSettings.baseLayerProfile);
|
userSettings.baseLayerProfile->AddLeastImportantParent(inboxSettings.baseLayerProfile);
|
||||||
userSettings.baseLayerProfile->_FinalizeInheritance();
|
userSettings.baseLayerProfile->_FinalizeInheritance();
|
||||||
// Layer user profile defaults -> user profiles
|
// Layer user profile defaults -> user profiles
|
||||||
for (const auto& profile : userSettings.profiles)
|
for (const auto& profile : userSettings.profiles)
|
||||||
{
|
{
|
||||||
profile->InsertParent(0, userSettings.baseLayerProfile);
|
profile->AddMostImportantParent(userSettings.baseLayerProfile);
|
||||||
profile->_FinalizeInheritance();
|
profile->_FinalizeInheritance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,7 +524,7 @@ void SettingsLoader::_parseFragment(const winrt::hstring& source, const std::str
|
||||||
{
|
{
|
||||||
if (const auto it = userSettings.profilesByGuid.find(updates); it != userSettings.profilesByGuid.end())
|
if (const auto it = userSettings.profilesByGuid.find(updates); it != userSettings.profilesByGuid.end())
|
||||||
{
|
{
|
||||||
it->second->InsertParent(0, fragmentProfile);
|
it->second->AddMostImportantParent(fragmentProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -598,7 +598,7 @@ void SettingsLoader::_addParentProfile(const winrt::com_ptr<implementation::Prof
|
||||||
{
|
{
|
||||||
// If inserted is false, we got a matching user profile with identical GUID.
|
// If inserted is false, we got a matching user profile with identical GUID.
|
||||||
// --> The generated profile is a parent of the existing user profile.
|
// --> The generated profile is a parent of the existing user profile.
|
||||||
it->second->InsertParent(profile);
|
it->second->AddLeastImportantParent(profile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ void GlobalAppSettings::_FinalizeInheritance()
|
||||||
{
|
{
|
||||||
for (const auto& parent : _parents)
|
for (const auto& parent : _parents)
|
||||||
{
|
{
|
||||||
_actionMap->InsertParent(parent->_actionMap);
|
_actionMap->AddLeastImportantParent(parent->_actionMap);
|
||||||
_keybindingsWarnings.insert(_keybindingsWarnings.end(), parent->_keybindingsWarnings.begin(), parent->_keybindingsWarnings.end());
|
_keybindingsWarnings.insert(_keybindingsWarnings.end(), parent->_keybindingsWarnings.begin(), parent->_keybindingsWarnings.end());
|
||||||
for (const auto& [k, v] : parent->_colorSchemes)
|
for (const auto& [k, v] : parent->_colorSchemes)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ winrt::com_ptr<GlobalAppSettings> GlobalAppSettings::Copy() const
|
||||||
|
|
||||||
for (const auto& parent : _parents)
|
for (const auto& parent : _parents)
|
||||||
{
|
{
|
||||||
globals->InsertParent(parent->Copy());
|
globals->AddLeastImportantParent(parent->Copy());
|
||||||
}
|
}
|
||||||
return globals;
|
return globals;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||||
// to pass ownership over to the com_ptr.
|
// to pass ownership over to the com_ptr.
|
||||||
com_ptr<T> parent;
|
com_ptr<T> parent;
|
||||||
winrt::copy_from_abi(parent, const_cast<T*>(static_cast<const T*>(this)));
|
winrt::copy_from_abi(parent, const_cast<T*>(static_cast<const T*>(this)));
|
||||||
child->InsertParent(parent);
|
child->AddLeastImportantParent(parent);
|
||||||
|
|
||||||
child->_FinalizeInheritance();
|
child->_FinalizeInheritance();
|
||||||
return child;
|
return child;
|
||||||
|
@ -46,15 +46,14 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||||
_parents.clear();
|
_parents.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertParent(com_ptr<T> parent)
|
void AddLeastImportantParent(com_ptr<T> parent)
|
||||||
{
|
{
|
||||||
_parents.emplace_back(std::move(parent));
|
_parents.emplace_back(std::move(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertParent(size_t index, com_ptr<T> parent)
|
void AddMostImportantParent(com_ptr<T> parent)
|
||||||
{
|
{
|
||||||
auto pos{ _parents.begin() + index };
|
_parents.emplace(_parents.begin(), std::move(parent));
|
||||||
_parents.emplace(pos, std::move(parent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<com_ptr<T>>& Parents()
|
const std::vector<com_ptr<T>>& Parents()
|
||||||
|
|
|
@ -46,7 +46,7 @@ void Profile::CreateUnfocusedAppearance()
|
||||||
// taken from this profile's default appearance, so add it as a parent
|
// taken from this profile's default appearance, so add it as a parent
|
||||||
com_ptr<AppearanceConfig> parentCom;
|
com_ptr<AppearanceConfig> parentCom;
|
||||||
parentCom.copy_from(winrt::get_self<implementation::AppearanceConfig>(_DefaultAppearance));
|
parentCom.copy_from(winrt::get_self<implementation::AppearanceConfig>(_DefaultAppearance));
|
||||||
unfocusedAppearance->InsertParent(parentCom);
|
unfocusedAppearance->AddLeastImportantParent(parentCom);
|
||||||
|
|
||||||
_UnfocusedAppearance = *unfocusedAppearance;
|
_UnfocusedAppearance = *unfocusedAppearance;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ winrt::com_ptr<Profile> Profile::CopySettings() const
|
||||||
if (*_UnfocusedAppearance)
|
if (*_UnfocusedAppearance)
|
||||||
{
|
{
|
||||||
const auto appearance = AppearanceConfig::CopyAppearance(winrt::get_self<AppearanceConfig>(*_UnfocusedAppearance), weakProfile);
|
const auto appearance = AppearanceConfig::CopyAppearance(winrt::get_self<AppearanceConfig>(*_UnfocusedAppearance), weakProfile);
|
||||||
appearance->InsertParent(defaultAppearance);
|
appearance->AddLeastImportantParent(defaultAppearance);
|
||||||
unfocused = *appearance;
|
unfocused = *appearance;
|
||||||
}
|
}
|
||||||
profile->_UnfocusedAppearance = unfocused;
|
profile->_UnfocusedAppearance = unfocused;
|
||||||
|
@ -189,7 +189,7 @@ void Profile::LayerJson(const Json::Value& json)
|
||||||
// taken from this profile's default appearance, so add it as a parent
|
// taken from this profile's default appearance, so add it as a parent
|
||||||
com_ptr<AppearanceConfig> parentCom;
|
com_ptr<AppearanceConfig> parentCom;
|
||||||
parentCom.copy_from(defaultAppearanceImpl);
|
parentCom.copy_from(defaultAppearanceImpl);
|
||||||
unfocusedAppearance->InsertParent(parentCom);
|
unfocusedAppearance->AddLeastImportantParent(parentCom);
|
||||||
|
|
||||||
unfocusedAppearance->LayerJson(json[JsonKey(UnfocusedAppearanceKey)]);
|
unfocusedAppearance->LayerJson(json[JsonKey(UnfocusedAppearanceKey)]);
|
||||||
_UnfocusedAppearance = *unfocusedAppearance;
|
_UnfocusedAppearance = *unfocusedAppearance;
|
||||||
|
@ -218,7 +218,7 @@ void Profile::_FinalizeInheritance()
|
||||||
{
|
{
|
||||||
if (auto parentDefaultAppearanceImpl = parent->_DefaultAppearance.try_as<AppearanceConfig>())
|
if (auto parentDefaultAppearanceImpl = parent->_DefaultAppearance.try_as<AppearanceConfig>())
|
||||||
{
|
{
|
||||||
defaultAppearanceImpl->InsertParent(parentDefaultAppearanceImpl);
|
defaultAppearanceImpl->AddLeastImportantParent(parentDefaultAppearanceImpl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ void Profile::_FinalizeInheritance()
|
||||||
{
|
{
|
||||||
if (auto parentFontInfoImpl = parent->_FontInfo.try_as<FontConfig>())
|
if (auto parentFontInfoImpl = parent->_FontInfo.try_as<FontConfig>())
|
||||||
{
|
{
|
||||||
fontInfoImpl->InsertParent(parentFontInfoImpl);
|
fontInfoImpl->AddLeastImportantParent(parentFontInfoImpl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||||
ClearParents();
|
ClearParents();
|
||||||
com_ptr<TerminalSettings> parentImpl;
|
com_ptr<TerminalSettings> parentImpl;
|
||||||
parentImpl.copy_from(get_self<TerminalSettings>(parent));
|
parentImpl.copy_from(get_self<TerminalSettings>(parent));
|
||||||
InsertParent(parentImpl);
|
AddLeastImportantParent(parentImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
Model::TerminalSettings TerminalSettings::GetParent()
|
Model::TerminalSettings TerminalSettings::GetParent()
|
||||||
|
|
Loading…
Reference in a new issue