2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-09 14:53:06 +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-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
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/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
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** 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-11-01 14:13:41 +01:00
|
|
|
#include <projectexplorer/localenvironmentaspect.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;
|
2014-05-26 22:13:14 +03:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-09 14:53:06 +01:00
|
|
|
|
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";
|
2010-01-19 13:41:02 +01:00
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, Core::Id id, const QString &target,
|
2012-04-24 15:49:09 +02:00
|
|
|
const QString &workingDirectory, const QString &title) :
|
2014-05-26 22:13:14 +03:00
|
|
|
LocalApplicationRunConfiguration(parent, id),
|
2014-05-26 23:42:25 +03:00
|
|
|
m_runMode(ProjectExplorer::ApplicationLauncher::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_enabled(true)
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
addExtraAspect(new LocalEnvironmentAspect(this));
|
2010-01-19 13:41:02 +01:00
|
|
|
ctor();
|
|
|
|
|
}
|
2009-11-26 14:43:27 +01:00
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, CMakeRunConfiguration *source) :
|
|
|
|
|
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),
|
2010-06-09 13:21:08 +02:00
|
|
|
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());
|
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
|
|
|
}
|
|
|
|
|
|
2014-05-26 23:42:25 +03:00
|
|
|
ApplicationLauncher::Mode 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
|
|
|
}
|
|
|
|
|
|
2014-05-26 23:42:25 +03:00
|
|
|
void CMakeRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode)
|
2011-04-27 16:33:21 +02:00
|
|
|
{
|
|
|
|
|
m_runMode = runMode;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
QString CMakeRunConfiguration::workingDirectory() const
|
2010-09-27 15:04:58 +01:00
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
|
2013-01-29 18:00:30 +01:00
|
|
|
QTC_ASSERT(aspect, return QString());
|
|
|
|
|
return QDir::cleanPath(aspect->environment().expandVariables(
|
2014-10-15 14:45:31 +02:00
|
|
|
macroExpander()->expand(baseWorkingDirectory())));
|
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
|
|
|
{
|
2014-10-21 13:19:38 +02:00
|
|
|
return macroExpander()->expandProcessArgs(m_arguments);
|
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
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
QVariantMap map(LocalApplicationRunConfiguration::toMap());
|
2010-01-19 13:41:02 +01:00
|
|
|
|
|
|
|
|
map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory);
|
2014-05-26 23:42:25 +03:00
|
|
|
map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == ApplicationLauncher::Console);
|
2010-01-19 13:41:02 +01:00
|
|
|
map.insert(QLatin1String(TITLE_KEY), m_title);
|
|
|
|
|
map.insert(QLatin1String(ARGUMENTS_KEY), m_arguments);
|
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();
|
2014-05-26 23:42:25 +03:00
|
|
|
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() ? ApplicationLauncher::Console
|
|
|
|
|
: ApplicationLauncher::Gui;
|
2010-01-19 13:41:02 +01:00
|
|
|
m_title = map.value(QLatin1String(TITLE_KEY)).toString();
|
|
|
|
|
m_arguments = map.value(QLatin1String(ARGUMENTS_KEY)).toString();
|
|
|
|
|
|
|
|
|
|
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");
|
2013-10-17 14:52:10 +02:00
|
|
|
QString result = m_title;
|
|
|
|
|
if (!m_enabled) {
|
|
|
|
|
result += QLatin1Char(' ');
|
|
|
|
|
result += tr("(disabled)");
|
|
|
|
|
}
|
|
|
|
|
return result;
|
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
|
|
|
}
|
|
|
|
|
|
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);
|
2014-05-02 12:53:36 +02:00
|
|
|
m_workingDirectoryEdit->setBaseFileName(m_cmakeRunConfiguration->target()->project()->projectDirectory());
|
2010-09-27 15:04:58 +01:00
|
|
|
m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->baseWorkingDirectory());
|
2014-02-07 14:33:53 +01:00
|
|
|
m_workingDirectoryEdit->setHistoryCompleter(QLatin1String("CMake.WorkingDir.History"));
|
2014-05-26 22:13:14 +03:00
|
|
|
EnvironmentAspect *aspect
|
|
|
|
|
= m_cmakeRunConfiguration->extraAspect<EnvironmentAspect>();
|
2013-01-29 18:00:30 +01:00
|
|
|
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();
|
2014-03-13 09:55:53 +01:00
|
|
|
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);
|
2013-09-03 18:48:02 +02:00
|
|
|
vbx->setMargin(0);
|
2009-10-01 19:04:53 +02:00
|
|
|
vbx->addWidget(m_detailsContainer);
|
2009-07-20 16:50:05 +02:00
|
|
|
|
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)));
|
|
|
|
|
|
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)));
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2014-05-26 23:42:25 +03:00
|
|
|
m_cmakeRunConfiguration->setRunMode(toggled ? ApplicationLauncher::Console
|
|
|
|
|
: ApplicationLauncher::Gui);
|
2011-04-27 16:33:21 +02:00
|
|
|
}
|
|
|
|
|
|
2013-01-29 18:00:30 +01:00
|
|
|
void CMakeRunConfigurationWidget::environmentWasChanged()
|
|
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
EnvironmentAspect *aspect = m_cmakeRunConfiguration->extraAspect<EnvironmentAspect>();
|
2013-01-29 18:00:30 +01:00
|
|
|
QTC_ASSERT(aspect, return);
|
|
|
|
|
m_workingDirectoryEdit->setEnvironment(aspect->environment());
|
|
|
|
|
}
|
2009-05-27 17:28:50 +02:00
|
|
|
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) :
|
2014-05-26 22:13:14 +03:00
|
|
|
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
|
2014-06-12 16:24:52 +02:00
|
|
|
QList<Core::Id> CMakeRunConfigurationFactory::availableCreationIds(Target *parent, CreationMode mode) const
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2014-06-12 16:24:52 +02:00
|
|
|
Q_UNUSED(mode)
|
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
|
2014-07-01 11:08:26 +02:00
|
|
|
QString CMakeRunConfigurationFactory::displayNameForId(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
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool CMakeRunConfigurationFactory::canHandle(Target *parent) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
bool CMakeRunConfigurationFactory::canCreate(Target *parent, 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
|
|
|
}
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
RunConfiguration *CMakeRunConfigurationFactory::doCreate(Target *parent, 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
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool CMakeRunConfigurationFactory::canClone(Target *parent, 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
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
RunConfiguration *CMakeRunConfigurationFactory::clone(Target *parent, 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
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
bool CMakeRunConfigurationFactory::canRestore(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;
|
2014-05-26 22:13:14 +03:00
|
|
|
return idFromMap(map).name().startsWith(CMAKE_RC_PREFIX);
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
RunConfiguration *CMakeRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2014-05-26 22:13:14 +03:00
|
|
|
return new CMakeRunConfiguration(parent, 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
|
|
|
}
|