2013-05-15 13:39:00 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-05-15 13:39:00 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-05-15 13:39:00 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-05-15 13:39:00 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qbsrunconfiguration.h"
|
|
|
|
|
|
|
|
|
|
#include "qbsdeployconfigurationfactory.h"
|
2017-05-04 12:16:38 +02:00
|
|
|
#include "qbsinstallstep.h"
|
2013-05-15 13:39:00 +02:00
|
|
|
#include "qbsproject.h"
|
|
|
|
|
|
2016-04-07 11:08:12 +02:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2015-08-21 14:35:28 +02:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <projectexplorer/buildstep.h>
|
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
|
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
|
|
|
|
#include <projectexplorer/localenvironmentaspect.h>
|
2015-05-05 09:48:50 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2015-04-30 08:33:38 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2016-04-26 23:01:12 +03:00
|
|
|
#include <utils/algorithm.h>
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/detailswidget.h>
|
|
|
|
|
#include <utils/stringutils.h>
|
|
|
|
|
#include <utils/persistentsettings.h>
|
|
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
|
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
#include <utils/hostosinfo.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2014-06-04 19:03:55 +02:00
|
|
|
#include "api/runenvironment.h"
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
using namespace ProjectExplorer;
|
2016-01-25 15:00:20 +01:00
|
|
|
using namespace Utils;
|
2014-05-26 22:13:14 +03:00
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
namespace QbsProjectManager {
|
|
|
|
|
namespace Internal {
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); }
|
|
|
|
|
|
|
|
|
|
static Core::Id idFromProduct(const QbsProject *project, const qbs::ProductData &product)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
QString id = QLatin1String(QBS_RC_PREFIX);
|
|
|
|
|
id.append(QbsProject::uniqueProductName(product)).append(rcNameSeparator())
|
|
|
|
|
.append(QbsProject::productDisplayName(project->qbsProject(), product));
|
|
|
|
|
return Core::Id::fromString(id);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-05 12:08:15 +02:00
|
|
|
static QString uniqueProductNameFromId(Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
|
|
|
|
|
return suffix.left(suffix.indexOf(rcNameSeparator()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString productDisplayNameFromId(Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
const QString suffix = id.suffixAfter(QBS_RC_PREFIX);
|
|
|
|
|
const int sepPos = suffix.indexOf(rcNameSeparator());
|
|
|
|
|
if (sepPos == -1)
|
|
|
|
|
return suffix;
|
|
|
|
|
return suffix.mid(sepPos + rcNameSeparator().count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &uniqeName)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2013-06-21 15:09:01 +02:00
|
|
|
foreach (const qbs::ProductData &product, pro.allProducts()) {
|
2014-09-05 12:08:15 +02:00
|
|
|
if (QbsProject::uniqueProductName(product) == uniqeName)
|
2013-06-21 15:09:01 +02:00
|
|
|
return product;
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
2013-06-21 15:09:01 +02:00
|
|
|
return qbs::ProductData();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsRunConfiguration:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
|
2016-01-25 15:00:20 +01:00
|
|
|
RunConfiguration(parent, id),
|
2014-09-05 12:08:15 +02:00
|
|
|
m_uniqueProductName(uniqueProductNameFromId(id)),
|
2017-05-04 12:16:38 +02:00
|
|
|
m_currentInstallStep(0),
|
2013-05-15 13:39:00 +02:00
|
|
|
m_currentBuildStepList(0)
|
|
|
|
|
{
|
2017-02-28 11:31:09 +01:00
|
|
|
auto * const envAspect = new LocalEnvironmentAspect(this,
|
|
|
|
|
[](RunConfiguration *rc, Environment &env) {
|
|
|
|
|
static_cast<QbsRunConfiguration *>(rc)->addToBaseEnvironment(env);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
addExtraAspect(envAspect);
|
|
|
|
|
connect(static_cast<QbsProject *>(parent->project()), &QbsProject::parsingFinished, this,
|
|
|
|
|
[envAspect]() { envAspect->buildEnvironmentHasChanged(); });
|
2015-04-30 08:33:38 +02:00
|
|
|
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments")));
|
2015-05-05 09:48:50 +02:00
|
|
|
addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory")));
|
2013-11-01 14:13:41 +01:00
|
|
|
|
2015-05-12 13:05:14 +02:00
|
|
|
addExtraAspect(new TerminalAspect(this,
|
|
|
|
|
QStringLiteral("Qbs.RunConfiguration.UseTerminal"),
|
|
|
|
|
isConsoleApplication()));
|
2014-11-07 11:53:08 +01:00
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
ctor();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
|
2016-01-25 15:00:20 +01:00
|
|
|
RunConfiguration(parent, source),
|
2014-09-05 12:08:15 +02:00
|
|
|
m_uniqueProductName(source->m_uniqueProductName),
|
2017-05-04 12:16:38 +02:00
|
|
|
m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway.
|
2013-10-18 17:45:07 +02:00
|
|
|
m_currentBuildStepList(0) // ditto
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
|
|
|
|
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
2014-11-07 11:53:08 +01:00
|
|
|
connect(project, &QbsProject::projectParsingStarted, this, &RunConfiguration::enabledChanged);
|
|
|
|
|
connect(project, &QbsProject::projectParsingDone, this, [this](bool success) {
|
2015-05-12 13:05:14 +02:00
|
|
|
auto terminalAspect = extraAspect<TerminalAspect>();
|
|
|
|
|
if (success && !terminalAspect->isUserSet())
|
|
|
|
|
terminalAspect->setUseTerminal(isConsoleApplication());
|
2014-11-07 11:53:08 +01:00
|
|
|
emit enabledChanged();
|
|
|
|
|
});
|
2015-08-21 14:35:28 +02:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildStateChanged, this,
|
|
|
|
|
[this, project](Project *p) {
|
|
|
|
|
if (p == project && !BuildManager::isBuilding(p))
|
|
|
|
|
emit enabledChanged();
|
|
|
|
|
}
|
|
|
|
|
);
|
2014-11-07 11:53:08 +01:00
|
|
|
|
|
|
|
|
connect(target(), &Target::activeDeployConfigurationChanged,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
2013-05-15 13:39:00 +02:00
|
|
|
installStepChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *QbsRunConfiguration::createConfigurationWidget()
|
|
|
|
|
{
|
2016-01-06 17:58:59 +01:00
|
|
|
return new QbsRunConfigurationWidget(this);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfiguration::installStepChanged()
|
|
|
|
|
{
|
2017-05-04 12:16:38 +02:00
|
|
|
if (m_currentInstallStep) {
|
|
|
|
|
disconnect(m_currentInstallStep, &QbsInstallStep::changed,
|
|
|
|
|
this, &QbsRunConfiguration::targetInformationChanged);
|
|
|
|
|
}
|
2013-05-15 13:39:00 +02:00
|
|
|
if (m_currentBuildStepList) {
|
2016-01-06 17:58:59 +01:00
|
|
|
disconnect(m_currentBuildStepList, &BuildStepList::stepInserted,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
|
|
|
|
disconnect(m_currentBuildStepList, &BuildStepList::stepRemoved,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
|
|
|
|
disconnect(m_currentBuildStepList, &BuildStepList::stepMoved,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QbsDeployConfiguration *activeDc = qobject_cast<QbsDeployConfiguration *>(target()->activeDeployConfiguration());
|
|
|
|
|
m_currentBuildStepList = activeDc ? activeDc->stepList() : 0;
|
2017-05-04 12:16:38 +02:00
|
|
|
if (m_currentInstallStep) {
|
|
|
|
|
connect(m_currentInstallStep, &QbsInstallStep::changed,
|
|
|
|
|
this, &QbsRunConfiguration::targetInformationChanged);
|
|
|
|
|
}
|
2013-05-15 13:39:00 +02:00
|
|
|
if (m_currentBuildStepList) {
|
2016-01-06 17:58:59 +01:00
|
|
|
connect(m_currentBuildStepList, &BuildStepList::stepInserted,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
2017-05-04 12:16:38 +02:00
|
|
|
connect(m_currentBuildStepList, &BuildStepList::aboutToRemoveStep, this,
|
|
|
|
|
&QbsRunConfiguration::installStepToBeRemoved);
|
2016-01-06 17:58:59 +01:00
|
|
|
connect(m_currentBuildStepList, &BuildStepList::stepRemoved,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
|
|
|
|
connect(m_currentBuildStepList, &BuildStepList::stepMoved,
|
|
|
|
|
this, &QbsRunConfiguration::installStepChanged);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit targetInformationChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-04 12:16:38 +02:00
|
|
|
void QbsRunConfiguration::installStepToBeRemoved(int pos)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_currentBuildStepList, return);
|
|
|
|
|
// TODO: Our logic is rather broken. Users can create as many qbs install steps as they want,
|
|
|
|
|
// but we ignore all but the first one.
|
|
|
|
|
if (m_currentBuildStepList->steps().at(pos) != m_currentInstallStep)
|
|
|
|
|
return;
|
|
|
|
|
disconnect(m_currentInstallStep, &QbsInstallStep::changed,
|
|
|
|
|
this, &QbsRunConfiguration::targetInformationChanged);
|
|
|
|
|
m_currentInstallStep = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-25 15:00:20 +01:00
|
|
|
Runnable QbsRunConfiguration::runnable() const
|
|
|
|
|
{
|
|
|
|
|
StandardRunnable r;
|
|
|
|
|
r.executable = executable();
|
|
|
|
|
r.workingDirectory = extraAspect<WorkingDirectoryAspect>()->workingDirectory().toString();
|
|
|
|
|
r.commandLineArguments = extraAspect<ArgumentsAspect>()->arguments();
|
|
|
|
|
r.runMode = extraAspect<TerminalAspect>()->runMode();
|
|
|
|
|
r.environment = extraAspect<LocalEnvironmentAspect>()->environment();
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
QString QbsRunConfiguration::executable() const
|
|
|
|
|
{
|
|
|
|
|
QbsProject *pro = static_cast<QbsProject *>(target()->project());
|
2014-09-05 12:08:15 +02:00
|
|
|
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_uniqueProductName);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2013-09-06 18:02:46 +02:00
|
|
|
if (!product.isValid() || !pro->qbsProject().isValid())
|
2013-05-15 13:39:00 +02:00
|
|
|
return QString();
|
|
|
|
|
|
2016-08-10 10:54:15 +02:00
|
|
|
return product.targetExecutable();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2013-11-19 11:30:00 +01:00
|
|
|
bool QbsRunConfiguration::isConsoleApplication() const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2013-08-07 14:18:19 +02:00
|
|
|
QbsProject *pro = static_cast<QbsProject *>(target()->project());
|
2014-09-05 12:08:15 +02:00
|
|
|
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_uniqueProductName);
|
2014-11-07 11:53:08 +01:00
|
|
|
return product.properties().value(QLatin1String("consoleApplication"), false).toBool();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsRunConfiguration::baseWorkingDirectory() const
|
|
|
|
|
{
|
|
|
|
|
const QString exe = executable();
|
|
|
|
|
if (!exe.isEmpty())
|
2016-01-05 15:50:17 +02:00
|
|
|
return QFileInfo(exe).absolutePath();
|
2013-05-15 13:39:00 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
|
|
|
|
{
|
2014-06-04 19:03:55 +02:00
|
|
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
2016-07-01 16:55:02 +02:00
|
|
|
if (project && project->qbsProject().isValid()) {
|
2014-09-05 12:08:15 +02:00
|
|
|
const qbs::ProductData product = findProduct(project->qbsProjectData(), m_uniqueProductName);
|
2014-06-04 19:03:55 +02:00
|
|
|
if (product.isValid()) {
|
2014-09-27 21:44:37 -04:00
|
|
|
QProcessEnvironment procEnv = env.toProcessEnvironment();
|
|
|
|
|
procEnv.insert(QLatin1String("QBS_RUN_FILE_PATH"), executable());
|
2017-02-13 15:40:59 +01:00
|
|
|
qbs::RunEnvironment qbsRunEnv = project->qbsProject().getRunEnvironment(product,
|
|
|
|
|
qbs::InstallOptions(), procEnv, QbsManager::settings());
|
2016-04-07 11:08:12 +02:00
|
|
|
qbs::ErrorInfo error;
|
|
|
|
|
procEnv = qbsRunEnv.runEnvironment(&error);
|
|
|
|
|
if (error.hasError()) {
|
|
|
|
|
Core::MessageManager::write(tr("Error retrieving run environment: %1")
|
|
|
|
|
.arg(error.toString()));
|
|
|
|
|
}
|
2014-06-04 19:03:55 +02:00
|
|
|
if (!procEnv.isEmpty()) {
|
|
|
|
|
env = Utils::Environment();
|
|
|
|
|
foreach (const QString &key, procEnv.keys())
|
|
|
|
|
env.set(key, procEnv.value(key));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
|
|
|
|
if (qtVersion)
|
|
|
|
|
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 14:28:49 +01:00
|
|
|
QString QbsRunConfiguration::buildSystemTarget() const
|
2017-06-09 07:53:21 +02:00
|
|
|
{
|
|
|
|
|
return productDisplayNameFromId(id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QbsRunConfiguration::uniqueProductName() const
|
2013-05-16 16:10:47 +02:00
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
return m_uniqueProductName;
|
2013-05-16 16:10:47 +02:00
|
|
|
}
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
QString QbsRunConfiguration::defaultDisplayName()
|
|
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
QString defaultName = productDisplayNameFromId(id());
|
|
|
|
|
if (defaultName.isEmpty())
|
2013-05-15 13:39:00 +02:00
|
|
|
defaultName = tr("Qbs Run Configuration");
|
|
|
|
|
return defaultName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::OutputFormatter *QbsRunConfiguration::createOutputFormatter() const
|
|
|
|
|
{
|
|
|
|
|
return new QtSupport::QtOutputFormatter(target()->project());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsRunConfigurationWidget:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
2016-01-06 17:58:59 +01:00
|
|
|
QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc)
|
|
|
|
|
: m_rc(rc)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2016-01-06 17:58:59 +01:00
|
|
|
auto vboxTopLayout = new QVBoxLayout(this);
|
2013-05-15 13:39:00 +02:00
|
|
|
vboxTopLayout->setMargin(0);
|
|
|
|
|
|
2016-01-06 17:58:59 +01:00
|
|
|
auto hl = new QHBoxLayout();
|
2013-05-15 13:39:00 +02:00
|
|
|
hl->addStretch();
|
|
|
|
|
m_disabledIcon = new QLabel(this);
|
2016-08-03 17:55:54 +02:00
|
|
|
m_disabledIcon->setPixmap(Utils::Icons::WARNING.pixmap());
|
2013-05-15 13:39:00 +02:00
|
|
|
hl->addWidget(m_disabledIcon);
|
|
|
|
|
m_disabledReason = new QLabel(this);
|
|
|
|
|
m_disabledReason->setVisible(false);
|
|
|
|
|
hl->addWidget(m_disabledReason);
|
|
|
|
|
hl->addStretch();
|
|
|
|
|
vboxTopLayout->addLayout(hl);
|
|
|
|
|
|
2016-01-06 17:58:59 +01:00
|
|
|
auto detailsContainer = new Utils::DetailsWidget(this);
|
|
|
|
|
detailsContainer->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
vboxTopLayout->addWidget(detailsContainer);
|
|
|
|
|
auto detailsWidget = new QWidget(detailsContainer);
|
|
|
|
|
detailsContainer->setWidget(detailsWidget);
|
|
|
|
|
auto toplayout = new QFormLayout(detailsWidget);
|
2013-05-15 13:39:00 +02:00
|
|
|
toplayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
|
toplayout->setMargin(0);
|
|
|
|
|
|
2015-01-23 12:05:14 +01:00
|
|
|
m_executableLineLabel = new QLabel(this);
|
|
|
|
|
m_executableLineLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
|
|
|
|
setExecutableLineText();
|
|
|
|
|
toplayout->addRow(tr("Executable:"), m_executableLineLabel);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2015-04-30 08:33:38 +02:00
|
|
|
m_rc->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, toplayout);
|
2015-05-05 09:48:50 +02:00
|
|
|
m_rc->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, toplayout);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2015-05-12 13:05:14 +02:00
|
|
|
m_rc->extraAspect<TerminalAspect>()->addToMainConfigurationWidget(this, toplayout);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
runConfigurationEnabledChange();
|
|
|
|
|
|
2016-01-06 17:58:59 +01:00
|
|
|
connect(m_rc, &QbsRunConfiguration::targetInformationChanged,
|
|
|
|
|
this, &QbsRunConfigurationWidget::targetInformationHasChanged, Qt::QueuedConnection);
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2016-01-06 17:58:59 +01:00
|
|
|
connect(m_rc, &RunConfiguration::enabledChanged,
|
|
|
|
|
this, &QbsRunConfigurationWidget::runConfigurationEnabledChange);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfigurationWidget::runConfigurationEnabledChange()
|
|
|
|
|
{
|
|
|
|
|
bool enabled = m_rc->isEnabled();
|
|
|
|
|
m_disabledIcon->setVisible(!enabled);
|
|
|
|
|
m_disabledReason->setVisible(!enabled);
|
|
|
|
|
m_disabledReason->setText(m_rc->disabledReason());
|
2013-11-19 11:30:00 +01:00
|
|
|
|
2013-05-24 16:19:55 +02:00
|
|
|
targetInformationHasChanged();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QbsRunConfigurationWidget::targetInformationHasChanged()
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2015-01-23 12:05:14 +01:00
|
|
|
setExecutableLineText(m_rc->executable());
|
2013-05-24 16:19:55 +02:00
|
|
|
|
2015-05-05 09:48:50 +02:00
|
|
|
WorkingDirectoryAspect *aspect = m_rc->extraAspect<WorkingDirectoryAspect>();
|
2016-01-05 15:49:50 +02:00
|
|
|
aspect->setDefaultWorkingDirectory(Utils::FileName::fromString(m_rc->baseWorkingDirectory()));
|
2015-05-05 09:48:50 +02:00
|
|
|
aspect->pathChooser()->setBaseFileName(m_rc->target()->project()->projectDirectory());
|
2013-05-15 13:39:00 +02:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-23 12:05:14 +01:00
|
|
|
void QbsRunConfigurationWidget::setExecutableLineText(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
const QString newText = text.isEmpty() ? tr("<unknown>") : text;
|
|
|
|
|
m_executableLineLabel->setText(newText);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
// QbsRunConfigurationFactory:
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
QbsRunConfigurationFactory::QbsRunConfigurationFactory(QObject *parent) :
|
2014-05-26 22:13:14 +03:00
|
|
|
IRunConfigurationFactory(parent)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
setObjectName(QLatin1String("QbsRunConfigurationFactory"));
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
bool QbsRunConfigurationFactory::canCreate(Target *parent, Core::Id id) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
2014-09-05 12:08:15 +02:00
|
|
|
return findProduct(project->qbsProjectData(), uniqueProductNameFromId(id)).isValid();
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
RunConfiguration *QbsRunConfigurationFactory::doCreate(Target *parent, Core::Id id)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
return new QbsRunConfiguration(parent, id);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool QbsRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!canHandle(parent))
|
|
|
|
|
return false;
|
2014-05-26 22:13:14 +03:00
|
|
|
return idFromMap(map).toString().startsWith(QLatin1String(QBS_RC_PREFIX));
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
RunConfiguration *QbsRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
return new QbsRunConfiguration(parent, idFromMap(map));
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool QbsRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
return canCreate(parent, source->id());
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
RunConfiguration *QbsRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
|
|
|
|
QbsRunConfiguration *old = static_cast<QbsRunConfiguration *>(source);
|
|
|
|
|
return new QbsRunConfiguration(parent, old);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 16:24:52 +02:00
|
|
|
QList<Core::Id> QbsRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2016-04-26 23:01:12 +03:00
|
|
|
QList<qbs::ProductData> products;
|
|
|
|
|
|
2013-05-15 13:39:00 +02:00
|
|
|
if (!canHandle(parent))
|
2016-04-26 23:01:12 +03:00
|
|
|
return QList<Core::Id>();
|
2013-05-15 13:39:00 +02:00
|
|
|
|
|
|
|
|
QbsProject *project = static_cast<QbsProject *>(parent->project());
|
2013-09-06 18:02:46 +02:00
|
|
|
if (!project || !project->qbsProject().isValid())
|
2016-04-26 23:01:12 +03:00
|
|
|
return QList<Core::Id>();
|
2013-05-15 13:39:00 +02:00
|
|
|
|
2014-03-21 11:02:54 +01:00
|
|
|
foreach (const qbs::ProductData &product, project->qbsProjectData().allProducts()) {
|
2014-04-30 11:03:14 +02:00
|
|
|
if (product.isRunnable() && product.isEnabled())
|
2016-04-26 23:01:12 +03:00
|
|
|
products << product;
|
2014-03-21 11:02:54 +01:00
|
|
|
}
|
2014-03-03 16:04:44 +01:00
|
|
|
|
2016-04-26 23:01:12 +03:00
|
|
|
if (mode == AutoCreate) {
|
|
|
|
|
std::function<bool (const qbs::ProductData &)> hasQtcRunnable = [](const qbs::ProductData &product) {
|
|
|
|
|
return product.properties().value("qtcRunnable").toBool();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (Utils::anyOf(products, hasQtcRunnable))
|
|
|
|
|
Utils::erase(products, std::not1(hasQtcRunnable));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Utils::transform(products, [project](const qbs::ProductData &product) {
|
|
|
|
|
return idFromProduct(project, product);
|
|
|
|
|
});
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
QString QbsRunConfigurationFactory::displayNameForId(Core::Id id) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
2014-09-05 12:08:15 +02:00
|
|
|
return productDisplayNameFromId(id);
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool QbsRunConfigurationFactory::canHandle(Target *t) const
|
2013-05-15 13:39:00 +02:00
|
|
|
{
|
|
|
|
|
if (!t->project()->supportsKit(t->kit()))
|
|
|
|
|
return false;
|
|
|
|
|
if (!qobject_cast<QbsProject *>(t->project()))
|
|
|
|
|
return false;
|
2014-05-26 22:13:14 +03:00
|
|
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(t->kit());
|
|
|
|
|
return devType == Constants::DESKTOP_DEVICE_TYPE;
|
2013-05-15 13:39:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QbsProjectManager
|