2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-11-01 11:18:27 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2010-11-01 11:18:27 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-11-01 11:18:27 +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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-11-01 11:18:27 +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
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 17:14:20 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-11-01 11:18:27 +01:00
|
|
|
|
|
|
|
|
#include "customexecutableconfigurationwidget.h"
|
|
|
|
|
#include "customexecutablerunconfiguration.h"
|
|
|
|
|
|
2014-11-05 16:10:22 +01:00
|
|
|
#include <coreplugin/variablechooser.h>
|
2013-01-29 18:00:30 +01:00
|
|
|
#include <projectexplorer/environmentaspect.h>
|
2012-05-16 16:24:16 +02:00
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
2010-11-01 11:18:27 +01:00
|
|
|
#include <utils/detailswidget.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
2010-11-01 11:18:27 +01:00
|
|
|
|
2011-02-24 14:58:37 +01:00
|
|
|
|
2012-05-16 16:24:16 +02:00
|
|
|
namespace QtSupport {
|
2010-11-01 11:18:27 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-07-29 18:14:35 +02:00
|
|
|
CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode)
|
2010-11-01 11:18:27 +01:00
|
|
|
: m_ignoreChange(false), m_runConfiguration(rc)
|
|
|
|
|
{
|
|
|
|
|
QFormLayout *layout = new QFormLayout;
|
|
|
|
|
layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
|
|
|
|
|
m_executableChooser = new Utils::PathChooser(this);
|
2013-11-25 14:37:21 +01:00
|
|
|
m_executableChooser->setHistoryCompleter(QLatin1String("Qt.CustomExecutable.History"));
|
2010-11-01 11:18:27 +01:00
|
|
|
m_executableChooser->setExpectedKind(Utils::PathChooser::Command);
|
2013-05-13 17:16:52 +02:00
|
|
|
layout->addRow(tr("Executable:"), m_executableChooser);
|
2010-11-01 11:18:27 +01:00
|
|
|
|
|
|
|
|
m_commandLineArgumentsLineEdit = new QLineEdit(this);
|
|
|
|
|
m_commandLineArgumentsLineEdit->setMinimumWidth(200); // this shouldn't be fixed here...
|
|
|
|
|
layout->addRow(tr("Arguments:"), m_commandLineArgumentsLineEdit);
|
|
|
|
|
|
2011-03-08 17:24:19 +01:00
|
|
|
m_workingDirectory = new Utils::PathChooser(this);
|
2014-02-07 14:33:53 +01:00
|
|
|
m_workingDirectory->setHistoryCompleter(QLatin1String("Qt.WorkingDir.History"));
|
2011-03-08 17:24:19 +01:00
|
|
|
m_workingDirectory->setExpectedKind(Utils::PathChooser::Directory);
|
2014-05-02 12:53:36 +02:00
|
|
|
m_workingDirectory->setBaseFileName(rc->target()->project()->projectDirectory());
|
2013-01-29 18:00:30 +01:00
|
|
|
|
2010-11-01 11:18:27 +01:00
|
|
|
layout->addRow(tr("Working directory:"), m_workingDirectory);
|
|
|
|
|
|
2012-03-05 14:40:20 +01:00
|
|
|
m_useTerminalCheck = new QCheckBox(tr("Run in &terminal"), this);
|
2010-11-01 11:18:27 +01:00
|
|
|
layout->addRow(QString(), m_useTerminalCheck);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *vbox = new QVBoxLayout(this);
|
|
|
|
|
vbox->setMargin(0);
|
|
|
|
|
|
|
|
|
|
m_detailsContainer = new Utils::DetailsWidget(this);
|
|
|
|
|
m_detailsContainer->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
vbox->addWidget(m_detailsContainer);
|
|
|
|
|
|
|
|
|
|
QWidget *detailsWidget = new QWidget(m_detailsContainer);
|
|
|
|
|
m_detailsContainer->setWidget(detailsWidget);
|
|
|
|
|
detailsWidget->setLayout(layout);
|
|
|
|
|
|
|
|
|
|
changed();
|
|
|
|
|
|
2014-07-29 18:14:35 +02:00
|
|
|
if (mode == InstantApply) {
|
|
|
|
|
connect(m_executableChooser, SIGNAL(changed(QString)),
|
|
|
|
|
this, SLOT(executableEdited()));
|
|
|
|
|
connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(QString)),
|
|
|
|
|
this, SLOT(argumentsEdited(QString)));
|
|
|
|
|
connect(m_workingDirectory, SIGNAL(changed(QString)),
|
|
|
|
|
this, SLOT(workingDirectoryEdited()));
|
|
|
|
|
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(termToggled(bool)));
|
|
|
|
|
} else {
|
|
|
|
|
connect(m_executableChooser, SIGNAL(changed(QString)),
|
|
|
|
|
this, SIGNAL(validChanged()));
|
|
|
|
|
connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(QString)),
|
|
|
|
|
this, SIGNAL(validChanged()));
|
|
|
|
|
connect(m_workingDirectory, SIGNAL(changed(QString)),
|
|
|
|
|
this, SIGNAL(validChanged()));
|
|
|
|
|
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SIGNAL(validChanged()));
|
|
|
|
|
}
|
2010-11-01 11:18:27 +01:00
|
|
|
|
2013-01-29 18:00:30 +01:00
|
|
|
ProjectExplorer::EnvironmentAspect *aspect = rc->extraAspect<ProjectExplorer::EnvironmentAspect>();
|
|
|
|
|
if (aspect) {
|
|
|
|
|
connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged()));
|
|
|
|
|
environmentWasChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-29 18:14:35 +02:00
|
|
|
// If we are in mode InstantApply, we keep us in sync with the rc
|
|
|
|
|
// otherwise we ignore changes to the rc and override them on apply,
|
|
|
|
|
// or keep them on cancel
|
|
|
|
|
if (mode == InstantApply)
|
|
|
|
|
connect(m_runConfiguration, SIGNAL(changed()), this, SLOT(changed()));
|
2014-11-05 16:10:22 +01:00
|
|
|
|
|
|
|
|
Core::VariableChooser::addSupportForChildWidgets(this, m_runConfiguration->macroExpander());
|
2010-11-01 11:18:27 +01:00
|
|
|
}
|
|
|
|
|
|
2013-01-29 18:00:30 +01:00
|
|
|
void CustomExecutableConfigurationWidget::environmentWasChanged()
|
|
|
|
|
{
|
|
|
|
|
ProjectExplorer::EnvironmentAspect *aspect
|
|
|
|
|
= m_runConfiguration->extraAspect<ProjectExplorer::EnvironmentAspect>();
|
|
|
|
|
QTC_ASSERT(aspect, return);
|
|
|
|
|
m_workingDirectory->setEnvironment(aspect->environment());
|
|
|
|
|
m_executableChooser->setEnvironment(aspect->environment());
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-01 11:18:27 +01:00
|
|
|
void CustomExecutableConfigurationWidget::executableEdited()
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
|
|
|
|
m_runConfiguration->setExecutable(m_executableChooser->rawPath());
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
void CustomExecutableConfigurationWidget::argumentsEdited(const QString &arguments)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2010-10-19 11:14:03 +02:00
|
|
|
m_runConfiguration->setCommandLineArguments(arguments);
|
2010-11-01 11:18:27 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
void CustomExecutableConfigurationWidget::workingDirectoryEdited()
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
|
|
|
|
m_runConfiguration->setBaseWorkingDirectory(m_workingDirectory->rawPath());
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomExecutableConfigurationWidget::termToggled(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
2014-05-26 23:42:25 +03:00
|
|
|
m_runConfiguration->setRunMode(on ? ProjectExplorer::ApplicationLauncher::Console
|
|
|
|
|
: ProjectExplorer::ApplicationLauncher::Gui);
|
2010-11-01 11:18:27 +01:00
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomExecutableConfigurationWidget::changed()
|
|
|
|
|
{
|
|
|
|
|
// We triggered the change, don't update us
|
|
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_executableChooser->setPath(m_runConfiguration->rawExecutable());
|
2010-11-12 17:23:55 +01:00
|
|
|
m_commandLineArgumentsLineEdit->setText(m_runConfiguration->rawCommandLineArguments());
|
2010-11-01 11:18:27 +01:00
|
|
|
m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory());
|
2012-05-16 16:24:16 +02:00
|
|
|
m_useTerminalCheck->setChecked(m_runConfiguration->runMode()
|
2014-05-26 23:42:25 +03:00
|
|
|
== ProjectExplorer::ApplicationLauncher::Console);
|
2010-11-01 11:18:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-29 18:14:35 +02:00
|
|
|
void CustomExecutableConfigurationWidget::apply()
|
|
|
|
|
{
|
|
|
|
|
m_ignoreChange = true;
|
|
|
|
|
m_runConfiguration->setExecutable(m_executableChooser->rawPath());
|
|
|
|
|
m_runConfiguration->setCommandLineArguments(m_commandLineArgumentsLineEdit->text());
|
|
|
|
|
m_runConfiguration->setBaseWorkingDirectory(m_workingDirectory->rawPath());
|
|
|
|
|
m_runConfiguration->setRunMode(m_useTerminalCheck->isChecked() ? ProjectExplorer::ApplicationLauncher::Console
|
|
|
|
|
: ProjectExplorer::ApplicationLauncher::Gui);
|
|
|
|
|
m_ignoreChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CustomExecutableConfigurationWidget::isValid() const
|
|
|
|
|
{
|
|
|
|
|
return !m_executableChooser->rawPath().isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-01 11:18:27 +01:00
|
|
|
} // namespace Internal
|
2012-05-16 16:24:16 +02:00
|
|
|
} // namespace QtSupport
|