2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "runconfiguration.h"
|
2010-01-07 18:17:24 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "project.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "target.h"
|
2011-02-01 18:36:00 +01:00
|
|
|
#include "toolchain.h"
|
2011-08-18 13:46:52 +02:00
|
|
|
#include "abi.h"
|
2009-10-28 17:21:27 +01:00
|
|
|
#include "buildconfiguration.h"
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kitinformation.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
|
2011-08-18 13:46:52 +02:00
|
|
|
#include <utils/outputformatter.h>
|
2011-01-17 13:52:14 +01:00
|
|
|
#include <utils/checkablemessagebox.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2013-03-26 11:32:14 +01:00
|
|
|
#include <coreplugin/icontext.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTimer>
|
|
|
|
|
#include <QPushButton>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
2012-02-23 17:40:48 +01:00
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::ProcessHandle
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The ProcessHandle class is a helper class to describe a process.
|
2011-05-31 09:48:00 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Encapsulates parameters of a running process, local (PID) or remote (to be
|
|
|
|
|
done, address, port, and so on).
|
2011-05-31 09:48:00 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-07-06 10:25:18 +02:00
|
|
|
ProcessHandle::ProcessHandle(quint64 pid) :
|
|
|
|
|
m_pid(pid)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessHandle::isValid() const
|
|
|
|
|
{
|
|
|
|
|
return m_pid != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessHandle::setPid(quint64 pid)
|
|
|
|
|
{
|
|
|
|
|
m_pid = pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quint64 ProcessHandle::pid() const
|
|
|
|
|
{
|
|
|
|
|
return m_pid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProcessHandle::toString() const
|
|
|
|
|
{
|
|
|
|
|
if (m_pid)
|
|
|
|
|
return RunControl::tr("PID %1").arg(m_pid);
|
|
|
|
|
//: Invalid process handle.
|
|
|
|
|
return RunControl::tr("Invalid");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ProcessHandle::equals(const ProcessHandle &rhs) const
|
|
|
|
|
{
|
|
|
|
|
return m_pid == rhs.m_pid;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-12 17:04:10 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ISettingsAspect
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
ISettingsAspect *ISettingsAspect::clone() const
|
|
|
|
|
{
|
|
|
|
|
ISettingsAspect *other = create();
|
|
|
|
|
QVariantMap data;
|
|
|
|
|
toMap(data);
|
|
|
|
|
other->fromMap(data);
|
|
|
|
|
return other;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// IRunConfigurationAspect
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
IRunConfigurationAspect::IRunConfigurationAspect(RunConfiguration *parent)
|
|
|
|
|
{
|
|
|
|
|
m_runConfiguration = parent;
|
|
|
|
|
m_projectSettings = 0;
|
|
|
|
|
m_globalSettings = 0;
|
|
|
|
|
m_useGlobalSettings = false;
|
|
|
|
|
connect(this, SIGNAL(requestRunActionsUpdate()), parent, SIGNAL(requestRunActionsUpdate()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IRunConfigurationAspect::~IRunConfigurationAspect()
|
|
|
|
|
{
|
|
|
|
|
delete m_projectSettings;
|
|
|
|
|
}
|
2012-02-17 19:05:11 +01:00
|
|
|
|
2013-06-05 08:43:52 +03:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns the widget used to configure this run configuration. Ownership is
|
|
|
|
|
transferred to the caller.
|
2013-06-05 08:43:52 +03:00
|
|
|
*/
|
2013-08-12 17:04:10 +02:00
|
|
|
|
2013-03-27 17:17:24 +01:00
|
|
|
RunConfigWidget *IRunConfigurationAspect::createConfigurationWidget()
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-12 17:04:10 +02:00
|
|
|
void IRunConfigurationAspect::setProjectSettings(ISettingsAspect *settings)
|
|
|
|
|
{
|
|
|
|
|
m_projectSettings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::setGlobalSettings(ISettingsAspect *settings)
|
|
|
|
|
{
|
|
|
|
|
m_globalSettings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::setUsingGlobalSettings(bool value)
|
|
|
|
|
{
|
|
|
|
|
m_useGlobalSettings = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ISettingsAspect *IRunConfigurationAspect::currentSettings() const
|
|
|
|
|
{
|
|
|
|
|
return m_useGlobalSettings ? m_globalSettings : m_projectSettings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
m_projectSettings->fromMap(map);
|
|
|
|
|
m_useGlobalSettings = map.value(m_id.toString() + QLatin1String(".UseGlobalSettings"), true).toBool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::toMap(QVariantMap &map) const
|
|
|
|
|
{
|
|
|
|
|
m_projectSettings->toMap(map);
|
|
|
|
|
map.insert(m_id.toString() + QLatin1String(".UseGlobalSettings"), m_useGlobalSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IRunConfigurationAspect *IRunConfigurationAspect::clone(RunConfiguration *parent) const
|
|
|
|
|
{
|
|
|
|
|
IRunConfigurationAspect *other = create(parent);
|
2013-08-24 23:39:47 +03:00
|
|
|
if (m_projectSettings)
|
|
|
|
|
other->m_projectSettings = m_projectSettings->clone();
|
2013-08-12 17:04:10 +02:00
|
|
|
other->m_globalSettings = m_globalSettings;
|
|
|
|
|
other->m_useGlobalSettings = m_useGlobalSettings;
|
|
|
|
|
return other;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IRunConfigurationAspect::resetProjectToGlobalSettings()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_globalSettings, return);
|
|
|
|
|
QVariantMap map;
|
|
|
|
|
m_globalSettings->toMap(map);
|
|
|
|
|
m_projectSettings->fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-27 17:17:24 +01:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::RunConfiguration
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The RunConfiguration class is the base class for a run configuration.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
A run configuration specifies how a target should be run, while a runner
|
|
|
|
|
does the actual running.
|
|
|
|
|
|
|
|
|
|
All RunControls and the target hold a shared pointer to the run
|
|
|
|
|
configuration. That is, the lifetime of the run configuration might exceed
|
|
|
|
|
the life of the target.
|
2011-04-14 12:58:14 +02:00
|
|
|
The user might still have a RunControl running (or output tab of that RunControl open)
|
|
|
|
|
and yet unloaded the target.
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
Also, a run configuration might be already removed from the list of run
|
|
|
|
|
configurations
|
2011-04-14 12:58:14 +02:00
|
|
|
for a target, but still be runnable via the output tab.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
RunConfiguration::RunConfiguration(Target *target, const Core::Id id) :
|
2010-09-01 11:34:34 +02:00
|
|
|
ProjectConfiguration(target, id),
|
2013-03-26 16:39:41 +01:00
|
|
|
m_aspectsInitialized(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
2013-03-27 13:03:15 +01:00
|
|
|
ctor();
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
2010-09-08 11:20:56 +02:00
|
|
|
ProjectConfiguration(target, source),
|
2013-03-26 16:39:41 +01:00
|
|
|
m_aspectsInitialized(true)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
Q_ASSERT(target);
|
2013-03-27 13:03:15 +01:00
|
|
|
ctor();
|
2012-09-20 14:42:57 +02:00
|
|
|
foreach (IRunConfigurationAspect *aspect, source->m_aspects) {
|
2013-03-22 15:18:52 +01:00
|
|
|
IRunConfigurationAspect *clone = aspect->clone(this);
|
|
|
|
|
if (clone)
|
|
|
|
|
m_aspects.append(clone);
|
2012-09-20 14:42:57 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunConfiguration::~RunConfiguration()
|
|
|
|
|
{
|
2011-02-28 12:23:12 +01:00
|
|
|
qDeleteAll(m_aspects);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfiguration::addExtraAspects()
|
|
|
|
|
{
|
2013-03-26 16:39:41 +01:00
|
|
|
if (m_aspectsInitialized)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-06-18 11:34:15 +02:00
|
|
|
foreach (IRunControlFactory *factory, ExtensionSystem::PluginManager::getObjects<IRunControlFactory>())
|
2013-04-05 17:27:45 +02:00
|
|
|
addExtraAspect(factory->createRunConfigurationAspect(this));
|
2013-03-26 16:39:41 +01:00
|
|
|
m_aspectsInitialized = true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-04-05 17:27:45 +02:00
|
|
|
void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect)
|
|
|
|
|
{
|
|
|
|
|
if (aspect)
|
|
|
|
|
m_aspects += aspect;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-27 13:03:15 +01:00
|
|
|
void RunConfiguration::ctor()
|
|
|
|
|
{
|
|
|
|
|
connect(this, SIGNAL(enabledChanged()), this, SIGNAL(requestRunActionsUpdate()));
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Checks whether a run configuration is enabled.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-05-26 15:33:24 +02:00
|
|
|
bool RunConfiguration::isEnabled() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
return true;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-26 16:30:35 +02:00
|
|
|
QString RunConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool RunConfiguration::isConfigured() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-13 11:27:15 +02:00
|
|
|
bool RunConfiguration::ensureConfigured(QString *errorMessage)
|
|
|
|
|
{
|
|
|
|
|
if (isConfigured())
|
|
|
|
|
return true;
|
|
|
|
|
if (errorMessage)
|
|
|
|
|
*errorMessage = tr("Unknown error.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
BuildConfiguration *RunConfiguration::activeBuildConfiguration() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!target())
|
2010-01-19 13:41:02 +01:00
|
|
|
return 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
return target()->activeBuildConfiguration();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target *RunConfiguration::target() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
return static_cast<Target *>(parent());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
QVariantMap RunConfiguration::toMap() const
|
|
|
|
|
{
|
2012-02-22 11:56:08 +01:00
|
|
|
QVariantMap map = ProjectConfiguration::toMap();
|
|
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
2013-08-12 17:05:52 +02:00
|
|
|
aspect->toMap(map);
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 18:36:00 +01:00
|
|
|
ProjectExplorer::Abi RunConfiguration::abi() const
|
|
|
|
|
{
|
|
|
|
|
BuildConfiguration *bc = target()->activeBuildConfiguration();
|
|
|
|
|
if (!bc)
|
|
|
|
|
return Abi::hostAbi();
|
2012-09-03 18:31:44 +02:00
|
|
|
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
|
2011-02-01 18:36:00 +01:00
|
|
|
if (!tc)
|
|
|
|
|
return Abi::hostAbi();
|
|
|
|
|
return tc->targetAbi();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
bool RunConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2013-03-26 16:39:41 +01:00
|
|
|
addExtraAspects();
|
2010-09-09 17:00:26 +02:00
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
2012-02-22 12:36:39 +01:00
|
|
|
aspect->fromMap(map);
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2010-09-01 11:34:34 +02:00
|
|
|
return ProjectConfiguration::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunConfigurationAspect
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The IRunConfigurationAspect class provides an additional
|
|
|
|
|
configuration aspect.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Aspects are a mechanism to add RunControl-specific options to a run
|
|
|
|
|
configuration without subclassing the run configuration for every addition.
|
|
|
|
|
This prevents a combinatorial explosion of subclasses and eliminates
|
|
|
|
|
the need to add all options to the base class.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns extra aspects.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
|
|
|
|
\sa ProjectExplorer::IRunConfigurationAspect
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-28 12:23:12 +01:00
|
|
|
QList<IRunConfigurationAspect *> RunConfiguration::extraAspects() const
|
|
|
|
|
{
|
2013-03-26 16:39:41 +01:00
|
|
|
QTC_ASSERT(m_aspectsInitialized, return QList<IRunConfigurationAspect *>());
|
2011-02-28 12:23:12 +01:00
|
|
|
return m_aspects;
|
|
|
|
|
}
|
2013-08-12 17:04:10 +02:00
|
|
|
IRunConfigurationAspect *RunConfiguration::extraAspect(Core::Id id) const
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_aspectsInitialized, return 0);
|
|
|
|
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
|
|
|
|
if (aspect->id() == id)
|
|
|
|
|
return aspect;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2011-02-28 12:23:12 +01:00
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
Utils::OutputFormatter *RunConfiguration::createOutputFormatter() const
|
2010-07-13 15:02:37 +02:00
|
|
|
{
|
2011-04-15 12:59:44 +02:00
|
|
|
return new Utils::OutputFormatter();
|
2010-07-13 15:02:37 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunConfigurationFactory
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The IRunConfigurationFactory class restores run configurations from
|
|
|
|
|
settings.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
|
|
|
|
The run configuration factory is used for restoring run configurations from
|
2013-09-10 17:16:10 +02:00
|
|
|
settings and for creating new run configurations in the \gui {Run Settings}
|
|
|
|
|
dialog.
|
|
|
|
|
To restore run configurations, use the
|
|
|
|
|
\c {bool canRestore(Target *parent, const QString &id)}
|
|
|
|
|
and \c {RunConfiguration* create(Target *parent, const QString &id)}
|
|
|
|
|
functions.
|
|
|
|
|
|
|
|
|
|
To generate a list of creatable run configurations, use the
|
|
|
|
|
\c {QStringList availableCreationIds(Target *parent)} and
|
|
|
|
|
\c {QString displayNameForType(const QString&)} functions. To create a
|
|
|
|
|
run configuration, use \c create().
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QStringList ProjectExplorer::IRunConfigurationFactory::availableCreationIds(Target *parent) const
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Shows the list of possible additions to a target. Returns a list of types.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-05-23 16:13:55 +02:00
|
|
|
\fn QString ProjectExplorer::IRunConfigurationFactory::displayNameForId(const Core::Id id) const
|
2013-09-10 17:16:10 +02:00
|
|
|
Translates the types to names to display to the user.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
IRunConfigurationFactory::IRunConfigurationFactory(QObject *parent) :
|
|
|
|
|
QObject(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IRunConfigurationFactory::~IRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-26 16:39:41 +01:00
|
|
|
RunConfiguration *IRunConfigurationFactory::create(Target *parent, const Core::Id id)
|
|
|
|
|
{
|
|
|
|
|
if (!canCreate(parent, id))
|
|
|
|
|
return 0;
|
|
|
|
|
RunConfiguration *rc = doCreate(parent, id);
|
|
|
|
|
if (!rc)
|
|
|
|
|
return 0;
|
|
|
|
|
rc->addExtraAspects();
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-28 14:53:12 +01:00
|
|
|
RunConfiguration *IRunConfigurationFactory::restore(Target *parent, const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!canRestore(parent, map))
|
|
|
|
|
return 0;
|
|
|
|
|
RunConfiguration *rc = doRestore(parent, map);
|
|
|
|
|
if (!rc->fromMap(map)) {
|
|
|
|
|
delete rc;
|
|
|
|
|
rc = 0;
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, const QVariantMap &map)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> factories
|
2013-08-02 11:47:17 +02:00
|
|
|
= ExtensionSystem::PluginManager::getObjects<IRunConfigurationFactory>();
|
2012-04-24 15:49:09 +02:00
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
|
|
|
|
if (factory->canRestore(parent, map))
|
|
|
|
|
return factory;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
IRunConfigurationFactory *IRunConfigurationFactory::find(Target *parent, RunConfiguration *rc)
|
|
|
|
|
{
|
|
|
|
|
QList<IRunConfigurationFactory *> factories
|
2013-08-02 11:47:17 +02:00
|
|
|
= ExtensionSystem::PluginManager::getObjects<IRunConfigurationFactory>();
|
2012-09-20 14:42:57 +02:00
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
|
|
|
|
if (factory->canClone(parent, rc))
|
|
|
|
|
return factory;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> IRunConfigurationFactory::find(Target *parent)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> factories
|
2013-08-02 11:47:17 +02:00
|
|
|
= ExtensionSystem::PluginManager::getObjects<IRunConfigurationFactory>();
|
2012-04-24 15:49:09 +02:00
|
|
|
QList<IRunConfigurationFactory *> result;
|
|
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
|
|
|
|
if (!factory->availableCreationIds(parent).isEmpty())
|
|
|
|
|
result << factory;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::IRunControlFactory
|
|
|
|
|
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The IRunControlFactory class creates RunControl objects matching a
|
|
|
|
|
run configuration.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
2013-05-23 16:13:55 +02:00
|
|
|
\fn RunConfigWidget *ProjectExplorer::IRunConfigurationAspect::createConfigurationWidget()
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns a widget used to configure this runner. Ownership is transferred to
|
|
|
|
|
the caller.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns 0 if @p \a runConfiguration is not suitable for RunControls from this
|
|
|
|
|
factory, or no user-accessible
|
2011-04-14 12:58:14 +02:00
|
|
|
configuration is required.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
IRunControlFactory::IRunControlFactory(QObject *parent)
|
2009-06-16 15:11:47 +02:00
|
|
|
: QObject(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
IRunControlFactory::~IRunControlFactory()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
/*!
|
|
|
|
|
Returns an IRunConfigurationAspect to carry options for RunControls this
|
|
|
|
|
factory can create.
|
|
|
|
|
|
|
|
|
|
If no extra options are required, it is allowed to return null like the
|
|
|
|
|
default implementation does. This function is intended to be called from the
|
|
|
|
|
RunConfiguration constructor, so passing a RunConfiguration pointer makes
|
|
|
|
|
no sense because that object is under construction at the time.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-03-26 16:39:41 +01:00
|
|
|
IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
|
2011-02-28 12:23:12 +01:00
|
|
|
{
|
2013-03-26 16:39:41 +01:00
|
|
|
Q_UNUSED(rc);
|
2011-02-28 12:23:12 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::RunControl
|
2013-06-05 14:29:24 +02:00
|
|
|
\brief The RunControl class instances represent one item that is run.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\fn QIcon ProjectExplorer::RunControl::icon() const
|
2013-09-10 17:16:10 +02:00
|
|
|
Returns the icon to be shown in the Outputwindow.
|
2011-04-14 12:58:14 +02:00
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
TODO the icon differs currently only per "mode", so this is more flexible
|
|
|
|
|
than it needs to be.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2012-01-10 19:17:24 +01:00
|
|
|
RunControl::RunControl(RunConfiguration *runConfiguration, RunMode mode)
|
2010-07-15 10:46:01 +02:00
|
|
|
: m_runMode(mode), m_runConfiguration(runConfiguration), m_outputFormatter(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-13 15:02:37 +02:00
|
|
|
if (runConfiguration) {
|
2010-01-07 18:17:24 +01:00
|
|
|
m_displayName = runConfiguration->displayName();
|
2010-07-13 15:02:37 +02:00
|
|
|
m_outputFormatter = runConfiguration->createOutputFormatter();
|
|
|
|
|
}
|
|
|
|
|
// We need to ensure that there's always a OutputFormatter
|
|
|
|
|
if (!m_outputFormatter)
|
2011-04-15 12:59:44 +02:00
|
|
|
m_outputFormatter = new Utils::OutputFormatter();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
RunControl::~RunControl()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-13 15:02:37 +02:00
|
|
|
delete m_outputFormatter;
|
|
|
|
|
}
|
2009-10-08 18:37:18 +02:00
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
Utils::OutputFormatter *RunControl::outputFormatter()
|
2010-07-13 15:02:37 +02:00
|
|
|
{
|
|
|
|
|
return m_outputFormatter;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-10 19:17:24 +01:00
|
|
|
RunMode RunControl::runMode() const
|
2010-04-30 13:19:31 +02:00
|
|
|
{
|
|
|
|
|
return m_runMode;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
QString RunControl::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_displayName;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 09:06:59 +02:00
|
|
|
Abi RunControl::abi() const
|
|
|
|
|
{
|
|
|
|
|
if (const RunConfiguration *rc = m_runConfiguration.data())
|
|
|
|
|
return rc->abi();
|
|
|
|
|
return Abi();
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-31 15:06:07 +02:00
|
|
|
RunConfiguration *RunControl::runConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return m_runConfiguration.data();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
ProcessHandle RunControl::applicationProcessHandle() const
|
|
|
|
|
{
|
|
|
|
|
return m_applicationProcessHandle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::setApplicationProcessHandle(const ProcessHandle &handle)
|
|
|
|
|
{
|
2011-07-06 10:25:18 +02:00
|
|
|
if (m_applicationProcessHandle != handle) {
|
|
|
|
|
m_applicationProcessHandle = handle;
|
|
|
|
|
emit applicationProcessHandleChanged();
|
|
|
|
|
}
|
2011-05-31 09:48:00 +02:00
|
|
|
}
|
|
|
|
|
|
2013-09-10 17:16:10 +02:00
|
|
|
/*!
|
|
|
|
|
Prompts to stop. If \a optionalPrompt is passed, a \gui {Do not ask again}
|
|
|
|
|
checkbox is displayed and the result is returned in \a *optionalPrompt.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
bool RunControl::promptToStop(bool *optionalPrompt) const
|
2010-08-20 14:19:25 +02:00
|
|
|
{
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(isRunning(), return true);
|
2010-08-20 14:19:25 +02:00
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
if (optionalPrompt && !*optionalPrompt)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
const QString msg = tr("<html><head/><body><center><i>%1</i> is still running.<center/>"
|
|
|
|
|
"<center>Force it to quit?</center></body></html>").arg(displayName());
|
|
|
|
|
return showPromptToStopDialog(tr("Application Still Running"), msg,
|
|
|
|
|
tr("Force Quit"), tr("Keep Running"),
|
|
|
|
|
optionalPrompt);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
2013-09-10 17:16:10 +02:00
|
|
|
Prompts to terminate the application with the \gui {Do not ask again}
|
|
|
|
|
checkbox.
|
2011-04-14 12:58:14 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-01-17 13:52:14 +01:00
|
|
|
bool RunControl::showPromptToStopDialog(const QString &title,
|
|
|
|
|
const QString &text,
|
|
|
|
|
const QString &stopButtonText,
|
|
|
|
|
const QString &cancelButtonText,
|
|
|
|
|
bool *prompt) const
|
|
|
|
|
{
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(isRunning(), return true);
|
2011-01-17 13:52:14 +01:00
|
|
|
// Show a question message box where user can uncheck this
|
|
|
|
|
// question for this class.
|
2012-01-24 15:36:40 +01:00
|
|
|
Utils::CheckableMessageBox messageBox(Core::ICore::mainWindow());
|
2011-01-17 13:52:14 +01:00
|
|
|
messageBox.setWindowTitle(title);
|
|
|
|
|
messageBox.setText(text);
|
|
|
|
|
messageBox.setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::Cancel);
|
|
|
|
|
if (!stopButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Yes)->setText(stopButtonText);
|
|
|
|
|
if (!cancelButtonText.isEmpty())
|
|
|
|
|
messageBox.button(QDialogButtonBox::Cancel)->setText(cancelButtonText);
|
|
|
|
|
messageBox.setDefaultButton(QDialogButtonBox::Yes);
|
|
|
|
|
if (prompt) {
|
2013-10-31 15:39:49 +01:00
|
|
|
messageBox.setCheckBoxText(Utils::CheckableMessageBox::msgDoNotAskAgain());
|
2011-01-17 13:52:14 +01:00
|
|
|
messageBox.setChecked(false);
|
|
|
|
|
} else {
|
|
|
|
|
messageBox.setCheckBoxVisible(false);
|
|
|
|
|
}
|
|
|
|
|
messageBox.exec();
|
|
|
|
|
const bool close = messageBox.clickedStandardButton() == QDialogButtonBox::Yes;
|
|
|
|
|
if (close && prompt && messageBox.isChecked())
|
|
|
|
|
*prompt = false;
|
|
|
|
|
return close;
|
2010-08-20 14:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RunControl::sameRunConfiguration(const RunControl *other) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-08 18:37:18 +02:00
|
|
|
return other->m_runConfiguration.data() == m_runConfiguration.data();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::bringApplicationToForeground(qint64 pid)
|
|
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
m_internalPid = pid;
|
|
|
|
|
m_foregroundCount = 0;
|
|
|
|
|
bringApplicationToForegroundInternal();
|
2008-12-02 12:21:14 +01:00
|
|
|
#else
|
|
|
|
|
Q_UNUSED(pid)
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunControl::bringApplicationToForegroundInternal()
|
|
|
|
|
{
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
ProcessSerialNumber psn;
|
|
|
|
|
GetProcessForPID(m_internalPid, &psn);
|
|
|
|
|
if (SetFrontProcess(&psn) == procNotFound && m_foregroundCount < 15) {
|
|
|
|
|
// somehow the mac/carbon api says
|
|
|
|
|
// "-600 no eligible process with specified process id"
|
|
|
|
|
// if we call SetFrontProcess too early
|
|
|
|
|
++m_foregroundCount;
|
|
|
|
|
QTimer::singleShot(200, this, SLOT(bringApplicationToForegroundInternal()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2011-01-07 18:57:54 +01:00
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format)
|
2011-01-07 18:57:54 +01:00
|
|
|
{
|
|
|
|
|
emit appendMessage(this, msg, format);
|
|
|
|
|
}
|