forked from qt-creator/qt-creator
ProjectExplorer: Introduce base class for enabled/disabled project configuration
... and use this as a base for all RunConfigurations. Clean out code in the individual run configurations dealing with their enabled/disabled state. Change-Id: Icc2ea136b056f7aea7ce96480b4402459d7ac0ce Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -111,48 +111,16 @@ IosRunConfiguration::IosRunConfiguration(Target *parent, IosRunConfiguration *so
|
||||
|
||||
void IosRunConfiguration::init()
|
||||
{
|
||||
QmakeProject *project = static_cast<QmakeProject *>(target()->project());
|
||||
m_parseSuccess = project->validParse(m_profilePath);
|
||||
m_parseInProgress = project->parseInProgress(m_profilePath);
|
||||
m_lastIsEnabled = isEnabled();
|
||||
m_lastDisabledReason = disabledReason();
|
||||
updateDisplayNames();
|
||||
connect(DeviceManager::instance(), &DeviceManager::updated,
|
||||
this, &IosRunConfiguration::deviceChanges);
|
||||
connect(KitManager::instance(), &KitManager::kitsChanged,
|
||||
this, &IosRunConfiguration::deviceChanges);
|
||||
connect(project, &QmakeProject::proFileUpdated,
|
||||
this, &IosRunConfiguration::proFileUpdated);
|
||||
}
|
||||
|
||||
void IosRunConfiguration::enabledCheck()
|
||||
{
|
||||
bool newIsEnabled = isEnabled();
|
||||
QString newDisabledReason = disabledReason();
|
||||
if (newDisabledReason != m_lastDisabledReason || newIsEnabled != m_lastIsEnabled) {
|
||||
m_lastDisabledReason = newDisabledReason;
|
||||
m_lastIsEnabled = newIsEnabled;
|
||||
emit enabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void IosRunConfiguration::deviceChanges() {
|
||||
updateDisplayNames();
|
||||
enabledCheck();
|
||||
}
|
||||
|
||||
void IosRunConfiguration::proFileUpdated(QmakeProFile *pro, bool success,
|
||||
bool parseInProgress)
|
||||
{
|
||||
if (m_profilePath != pro->filePath())
|
||||
return;
|
||||
m_parseSuccess = success;
|
||||
m_parseInProgress = parseInProgress;
|
||||
if (success && !parseInProgress) {
|
||||
updateDisplayNames();
|
||||
emit localExecutableChanged();
|
||||
}
|
||||
enabledCheck();
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
QWidget *IosRunConfiguration::createConfigurationWidget()
|
||||
@@ -182,6 +150,21 @@ void IosRunConfiguration::updateDisplayNames()
|
||||
setDisplayName(tr("Run %1 on %2").arg(applicationName()).arg(devName));
|
||||
}
|
||||
|
||||
void IosRunConfiguration::updateEnabledState()
|
||||
{
|
||||
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
||||
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE) {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit());
|
||||
if (dev.isNull() || dev->deviceState() != IDevice::DeviceReadyToUse) {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
return RunConfiguration::updateEnabledState();
|
||||
}
|
||||
|
||||
IosDeployStep *IosRunConfiguration::deployStep() const
|
||||
{
|
||||
DeployConfiguration *config = target()->activeDeployConfiguration();
|
||||
@@ -287,26 +270,8 @@ QString IosRunConfiguration::buildSystemTarget() const
|
||||
return static_cast<QmakeProject *>(target()->project())->mapProFilePathToTarget(m_profilePath);
|
||||
}
|
||||
|
||||
bool IosRunConfiguration::isEnabled() const
|
||||
{
|
||||
if (m_parseInProgress || !m_parseSuccess)
|
||||
return false;
|
||||
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
||||
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
||||
return false;
|
||||
IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit());
|
||||
if (dev.isNull() || dev->deviceState() != IDevice::DeviceReadyToUse)
|
||||
return false;
|
||||
return RunConfiguration::isEnabled();
|
||||
}
|
||||
|
||||
QString IosRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (m_parseInProgress)
|
||||
return tr("The .pro file \"%1\" is currently being parsed.").arg(m_profilePath.fileName());
|
||||
if (!m_parseSuccess)
|
||||
return static_cast<QmakeProject *>(target()->project())
|
||||
->disabledReasonForRunConfiguration(m_profilePath);
|
||||
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
||||
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
||||
return tr("Kit has incorrect device type for running on iOS devices.");
|
||||
|
Reference in New Issue
Block a user