mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-14 12:37:23 +00:00
GH-1082 allow disabling components
Currently only ones that are removable and aren't dep-only
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user