GH-1082 allow disabling components

Currently only ones that are removable and aren't dep-only
This commit is contained in:
Petr Mrázek
2017-12-03 15:48:25 +01:00
parent 0a56b56286
commit 6a462d0778
4 changed files with 107 additions and 9 deletions

View File

@@ -50,6 +50,11 @@ std::shared_ptr<Meta::Version> Component::getMeta()
void Component::applyTo(LaunchProfile* profile)
{
// do not apply disabled components
if(!isEnabled())
{
return;
}
auto vfile = getVersionFile();
if(vfile)
{
@@ -137,6 +142,32 @@ QDateTime Component::getReleaseDateTime()
return QDateTime::currentDateTime();
}
bool Component::isEnabled()
{
return !canBeDisabled() || !m_disabled;
};
bool Component::canBeDisabled()
{
return isRemovable() && !m_dependencyOnly;
}
bool Component::setEnabled(bool state)
{
bool intendedDisabled = !state;
if (!canBeDisabled())
{
intendedDisabled = false;
}
if(intendedDisabled != m_disabled)
{
m_disabled = intendedDisabled;
emit dataChanged();
return true;
}
return false;
}
bool Component::isCustom()
{
return m_file != nullptr;