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:
@@ -40,7 +40,6 @@ public:
|
|||||||
BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent,
|
BareMetalCustomRunConfiguration(ProjectExplorer::Target *parent,
|
||||||
BareMetalCustomRunConfiguration *source);
|
BareMetalCustomRunConfiguration *source);
|
||||||
|
|
||||||
bool isEnabled() const override { return true; }
|
|
||||||
bool isConfigured() const override;
|
bool isConfigured() const override;
|
||||||
ConfigurationState ensureConfigured(QString *errorMessage) override;
|
ConfigurationState ensureConfigured(QString *errorMessage) override;
|
||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
|
@@ -75,17 +75,6 @@ void BareMetalRunConfiguration::init()
|
|||||||
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated); // Handles device changes, etc.
|
this, &BareMetalRunConfiguration::handleBuildSystemDataUpdated); // Handles device changes, etc.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BareMetalRunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
m_disabledReason.clear(); // FIXME: Check this makes sense.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString BareMetalRunConfiguration::disabledReason() const
|
|
||||||
{
|
|
||||||
return m_disabledReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *BareMetalRunConfiguration::createConfigurationWidget()
|
QWidget *BareMetalRunConfiguration::createConfigurationWidget()
|
||||||
{
|
{
|
||||||
return new BareMetalRunConfigurationWidget(this);
|
return new BareMetalRunConfigurationWidget(this);
|
||||||
@@ -167,11 +156,6 @@ QString BareMetalRunConfiguration::buildSystemTarget() const
|
|||||||
return (bst == targets.list.constEnd()) ? QString() : bst->targetName;
|
return (bst == targets.list.constEnd()) ? QString() : bst->targetName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BareMetalRunConfiguration::setDisabledReason(const QString &reason) const
|
|
||||||
{
|
|
||||||
m_disabledReason = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
|
void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
|
||||||
{
|
{
|
||||||
emit targetInformationChanged();
|
emit targetInformationChanged();
|
||||||
|
@@ -44,8 +44,6 @@ public:
|
|||||||
explicit BareMetalRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
|
explicit BareMetalRunConfiguration(ProjectExplorer::Target *parent, Core::Id id,
|
||||||
const QString &projectFilePath);
|
const QString &projectFilePath);
|
||||||
|
|
||||||
bool isEnabled() const override;
|
|
||||||
QString disabledReason() const override;
|
|
||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
Utils::OutputFormatter *createOutputFormatter() const override;
|
Utils::OutputFormatter *createOutputFormatter() const override;
|
||||||
|
|
||||||
@@ -70,14 +68,12 @@ protected:
|
|||||||
BareMetalRunConfiguration(ProjectExplorer::Target *parent, BareMetalRunConfiguration *source);
|
BareMetalRunConfiguration(ProjectExplorer::Target *parent, BareMetalRunConfiguration *source);
|
||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
QString defaultDisplayName();
|
QString defaultDisplayName();
|
||||||
void setDisabledReason(const QString &reason) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleBuildSystemDataUpdated();
|
void handleBuildSystemDataUpdated();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
QString m_projectFilePath;
|
QString m_projectFilePath;
|
||||||
mutable QString m_disabledReason;
|
|
||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -152,7 +152,7 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateApplicationAndDeploymentTargets();
|
updateApplicationAndDeploymentTargets();
|
||||||
updateTargetRunConfigurations(t);
|
t->updateDefaultRunConfigurations();
|
||||||
|
|
||||||
createGeneratedCodeModelSupport();
|
createGeneratedCodeModelSupport();
|
||||||
|
|
||||||
@@ -446,35 +446,6 @@ QStringList CMakeProject::filesGeneratedFrom(const QString &sourceFile) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeProject::updateTargetRunConfigurations(Target *t)
|
|
||||||
{
|
|
||||||
// *Update* existing runconfigurations (no need to update new ones!):
|
|
||||||
QHash<QString, const CMakeBuildTarget *> buildTargetHash;
|
|
||||||
const QList<CMakeBuildTarget> buildTargetList = buildTargets();
|
|
||||||
foreach (const CMakeBuildTarget &bt, buildTargetList) {
|
|
||||||
if (bt.targetType != ExecutableType || bt.executable.isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
buildTargetHash.insert(bt.title, &bt);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (RunConfiguration *rc, t->runConfigurations()) {
|
|
||||||
auto cmakeRc = qobject_cast<CMakeRunConfiguration *>(rc);
|
|
||||||
if (!cmakeRc)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto btIt = buildTargetHash.constFind(cmakeRc->title());
|
|
||||||
cmakeRc->setEnabled(btIt != buildTargetHash.constEnd());
|
|
||||||
if (btIt != buildTargetHash.constEnd()) {
|
|
||||||
cmakeRc->setExecutable(btIt.value()->executable.toString());
|
|
||||||
cmakeRc->setBaseWorkingDirectory(btIt.value()->workingDirectory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create new and remove obsolete RCs using the factories
|
|
||||||
t->updateDefaultRunConfigurations();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMakeProject::updateApplicationAndDeploymentTargets()
|
void CMakeProject::updateApplicationAndDeploymentTargets()
|
||||||
{
|
{
|
||||||
Target *t = activeTarget();
|
Target *t = activeTarget();
|
||||||
|
@@ -122,7 +122,6 @@ private:
|
|||||||
|
|
||||||
void createGeneratedCodeModelSupport();
|
void createGeneratedCodeModelSupport();
|
||||||
QStringList filesGeneratedFrom(const QString &sourceFile) const final;
|
QStringList filesGeneratedFrom(const QString &sourceFile) const final;
|
||||||
void updateTargetRunConfigurations(ProjectExplorer::Target *t);
|
|
||||||
void updateApplicationAndDeploymentTargets();
|
void updateApplicationAndDeploymentTargets();
|
||||||
|
|
||||||
ProjectExplorer::Target *m_connectedTarget = nullptr;
|
ProjectExplorer::Target *m_connectedTarget = nullptr;
|
||||||
|
@@ -82,8 +82,7 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, CMakeRunConfigurati
|
|||||||
RunConfiguration(parent, source),
|
RunConfiguration(parent, source),
|
||||||
m_buildSystemTarget(source->m_buildSystemTarget),
|
m_buildSystemTarget(source->m_buildSystemTarget),
|
||||||
m_executable(source->m_executable),
|
m_executable(source->m_executable),
|
||||||
m_title(source->m_title),
|
m_title(source->m_title)
|
||||||
m_enabled(source->m_enabled)
|
|
||||||
{
|
{
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
@@ -144,12 +143,16 @@ QString CMakeRunConfiguration::defaultDisplayName() const
|
|||||||
{
|
{
|
||||||
if (m_title.isEmpty())
|
if (m_title.isEmpty())
|
||||||
return tr("Run CMake kit");
|
return tr("Run CMake kit");
|
||||||
QString result = m_title;
|
return m_title;
|
||||||
if (!m_enabled) {
|
}
|
||||||
result += QLatin1Char(' ');
|
|
||||||
result += tr("(disabled)");
|
void CMakeRunConfiguration::updateEnabledState()
|
||||||
}
|
{
|
||||||
return result;
|
auto cp = qobject_cast<CMakeProject *>(target()->project());
|
||||||
|
if (!cp->hasBuildTarget(m_buildSystemTarget))
|
||||||
|
setEnabled(false);
|
||||||
|
else
|
||||||
|
RunConfiguration::updateEnabledState();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *CMakeRunConfiguration::createConfigurationWidget()
|
QWidget *CMakeRunConfiguration::createConfigurationWidget()
|
||||||
@@ -157,25 +160,14 @@ QWidget *CMakeRunConfiguration::createConfigurationWidget()
|
|||||||
return new CMakeRunConfigurationWidget(this);
|
return new CMakeRunConfigurationWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeRunConfiguration::setEnabled(bool b)
|
|
||||||
{
|
|
||||||
if (m_enabled == b)
|
|
||||||
return;
|
|
||||||
m_enabled = b;
|
|
||||||
emit enabledChanged();
|
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeRunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
return m_enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CMakeRunConfiguration::disabledReason() const
|
QString CMakeRunConfiguration::disabledReason() const
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
auto cp = qobject_cast<CMakeProject *>(target()->project());
|
||||||
return tr("The executable is not built by the current build configuration");
|
QTC_ASSERT(cp, return QString());
|
||||||
return QString();
|
|
||||||
|
if (cp->hasParsingData() && !cp->hasBuildTarget(m_buildSystemTarget))
|
||||||
|
return tr("The project no longer builds the target associated with this run configuration.");
|
||||||
|
return RunConfiguration::disabledReason();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateExecutable(CMakeRunConfiguration *rc, Utils::FancyLineEdit *fle)
|
static void updateExecutable(CMakeRunConfiguration *rc, Utils::FancyLineEdit *fle)
|
||||||
|
@@ -51,9 +51,6 @@ public:
|
|||||||
|
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
|
|
||||||
void setEnabled(bool b);
|
|
||||||
|
|
||||||
bool isEnabled() const override;
|
|
||||||
QString disabledReason() const override;
|
QString disabledReason() const override;
|
||||||
|
|
||||||
QString buildSystemTarget() const final { return m_buildSystemTarget; }
|
QString buildSystemTarget() const final { return m_buildSystemTarget; }
|
||||||
@@ -63,6 +60,8 @@ protected:
|
|||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
QString defaultDisplayName() const;
|
QString defaultDisplayName() const;
|
||||||
|
|
||||||
|
void updateEnabledState() final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString baseWorkingDirectory() const;
|
QString baseWorkingDirectory() const;
|
||||||
void ctor();
|
void ctor();
|
||||||
@@ -70,7 +69,6 @@ private:
|
|||||||
const QString m_buildSystemTarget;
|
const QString m_buildSystemTarget;
|
||||||
QString m_executable;
|
QString m_executable;
|
||||||
QString m_title;
|
QString m_title;
|
||||||
bool m_enabled = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMakeRunConfigurationWidget : public QWidget
|
class CMakeRunConfigurationWidget : public QWidget
|
||||||
|
@@ -111,48 +111,16 @@ IosRunConfiguration::IosRunConfiguration(Target *parent, IosRunConfiguration *so
|
|||||||
|
|
||||||
void IosRunConfiguration::init()
|
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();
|
updateDisplayNames();
|
||||||
connect(DeviceManager::instance(), &DeviceManager::updated,
|
connect(DeviceManager::instance(), &DeviceManager::updated,
|
||||||
this, &IosRunConfiguration::deviceChanges);
|
this, &IosRunConfiguration::deviceChanges);
|
||||||
connect(KitManager::instance(), &KitManager::kitsChanged,
|
connect(KitManager::instance(), &KitManager::kitsChanged,
|
||||||
this, &IosRunConfiguration::deviceChanges);
|
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() {
|
void IosRunConfiguration::deviceChanges() {
|
||||||
updateDisplayNames();
|
updateDisplayNames();
|
||||||
enabledCheck();
|
updateEnabledState();
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *IosRunConfiguration::createConfigurationWidget()
|
QWidget *IosRunConfiguration::createConfigurationWidget()
|
||||||
@@ -182,6 +150,21 @@ void IosRunConfiguration::updateDisplayNames()
|
|||||||
setDisplayName(tr("Run %1 on %2").arg(applicationName()).arg(devName));
|
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
|
IosDeployStep *IosRunConfiguration::deployStep() const
|
||||||
{
|
{
|
||||||
DeployConfiguration *config = target()->activeDeployConfiguration();
|
DeployConfiguration *config = target()->activeDeployConfiguration();
|
||||||
@@ -287,26 +270,8 @@ QString IosRunConfiguration::buildSystemTarget() const
|
|||||||
return static_cast<QmakeProject *>(target()->project())->mapProFilePathToTarget(m_profilePath);
|
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
|
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());
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
||||||
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
||||||
return tr("Kit has incorrect device type for running on iOS devices.");
|
return tr("Kit has incorrect device type for running on iOS devices.");
|
||||||
|
@@ -58,7 +58,6 @@ public:
|
|||||||
QString applicationName() const;
|
QString applicationName() const;
|
||||||
Utils::FileName bundleDirectory() const;
|
Utils::FileName bundleDirectory() const;
|
||||||
Utils::FileName localExecutable() const;
|
Utils::FileName localExecutable() const;
|
||||||
bool isEnabled() const override;
|
|
||||||
QString disabledReason() const override;
|
QString disabledReason() const override;
|
||||||
IosDeviceType deviceType() const;
|
IosDeviceType deviceType() const;
|
||||||
void setDeviceType(const IosDeviceType &deviceType);
|
void setDeviceType(const IosDeviceType &deviceType);
|
||||||
@@ -75,18 +74,13 @@ signals:
|
|||||||
void localExecutableChanged();
|
void localExecutableChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void proFileUpdated(QmakeProjectManager::QmakeProFile *pro, bool success, bool parseInProgress);
|
|
||||||
void deviceChanges();
|
void deviceChanges();
|
||||||
void init();
|
void init();
|
||||||
void enabledCheck();
|
|
||||||
friend class IosRunConfigurationWidget;
|
friend class IosRunConfigurationWidget;
|
||||||
void updateDisplayNames();
|
void updateDisplayNames();
|
||||||
|
void updateEnabledState() final;
|
||||||
|
|
||||||
Utils::FileName m_profilePath;
|
Utils::FileName m_profilePath;
|
||||||
QString m_lastDisabledReason;
|
|
||||||
bool m_lastIsEnabled;
|
|
||||||
bool m_parseInProgress;
|
|
||||||
bool m_parseSuccess;
|
|
||||||
IosDeviceType m_deviceType;
|
IosDeviceType m_deviceType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -123,3 +123,26 @@ QString ProjectExplorer::displayNameFromMap(const QVariantMap &map)
|
|||||||
{
|
{
|
||||||
return map.value(QLatin1String(DISPLAY_NAME_KEY), QString()).toString();
|
return map.value(QLatin1String(DISPLAY_NAME_KEY), QString()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StatefulProjectConfiguration::isEnabled() const
|
||||||
|
{
|
||||||
|
return m_isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatefulProjectConfiguration::StatefulProjectConfiguration(QObject *parent, Core::Id id) :
|
||||||
|
ProjectConfiguration(parent, id)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
StatefulProjectConfiguration::StatefulProjectConfiguration(QObject *parent,
|
||||||
|
const StatefulProjectConfiguration *source) :
|
||||||
|
ProjectConfiguration(parent, source),
|
||||||
|
m_isEnabled(source->m_isEnabled)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void StatefulProjectConfiguration::setEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled == m_isEnabled)
|
||||||
|
return;
|
||||||
|
m_isEnabled = enabled;
|
||||||
|
emit enabledChanged();
|
||||||
|
}
|
||||||
|
@@ -81,6 +81,30 @@ private:
|
|||||||
Utils::MacroExpander m_macroExpander;
|
Utils::MacroExpander m_macroExpander;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PROJECTEXPLORER_EXPORT StatefulProjectConfiguration : public ProjectConfiguration
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
StatefulProjectConfiguration() = default;
|
||||||
|
|
||||||
|
bool isEnabled() const;
|
||||||
|
|
||||||
|
virtual QString disabledReason() const = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void enabledChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
StatefulProjectConfiguration(QObject *parent, Core::Id id);
|
||||||
|
StatefulProjectConfiguration(QObject *parent, const StatefulProjectConfiguration *source);
|
||||||
|
|
||||||
|
void setEnabled(bool enabled);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_isEnabled;
|
||||||
|
};
|
||||||
|
|
||||||
// helper functions:
|
// helper functions:
|
||||||
PROJECTEXPLORER_EXPORT Core::Id idFromMap(const QVariantMap &map);
|
PROJECTEXPLORER_EXPORT Core::Id idFromMap(const QVariantMap &map);
|
||||||
PROJECTEXPLORER_EXPORT QString displayNameFromMap(const QVariantMap &map);
|
PROJECTEXPLORER_EXPORT QString displayNameFromMap(const QVariantMap &map);
|
||||||
|
@@ -172,21 +172,24 @@ void IRunConfigurationAspect::resetProjectToGlobalSettings()
|
|||||||
A run configuration specifies how a target should be run, while a runner
|
A run configuration specifies how a target should be run, while a runner
|
||||||
does the actual running.
|
does the actual running.
|
||||||
|
|
||||||
All RunControls and the target hold a shared pointer to the run
|
The target owns the RunConfiguraitons and a RunControl will need to copy all
|
||||||
configuration. That is, the lifetime of the run configuration might exceed
|
necessary data as the RunControl may continue to exist after the RunConfiguration
|
||||||
the life of the target.
|
has been destroyed.
|
||||||
The user might still have a RunControl running (or output tab of that RunControl open)
|
|
||||||
and yet unloaded the target.
|
|
||||||
|
|
||||||
Also, a run configuration might be already removed from the list of run
|
A RunConfiguration disables itself when the project is parsing or has no parsing
|
||||||
configurations
|
data available. The disabledReason() method can be used to get a user-facing string
|
||||||
for a target, but still be runnable via the output tab.
|
describing why the RunConfiguration considers itself unfit for use.
|
||||||
|
|
||||||
|
Override updateEnabledState() to change the enabled state handling. Override
|
||||||
|
disabledReasons() to provide better/more descriptions to the user.
|
||||||
|
|
||||||
|
Connect signals that may change enabled state of your RunConfiguration to updateEnabledState.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
static std::vector<RunConfiguration::AspectFactory> theAspectFactories;
|
||||||
|
|
||||||
RunConfiguration::RunConfiguration(Target *target, Core::Id id) :
|
RunConfiguration::RunConfiguration(Target *target, Core::Id id) :
|
||||||
ProjectConfiguration(target, id)
|
StatefulProjectConfiguration(target, id)
|
||||||
{
|
{
|
||||||
Q_ASSERT(target);
|
Q_ASSERT(target);
|
||||||
ctor();
|
ctor();
|
||||||
@@ -196,7 +199,7 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
||||||
ProjectConfiguration(target, source)
|
StatefulProjectConfiguration(target, source)
|
||||||
{
|
{
|
||||||
Q_ASSERT(target);
|
Q_ASSERT(target);
|
||||||
ctor();
|
ctor();
|
||||||
@@ -212,6 +215,22 @@ RunConfiguration::~RunConfiguration()
|
|||||||
qDeleteAll(m_aspects);
|
qDeleteAll(m_aspects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RunConfiguration::disabledReason() const
|
||||||
|
{
|
||||||
|
if (target()->project()->isParsing())
|
||||||
|
return tr("The Project is currently being parsed.");
|
||||||
|
if (!target()->project()->hasParsingData())
|
||||||
|
return tr("The project could not be fully parsed.");
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunConfiguration::updateEnabledState()
|
||||||
|
{
|
||||||
|
Project *p = target()->project();
|
||||||
|
|
||||||
|
setEnabled(!p->isParsing() && p->hasParsingData());
|
||||||
|
}
|
||||||
|
|
||||||
void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory)
|
void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory)
|
||||||
{
|
{
|
||||||
theAspectFactories.push_back(aspectFactory);
|
theAspectFactories.push_back(aspectFactory);
|
||||||
@@ -225,6 +244,17 @@ void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect)
|
|||||||
|
|
||||||
void RunConfiguration::ctor()
|
void RunConfiguration::ctor()
|
||||||
{
|
{
|
||||||
|
connect(target()->project(), &Project::parsingStarted,
|
||||||
|
this, [this]() { updateEnabledState(); });
|
||||||
|
connect(target()->project(), &Project::parsingFinished,
|
||||||
|
this, [this]() { updateEnabledState(); });
|
||||||
|
|
||||||
|
connect(target(), &Target::addedRunConfiguration,
|
||||||
|
this, [this](const RunConfiguration *rc) {
|
||||||
|
if (rc == this)
|
||||||
|
updateEnabledState();
|
||||||
|
});
|
||||||
|
|
||||||
connect(this, &RunConfiguration::enabledChanged,
|
connect(this, &RunConfiguration::enabledChanged,
|
||||||
this, &RunConfiguration::requestRunActionsUpdate);
|
this, &RunConfiguration::requestRunActionsUpdate);
|
||||||
|
|
||||||
@@ -259,20 +289,6 @@ RunConfiguration *RunConfiguration::startupRunConfiguration()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Checks whether a run configuration is enabled.
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool RunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString RunConfiguration::disabledReason() const
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RunConfiguration::isConfigured() const
|
bool RunConfiguration::isConfigured() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -287,7 +303,6 @@ RunConfiguration::ConfigurationState RunConfiguration::ensureConfigured(QString
|
|||||||
return UnConfigured;
|
return UnConfigured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BuildConfiguration *RunConfiguration::activeBuildConfiguration() const
|
BuildConfiguration *RunConfiguration::activeBuildConfiguration() const
|
||||||
{
|
{
|
||||||
if (!target())
|
if (!target())
|
||||||
|
@@ -199,15 +199,15 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Documentation inside.
|
// Documentation inside.
|
||||||
class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration
|
class PROJECTEXPLORER_EXPORT RunConfiguration : public StatefulProjectConfiguration
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~RunConfiguration() override;
|
~RunConfiguration() override;
|
||||||
|
|
||||||
virtual bool isEnabled() const;
|
QString disabledReason() const override;
|
||||||
virtual QString disabledReason() const;
|
|
||||||
virtual QWidget *createConfigurationWidget() = 0;
|
virtual QWidget *createConfigurationWidget() = 0;
|
||||||
|
|
||||||
virtual bool isConfigured() const;
|
virtual bool isConfigured() const;
|
||||||
@@ -252,7 +252,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enabledChanged();
|
|
||||||
void requestRunActionsUpdate();
|
void requestRunActionsUpdate();
|
||||||
void configurationFinished();
|
void configurationFinished();
|
||||||
|
|
||||||
@@ -263,6 +262,8 @@ protected:
|
|||||||
/// convenience function to get current build configuration.
|
/// convenience function to get current build configuration.
|
||||||
BuildConfiguration *activeBuildConfiguration() const;
|
BuildConfiguration *activeBuildConfiguration() const;
|
||||||
|
|
||||||
|
virtual void updateEnabledState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ctor();
|
void ctor();
|
||||||
|
|
||||||
|
@@ -156,8 +156,6 @@ public:
|
|||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
bool isEnabled() const override { return m_enabled; }
|
|
||||||
QString disabledReason() const override;
|
|
||||||
Runnable runnable() const override;
|
Runnable runnable() const override;
|
||||||
|
|
||||||
bool supportsDebugger() const { return true; }
|
bool supportsDebugger() const { return true; }
|
||||||
@@ -165,7 +163,6 @@ public:
|
|||||||
QString arguments() const;
|
QString arguments() const;
|
||||||
QString interpreter() const { return m_interpreter; }
|
QString interpreter() const { return m_interpreter; }
|
||||||
void setInterpreter(const QString &interpreter) { m_interpreter = interpreter; }
|
void setInterpreter(const QString &interpreter) { m_interpreter = interpreter; }
|
||||||
void setEnabled(bool b);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class PythonRunConfigurationFactory;
|
friend class PythonRunConfigurationFactory;
|
||||||
@@ -174,15 +171,13 @@ private:
|
|||||||
|
|
||||||
QString m_interpreter;
|
QString m_interpreter;
|
||||||
QString m_mainScript;
|
QString m_mainScript;
|
||||||
bool m_enabled;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
PythonRunConfiguration::PythonRunConfiguration(Target *parent, Core::Id id) :
|
PythonRunConfiguration::PythonRunConfiguration(Target *parent, Core::Id id) :
|
||||||
RunConfiguration(parent, id),
|
RunConfiguration(parent, id),
|
||||||
m_mainScript(scriptFromId(id)),
|
m_mainScript(scriptFromId(id))
|
||||||
m_enabled(true)
|
|
||||||
{
|
{
|
||||||
Environment sysEnv = Environment::systemEnvironment();
|
Environment sysEnv = Environment::systemEnvironment();
|
||||||
const QString exec = sysEnv.searchInPath("python").toString();
|
const QString exec = sysEnv.searchInPath("python").toString();
|
||||||
@@ -197,8 +192,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *parent, Core::Id id) :
|
|||||||
PythonRunConfiguration::PythonRunConfiguration(Target *parent, PythonRunConfiguration *source) :
|
PythonRunConfiguration::PythonRunConfiguration(Target *parent, PythonRunConfiguration *source) :
|
||||||
RunConfiguration(parent, source),
|
RunConfiguration(parent, source),
|
||||||
m_interpreter(source->interpreter()),
|
m_interpreter(source->interpreter()),
|
||||||
m_mainScript(source->m_mainScript),
|
m_mainScript(source->m_mainScript)
|
||||||
m_enabled(source->m_enabled)
|
|
||||||
{
|
{
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
setDefaultDisplayName(defaultDisplayName());
|
||||||
}
|
}
|
||||||
@@ -220,10 +214,7 @@ bool PythonRunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
|
|
||||||
QString PythonRunConfiguration::defaultDisplayName() const
|
QString PythonRunConfiguration::defaultDisplayName() const
|
||||||
{
|
{
|
||||||
QString result = tr("Run %1").arg(m_mainScript);
|
return tr("Run %1").arg(m_mainScript);
|
||||||
if (!m_enabled)
|
|
||||||
result += ' ' + tr("(disabled)");
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *PythonRunConfiguration::createConfigurationWidget()
|
QWidget *PythonRunConfiguration::createConfigurationWidget()
|
||||||
@@ -231,22 +222,6 @@ QWidget *PythonRunConfiguration::createConfigurationWidget()
|
|||||||
return new PythonRunConfigurationWidget(this);
|
return new PythonRunConfigurationWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonRunConfiguration::setEnabled(bool b)
|
|
||||||
{
|
|
||||||
if (m_enabled == b)
|
|
||||||
return;
|
|
||||||
m_enabled = b;
|
|
||||||
emit enabledChanged();
|
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PythonRunConfiguration::disabledReason() const
|
|
||||||
{
|
|
||||||
if (!m_enabled)
|
|
||||||
return tr("The script is currently disabled.");
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
Runnable PythonRunConfiguration::runnable() const
|
Runnable PythonRunConfiguration::runnable() const
|
||||||
{
|
{
|
||||||
StandardRunnable r;
|
StandardRunnable r;
|
||||||
|
@@ -44,11 +44,11 @@
|
|||||||
#include <utils/detailswidget.h>
|
#include <utils/detailswidget.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/persistentsettings.h>
|
#include <utils/persistentsettings.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
#include <qtsupport/qtoutputformatter.h>
|
#include <qtsupport/qtoutputformatter.h>
|
||||||
#include <qtsupport/qtsupportconstants.h>
|
#include <qtsupport/qtsupportconstants.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/utilsicons.h>
|
|
||||||
|
|
||||||
#include "api/runenvironment.h"
|
#include "api/runenvironment.h"
|
||||||
|
|
||||||
@@ -140,34 +140,15 @@ QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *so
|
|||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QbsRunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
|
||||||
return !project->isParsing() && project->hasParseResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QbsRunConfiguration::disabledReason() const
|
|
||||||
{
|
|
||||||
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
|
||||||
if (project->isParsing())
|
|
||||||
return tr("The .qbs files are currently being parsed.");
|
|
||||||
|
|
||||||
if (!project->hasParseResult())
|
|
||||||
return tr("Parsing of .qbs files has failed.");
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsRunConfiguration::ctor()
|
void QbsRunConfiguration::ctor()
|
||||||
{
|
{
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
setDefaultDisplayName(defaultDisplayName());
|
||||||
|
|
||||||
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
||||||
connect(project, &Project::parsingStarted, this, &RunConfiguration::enabledChanged);
|
|
||||||
connect(project, &Project::parsingFinished, this, [this](bool success) {
|
connect(project, &Project::parsingFinished, this, [this](bool success) {
|
||||||
auto terminalAspect = extraAspect<TerminalAspect>();
|
auto terminalAspect = extraAspect<TerminalAspect>();
|
||||||
if (success && !terminalAspect->isUserSet())
|
if (success && !terminalAspect->isUserSet())
|
||||||
terminalAspect->setUseTerminal(isConsoleApplication());
|
terminalAspect->setUseTerminal(isConsoleApplication());
|
||||||
emit enabledChanged();
|
|
||||||
});
|
});
|
||||||
connect(BuildManager::instance(), &BuildManager::buildStateChanged, this,
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged, this,
|
||||||
[this, project](Project *p) {
|
[this, project](Project *p) {
|
||||||
|
@@ -64,8 +64,6 @@ class QbsRunConfiguration : public ProjectExplorer::RunConfiguration
|
|||||||
public:
|
public:
|
||||||
QbsRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
QbsRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
||||||
|
|
||||||
bool isEnabled() const override;
|
|
||||||
QString disabledReason() const override;
|
|
||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
|
|
||||||
ProjectExplorer::Runnable runnable() const override;
|
ProjectExplorer::Runnable runnable() const override;
|
||||||
|
@@ -58,26 +58,20 @@ QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, Core:
|
|||||||
: AndroidRunConfiguration(parent, id)
|
: AndroidRunConfiguration(parent, id)
|
||||||
, m_proFilePath(path)
|
, m_proFilePath(path)
|
||||||
{
|
{
|
||||||
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
ctor();
|
||||||
m_parseSuccess = project->validParse(m_proFilePath);
|
|
||||||
m_parseInProgress = project->parseInProgress(m_proFilePath);
|
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, QmakeAndroidRunConfiguration *source)
|
QmakeAndroidRunConfiguration::QmakeAndroidRunConfiguration(Target *parent, QmakeAndroidRunConfiguration *source)
|
||||||
: AndroidRunConfiguration(parent, source)
|
: AndroidRunConfiguration(parent, source)
|
||||||
, m_proFilePath(source->m_proFilePath)
|
, m_proFilePath(source->m_proFilePath)
|
||||||
, m_parseSuccess(source->m_parseSuccess)
|
|
||||||
, m_parseInProgress(source->m_parseInProgress)
|
|
||||||
{
|
{
|
||||||
init();
|
ctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeAndroidRunConfiguration::init()
|
void QmakeAndroidRunConfiguration::ctor()
|
||||||
{
|
{
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
setDefaultDisplayName(defaultDisplayName());
|
||||||
connect(qmakeProject(), &QmakeProject::proFileUpdated,
|
QTC_CHECK(!m_proFilePath.isEmpty());
|
||||||
this, &QmakeAndroidRunConfiguration::proFileUpdated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeAndroidRunConfiguration::fromMap(const QVariantMap &map)
|
bool QmakeAndroidRunConfiguration::fromMap(const QVariantMap &map)
|
||||||
@@ -86,24 +80,17 @@ bool QmakeAndroidRunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
QTC_ASSERT(project, return false);
|
QTC_ASSERT(project, return false);
|
||||||
const QDir projectDir = QDir(project->projectDirectory().toString());
|
const QDir projectDir = QDir(project->projectDirectory().toString());
|
||||||
m_proFilePath = Utils::FileName::fromUserInput(projectDir.filePath(map.value(PRO_FILE_KEY).toString()));
|
m_proFilePath = Utils::FileName::fromUserInput(projectDir.filePath(map.value(PRO_FILE_KEY).toString()));
|
||||||
m_parseSuccess = project->validParse(m_proFilePath);
|
|
||||||
m_parseInProgress = project->parseInProgress(m_proFilePath);
|
|
||||||
|
|
||||||
return AndroidRunConfiguration::fromMap(map);
|
return AndroidRunConfiguration::fromMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap QmakeAndroidRunConfiguration::toMap() const
|
QVariantMap QmakeAndroidRunConfiguration::toMap() const
|
||||||
{
|
{
|
||||||
QmakeProject *project = qmakeProject();
|
|
||||||
if (m_proFilePath.isEmpty()) {
|
|
||||||
if (!project->rootProjectNode())
|
|
||||||
return QVariantMap();
|
|
||||||
m_proFilePath = project->rootProjectNode()->filePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
const QDir projectDir = QDir(project->projectDirectory().toString());
|
|
||||||
QVariantMap map(AndroidRunConfiguration::toMap());
|
QVariantMap map(AndroidRunConfiguration::toMap());
|
||||||
|
|
||||||
|
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
||||||
map.insert(PRO_FILE_KEY, projectDir.relativeFilePath(m_proFilePath.toString()));
|
map.insert(PRO_FILE_KEY, projectDir.relativeFilePath(m_proFilePath.toString()));
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,18 +107,13 @@ QString QmakeAndroidRunConfiguration::defaultDisplayName()
|
|||||||
return QFileInfo(pathFromId(id())).completeBaseName();
|
return QFileInfo(pathFromId(id())).completeBaseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeAndroidRunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
return m_parseSuccess && !m_parseInProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QmakeAndroidRunConfiguration::disabledReason() const
|
QString QmakeAndroidRunConfiguration::disabledReason() const
|
||||||
{
|
{
|
||||||
if (m_parseInProgress)
|
if (qmakeProject()->isParsing())
|
||||||
return tr("The .pro file \"%1\" is currently being parsed.")
|
return tr("The .pro file \"%1\" is currently being parsed.")
|
||||||
.arg(m_proFilePath.fileName());
|
.arg(m_proFilePath.fileName());
|
||||||
|
|
||||||
if (!m_parseSuccess)
|
if (!qmakeProject()->hasParsingData())
|
||||||
return qmakeProject()->disabledReasonForRunConfiguration(m_proFilePath);
|
return qmakeProject()->disabledReasonForRunConfiguration(m_proFilePath);
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
@@ -141,27 +123,6 @@ QString QmakeAndroidRunConfiguration::buildSystemTarget() const
|
|||||||
return qmakeProject()->mapProFilePathToTarget(m_proFilePath);
|
return qmakeProject()->mapProFilePathToTarget(m_proFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmakeAndroidRunConfiguration::proFileUpdated(QmakeProjectManager::QmakeProFile *pro,
|
|
||||||
bool success, bool parseInProgress)
|
|
||||||
{
|
|
||||||
QmakeProject *project = qmakeProject();
|
|
||||||
if (m_proFilePath.isEmpty() && project->rootProjectNode())
|
|
||||||
m_proFilePath = project->rootProjectNode()->filePath();
|
|
||||||
|
|
||||||
if (m_proFilePath != pro->filePath())
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool enabled = isEnabled();
|
|
||||||
QString reason = disabledReason();
|
|
||||||
m_parseSuccess = success;
|
|
||||||
m_parseInProgress = parseInProgress;
|
|
||||||
if (enabled != isEnabled() || reason != disabledReason())
|
|
||||||
emit enabledChanged();
|
|
||||||
|
|
||||||
if (!parseInProgress)
|
|
||||||
setDefaultDisplayName(defaultDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
QmakeProject *QmakeAndroidRunConfiguration::qmakeProject() const
|
QmakeProject *QmakeAndroidRunConfiguration::qmakeProject() const
|
||||||
{
|
{
|
||||||
Target *t = target();
|
Target *t = target();
|
||||||
|
@@ -48,7 +48,6 @@ public:
|
|||||||
|
|
||||||
Utils::FileName proFilePath() const;
|
Utils::FileName proFilePath() const;
|
||||||
|
|
||||||
bool isEnabled() const override;
|
|
||||||
QString disabledReason() const override;
|
QString disabledReason() const override;
|
||||||
|
|
||||||
QString buildSystemTarget() const final;
|
QString buildSystemTarget() const final;
|
||||||
@@ -61,13 +60,10 @@ protected:
|
|||||||
QString defaultDisplayName();
|
QString defaultDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void proFileUpdated(QmakeProjectManager::QmakeProFile *pro, bool success, bool parseInProgress);
|
|
||||||
QmakeProjectManager::QmakeProject *qmakeProject() const;
|
QmakeProjectManager::QmakeProject *qmakeProject() const;
|
||||||
void init();
|
void ctor();
|
||||||
|
|
||||||
mutable Utils::FileName m_proFilePath;
|
mutable Utils::FileName m_proFilePath;
|
||||||
bool m_parseSuccess;
|
|
||||||
bool m_parseInProgress;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -87,9 +87,6 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Core:
|
|||||||
addExtraAspect(new TerminalAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UseTerminal")));
|
addExtraAspect(new TerminalAspect(this, QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UseTerminal")));
|
||||||
addExtraAspect(new WorkingDirectoryAspect(this,
|
addExtraAspect(new WorkingDirectoryAspect(this,
|
||||||
QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory")));
|
QStringLiteral("Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory")));
|
||||||
QmakeProject *project = qmakeProject();
|
|
||||||
m_parseSuccess = project->validParse(m_proFilePath);
|
|
||||||
m_parseInProgress = project->parseInProgress(m_proFilePath);
|
|
||||||
|
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
@@ -98,44 +95,11 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Deskt
|
|||||||
RunConfiguration(parent, source),
|
RunConfiguration(parent, source),
|
||||||
m_proFilePath(source->m_proFilePath),
|
m_proFilePath(source->m_proFilePath),
|
||||||
m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix),
|
m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix),
|
||||||
m_isUsingLibrarySearchPath(source->m_isUsingLibrarySearchPath),
|
m_isUsingLibrarySearchPath(source->m_isUsingLibrarySearchPath)
|
||||||
m_parseSuccess(source->m_parseSuccess),
|
|
||||||
m_parseInProgress(source->m_parseInProgress)
|
|
||||||
{
|
{
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DesktopQmakeRunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
return m_parseSuccess && !m_parseInProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString DesktopQmakeRunConfiguration::disabledReason() const
|
|
||||||
{
|
|
||||||
if (m_parseInProgress)
|
|
||||||
return tr("The .pro file \"%1\" is currently being parsed.")
|
|
||||||
.arg(m_proFilePath.fileName());
|
|
||||||
|
|
||||||
if (!m_parseSuccess)
|
|
||||||
return qmakeProject()->disabledReasonForRunConfiguration(m_proFilePath);
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopQmakeRunConfiguration::proFileUpdated(QmakeProFile *pro, bool success, bool parseInProgress)
|
|
||||||
{
|
|
||||||
if (m_proFilePath != pro->filePath())
|
|
||||||
return;
|
|
||||||
const bool enabled = isEnabled();
|
|
||||||
const QString reason = disabledReason();
|
|
||||||
m_parseSuccess = success;
|
|
||||||
m_parseInProgress = parseInProgress;
|
|
||||||
if (enabled != isEnabled() || reason != disabledReason())
|
|
||||||
emit enabledChanged();
|
|
||||||
|
|
||||||
if (!parseInProgress)
|
|
||||||
updateTargetInformation();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopQmakeRunConfiguration::proFileEvaluated()
|
void DesktopQmakeRunConfiguration::proFileEvaluated()
|
||||||
{
|
{
|
||||||
// We depend on all .pro files for the LD_LIBRARY_PATH so we emit a signal for all .pro files
|
// We depend on all .pro files for the LD_LIBRARY_PATH so we emit a signal for all .pro files
|
||||||
@@ -165,8 +129,8 @@ void DesktopQmakeRunConfiguration::ctor()
|
|||||||
setDefaultDisplayName(defaultDisplayName());
|
setDefaultDisplayName(defaultDisplayName());
|
||||||
|
|
||||||
QmakeProject *project = qmakeProject();
|
QmakeProject *project = qmakeProject();
|
||||||
connect(project, &QmakeProject::proFileUpdated,
|
connect(project, &Project::parsingFinished,
|
||||||
this, &DesktopQmakeRunConfiguration::proFileUpdated);
|
this, &DesktopQmakeRunConfiguration::updateTargetInformation);
|
||||||
connect(project, &QmakeProject::proFilesEvaluated,
|
connect(project, &QmakeProject::proFilesEvaluated,
|
||||||
this, &DesktopQmakeRunConfiguration::proFileEvaluated);
|
this, &DesktopQmakeRunConfiguration::proFileEvaluated);
|
||||||
|
|
||||||
@@ -337,9 +301,6 @@ bool DesktopQmakeRunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
m_isUsingDyldImageSuffix = map.value(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), false).toBool();
|
m_isUsingDyldImageSuffix = map.value(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), false).toBool();
|
||||||
m_isUsingLibrarySearchPath = map.value(QLatin1String(USE_LIBRARY_SEARCH_PATH), true).toBool();
|
m_isUsingLibrarySearchPath = map.value(QLatin1String(USE_LIBRARY_SEARCH_PATH), true).toBool();
|
||||||
|
|
||||||
m_parseSuccess = qmakeProject()->validParse(m_proFilePath);
|
|
||||||
m_parseInProgress = qmakeProject()->parseInProgress(m_proFilePath);
|
|
||||||
|
|
||||||
return RunConfiguration::fromMap(map);
|
return RunConfiguration::fromMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,8 +58,6 @@ class DesktopQmakeRunConfiguration : public ProjectExplorer::RunConfiguration
|
|||||||
public:
|
public:
|
||||||
DesktopQmakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
DesktopQmakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
||||||
|
|
||||||
bool isEnabled() const override;
|
|
||||||
QString disabledReason() const override;
|
|
||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
|
|
||||||
ProjectExplorer::Runnable runnable() const override;
|
ProjectExplorer::Runnable runnable() const override;
|
||||||
@@ -94,7 +92,6 @@ protected:
|
|||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void proFileUpdated(QmakeProjectManager::QmakeProFile *pro, bool success, bool parseInProgress);
|
|
||||||
void proFileEvaluated();
|
void proFileEvaluated();
|
||||||
void updateTargetInformation();
|
void updateTargetInformation();
|
||||||
|
|
||||||
@@ -113,8 +110,6 @@ private:
|
|||||||
// Cached startup sub project information
|
// Cached startup sub project information
|
||||||
bool m_isUsingDyldImageSuffix = false;
|
bool m_isUsingDyldImageSuffix = false;
|
||||||
bool m_isUsingLibrarySearchPath = true;
|
bool m_isUsingLibrarySearchPath = true;
|
||||||
bool m_parseSuccess = false;
|
|
||||||
bool m_parseInProgress = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DesktopQmakeRunConfigurationWidget : public QWidget
|
class DesktopQmakeRunConfigurationWidget : public QWidget
|
||||||
|
@@ -733,22 +733,6 @@ QmakeProFileNode *QmakeProject::rootProjectNode() const
|
|||||||
return static_cast<QmakeProFileNode *>(Project::rootProjectNode());
|
return static_cast<QmakeProFileNode *>(Project::rootProjectNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmakeProject::validParse(const FileName &proFilePath) const
|
|
||||||
{
|
|
||||||
if (!rootProFile())
|
|
||||||
return false;
|
|
||||||
const QmakeProFile *pro = rootProFile()->findProFile(proFilePath);
|
|
||||||
return pro && pro->validParse();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QmakeProject::parseInProgress(const FileName &proFilePath) const
|
|
||||||
{
|
|
||||||
if (!rootProFile())
|
|
||||||
return false;
|
|
||||||
const QmakeProFile *pro = rootProFile()->findProFile(proFilePath);
|
|
||||||
return pro && pro->parseInProgress();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QmakeProFile *>
|
QList<QmakeProFile *>
|
||||||
QmakeProject::collectAllProFiles(QmakeProFile *file, Parsing parse,
|
QmakeProject::collectAllProFiles(QmakeProFile *file, Parsing parse,
|
||||||
const QList<ProjectType> &projectTypes)
|
const QList<ProjectType> &projectTypes)
|
||||||
|
@@ -68,8 +68,6 @@ public:
|
|||||||
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const final;
|
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMesage) const final;
|
||||||
|
|
||||||
QmakeProFileNode *rootProjectNode() const final;
|
QmakeProFileNode *rootProjectNode() const final;
|
||||||
bool validParse(const Utils::FileName &proFilePath) const;
|
|
||||||
bool parseInProgress(const Utils::FileName &proFilePath) const;
|
|
||||||
|
|
||||||
virtual QStringList filesGeneratedFrom(const QString &file) const final;
|
virtual QStringList filesGeneratedFrom(const QString &file) const final;
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ void QmlProject::addedRunConfiguration(RunConfiguration *rc)
|
|||||||
// they have been added to a project
|
// they have been added to a project
|
||||||
QmlProjectRunConfiguration *qmlrc = qobject_cast<QmlProjectRunConfiguration *>(rc);
|
QmlProjectRunConfiguration *qmlrc = qobject_cast<QmlProjectRunConfiguration *>(rc);
|
||||||
if (qmlrc)
|
if (qmlrc)
|
||||||
qmlrc->updateEnabled();
|
qmlrc->updateEnabledState();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir QmlProject::projectDir() const
|
QDir QmlProject::projectDir() const
|
||||||
|
@@ -53,8 +53,7 @@ const char M_CURRENT_FILE[] = "CurrentFile";
|
|||||||
|
|
||||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent, Id id) :
|
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent, Id id) :
|
||||||
RunConfiguration(parent, id),
|
RunConfiguration(parent, id),
|
||||||
m_scriptFile(QLatin1String(M_CURRENT_FILE)),
|
m_scriptFile(QLatin1String(M_CURRENT_FILE))
|
||||||
m_isEnabled(false)
|
|
||||||
{
|
{
|
||||||
addExtraAspect(new QmlProjectEnvironmentAspect(this));
|
addExtraAspect(new QmlProjectEnvironmentAspect(this));
|
||||||
|
|
||||||
@@ -79,22 +78,18 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *parent,
|
|||||||
m_currentFileFilename(source->m_currentFileFilename),
|
m_currentFileFilename(source->m_currentFileFilename),
|
||||||
m_mainScriptFilename(source->m_mainScriptFilename),
|
m_mainScriptFilename(source->m_mainScriptFilename),
|
||||||
m_scriptFile(source->m_scriptFile),
|
m_scriptFile(source->m_scriptFile),
|
||||||
m_qmlViewerArgs(source->m_qmlViewerArgs),
|
m_qmlViewerArgs(source->m_qmlViewerArgs)
|
||||||
m_isEnabled(source->m_isEnabled)
|
|
||||||
{
|
{
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProjectRunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
return m_isEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString QmlProjectRunConfiguration::disabledReason() const
|
QString QmlProjectRunConfiguration::disabledReason() const
|
||||||
{
|
{
|
||||||
if (!m_isEnabled)
|
if (mainScript().isEmpty())
|
||||||
|
return tr("No script file to execute.");
|
||||||
|
if (!QFileInfo(executable()).exists())
|
||||||
return tr("No qmlviewer or qmlscene found.");
|
return tr("No qmlviewer or qmlscene found.");
|
||||||
return QString();
|
return RunConfiguration::disabledReason();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::ctor()
|
void QmlProjectRunConfiguration::ctor()
|
||||||
@@ -106,13 +101,13 @@ void QmlProjectRunConfiguration::ctor()
|
|||||||
this, [this] { changeCurrentFile(); });
|
this, [this] { changeCurrentFile(); });
|
||||||
|
|
||||||
connect(target(), &Target::kitChanged,
|
connect(target(), &Target::kitChanged,
|
||||||
this, &QmlProjectRunConfiguration::updateEnabled);
|
this, &QmlProjectRunConfiguration::updateEnabledState);
|
||||||
|
|
||||||
if (id() == Constants::QML_SCENE_RC_ID)
|
if (id() == Constants::QML_SCENE_RC_ID)
|
||||||
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
|
setDisplayName(tr("QML Scene", "QMLRunConfiguration display name."));
|
||||||
else
|
else
|
||||||
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
|
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
|
||||||
updateEnabled();
|
updateEnabledState();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlProjectRunConfiguration::executable() const
|
QString QmlProjectRunConfiguration::executable() const
|
||||||
@@ -215,7 +210,7 @@ void QmlProjectRunConfiguration::setScriptSource(MainScriptSource source,
|
|||||||
m_mainScriptFilename
|
m_mainScriptFilename
|
||||||
= target()->project()->projectDirectory().toString() + QLatin1Char('/') + m_scriptFile;
|
= target()->project()->projectDirectory().toString() + QLatin1Char('/') + m_scriptFile;
|
||||||
}
|
}
|
||||||
updateEnabled();
|
updateEnabledState();
|
||||||
|
|
||||||
emit scriptSourceChanged();
|
emit scriptSourceChanged();
|
||||||
}
|
}
|
||||||
@@ -258,10 +253,10 @@ void QmlProjectRunConfiguration::changeCurrentFile(IEditor *editor)
|
|||||||
|
|
||||||
if (editor)
|
if (editor)
|
||||||
m_currentFileFilename = editor->document()->filePath().toString();
|
m_currentFileFilename = editor->document()->filePath().toString();
|
||||||
updateEnabled();
|
updateEnabledState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProjectRunConfiguration::updateEnabled()
|
void QmlProjectRunConfiguration::updateEnabledState()
|
||||||
{
|
{
|
||||||
bool qmlFileFound = false;
|
bool qmlFileFound = false;
|
||||||
if (mainScriptSource() == FileInEditor) {
|
if (mainScriptSource() == FileInEditor) {
|
||||||
@@ -293,11 +288,10 @@ void QmlProjectRunConfiguration::updateEnabled()
|
|||||||
qmlFileFound = !mainScript().isEmpty();
|
qmlFileFound = !mainScript().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool newValue = QFileInfo::exists(executable()) && qmlFileFound;
|
if (QFileInfo::exists(executable()) && qmlFileFound)
|
||||||
m_isEnabled = newValue;
|
RunConfiguration::updateEnabledState();
|
||||||
|
else
|
||||||
// Always emit change signal to force reevaluation of run/debug buttons
|
setEnabled(false);
|
||||||
emit enabledChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProjectRunConfiguration::isValidVersion(QtSupport::BaseQtVersion *version)
|
bool QmlProjectRunConfiguration::isValidVersion(QtSupport::BaseQtVersion *version)
|
||||||
|
@@ -70,7 +70,6 @@ public:
|
|||||||
QString mainScript() const;
|
QString mainScript() const;
|
||||||
|
|
||||||
// RunConfiguration
|
// RunConfiguration
|
||||||
bool isEnabled() const override;
|
|
||||||
QString disabledReason() const override;
|
QString disabledReason() const override;
|
||||||
virtual QWidget *createConfigurationWidget() override;
|
virtual QWidget *createConfigurationWidget() override;
|
||||||
Utils::OutputFormatter *createOutputFormatter() const override;
|
Utils::OutputFormatter *createOutputFormatter() const override;
|
||||||
@@ -84,13 +83,12 @@ protected:
|
|||||||
QmlProjectRunConfiguration(ProjectExplorer::Target *parent,
|
QmlProjectRunConfiguration(ProjectExplorer::Target *parent,
|
||||||
QmlProjectRunConfiguration *source);
|
QmlProjectRunConfiguration *source);
|
||||||
virtual bool fromMap(const QVariantMap &map) override;
|
virtual bool fromMap(const QVariantMap &map) override;
|
||||||
void setEnabled(bool value);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ctor();
|
void ctor();
|
||||||
|
|
||||||
void changeCurrentFile(Core::IEditor* = 0);
|
void changeCurrentFile(Core::IEditor* = 0);
|
||||||
void updateEnabled();
|
void updateEnabledState() final;
|
||||||
|
|
||||||
QString executable() const;
|
QString executable() const;
|
||||||
QString commandLineArguments() const;
|
QString commandLineArguments() const;
|
||||||
@@ -106,8 +104,6 @@ private:
|
|||||||
|
|
||||||
QString m_scriptFile;
|
QString m_scriptFile;
|
||||||
QString m_qmlViewerArgs;
|
QString m_qmlViewerArgs;
|
||||||
|
|
||||||
bool m_isEnabled;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlProjectManager
|
} // namespace QmlProjectManager
|
||||||
|
@@ -41,7 +41,6 @@ public:
|
|||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
|
|
||||||
bool isEnabled() const override { return true; }
|
|
||||||
bool isConfigured() const override;
|
bool isConfigured() const override;
|
||||||
ConfigurationState ensureConfigured(QString *errorMessage) override;
|
ConfigurationState ensureConfigured(QString *errorMessage) override;
|
||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
|
@@ -115,11 +115,6 @@ void RemoteLinuxRunConfiguration::init()
|
|||||||
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
|
this, &RemoteLinuxRunConfiguration::handleBuildSystemDataUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RemoteLinuxRunConfiguration::isEnabled() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *RemoteLinuxRunConfiguration::createConfigurationWidget()
|
QWidget *RemoteLinuxRunConfiguration::createConfigurationWidget()
|
||||||
{
|
{
|
||||||
return new RemoteLinuxRunConfigurationWidget(this);
|
return new RemoteLinuxRunConfigurationWidget(this);
|
||||||
|
@@ -51,7 +51,6 @@ public:
|
|||||||
const QString &targetName);
|
const QString &targetName);
|
||||||
~RemoteLinuxRunConfiguration() override;
|
~RemoteLinuxRunConfiguration() override;
|
||||||
|
|
||||||
bool isEnabled() const override;
|
|
||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
Utils::OutputFormatter *createOutputFormatter() const override;
|
Utils::OutputFormatter *createOutputFormatter() const override;
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ public:
|
|||||||
explicit WinRtRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
explicit WinRtRunConfiguration(ProjectExplorer::Target *parent, Core::Id id);
|
||||||
|
|
||||||
QWidget *createConfigurationWidget() override;
|
QWidget *createConfigurationWidget() override;
|
||||||
bool isEnabled() const override { return true; } // Always enabled like DLL run control
|
|
||||||
QVariantMap toMap() const override;
|
QVariantMap toMap() const override;
|
||||||
bool fromMap(const QVariantMap &map) override;
|
bool fromMap(const QVariantMap &map) override;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user