2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-09 14:53:06 +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-09 14:53:06 +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-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
#include "cmakerunconfiguration.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
#include "cmakebuildconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "cmakeproject.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
#include "cmakeprojectconstants.h"
|
2008-12-09 14:53:06 +01:00
|
|
|
|
2010-07-30 22:16:59 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2011-02-24 14:58:37 +01:00
|
|
|
#include <coreplugin/helpmanager.h>
|
2013-04-09 12:05:15 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2013-01-29 18:00:30 +01:00
|
|
|
#include <projectexplorer/environmentaspect.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
#include <projectexplorer/environmentwidget.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/detailswidget.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2011-08-18 13:46:52 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
#include <utils/stringutils.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QCheckBox>
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
using namespace CMakeProjectManager;
|
|
|
|
|
using namespace CMakeProjectManager::Internal;
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
namespace {
|
2011-11-02 16:45:13 +01:00
|
|
|
const char CMAKE_RC_PREFIX[] = "CMakeProjectManager.CMakeRunConfiguration.";
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2011-11-02 16:45:13 +01:00
|
|
|
const char USER_WORKING_DIRECTORY_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory";
|
|
|
|
|
const char USE_TERMINAL_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UseTerminal";
|
|
|
|
|
const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title";
|
|
|
|
|
const char ARGUMENTS_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.Arguments";
|
|
|
|
|
const char USER_ENVIRONMENT_CHANGES_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UserEnvironmentChanges";
|
|
|
|
|
const char BASE_ENVIRONMENT_BASE_KEY[] = "CMakeProjectManager.BaseEnvironmentBase";
|
2010-01-19 13:41:02 +01:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
CMakeRunConfiguration::CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target,
|
|
|
|
|
const QString &workingDirectory, const QString &title) :
|
|
|
|
|
ProjectExplorer::LocalApplicationRunConfiguration(parent, id),
|
2010-01-19 13:41:02 +01:00
|
|
|
m_runMode(Gui),
|
2010-02-02 12:01:11 +01:00
|
|
|
m_buildTarget(target),
|
2010-01-19 13:41:02 +01:00
|
|
|
m_workingDirectory(workingDirectory),
|
|
|
|
|
m_title(title),
|
2010-06-09 13:21:08 +02:00
|
|
|
m_baseEnvironmentBase(CMakeRunConfiguration::BuildEnvironmentBase),
|
|
|
|
|
m_enabled(true)
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
ctor();
|
|
|
|
|
}
|
2009-11-26 14:43:27 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
CMakeRunConfiguration::CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source) :
|
2010-02-08 15:50:06 +01:00
|
|
|
ProjectExplorer::LocalApplicationRunConfiguration(parent, source),
|
2010-01-19 13:41:02 +01:00
|
|
|
m_runMode(source->m_runMode),
|
2010-02-02 12:01:11 +01:00
|
|
|
m_buildTarget(source->m_buildTarget),
|
2010-01-19 13:41:02 +01:00
|
|
|
m_workingDirectory(source->m_workingDirectory),
|
|
|
|
|
m_userWorkingDirectory(source->m_userWorkingDirectory),
|
|
|
|
|
m_title(source->m_title),
|
|
|
|
|
m_arguments(source->m_arguments),
|
|
|
|
|
m_userEnvironmentChanges(source->m_userEnvironmentChanges),
|
2010-06-09 13:21:08 +02:00
|
|
|
m_baseEnvironmentBase(source->m_baseEnvironmentBase),
|
|
|
|
|
m_enabled(source->m_enabled)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
|
|
|
|
ctor();
|
2009-11-26 14:43:27 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
CMakeRunConfiguration::~CMakeRunConfiguration()
|
2009-11-26 14:43:27 +01:00
|
|
|
{
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
void CMakeRunConfiguration::ctor()
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2010-08-19 12:26:21 +02:00
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
2013-01-09 12:42:59 +01:00
|
|
|
connect(target(), SIGNAL(environmentChanged()),
|
|
|
|
|
this, SIGNAL(baseEnvironmentChanged()));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
QString CMakeRunConfiguration::executable() const
|
|
|
|
|
{
|
2010-02-02 12:01:11 +01:00
|
|
|
return m_buildTarget;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
ProjectExplorer::LocalApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2009-02-18 17:04:04 +01:00
|
|
|
return m_runMode;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-27 16:33:21 +02:00
|
|
|
void CMakeRunConfiguration::setRunMode(RunMode runMode)
|
|
|
|
|
{
|
|
|
|
|
m_runMode = runMode;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
QString CMakeRunConfiguration::workingDirectory() const
|
2010-09-27 15:04:58 +01:00
|
|
|
{
|
2013-01-29 18:00:30 +01:00
|
|
|
ProjectExplorer::EnvironmentAspect *aspect = extraAspect<ProjectExplorer::EnvironmentAspect>();
|
|
|
|
|
QTC_ASSERT(aspect, return QString());
|
|
|
|
|
return QDir::cleanPath(aspect->environment().expandVariables(
|
|
|
|
|
Utils::expandMacros(baseWorkingDirectory(), macroExpander())));
|
2010-09-27 15:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CMakeRunConfiguration::baseWorkingDirectory() const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2009-06-16 18:37:16 +02:00
|
|
|
if (!m_userWorkingDirectory.isEmpty())
|
|
|
|
|
return m_userWorkingDirectory;
|
2008-12-09 14:53:06 +01:00
|
|
|
return m_workingDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-19 11:14:03 +02:00
|
|
|
QString CMakeRunConfiguration::commandLineArguments() const
|
2010-09-27 15:04:58 +01:00
|
|
|
{
|
2010-11-12 17:23:55 +01:00
|
|
|
return Utils::QtcProcess::expandMacros(m_arguments, macroExpander());
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-16 17:33:05 +01:00
|
|
|
QString CMakeRunConfiguration::title() const
|
|
|
|
|
{
|
|
|
|
|
return m_title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfiguration::setExecutable(const QString &executable)
|
|
|
|
|
{
|
2010-02-02 12:01:11 +01:00
|
|
|
m_buildTarget = executable;
|
2009-03-16 17:33:05 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-27 15:11:26 +01:00
|
|
|
void CMakeRunConfiguration::setBaseWorkingDirectory(const QString &wd)
|
2009-03-16 17:33:05 +01:00
|
|
|
{
|
2010-09-27 15:04:58 +01:00
|
|
|
const QString &oldWorkingDirectory = workingDirectory();
|
2009-06-16 18:37:16 +02:00
|
|
|
|
|
|
|
|
m_workingDirectory = wd;
|
|
|
|
|
|
|
|
|
|
const QString &newWorkingDirectory = workingDirectory();
|
|
|
|
|
if (oldWorkingDirectory != newWorkingDirectory)
|
2010-09-27 15:11:26 +01:00
|
|
|
emit baseWorkingDirectoryChanged(newWorkingDirectory);
|
2009-06-16 18:37:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfiguration::setUserWorkingDirectory(const QString &wd)
|
|
|
|
|
{
|
|
|
|
|
const QString & oldWorkingDirectory = workingDirectory();
|
|
|
|
|
|
|
|
|
|
m_userWorkingDirectory = wd;
|
|
|
|
|
|
|
|
|
|
const QString &newWorkingDirectory = workingDirectory();
|
|
|
|
|
if (oldWorkingDirectory != newWorkingDirectory)
|
2010-09-27 15:11:26 +01:00
|
|
|
emit baseWorkingDirectoryChanged(newWorkingDirectory);
|
2009-03-16 17:33:05 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
QVariantMap CMakeRunConfiguration::toMap() const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
QVariantMap map(ProjectExplorer::LocalApplicationRunConfiguration::toMap());
|
|
|
|
|
|
|
|
|
|
map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory);
|
|
|
|
|
map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == Console);
|
|
|
|
|
map.insert(QLatin1String(TITLE_KEY), m_title);
|
|
|
|
|
map.insert(QLatin1String(ARGUMENTS_KEY), m_arguments);
|
2010-09-23 10:35:23 +02:00
|
|
|
map.insert(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY), Utils::EnvironmentItem::toStringList(m_userEnvironmentChanges));
|
2010-01-19 13:41:02 +01:00
|
|
|
map.insert(QLatin1String(BASE_ENVIRONMENT_BASE_KEY), m_baseEnvironmentBase);
|
2009-06-16 18:37:16 +02:00
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
return map;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
bool CMakeRunConfiguration::fromMap(const QVariantMap &map)
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
m_userWorkingDirectory = map.value(QLatin1String(USER_WORKING_DIRECTORY_KEY)).toString();
|
|
|
|
|
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() ? Console : Gui;
|
|
|
|
|
m_title = map.value(QLatin1String(TITLE_KEY)).toString();
|
|
|
|
|
m_arguments = map.value(QLatin1String(ARGUMENTS_KEY)).toString();
|
2010-09-23 10:35:23 +02:00
|
|
|
m_userEnvironmentChanges = Utils::EnvironmentItem::fromStringList(map.value(QLatin1String(USER_ENVIRONMENT_CHANGES_KEY)).toStringList());
|
2010-01-19 13:41:02 +01:00
|
|
|
m_baseEnvironmentBase = static_cast<BaseEnvironmentBase>(map.value(QLatin1String(BASE_ENVIRONMENT_BASE_KEY), static_cast<int>(CMakeRunConfiguration::BuildEnvironmentBase)).toInt());
|
|
|
|
|
|
|
|
|
|
return RunConfiguration::fromMap(map);
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-19 12:26:21 +02:00
|
|
|
QString CMakeRunConfiguration::defaultDisplayName() const
|
|
|
|
|
{
|
|
|
|
|
if (m_title.isEmpty())
|
2012-10-19 17:07:26 +02:00
|
|
|
return tr("Run CMake kit");
|
2012-11-21 23:54:06 +02:00
|
|
|
return m_title + (m_enabled ? QString() : tr(" (disabled)"));
|
2010-08-19 12:26:21 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
QWidget *CMakeRunConfiguration::createConfigurationWidget()
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2009-05-27 17:28:50 +02:00
|
|
|
return new CMakeRunConfigurationWidget(this);
|
2009-03-25 18:29:42 +01:00
|
|
|
}
|
|
|
|
|
|
2010-09-27 15:11:26 +01:00
|
|
|
void CMakeRunConfiguration::setCommandLineArguments(const QString &newText)
|
2009-03-25 18:29:42 +01:00
|
|
|
{
|
|
|
|
|
m_arguments = newText;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2009-03-25 15:18:37 +01:00
|
|
|
QString CMakeRunConfiguration::dumperLibrary() const
|
|
|
|
|
{
|
2013-04-09 12:05:15 +02:00
|
|
|
return QtSupport::QtKitInformation::dumperLibrary(target()->kit());
|
2009-03-25 15:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-15 17:41:45 +02:00
|
|
|
QStringList CMakeRunConfiguration::dumperLibraryLocations() const
|
|
|
|
|
{
|
2013-04-09 12:05:15 +02:00
|
|
|
return QtSupport::QtKitInformation::dumperLibraryLocations(target()->kit());
|
2009-07-15 17:41:45 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment CMakeRunConfiguration::baseEnvironment() const
|
2009-05-27 17:28:50 +02:00
|
|
|
{
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment env;
|
2009-05-28 18:52:06 +02:00
|
|
|
if (m_baseEnvironmentBase == CMakeRunConfiguration::CleanEnvironmentBase) {
|
|
|
|
|
// Nothing
|
|
|
|
|
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::SystemEnvironmentBase) {
|
2010-09-23 10:35:23 +02:00
|
|
|
env = Utils::Environment::systemEnvironment();
|
2009-05-28 18:52:06 +02:00
|
|
|
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::BuildEnvironmentBase) {
|
2010-02-08 15:50:06 +01:00
|
|
|
env = activeBuildConfiguration()->environment();
|
2009-05-28 18:52:06 +02:00
|
|
|
}
|
2009-05-27 17:28:50 +02:00
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-14 13:40:17 +01:00
|
|
|
QString CMakeRunConfiguration::baseEnvironmentText() const
|
|
|
|
|
{
|
|
|
|
|
if (m_baseEnvironmentBase == CMakeRunConfiguration::CleanEnvironmentBase) {
|
|
|
|
|
return tr("Clean Environment");
|
|
|
|
|
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::SystemEnvironmentBase) {
|
|
|
|
|
return tr("System Environment");
|
|
|
|
|
} else if (m_baseEnvironmentBase == CMakeRunConfiguration::BuildEnvironmentBase) {
|
|
|
|
|
return tr("Build Environment");
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 18:52:06 +02:00
|
|
|
void CMakeRunConfiguration::setBaseEnvironmentBase(BaseEnvironmentBase env)
|
|
|
|
|
{
|
|
|
|
|
if (m_baseEnvironmentBase == env)
|
|
|
|
|
return;
|
|
|
|
|
m_baseEnvironmentBase = env;
|
|
|
|
|
emit baseEnvironmentChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CMakeRunConfiguration::BaseEnvironmentBase CMakeRunConfiguration::baseEnvironmentBase() const
|
|
|
|
|
{
|
|
|
|
|
return m_baseEnvironmentBase;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment CMakeRunConfiguration::environment() const
|
2009-05-27 17:28:50 +02:00
|
|
|
{
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment env = baseEnvironment();
|
2009-05-27 17:28:50 +02:00
|
|
|
env.modify(userEnvironmentChanges());
|
|
|
|
|
return env;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
QList<Utils::EnvironmentItem> CMakeRunConfiguration::userEnvironmentChanges() const
|
2009-05-27 17:28:50 +02:00
|
|
|
{
|
|
|
|
|
return m_userEnvironmentChanges;
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
void CMakeRunConfiguration::setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff)
|
2009-05-27 17:28:50 +02:00
|
|
|
{
|
|
|
|
|
if (m_userEnvironmentChanges != diff) {
|
|
|
|
|
m_userEnvironmentChanges = diff;
|
|
|
|
|
emit userEnvironmentChangesChanged(diff);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 13:21:08 +02:00
|
|
|
void CMakeRunConfiguration::setEnabled(bool b)
|
|
|
|
|
{
|
|
|
|
|
if (m_enabled == b)
|
|
|
|
|
return;
|
|
|
|
|
m_enabled = b;
|
2012-03-29 13:11:00 +02:00
|
|
|
emit enabledChanged();
|
2010-08-19 12:26:21 +02:00
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
2010-06-09 13:21:08 +02:00
|
|
|
}
|
2009-05-27 17:28:50 +02:00
|
|
|
|
2011-05-26 15:33:24 +02:00
|
|
|
bool CMakeRunConfiguration::isEnabled() const
|
2010-06-09 13:21:08 +02:00
|
|
|
{
|
2011-05-26 15:33:24 +02:00
|
|
|
return m_enabled;
|
2010-06-09 13:21:08 +02:00
|
|
|
}
|
2009-05-27 17:28:50 +02:00
|
|
|
|
2011-05-26 16:30:35 +02:00
|
|
|
QString CMakeRunConfiguration::disabledReason() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_enabled)
|
2012-01-31 11:03:22 +01:00
|
|
|
return tr("The executable is not built by the current build configuration");
|
2011-05-26 16:30:35 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 13:21:08 +02:00
|
|
|
// Configuration widget
|
2009-05-27 17:28:50 +02:00
|
|
|
CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent)
|
2009-05-28 18:52:06 +02:00
|
|
|
: QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration)
|
2009-05-27 17:28:50 +02:00
|
|
|
{
|
|
|
|
|
QFormLayout *fl = new QFormLayout();
|
2009-07-23 17:00:38 +02:00
|
|
|
fl->setMargin(0);
|
|
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
2009-05-27 17:28:50 +02:00
|
|
|
QLineEdit *argumentsLineEdit = new QLineEdit();
|
2010-10-19 11:14:03 +02:00
|
|
|
argumentsLineEdit->setText(cmakeRunConfiguration->commandLineArguments());
|
2009-05-27 17:28:50 +02:00
|
|
|
connect(argumentsLineEdit, SIGNAL(textChanged(QString)),
|
|
|
|
|
this, SLOT(setArguments(QString)));
|
|
|
|
|
fl->addRow(tr("Arguments:"), argumentsLineEdit);
|
|
|
|
|
|
2009-10-05 11:06:05 +02:00
|
|
|
m_workingDirectoryEdit = new Utils::PathChooser();
|
2011-03-08 18:26:15 +01:00
|
|
|
m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory);
|
2010-09-17 14:58:07 +02:00
|
|
|
m_workingDirectoryEdit->setBaseDirectory(m_cmakeRunConfiguration->target()->project()->projectDirectory());
|
2010-09-27 15:04:58 +01:00
|
|
|
m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->baseWorkingDirectory());
|
2013-01-29 18:00:30 +01:00
|
|
|
ProjectExplorer::EnvironmentAspect *aspect
|
|
|
|
|
= m_cmakeRunConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
|
|
|
|
|
if (aspect) {
|
|
|
|
|
connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged()));
|
|
|
|
|
environmentWasChanged();
|
|
|
|
|
}
|
2010-05-14 15:45:43 +02:00
|
|
|
m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory"));
|
2009-06-16 18:37:16 +02:00
|
|
|
|
|
|
|
|
QToolButton *resetButton = new QToolButton();
|
|
|
|
|
resetButton->setToolTip(tr("Reset to default"));
|
2010-07-30 22:16:59 +02:00
|
|
|
resetButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RESET)));
|
2009-06-16 18:37:16 +02:00
|
|
|
|
|
|
|
|
QHBoxLayout *boxlayout = new QHBoxLayout();
|
|
|
|
|
boxlayout->addWidget(m_workingDirectoryEdit);
|
|
|
|
|
boxlayout->addWidget(resetButton);
|
|
|
|
|
|
2010-09-14 14:51:50 +02:00
|
|
|
fl->addRow(tr("Working directory:"), boxlayout);
|
2009-06-16 18:37:16 +02:00
|
|
|
|
2011-04-27 16:33:21 +02:00
|
|
|
QCheckBox *runInTerminal = new QCheckBox;
|
|
|
|
|
fl->addRow(tr("Run in Terminal"), runInTerminal);
|
|
|
|
|
|
2009-10-01 19:04:53 +02:00
|
|
|
m_detailsContainer = new Utils::DetailsWidget(this);
|
2010-02-01 17:22:05 +01:00
|
|
|
m_detailsContainer->setState(Utils::DetailsWidget::NoSummary);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-10-01 19:04:53 +02:00
|
|
|
QWidget *m_details = new QWidget(m_detailsContainer);
|
|
|
|
|
m_detailsContainer->setWidget(m_details);
|
|
|
|
|
m_details->setLayout(fl);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2009-07-20 16:50:05 +02:00
|
|
|
QVBoxLayout *vbx = new QVBoxLayout(this);
|
2009-10-01 19:04:53 +02:00
|
|
|
vbx->setMargin(0);;
|
|
|
|
|
vbx->addWidget(m_detailsContainer);
|
2009-07-20 16:50:05 +02:00
|
|
|
|
|
|
|
|
QLabel *environmentLabel = new QLabel(this);
|
|
|
|
|
environmentLabel->setText(tr("Run Environment"));
|
|
|
|
|
QFont f = environmentLabel->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() *1.2);
|
|
|
|
|
environmentLabel->setFont(f);
|
|
|
|
|
vbx->addWidget(environmentLabel);
|
2009-05-28 18:52:06 +02:00
|
|
|
|
2009-07-23 15:57:45 +02:00
|
|
|
QWidget *baseEnvironmentWidget = new QWidget;
|
|
|
|
|
QHBoxLayout *baseEnvironmentLayout = new QHBoxLayout(baseEnvironmentWidget);
|
|
|
|
|
baseEnvironmentLayout->setMargin(0);
|
2009-05-28 18:52:06 +02:00
|
|
|
QLabel *label = new QLabel(tr("Base environment for this runconfiguration:"), this);
|
2009-07-23 15:57:45 +02:00
|
|
|
baseEnvironmentLayout->addWidget(label);
|
2009-07-20 16:50:05 +02:00
|
|
|
m_baseEnvironmentComboBox = new QComboBox(this);
|
2009-07-20 15:46:11 +02:00
|
|
|
m_baseEnvironmentComboBox->addItems(QStringList()
|
|
|
|
|
<< tr("Clean Environment")
|
|
|
|
|
<< tr("System Environment")
|
|
|
|
|
<< tr("Build Environment"));
|
|
|
|
|
m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase());
|
|
|
|
|
connect(m_baseEnvironmentComboBox, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(baseEnvironmentComboBoxChanged(int)));
|
2009-07-23 15:57:45 +02:00
|
|
|
baseEnvironmentLayout->addWidget(m_baseEnvironmentComboBox);
|
|
|
|
|
baseEnvironmentLayout->addStretch(10);
|
2009-05-28 18:52:06 +02:00
|
|
|
|
2009-09-17 13:59:10 +02:00
|
|
|
m_environmentWidget = new ProjectExplorer::EnvironmentWidget(this, baseEnvironmentWidget);
|
|
|
|
|
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
|
2009-12-14 13:40:17 +01:00
|
|
|
m_environmentWidget->setBaseEnvironmentText(m_cmakeRunConfiguration->baseEnvironmentText());
|
2009-09-17 13:59:10 +02:00
|
|
|
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
|
|
|
|
|
|
|
|
|
|
vbx->addWidget(m_environmentWidget);
|
|
|
|
|
|
2009-06-19 17:55:47 +02:00
|
|
|
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
|
2009-06-16 18:37:16 +02:00
|
|
|
this, SLOT(setWorkingDirectory()));
|
|
|
|
|
|
|
|
|
|
connect(resetButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(resetWorkingDirectory()));
|
|
|
|
|
|
2011-04-27 16:33:21 +02:00
|
|
|
connect(runInTerminal, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(runInTerminalToggled(bool)));
|
|
|
|
|
|
2009-12-03 19:45:09 +01:00
|
|
|
connect(m_environmentWidget, SIGNAL(userChangesChanged()),
|
|
|
|
|
this, SLOT(userChangesChanged()));
|
2009-05-27 17:28:50 +02:00
|
|
|
|
2010-09-27 18:09:54 +01:00
|
|
|
connect(m_cmakeRunConfiguration, SIGNAL(baseWorkingDirectoryChanged(QString)),
|
2009-06-16 18:37:16 +02:00
|
|
|
this, SLOT(workingDirectoryChanged(QString)));
|
2009-05-27 17:28:50 +02:00
|
|
|
connect(m_cmakeRunConfiguration, SIGNAL(baseEnvironmentChanged()),
|
|
|
|
|
this, SLOT(baseEnvironmentChanged()));
|
2010-09-23 10:35:23 +02:00
|
|
|
connect(m_cmakeRunConfiguration, SIGNAL(userEnvironmentChangesChanged(QList<Utils::EnvironmentItem>)),
|
2009-05-27 17:28:50 +02:00
|
|
|
this, SLOT(userEnvironmentChangesChanged()));
|
2009-06-16 18:37:16 +02:00
|
|
|
|
2010-10-29 13:40:30 +02:00
|
|
|
setEnabled(m_cmakeRunConfiguration->isEnabled());
|
2009-06-16 18:37:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::setWorkingDirectory()
|
|
|
|
|
{
|
|
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
m_ignoreChange = true;
|
2010-09-24 12:39:25 +02:00
|
|
|
m_cmakeRunConfiguration->setUserWorkingDirectory(m_workingDirectoryEdit->rawPath());
|
2009-06-16 18:37:16 +02:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::workingDirectoryChanged(const QString &workingDirectory)
|
|
|
|
|
{
|
2012-12-14 13:18:59 +01:00
|
|
|
if (!m_ignoreChange) {
|
|
|
|
|
m_ignoreChange = true;
|
2009-06-16 18:37:16 +02:00
|
|
|
m_workingDirectoryEdit->setPath(workingDirectory);
|
2012-12-14 13:18:59 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
2009-06-16 18:37:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::resetWorkingDirectory()
|
|
|
|
|
{
|
|
|
|
|
// This emits a signal connected to workingDirectoryChanged()
|
|
|
|
|
// that sets the m_workingDirectoryEdit
|
2010-09-24 12:39:25 +02:00
|
|
|
m_cmakeRunConfiguration->setUserWorkingDirectory(QString());
|
2009-05-27 17:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-27 16:33:21 +02:00
|
|
|
void CMakeRunConfigurationWidget::runInTerminalToggled(bool toggled)
|
|
|
|
|
{
|
|
|
|
|
m_cmakeRunConfiguration->setRunMode(toggled ? ProjectExplorer::LocalApplicationRunConfiguration::Console
|
|
|
|
|
: ProjectExplorer::LocalApplicationRunConfiguration::Gui);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-29 18:00:30 +01:00
|
|
|
void CMakeRunConfigurationWidget::environmentWasChanged()
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::EnvironmentAspect *aspect
|
|
|
|
|
= m_cmakeRunConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
|
|
|
|
|
QTC_ASSERT(aspect, return);
|
|
|
|
|
m_workingDirectoryEdit->setEnvironment(aspect->environment());
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-03 19:45:09 +01:00
|
|
|
void CMakeRunConfigurationWidget::userChangesChanged()
|
2009-05-27 17:28:50 +02:00
|
|
|
{
|
|
|
|
|
m_cmakeRunConfiguration->setUserEnvironmentChanges(m_environmentWidget->userChanges());
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-20 15:46:11 +02:00
|
|
|
void CMakeRunConfigurationWidget::baseEnvironmentComboBoxChanged(int index)
|
2009-05-28 18:52:06 +02:00
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2009-07-20 15:46:11 +02:00
|
|
|
m_cmakeRunConfiguration->setBaseEnvironmentBase(CMakeRunConfiguration::BaseEnvironmentBase(index));
|
2009-05-28 18:52:06 +02:00
|
|
|
|
|
|
|
|
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
|
2009-12-14 13:40:17 +01:00
|
|
|
m_environmentWidget->setBaseEnvironmentText(m_cmakeRunConfiguration->baseEnvironmentText());
|
2009-05-28 18:52:06 +02:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-27 17:28:50 +02:00
|
|
|
void CMakeRunConfigurationWidget::baseEnvironmentChanged()
|
|
|
|
|
{
|
2009-05-28 18:52:06 +02:00
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-07-20 15:46:11 +02:00
|
|
|
m_baseEnvironmentComboBox->setCurrentIndex(m_cmakeRunConfiguration->baseEnvironmentBase());
|
2009-05-27 17:28:50 +02:00
|
|
|
m_environmentWidget->setBaseEnvironment(m_cmakeRunConfiguration->baseEnvironment());
|
2009-12-14 13:40:17 +01:00
|
|
|
m_environmentWidget->setBaseEnvironmentText(m_cmakeRunConfiguration->baseEnvironmentText());
|
2009-05-27 17:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::userEnvironmentChangesChanged()
|
|
|
|
|
{
|
|
|
|
|
m_environmentWidget->setUserChanges(m_cmakeRunConfiguration->userEnvironmentChanges());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeRunConfigurationWidget::setArguments(const QString &args)
|
|
|
|
|
{
|
2010-09-27 15:11:26 +01:00
|
|
|
m_cmakeRunConfiguration->setCommandLineArguments(args);
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
// Factory
|
2010-01-19 13:41:02 +01:00
|
|
|
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) :
|
|
|
|
|
ProjectExplorer::IRunConfigurationFactory(parent)
|
2012-04-24 15:49:09 +02:00
|
|
|
{ setObjectName(QLatin1String("CMakeRunConfigurationFactory")); }
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
CMakeRunConfigurationFactory::~CMakeRunConfigurationFactory()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
// used to show the list of possible additons to a project, returns a list of ids
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> CMakeRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2012-03-15 17:17:40 +01:00
|
|
|
return QList<Core::Id>();
|
2012-07-04 12:20:13 +02:00
|
|
|
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> allIds;
|
2013-02-16 14:18:39 +01:00
|
|
|
foreach (const QString &buildTarget, project->buildTargetTitles(true))
|
2010-02-02 12:01:11 +01:00
|
|
|
allIds << idFromBuildTarget(buildTarget);
|
2010-01-19 13:41:02 +01:00
|
|
|
return allIds;
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
// used to translate the ids to names to display to the user
|
2012-03-15 17:17:40 +01:00
|
|
|
QString CMakeRunConfigurationFactory::displayNameForId(const Core::Id id) const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2010-02-02 12:01:11 +01:00
|
|
|
return buildTargetFromId(id);
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
2008-12-09 14:53:06 +01:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
bool CMakeRunConfigurationFactory::canHandle(ProjectExplorer::Target *parent) const
|
|
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!parent->project()->supportsKit(parent->kit()))
|
2012-04-24 15:49:09 +02:00
|
|
|
return false;
|
|
|
|
|
return qobject_cast<CMakeProject *>(parent->project());
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-15 17:17:40 +01:00
|
|
|
bool CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2010-01-19 13:41:02 +01:00
|
|
|
return false;
|
2012-04-24 15:49:09 +02:00
|
|
|
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
|
|
|
|
return project->hasBuildTarget(buildTargetFromId(id));
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-26 16:39:41 +01:00
|
|
|
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent,
|
|
|
|
|
const Core::Id id)
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
|
2010-02-02 12:01:11 +01:00
|
|
|
const QString title(buildTargetFromId(id));
|
2012-04-24 15:49:09 +02:00
|
|
|
const CMakeBuildTarget &ct = project->buildTargetForTitle(title);
|
|
|
|
|
return new CMakeRunConfiguration(parent, id, ct.executable, ct.workingDirectory, ct.title);
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool CMakeRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2010-01-19 13:41:02 +01:00
|
|
|
return false;
|
2013-03-21 16:22:27 +01:00
|
|
|
return source->id().name().startsWith(CMAKE_RC_PREFIX);
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration * source)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
|
|
|
|
CMakeRunConfiguration *crc(static_cast<CMakeRunConfiguration *>(source));
|
2012-04-24 15:49:09 +02:00
|
|
|
return new CMakeRunConfiguration(parent, crc);
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool CMakeRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!qobject_cast<CMakeProject *>(parent->project()))
|
2010-01-19 13:41:02 +01:00
|
|
|
return false;
|
2013-03-21 16:22:27 +01:00
|
|
|
return ProjectExplorer::idFromMap(map).name().startsWith(CMAKE_RC_PREFIX);
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-28 14:53:12 +01:00
|
|
|
ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent,
|
|
|
|
|
const QVariantMap &map)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2013-03-28 14:53:12 +01:00
|
|
|
return new CMakeRunConfiguration(parent, ProjectExplorer::idFromMap(map),
|
|
|
|
|
QString(), QString(), QString());
|
2008-12-09 14:53:06 +01:00
|
|
|
}
|
2012-07-17 15:56:43 +02:00
|
|
|
|
|
|
|
|
QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id)
|
|
|
|
|
{
|
2013-03-21 16:22:27 +01:00
|
|
|
return id.suffixAfter(CMAKE_RC_PREFIX);
|
2012-07-17 15:56:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::Id CMakeRunConfigurationFactory::idFromBuildTarget(const QString &target)
|
|
|
|
|
{
|
2013-03-21 16:22:27 +01:00
|
|
|
return Core::Id(CMAKE_RC_PREFIX).withSuffix(target);
|
2012-07-17 15:56:43 +02:00
|
|
|
}
|