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
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
#include "desktopqmakerunconfiguration.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2013-10-16 12:10:22 +02:00
|
|
|
#include "qmakenodes.h"
|
|
|
|
|
#include "qmakeproject.h"
|
|
|
|
|
#include "qmakebuildconfiguration.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-07-30 22:16:59 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2013-01-29 18:00:30 +01:00
|
|
|
#include <projectexplorer/localenvironmentaspect.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2013-10-29 17:48:43 +01:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2011-05-20 21:40:53 +02:00
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2013-10-29 17:48:43 +01:00
|
|
|
#include <utils/detailswidget.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2013-10-29 17:48:43 +01:00
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
#include <utils/persistentsettings.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
#include <utils/stringutils.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QToolButton>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
namespace QmakeProjectManager {
|
|
|
|
|
namespace Internal {
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2013-10-29 16:08:37 +01:00
|
|
|
const char QMAKE_RC_PREFIX[] = "Qt4ProjectManager.Qt4RunConfiguration:";
|
2013-03-21 16:23:17 +01:00
|
|
|
const char COMMAND_LINE_ARGUMENTS_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments";
|
|
|
|
|
const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile";
|
|
|
|
|
const char USE_TERMINAL_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UseTerminal";
|
|
|
|
|
const char USE_DYLD_IMAGE_SUFFIX_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix";
|
|
|
|
|
const char USER_WORKING_DIRECTORY_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory";
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
static QString pathFromId(Core::Id id)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-10-29 16:08:37 +01:00
|
|
|
return id.suffixAfter(QMAKE_RC_PREFIX);
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
2009-03-19 15:04:43 +01:00
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
//
|
2013-10-29 17:48:43 +01:00
|
|
|
// QmakeRunConfiguration
|
2010-01-19 13:41:02 +01:00
|
|
|
//
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Core::Id id) :
|
2012-04-24 15:49:09 +02:00
|
|
|
LocalApplicationRunConfiguration(parent, id),
|
|
|
|
|
m_proFilePath(pathFromId(id)),
|
2014-05-26 23:42:25 +03:00
|
|
|
m_runMode(ApplicationLauncher::Gui),
|
2013-01-29 18:01:47 +01:00
|
|
|
m_isUsingDyldImageSuffix(false)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2013-11-01 14:13:41 +01:00
|
|
|
addExtraAspect(new ProjectExplorer::LocalEnvironmentAspect(this));
|
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
2012-04-24 15:49:09 +02:00
|
|
|
m_parseSuccess = project->validParse(m_proFilePath);
|
|
|
|
|
m_parseInProgress = project->parseInProgress(m_proFilePath);
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
ctor();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, DesktopQmakeRunConfiguration *source) :
|
2010-01-19 13:41:02 +01:00
|
|
|
LocalApplicationRunConfiguration(parent, source),
|
|
|
|
|
m_commandLineArguments(source->m_commandLineArguments),
|
|
|
|
|
m_proFilePath(source->m_proFilePath),
|
|
|
|
|
m_runMode(source->m_runMode),
|
2014-01-16 12:05:05 +01:00
|
|
|
m_forcedGuiMode(source->m_forcedGuiMode),
|
2010-01-19 13:41:02 +01:00
|
|
|
m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix),
|
|
|
|
|
m_userWorkingDirectory(source->m_userWorkingDirectory),
|
2011-06-10 15:37:10 +02:00
|
|
|
m_parseSuccess(source->m_parseSuccess),
|
|
|
|
|
m_parseInProgress(source->m_parseInProgress)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
ctor();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfiguration::~DesktopQmakeRunConfiguration()
|
2009-11-26 14:43:27 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfiguration::isEnabled() const
|
2009-06-12 12:58:02 +02:00
|
|
|
{
|
2011-06-10 15:37:10 +02:00
|
|
|
return m_parseSuccess && !m_parseInProgress;
|
2009-06-12 12:58:02 +02:00
|
|
|
}
|
2009-01-27 18:23:02 +01:00
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::disabledReason() const
|
2011-05-26 16:30:35 +02:00
|
|
|
{
|
2011-06-10 15:37:10 +02:00
|
|
|
if (m_parseInProgress)
|
2014-04-17 14:09:47 +02:00
|
|
|
return tr("The .pro file \"%1\" is currently being parsed.")
|
2012-05-09 12:44:37 +02:00
|
|
|
.arg(QFileInfo(m_proFilePath).fileName());
|
|
|
|
|
|
2011-05-26 16:30:35 +02:00
|
|
|
if (!m_parseSuccess)
|
2013-10-29 14:22:31 +01:00
|
|
|
return static_cast<QmakeProject *>(target()->project())->disabledReasonForRunConfiguration(m_proFilePath);
|
2011-05-26 16:30:35 +02:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfiguration::proFileUpdated(QmakeProFileNode *pro, bool success, bool parseInProgress)
|
2009-12-03 18:37:27 +01:00
|
|
|
{
|
2013-10-29 17:48:43 +01:00
|
|
|
LocalEnvironmentAspect *aspect = extraAspect<LocalEnvironmentAspect>();
|
2013-01-29 18:00:30 +01:00
|
|
|
QTC_ASSERT(aspect, return);
|
|
|
|
|
|
2011-10-04 12:29:36 +02:00
|
|
|
if (m_proFilePath != pro->path()) {
|
|
|
|
|
if (!parseInProgress) {
|
|
|
|
|
// We depend on all .pro files for the LD_LIBRARY_PATH so we emit a signal for all .pro files
|
|
|
|
|
// This can be optimized by checking whether LD_LIBRARY_PATH changed
|
2013-01-29 18:00:30 +01:00
|
|
|
aspect->buildEnvironmentHasChanged();
|
2011-10-04 12:29:36 +02:00
|
|
|
}
|
2011-06-10 15:37:10 +02:00
|
|
|
return;
|
2011-10-04 12:29:36 +02:00
|
|
|
}
|
2011-06-10 15:37:10 +02:00
|
|
|
|
2010-10-27 16:27:22 +02:00
|
|
|
bool enabled = isEnabled();
|
2012-05-08 12:02:51 +02:00
|
|
|
QString reason = disabledReason();
|
2010-10-27 16:27:22 +02:00
|
|
|
m_parseSuccess = success;
|
2011-06-10 15:37:10 +02:00
|
|
|
m_parseInProgress = parseInProgress;
|
2012-05-08 12:02:51 +02:00
|
|
|
if (enabled != isEnabled() || reason != disabledReason())
|
2012-03-29 13:11:00 +02:00
|
|
|
emit enabledChanged();
|
2010-10-27 16:27:22 +02:00
|
|
|
|
2011-06-10 15:37:10 +02:00
|
|
|
if (!parseInProgress) {
|
|
|
|
|
emit effectiveTargetInformationChanged();
|
2013-01-29 18:00:30 +01:00
|
|
|
aspect->buildEnvironmentHasChanged();
|
2011-06-10 15:37:10 +02:00
|
|
|
}
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfiguration::ctor()
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2010-08-19 12:26:21 +02:00
|
|
|
setDefaultDisplayName(defaultDisplayName());
|
2010-08-18 15:42:01 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
2012-11-26 15:09:56 +02:00
|
|
|
m_forcedGuiMode = (version && version->type() == QLatin1String(QtSupport::Constants::SIMULATORQT));
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
connect(target()->project(), SIGNAL(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)),
|
|
|
|
|
this, SLOT(proFileUpdated(QmakeProjectManager::QmakeProFileNode*,bool,bool)));
|
2012-09-03 18:31:44 +02:00
|
|
|
connect(target(), SIGNAL(kitChanged()),
|
|
|
|
|
this, SLOT(kitChanged()));
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfiguration::kitChanged()
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
2012-11-26 15:09:56 +02:00
|
|
|
m_forcedGuiMode = (version && version->type() == QLatin1String(QtSupport::Constants::SIMULATORQT));
|
2012-04-24 15:49:09 +02:00
|
|
|
emit runModeChanged(runMode()); // Always emit
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2009-01-27 18:23:02 +01:00
|
|
|
//////
|
2013-10-29 18:14:50 +01:00
|
|
|
/// DesktopQmakeRunConfigurationWidget
|
2009-01-27 18:23:02 +01:00
|
|
|
/////
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfigurationWidget::DesktopQmakeRunConfigurationWidget(DesktopQmakeRunConfiguration *qmakeRunConfiguration, QWidget *parent)
|
2009-03-26 12:01:08 +01:00
|
|
|
: QWidget(parent),
|
2013-10-29 15:15:10 +01:00
|
|
|
m_qmakeRunConfiguration(qmakeRunConfiguration),
|
2009-03-26 12:01:08 +01:00
|
|
|
m_ignoreChange(false),
|
2009-03-26 15:33:32 +01:00
|
|
|
m_usingDyldImageSuffix(0),
|
|
|
|
|
m_isShown(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-10-01 14:24:44 +02:00
|
|
|
QVBoxLayout *vboxTopLayout = new QVBoxLayout(this);
|
|
|
|
|
vboxTopLayout->setMargin(0);
|
|
|
|
|
|
2011-06-10 15:37:10 +02:00
|
|
|
QHBoxLayout *hl = new QHBoxLayout();
|
|
|
|
|
hl->addStretch();
|
|
|
|
|
m_disabledIcon = new QLabel(this);
|
2014-05-19 12:21:28 +02:00
|
|
|
m_disabledIcon->setPixmap(QPixmap(QLatin1String(ProjectExplorer::Constants::ICON_WARNING)));
|
2011-06-10 15:37:10 +02:00
|
|
|
hl->addWidget(m_disabledIcon);
|
|
|
|
|
m_disabledReason = new QLabel(this);
|
|
|
|
|
m_disabledReason->setVisible(false);
|
|
|
|
|
hl->addWidget(m_disabledReason);
|
|
|
|
|
hl->addStretch();
|
|
|
|
|
vboxTopLayout->addLayout(hl);
|
|
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
m_detailsContainer = new DetailsWidget(this);
|
|
|
|
|
m_detailsContainer->setState(DetailsWidget::NoSummary);
|
2009-10-01 14:24:44 +02:00
|
|
|
vboxTopLayout->addWidget(m_detailsContainer);
|
|
|
|
|
QWidget *detailsWidget = new QWidget(m_detailsContainer);
|
|
|
|
|
m_detailsContainer->setWidget(detailsWidget);
|
|
|
|
|
QFormLayout *toplayout = new QFormLayout(detailsWidget);
|
2009-07-22 17:02:12 +02:00
|
|
|
toplayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
2008-12-02 12:01:29 +01:00
|
|
|
toplayout->setMargin(0);
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
m_executableLineEdit = new QLineEdit(m_qmakeRunConfiguration->executable(), this);
|
2010-08-18 15:42:01 +02:00
|
|
|
m_executableLineEdit->setEnabled(false);
|
|
|
|
|
toplayout->addRow(tr("Executable:"), m_executableLineEdit);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-23 14:33:41 +01:00
|
|
|
QLabel *argumentsLabel = new QLabel(tr("Arguments:"), this);
|
2013-10-29 15:15:10 +01:00
|
|
|
m_argumentsLineEdit = new QLineEdit(qmakeRunConfiguration->rawCommandLineArguments(), this);
|
2010-02-01 17:22:05 +01:00
|
|
|
argumentsLabel->setBuddy(m_argumentsLineEdit);
|
|
|
|
|
toplayout->addRow(argumentsLabel, m_argumentsLineEdit);
|
|
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
m_workingDirectoryEdit = new PathChooser(this);
|
|
|
|
|
m_workingDirectoryEdit->setExpectedKind(PathChooser::Directory);
|
2014-02-07 14:33:53 +01:00
|
|
|
m_workingDirectoryEdit->setHistoryCompleter(QLatin1String("Qmake.WorkingDir.History"));
|
2013-10-29 15:15:10 +01:00
|
|
|
m_workingDirectoryEdit->setPath(m_qmakeRunConfiguration->baseWorkingDirectory());
|
2014-05-02 12:53:36 +02:00
|
|
|
m_workingDirectoryEdit->setBaseFileName(m_qmakeRunConfiguration->target()->project()->projectDirectory());
|
2013-10-29 17:48:43 +01:00
|
|
|
EnvironmentAspect *aspect = qmakeRunConfiguration->extraAspect<EnvironmentAspect>();
|
2013-01-29 18:00:30 +01:00
|
|
|
if (aspect) {
|
2013-04-11 16:09:02 +02:00
|
|
|
connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged()));
|
2013-01-29 18:00:30 +01:00
|
|
|
environmentWasChanged();
|
|
|
|
|
}
|
2010-05-14 15:45:43 +02:00
|
|
|
m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory"));
|
2009-05-13 17:08:48 +02:00
|
|
|
|
2010-02-23 14:33:41 +01:00
|
|
|
QToolButton *resetButton = new QToolButton(this);
|
2009-05-13 17:08:48 +02:00
|
|
|
resetButton->setToolTip(tr("Reset to default"));
|
2010-07-30 22:16:59 +02:00
|
|
|
resetButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RESET)));
|
2009-05-13 17:08:48 +02:00
|
|
|
|
|
|
|
|
QHBoxLayout *boxlayout = new QHBoxLayout();
|
2009-09-23 17:16:09 +02:00
|
|
|
boxlayout->setMargin(0);
|
2009-05-13 17:08:48 +02:00
|
|
|
boxlayout->addWidget(m_workingDirectoryEdit);
|
|
|
|
|
boxlayout->addWidget(resetButton);
|
2010-05-14 15:45:43 +02:00
|
|
|
toplayout->addRow(tr("Working directory:"), boxlayout);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-02-21 17:36:55 +01:00
|
|
|
QHBoxLayout *innerBox = new QHBoxLayout();
|
2010-05-14 15:45:43 +02:00
|
|
|
m_useTerminalCheck = new QCheckBox(tr("Run in terminal"), this);
|
2014-05-26 23:42:25 +03:00
|
|
|
m_useTerminalCheck->setChecked(m_qmakeRunConfiguration->runMode() == ApplicationLauncher::Console);
|
2013-10-29 15:15:10 +01:00
|
|
|
m_useTerminalCheck->setVisible(!m_qmakeRunConfiguration->forcedGuiMode());
|
2013-02-21 17:36:55 +01:00
|
|
|
innerBox->addWidget(m_useTerminalCheck);
|
|
|
|
|
|
|
|
|
|
m_useQvfbCheck = new QCheckBox(tr("Run on QVFb"), this);
|
|
|
|
|
m_useQvfbCheck->setToolTip(tr("Check this option to run the application on a Qt Virtual Framebuffer."));
|
2014-05-26 23:42:25 +03:00
|
|
|
m_useQvfbCheck->setChecked(m_qmakeRunConfiguration->runMode() == ApplicationLauncher::Console);
|
2013-02-21 17:36:55 +01:00
|
|
|
m_useQvfbCheck->setVisible(false);
|
|
|
|
|
innerBox->addWidget(m_useQvfbCheck);
|
|
|
|
|
innerBox->addStretch();
|
|
|
|
|
toplayout->addRow(QString(), innerBox);
|
2009-02-18 17:04:04 +01:00
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
if (HostOsInfo::isMacHost()) {
|
2012-08-23 15:53:58 +02:00
|
|
|
m_usingDyldImageSuffix = new QCheckBox(tr("Use debug version of frameworks (DYLD_IMAGE_SUFFIX=_debug)"), this);
|
2013-10-29 15:15:10 +01:00
|
|
|
m_usingDyldImageSuffix->setChecked(m_qmakeRunConfiguration->isUsingDyldImageSuffix());
|
2012-08-23 15:53:58 +02:00
|
|
|
toplayout->addRow(QString(), m_usingDyldImageSuffix);
|
|
|
|
|
connect(m_usingDyldImageSuffix, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(usingDyldImageSuffixToggled(bool)));
|
|
|
|
|
}
|
2009-03-26 12:01:08 +01:00
|
|
|
|
2012-03-29 13:11:00 +02:00
|
|
|
runConfigurationEnabledChange();
|
2010-10-27 16:27:22 +02:00
|
|
|
|
2009-06-19 17:55:47 +02:00
|
|
|
connect(m_workingDirectoryEdit, SIGNAL(changed(QString)),
|
2009-12-03 18:37:27 +01:00
|
|
|
this, SLOT(workDirectoryEdited()));
|
2009-05-13 17:08:48 +02:00
|
|
|
|
|
|
|
|
connect(resetButton, SIGNAL(clicked()),
|
2009-12-03 18:37:27 +01:00
|
|
|
this, SLOT(workingDirectoryReseted()));
|
2009-05-13 17:08:48 +02:00
|
|
|
|
2009-03-18 17:43:55 +01:00
|
|
|
connect(m_argumentsLineEdit, SIGNAL(textEdited(QString)),
|
2009-12-03 18:37:27 +01:00
|
|
|
this, SLOT(argumentsEdited(QString)));
|
2009-02-18 17:04:04 +01:00
|
|
|
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(termToggled(bool)));
|
2013-02-21 17:36:55 +01:00
|
|
|
connect(m_useQvfbCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(qvfbToggled(bool)));
|
2009-02-18 17:04:04 +01:00
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
connect(qmakeRunConfiguration, SIGNAL(baseWorkingDirectoryChanged(QString)),
|
2009-05-13 17:08:48 +02:00
|
|
|
this, SLOT(workingDirectoryChanged(QString)));
|
|
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
connect(qmakeRunConfiguration, SIGNAL(commandLineArgumentsChanged(QString)),
|
2009-01-27 18:23:02 +01:00
|
|
|
this, SLOT(commandLineArgumentsChanged(QString)));
|
2014-05-26 23:42:25 +03:00
|
|
|
connect(qmakeRunConfiguration, SIGNAL(runModeChanged(ProjectExplorer::ApplicationLauncher::Mode)),
|
|
|
|
|
this, SLOT(runModeChanged(ProjectExplorer::ApplicationLauncher::Mode)));
|
2013-10-29 15:15:10 +01:00
|
|
|
connect(qmakeRunConfiguration, SIGNAL(usingDyldImageSuffixChanged(bool)),
|
2009-03-26 12:01:08 +01:00
|
|
|
this, SLOT(usingDyldImageSuffixChanged(bool)));
|
2013-10-29 15:15:10 +01:00
|
|
|
connect(qmakeRunConfiguration, SIGNAL(effectiveTargetInformationChanged()),
|
2009-03-19 15:04:43 +01:00
|
|
|
this, SLOT(effectiveTargetInformationChanged()), Qt::QueuedConnection);
|
2009-05-27 13:37:21 +02:00
|
|
|
|
2013-10-29 15:15:10 +01:00
|
|
|
connect(qmakeRunConfiguration, SIGNAL(enabledChanged()),
|
2012-03-29 13:11:00 +02:00
|
|
|
this, SLOT(runConfigurationEnabledChange()));
|
2009-05-27 14:41:07 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfigurationWidget::~DesktopQmakeRunConfigurationWidget()
|
2010-02-23 14:33:41 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::environmentWasChanged()
|
2013-01-29 18:00:30 +01:00
|
|
|
{
|
2013-10-29 17:48:43 +01:00
|
|
|
EnvironmentAspect *aspect = m_qmakeRunConfiguration->extraAspect<EnvironmentAspect>();
|
2013-01-29 18:00:30 +01:00
|
|
|
QTC_ASSERT(aspect, return);
|
|
|
|
|
m_workingDirectoryEdit->setEnvironment(aspect->environment());
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::runConfigurationEnabledChange()
|
2010-10-27 16:27:22 +02:00
|
|
|
{
|
2013-10-29 15:15:10 +01:00
|
|
|
bool enabled = m_qmakeRunConfiguration->isEnabled();
|
2011-06-10 15:37:10 +02:00
|
|
|
m_disabledIcon->setVisible(!enabled);
|
|
|
|
|
m_disabledReason->setVisible(!enabled);
|
2013-10-29 15:15:10 +01:00
|
|
|
m_disabledReason->setText(m_qmakeRunConfiguration->disabledReason());
|
2010-10-27 16:27:22 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::workDirectoryEdited()
|
2009-05-13 17:08:48 +02:00
|
|
|
{
|
|
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
m_ignoreChange = true;
|
2013-10-29 15:15:10 +01:00
|
|
|
m_qmakeRunConfiguration->setBaseWorkingDirectory(m_workingDirectoryEdit->rawPath());
|
2009-05-13 17:08:48 +02:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::workingDirectoryReseted()
|
2009-05-13 17:08:48 +02:00
|
|
|
{
|
|
|
|
|
// This emits a signal connected to workingDirectoryChanged()
|
|
|
|
|
// that sets the m_workingDirectoryEdit
|
2013-10-29 15:15:10 +01:00
|
|
|
m_qmakeRunConfiguration->setBaseWorkingDirectory(QString());
|
2009-05-13 17:08:48 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::argumentsEdited(const QString &args)
|
2009-01-27 18:23:02 +01:00
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2013-10-29 15:15:10 +01:00
|
|
|
m_qmakeRunConfiguration->setCommandLineArguments(args);
|
2009-01-27 18:23:02 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::termToggled(bool on)
|
2009-02-18 17:04:04 +01:00
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2014-05-26 23:42:25 +03:00
|
|
|
m_qmakeRunConfiguration->setRunMode(on ? ApplicationLauncher::Console
|
|
|
|
|
: ApplicationLauncher::Gui);
|
2009-02-18 17:04:04 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::qvfbToggled(bool on)
|
2013-02-21 17:36:55 +01:00
|
|
|
{
|
2013-02-28 13:11:45 +01:00
|
|
|
Q_UNUSED(on);
|
2013-02-21 17:36:55 +01:00
|
|
|
m_ignoreChange = true;
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::usingDyldImageSuffixToggled(bool state)
|
2009-03-26 12:01:08 +01:00
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2013-10-29 15:15:10 +01:00
|
|
|
m_qmakeRunConfiguration->setUsingDyldImageSuffix(state);
|
2009-03-26 12:01:08 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::workingDirectoryChanged(const QString &workingDirectory)
|
2009-05-13 17:08:48 +02:00
|
|
|
{
|
|
|
|
|
if (!m_ignoreChange)
|
|
|
|
|
m_workingDirectoryEdit->setPath(workingDirectory);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::commandLineArgumentsChanged(const QString &args)
|
2009-01-27 18:23:02 +01:00
|
|
|
{
|
2009-09-17 13:59:10 +02:00
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
m_argumentsLineEdit->setText(args);
|
2009-01-27 18:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 23:42:25 +03:00
|
|
|
void DesktopQmakeRunConfigurationWidget::runModeChanged(ApplicationLauncher::Mode runMode)
|
2009-02-18 17:04:04 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!m_ignoreChange) {
|
2013-10-29 15:15:10 +01:00
|
|
|
m_useTerminalCheck->setVisible(!m_qmakeRunConfiguration->forcedGuiMode());
|
2014-05-26 23:42:25 +03:00
|
|
|
m_useTerminalCheck->setChecked(runMode == ApplicationLauncher::Console);
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
2009-02-18 17:04:04 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::usingDyldImageSuffixChanged(bool state)
|
2009-03-26 12:01:08 +01:00
|
|
|
{
|
|
|
|
|
if (!m_ignoreChange && m_usingDyldImageSuffix)
|
|
|
|
|
m_usingDyldImageSuffix->setChecked(state);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::effectiveTargetInformationChanged()
|
2009-01-27 18:23:02 +01:00
|
|
|
{
|
2009-03-19 15:04:43 +01:00
|
|
|
if (m_isShown) {
|
2013-10-29 15:15:10 +01:00
|
|
|
m_executableLineEdit->setText(QDir::toNativeSeparators(m_qmakeRunConfiguration->executable()));
|
2009-05-13 17:08:48 +02:00
|
|
|
m_ignoreChange = true;
|
2013-10-29 15:15:10 +01:00
|
|
|
m_workingDirectoryEdit->setPath(QDir::toNativeSeparators(m_qmakeRunConfiguration->baseWorkingDirectory()));
|
2009-05-13 17:08:48 +02:00
|
|
|
m_ignoreChange = false;
|
2009-03-19 15:04:43 +01:00
|
|
|
}
|
2009-01-27 18:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::showEvent(QShowEvent *event)
|
2009-01-27 18:23:02 +01:00
|
|
|
{
|
2009-03-19 15:04:43 +01:00
|
|
|
m_isShown = true;
|
|
|
|
|
effectiveTargetInformationChanged();
|
|
|
|
|
QWidget::showEvent(event);
|
2009-01-27 18:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfigurationWidget::hideEvent(QHideEvent *event)
|
2009-03-19 15:04:43 +01:00
|
|
|
{
|
|
|
|
|
m_isShown = false;
|
|
|
|
|
QWidget::hideEvent(event);
|
|
|
|
|
}
|
2009-01-27 18:23:02 +01:00
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QWidget *DesktopQmakeRunConfiguration::createConfigurationWidget()
|
2009-01-27 18:23:02 +01:00
|
|
|
{
|
2013-10-29 18:14:50 +01:00
|
|
|
return new DesktopQmakeRunConfigurationWidget(this, 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QVariantMap DesktopQmakeRunConfiguration::toMap() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-05-02 12:53:36 +02:00
|
|
|
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
2010-01-19 13:41:02 +01:00
|
|
|
QVariantMap map(LocalApplicationRunConfiguration::toMap());
|
|
|
|
|
map.insert(QLatin1String(COMMAND_LINE_ARGUMENTS_KEY), m_commandLineArguments);
|
|
|
|
|
map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath));
|
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(USE_DYLD_IMAGE_SUFFIX_KEY), m_isUsingDyldImageSuffix);
|
|
|
|
|
map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory);
|
|
|
|
|
return map;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfiguration::fromMap(const QVariantMap &map)
|
2010-01-29 21:33:57 +01:00
|
|
|
{
|
2014-05-02 12:53:36 +02:00
|
|
|
const QDir projectDir = QDir(target()->project()->projectDirectory().toString());
|
2010-10-19 11:14:03 +02:00
|
|
|
m_commandLineArguments = map.value(QLatin1String(COMMAND_LINE_ARGUMENTS_KEY)).toString();
|
2011-10-04 12:52:29 +02:00
|
|
|
m_proFilePath = QDir::cleanPath(projectDir.filePath(map.value(QLatin1String(PRO_FILE_KEY)).toString()));
|
2014-05-26 23:42:25 +03:00
|
|
|
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY), false).toBool()
|
|
|
|
|
? ApplicationLauncher::Console : ApplicationLauncher::Gui;
|
2010-01-19 13:41:02 +01:00
|
|
|
m_isUsingDyldImageSuffix = map.value(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), false).toBool();
|
|
|
|
|
|
|
|
|
|
m_userWorkingDirectory = map.value(QLatin1String(USER_WORKING_DIRECTORY_KEY)).toString();
|
|
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
m_parseSuccess = static_cast<QmakeProject *>(target()->project())->validParse(m_proFilePath);
|
|
|
|
|
m_parseInProgress = static_cast<QmakeProject *>(target()->project())->parseInProgress(m_proFilePath);
|
2010-11-02 12:26:55 +01:00
|
|
|
|
2013-10-09 16:22:56 +02:00
|
|
|
return LocalApplicationRunConfiguration::fromMap(map);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::executable() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *pro = static_cast<QmakeProject *>(target()->project());
|
|
|
|
|
const QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(m_proFilePath);
|
2013-03-12 14:09:18 +01:00
|
|
|
return extractWorkingDirAndExecutable(node).second;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 23:42:25 +03:00
|
|
|
ApplicationLauncher::Mode DesktopQmakeRunConfiguration::runMode() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (m_forcedGuiMode)
|
2014-05-26 23:42:25 +03:00
|
|
|
return ProjectExplorer::ApplicationLauncher::Gui;
|
2008-12-02 12:01:29 +01:00
|
|
|
return m_runMode;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfiguration::forcedGuiMode() const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
|
|
|
|
return m_forcedGuiMode;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfiguration::isUsingDyldImageSuffix() const
|
2009-03-26 12:01:08 +01:00
|
|
|
{
|
|
|
|
|
return m_isUsingDyldImageSuffix;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfiguration::setUsingDyldImageSuffix(bool state)
|
2009-03-26 12:01:08 +01:00
|
|
|
{
|
|
|
|
|
m_isUsingDyldImageSuffix = state;
|
|
|
|
|
emit usingDyldImageSuffixChanged(state);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::workingDirectory() const
|
2010-09-27 15:04:58 +01:00
|
|
|
{
|
2013-10-29 17:48:43 +01:00
|
|
|
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
|
2013-01-29 18:00:30 +01:00
|
|
|
QTC_ASSERT(aspect, baseWorkingDirectory());
|
|
|
|
|
return QDir::cleanPath(aspect->environment().expandVariables(
|
2010-11-12 17:23:55 +01:00
|
|
|
Utils::expandMacros(baseWorkingDirectory(), macroExpander())));
|
2010-09-27 15:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::baseWorkingDirectory() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-05-13 17:08:48 +02:00
|
|
|
// if the user overrode us, then return his working directory
|
2010-11-12 14:36:54 +01:00
|
|
|
if (!m_userWorkingDirectory.isEmpty())
|
2009-05-13 17:08:48 +02:00
|
|
|
return m_userWorkingDirectory;
|
|
|
|
|
|
|
|
|
|
// else what the pro file reader tells us
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *pro = static_cast<QmakeProject *>(target()->project());
|
|
|
|
|
const QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(m_proFilePath);
|
2013-03-12 14:09:18 +01:00
|
|
|
return extractWorkingDirAndExecutable(node).first;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::commandLineArguments() const
|
2010-11-12 17:23:55 +01:00
|
|
|
{
|
2013-10-29 17:48:43 +01:00
|
|
|
return QtcProcess::expandMacros(m_commandLineArguments, macroExpander());
|
2010-11-12 17:23:55 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::rawCommandLineArguments() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return m_commandLineArguments;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfiguration::setBaseWorkingDirectory(const QString &wd)
|
2009-05-13 17:08:48 +02:00
|
|
|
{
|
2010-11-12 14:36:54 +01:00
|
|
|
const QString &oldWorkingDirectory = workingDirectory();
|
|
|
|
|
|
|
|
|
|
m_userWorkingDirectory = wd;
|
|
|
|
|
|
|
|
|
|
const QString &newWorkingDirectory = workingDirectory();
|
|
|
|
|
if (oldWorkingDirectory != newWorkingDirectory)
|
|
|
|
|
emit baseWorkingDirectoryChanged(newWorkingDirectory);
|
2009-05-13 17:08:48 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfiguration::setCommandLineArguments(const QString &argumentsString)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-10-19 11:14:03 +02:00
|
|
|
m_commandLineArguments = argumentsString;
|
|
|
|
|
emit commandLineArgumentsChanged(argumentsString);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2014-05-26 23:42:25 +03:00
|
|
|
void DesktopQmakeRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode)
|
2009-02-18 17:04:04 +01:00
|
|
|
{
|
|
|
|
|
m_runMode = runMode;
|
|
|
|
|
emit runModeChanged(runMode);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const
|
2013-01-29 17:04:19 +01:00
|
|
|
{
|
|
|
|
|
if (m_isUsingDyldImageSuffix)
|
|
|
|
|
env.set(QLatin1String("DYLD_IMAGE_SUFFIX"), QLatin1String("_debug"));
|
|
|
|
|
|
|
|
|
|
// The user could be linking to a library found via a -L/some/dir switch
|
|
|
|
|
// to find those libraries while actually running we explicitly prepend those
|
|
|
|
|
// dirs to the library search path
|
2013-10-29 14:22:31 +01:00
|
|
|
const QmakeProFileNode *node = static_cast<QmakeProject *>(target()->project())->rootQmakeProjectNode()->findProFileFor(m_proFilePath);
|
2013-01-29 17:04:19 +01:00
|
|
|
if (node) {
|
|
|
|
|
const QStringList libDirectories = node->variableValue(LibDirectoriesVar);
|
|
|
|
|
if (!libDirectories.isEmpty()) {
|
|
|
|
|
const QString proDirectory = node->buildDir();
|
|
|
|
|
foreach (QString dir, libDirectories) {
|
|
|
|
|
// Fix up relative entries like "LIBS+=-L.."
|
|
|
|
|
const QFileInfo fi(dir);
|
|
|
|
|
if (!fi.isAbsolute())
|
|
|
|
|
dir = QDir::cleanPath(proDirectory + QLatin1Char('/') + dir);
|
|
|
|
|
env.prependOrSetLibrarySearchPath(dir);
|
|
|
|
|
} // foreach
|
|
|
|
|
} // libDirectories
|
|
|
|
|
} // node
|
|
|
|
|
|
|
|
|
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());
|
|
|
|
|
if (qtVersion)
|
|
|
|
|
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::proFilePath() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return m_proFilePath;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfiguration::defaultDisplayName()
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2010-08-18 15:42:01 +02:00
|
|
|
QString defaultName;
|
2010-01-19 13:41:02 +01:00
|
|
|
if (!m_proFilePath.isEmpty())
|
2010-08-18 15:42:01 +02:00
|
|
|
defaultName = QFileInfo(m_proFilePath).completeBaseName();
|
2010-01-19 13:41:02 +01:00
|
|
|
else
|
2012-11-06 13:45:14 +01:00
|
|
|
defaultName = tr("Qt Run Configuration");
|
2010-08-18 15:42:01 +02:00
|
|
|
return defaultName;
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
OutputFormatter *DesktopQmakeRunConfiguration::createOutputFormatter() const
|
2010-07-13 15:02:37 +02:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
return new QtSupport::QtOutputFormatter(target()->project());
|
2010-07-13 15:02:37 +02:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QPair<QString, QString> DesktopQmakeRunConfiguration::extractWorkingDirAndExecutable(const QmakeProFileNode *node) const
|
2013-03-12 14:09:18 +01:00
|
|
|
{
|
|
|
|
|
if (!node)
|
|
|
|
|
return qMakePair(QString(), QString());
|
|
|
|
|
TargetInformation ti = node->targetInformation();
|
|
|
|
|
if (!ti.valid)
|
|
|
|
|
return qMakePair(QString(), QString());
|
|
|
|
|
|
|
|
|
|
const QStringList &config = node->variableValue(ConfigVar);
|
|
|
|
|
|
|
|
|
|
QString destDir = ti.destDir;
|
|
|
|
|
QString workingDir;
|
|
|
|
|
if (!destDir.isEmpty()) {
|
|
|
|
|
bool workingDirIsBaseDir = false;
|
2013-11-11 22:20:47 +02:00
|
|
|
if (destDir == ti.buildTarget)
|
2013-03-12 14:09:18 +01:00
|
|
|
workingDirIsBaseDir = true;
|
|
|
|
|
if (QDir::isRelativePath(destDir))
|
|
|
|
|
destDir = QDir::cleanPath(ti.buildDir + QLatin1Char('/') + destDir);
|
|
|
|
|
|
|
|
|
|
if (workingDirIsBaseDir)
|
|
|
|
|
workingDir = ti.buildDir;
|
|
|
|
|
else
|
|
|
|
|
workingDir = destDir;
|
|
|
|
|
} else {
|
|
|
|
|
destDir = ti.buildDir;
|
|
|
|
|
workingDir = ti.buildDir;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-29 17:48:43 +01:00
|
|
|
if (HostOsInfo::isMacHost() && config.contains(QLatin1String("app_bundle"))) {
|
2013-03-12 14:09:18 +01:00
|
|
|
const QString infix = QLatin1Char('/') + ti.target
|
|
|
|
|
+ QLatin1String(".app/Contents/MacOS");
|
|
|
|
|
workingDir += infix;
|
|
|
|
|
destDir += infix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString executable = QDir::cleanPath(destDir + QLatin1Char('/') + ti.target);
|
2013-10-29 17:48:43 +01:00
|
|
|
executable = HostOsInfo::withExecutableSuffix(executable);
|
|
|
|
|
//qDebug() << "##### QmakeRunConfiguration::extractWorkingDirAndExecutable:" workingDir << executable;
|
2013-03-12 14:09:18 +01:00
|
|
|
return qMakePair(workingDir, executable);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
///
|
2013-10-29 18:14:50 +01:00
|
|
|
/// DesktopQmakeRunConfigurationFactory
|
2008-12-02 12:01:29 +01:00
|
|
|
/// This class is used to restore run settings (saved in .user files)
|
|
|
|
|
///
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfigurationFactory::DesktopQmakeRunConfigurationFactory(QObject *parent) :
|
2012-04-24 15:49:09 +02:00
|
|
|
QmakeRunConfigurationFactory(parent)
|
2013-10-29 18:14:50 +01:00
|
|
|
{ setObjectName(QLatin1String("DesktopQmakeRunConfigurationFactory")); }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfigurationFactory::~DesktopQmakeRunConfigurationFactory()
|
2012-04-24 15:49:09 +02:00
|
|
|
{ }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfigurationFactory::canCreate(Target *parent, const Core::Id id) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2010-02-08 15:50:06 +01:00
|
|
|
return false;
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
2012-04-24 15:49:09 +02:00
|
|
|
return project->hasApplicationProFile(pathFromId(id));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
RunConfiguration *DesktopQmakeRunConfigurationFactory::doCreate(Target *parent, const Core::Id id)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfiguration *rc = new DesktopQmakeRunConfiguration(parent, id);
|
2013-10-29 14:22:31 +01:00
|
|
|
const QmakeProFileNode *node = static_cast<QmakeProject *>(parent->project())->rootQmakeProjectNode()->findProFileFor(rc->proFilePath());
|
2013-06-18 18:58:00 +02:00
|
|
|
if (node) // should always be found
|
2012-04-24 15:49:09 +02:00
|
|
|
rc->setRunMode(node->variableValue(ConfigVar).contains(QLatin1String("console"))
|
2013-06-11 17:42:19 +02:00
|
|
|
&& !node->variableValue(QtVar).contains(QLatin1String("testlib"))
|
2014-05-26 23:42:25 +03:00
|
|
|
? ApplicationLauncher::Console : ApplicationLauncher::Gui);
|
2012-04-24 15:49:09 +02:00
|
|
|
return rc;
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfigurationFactory::canRestore(Target *parent, const QVariantMap &map) 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-10-29 17:48:43 +01:00
|
|
|
return idFromMap(map).toString().startsWith(QLatin1String(QMAKE_RC_PREFIX));
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
RunConfiguration *DesktopQmakeRunConfigurationFactory::doRestore(Target *parent, const QVariantMap &map)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2013-10-29 18:14:50 +01:00
|
|
|
return new DesktopQmakeRunConfiguration(parent, idFromMap(map));
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfigurationFactory::canClone(Target *parent, RunConfiguration *source) const
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
return canCreate(parent, source->id());
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
RunConfiguration *DesktopQmakeRunConfigurationFactory::clone(Target *parent, RunConfiguration *source)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
|
|
|
|
if (!canClone(parent, source))
|
|
|
|
|
return 0;
|
2013-10-29 18:14:50 +01:00
|
|
|
DesktopQmakeRunConfiguration *old = static_cast<DesktopQmakeRunConfiguration *>(source);
|
|
|
|
|
return new DesktopQmakeRunConfiguration(parent, old);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QList<Core::Id> DesktopQmakeRunConfigurationFactory::availableCreationIds(Target *parent) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> result;
|
2012-04-24 15:49:09 +02:00
|
|
|
if (!canHandle(parent))
|
2012-03-15 17:17:40 +01:00
|
|
|
return result;
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *project = static_cast<QmakeProject *>(parent->project());
|
2013-10-29 16:08:37 +01:00
|
|
|
QStringList proFiles = project->applicationProFilePathes(QLatin1String(QMAKE_RC_PREFIX));
|
2012-03-15 17:17:40 +01:00
|
|
|
foreach (const QString &pf, proFiles)
|
2013-03-19 12:35:08 +01:00
|
|
|
result << Core::Id::fromString(pf);
|
2012-03-15 17:17:40 +01:00
|
|
|
return result;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
QString DesktopQmakeRunConfigurationFactory::displayNameForId(const Core::Id id) const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
return QFileInfo(pathFromId(id)).completeBaseName();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2013-10-29 18:14:50 +01:00
|
|
|
bool DesktopQmakeRunConfigurationFactory::canHandle(Target *t) const
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
if (!t->project()->supportsKit(t->kit()))
|
2012-04-24 15:49:09 +02:00
|
|
|
return false;
|
2013-10-29 14:22:31 +01:00
|
|
|
if (!qobject_cast<QmakeProject *>(t->project()))
|
2012-04-24 15:49:09 +02:00
|
|
|
return false;
|
2013-10-29 17:48:43 +01:00
|
|
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(t->kit());
|
|
|
|
|
return devType == Constants::DESKTOP_DEVICE_TYPE;
|
2012-04-24 15:49:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-04-29 08:35:00 +02:00
|
|
|
QList<RunConfiguration *> DesktopQmakeRunConfigurationFactory::runConfigurationsForNode(Target *t, const Node *n)
|
2012-04-24 15:49:09 +02:00
|
|
|
{
|
2013-10-29 17:48:43 +01:00
|
|
|
QList<RunConfiguration *> result;
|
|
|
|
|
foreach (RunConfiguration *rc, t->runConfigurations())
|
2013-10-29 18:14:50 +01:00
|
|
|
if (DesktopQmakeRunConfiguration *qt4c = qobject_cast<DesktopQmakeRunConfiguration *>(rc))
|
2012-04-24 15:49:09 +02:00
|
|
|
if (qt4c->proFilePath() == n->path())
|
|
|
|
|
result << rc;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2013-10-29 17:48:43 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmakeProjectManager
|