forked from qt-creator/qt-creator
Qbs: Use TerminalAspect in QbsRunConfiguration
Change-Id: I6f1ddec10abda39149dd3743bdff1d0186d1de31 Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com> Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -112,6 +112,13 @@ void TerminalAspect::setUseTerminal(bool useTerminal)
|
|||||||
m_useTerminal = useTerminal;
|
m_useTerminal = useTerminal;
|
||||||
emit useTerminalChanged(useTerminal);
|
emit useTerminalChanged(useTerminal);
|
||||||
}
|
}
|
||||||
|
if (m_checkBox)
|
||||||
|
m_checkBox->setChecked(m_useTerminal);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerminalAspect::isUserSet() const
|
||||||
|
{
|
||||||
|
return m_userSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationLauncher::Mode TerminalAspect::runMode() const
|
ApplicationLauncher::Mode TerminalAspect::runMode() const
|
||||||
@@ -122,8 +129,6 @@ ApplicationLauncher::Mode TerminalAspect::runMode() const
|
|||||||
void TerminalAspect::setRunMode(ApplicationLauncher::Mode runMode)
|
void TerminalAspect::setRunMode(ApplicationLauncher::Mode runMode)
|
||||||
{
|
{
|
||||||
setUseTerminal(runMode == ApplicationLauncher::Console);
|
setUseTerminal(runMode == ApplicationLauncher::Console);
|
||||||
if (m_checkBox)
|
|
||||||
m_checkBox->setChecked(m_useTerminal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public:
|
|||||||
ApplicationLauncher::Mode runMode() const;
|
ApplicationLauncher::Mode runMode() const;
|
||||||
void setRunMode(ApplicationLauncher::Mode runMode);
|
void setRunMode(ApplicationLauncher::Mode runMode);
|
||||||
|
|
||||||
|
bool isUserSet() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void useTerminalChanged(bool);
|
void useTerminalChanged(bool);
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ namespace QbsProjectManager {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
|
const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
|
||||||
const char USE_TERMINAL_KEY[] = "Qbs.RunConfiguration.UseTerminal";
|
|
||||||
|
|
||||||
static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); }
|
static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); }
|
||||||
|
|
||||||
@@ -113,7 +112,6 @@ const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &u
|
|||||||
QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
|
QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
|
||||||
LocalApplicationRunConfiguration(parent, id),
|
LocalApplicationRunConfiguration(parent, id),
|
||||||
m_uniqueProductName(uniqueProductNameFromId(id)),
|
m_uniqueProductName(uniqueProductNameFromId(id)),
|
||||||
m_runMode(ApplicationLauncher::Gui),
|
|
||||||
m_currentInstallStep(0),
|
m_currentInstallStep(0),
|
||||||
m_currentBuildStepList(0)
|
m_currentBuildStepList(0)
|
||||||
{
|
{
|
||||||
@@ -121,8 +119,9 @@ QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
|
|||||||
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments")));
|
addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments")));
|
||||||
addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory")));
|
addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory")));
|
||||||
|
|
||||||
m_runModeForced = false;
|
addExtraAspect(new TerminalAspect(this,
|
||||||
m_runMode = isConsoleApplication() ? ApplicationLauncher::Console : ApplicationLauncher::Gui;
|
QStringLiteral("Qbs.RunConfiguration.UseTerminal"),
|
||||||
|
isConsoleApplication()));
|
||||||
|
|
||||||
ctor();
|
ctor();
|
||||||
}
|
}
|
||||||
@@ -130,8 +129,6 @@ QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
|
|||||||
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
|
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
|
||||||
LocalApplicationRunConfiguration(parent, source),
|
LocalApplicationRunConfiguration(parent, source),
|
||||||
m_uniqueProductName(source->m_uniqueProductName),
|
m_uniqueProductName(source->m_uniqueProductName),
|
||||||
m_runMode(source->m_runMode),
|
|
||||||
m_runModeForced(source->m_runModeForced),
|
|
||||||
m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway.
|
m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway.
|
||||||
m_currentBuildStepList(0) // ditto
|
m_currentBuildStepList(0) // ditto
|
||||||
{
|
{
|
||||||
@@ -162,9 +159,9 @@ void QbsRunConfiguration::ctor()
|
|||||||
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
||||||
connect(project, &QbsProject::projectParsingStarted, this, &RunConfiguration::enabledChanged);
|
connect(project, &QbsProject::projectParsingStarted, this, &RunConfiguration::enabledChanged);
|
||||||
connect(project, &QbsProject::projectParsingDone, this, [this](bool success) {
|
connect(project, &QbsProject::projectParsingDone, this, [this](bool success) {
|
||||||
if (success && !m_runModeForced)
|
auto terminalAspect = extraAspect<TerminalAspect>();
|
||||||
m_runMode = isConsoleApplication() ? ApplicationLauncher::Console
|
if (success && !terminalAspect->isUserSet())
|
||||||
: ApplicationLauncher::Gui;
|
terminalAspect->setUseTerminal(isConsoleApplication());
|
||||||
emit enabledChanged();
|
emit enabledChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -178,25 +175,6 @@ QWidget *QbsRunConfiguration::createConfigurationWidget()
|
|||||||
return new QbsRunConfigurationWidget(this, 0);
|
return new QbsRunConfigurationWidget(this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap QbsRunConfiguration::toMap() const
|
|
||||||
{
|
|
||||||
QVariantMap map(LocalApplicationRunConfiguration::toMap());
|
|
||||||
if (m_runModeForced)
|
|
||||||
map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == ApplicationLauncher::Console);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QbsRunConfiguration::fromMap(const QVariantMap &map)
|
|
||||||
{
|
|
||||||
if (map.contains(QLatin1String(USE_TERMINAL_KEY))) {
|
|
||||||
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY), false).toBool() ?
|
|
||||||
ApplicationLauncher::Console : ApplicationLauncher::Gui;
|
|
||||||
m_runModeForced = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RunConfiguration::fromMap(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsRunConfiguration::installStepChanged()
|
void QbsRunConfiguration::installStepChanged()
|
||||||
{
|
{
|
||||||
if (m_currentInstallStep)
|
if (m_currentInstallStep)
|
||||||
@@ -249,7 +227,7 @@ QString QbsRunConfiguration::executable() const
|
|||||||
|
|
||||||
ApplicationLauncher::Mode QbsRunConfiguration::runMode() const
|
ApplicationLauncher::Mode QbsRunConfiguration::runMode() const
|
||||||
{
|
{
|
||||||
return m_runMode;
|
return extraAspect<TerminalAspect>()->runMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QbsRunConfiguration::isConsoleApplication() const
|
bool QbsRunConfiguration::isConsoleApplication() const
|
||||||
@@ -301,12 +279,7 @@ void QbsRunConfiguration::setBaseWorkingDirectory(const QString &wd)
|
|||||||
|
|
||||||
void QbsRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode)
|
void QbsRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode)
|
||||||
{
|
{
|
||||||
if (m_runMode == runMode)
|
extraAspect<TerminalAspect>()->setRunMode(runMode);
|
||||||
return;
|
|
||||||
|
|
||||||
m_runModeForced = true;
|
|
||||||
m_runMode = runMode;
|
|
||||||
emit runModeChanged(runMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const
|
||||||
@@ -406,20 +379,10 @@ QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc, QW
|
|||||||
m_rc->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, toplayout);
|
m_rc->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, toplayout);
|
||||||
m_rc->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, toplayout);
|
m_rc->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, toplayout);
|
||||||
|
|
||||||
QHBoxLayout *innerBox = new QHBoxLayout();
|
m_rc->extraAspect<TerminalAspect>()->addToMainConfigurationWidget(this, toplayout);
|
||||||
m_useTerminalCheck = new QCheckBox(tr("Run in terminal"), this);
|
|
||||||
innerBox->addWidget(m_useTerminalCheck);
|
|
||||||
|
|
||||||
innerBox->addStretch();
|
|
||||||
toplayout->addRow(QString(), innerBox);
|
|
||||||
|
|
||||||
runConfigurationEnabledChange();
|
runConfigurationEnabledChange();
|
||||||
|
|
||||||
connect(m_useTerminalCheck, SIGNAL(toggled(bool)),
|
|
||||||
this, SLOT(termToggled(bool)));
|
|
||||||
|
|
||||||
connect(m_rc, SIGNAL(runModeChanged(ProjectExplorer::ApplicationLauncher::Mode)),
|
|
||||||
this, SLOT(runModeChanged(ProjectExplorer::ApplicationLauncher::Mode)));
|
|
||||||
connect(m_rc, SIGNAL(targetInformationChanged()),
|
connect(m_rc, SIGNAL(targetInformationChanged()),
|
||||||
this, SLOT(targetInformationHasChanged()), Qt::QueuedConnection);
|
this, SLOT(targetInformationHasChanged()), Qt::QueuedConnection);
|
||||||
|
|
||||||
@@ -434,17 +397,9 @@ void QbsRunConfigurationWidget::runConfigurationEnabledChange()
|
|||||||
m_disabledReason->setVisible(!enabled);
|
m_disabledReason->setVisible(!enabled);
|
||||||
m_disabledReason->setText(m_rc->disabledReason());
|
m_disabledReason->setText(m_rc->disabledReason());
|
||||||
|
|
||||||
m_useTerminalCheck->setChecked(m_rc->runMode() == ApplicationLauncher::Console);
|
|
||||||
targetInformationHasChanged();
|
targetInformationHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsRunConfigurationWidget::termToggled(bool on)
|
|
||||||
{
|
|
||||||
m_ignoreChange = true;
|
|
||||||
m_rc->setRunMode(on ? ApplicationLauncher::Console : ApplicationLauncher::Gui);
|
|
||||||
m_ignoreChange = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsRunConfigurationWidget::targetInformationHasChanged()
|
void QbsRunConfigurationWidget::targetInformationHasChanged()
|
||||||
{
|
{
|
||||||
m_ignoreChange = true;
|
m_ignoreChange = true;
|
||||||
@@ -462,12 +417,6 @@ void QbsRunConfigurationWidget::setExecutableLineText(const QString &text)
|
|||||||
m_executableLineLabel->setText(newText);
|
m_executableLineLabel->setText(newText);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsRunConfigurationWidget::runModeChanged(ApplicationLauncher::Mode runMode)
|
|
||||||
{
|
|
||||||
if (!m_ignoreChange)
|
|
||||||
m_useTerminalCheck->setChecked(runMode == ApplicationLauncher::Console);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// QbsRunConfigurationFactory:
|
// QbsRunConfigurationFactory:
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|||||||
@@ -82,8 +82,6 @@ public:
|
|||||||
QString workingDirectory() const;
|
QString workingDirectory() const;
|
||||||
QString commandLineArguments() const;
|
QString commandLineArguments() const;
|
||||||
|
|
||||||
QVariantMap toMap() const;
|
|
||||||
|
|
||||||
Utils::OutputFormatter *createOutputFormatter() const;
|
Utils::OutputFormatter *createOutputFormatter() const;
|
||||||
|
|
||||||
void setRunMode(ProjectExplorer::ApplicationLauncher::Mode runMode);
|
void setRunMode(ProjectExplorer::ApplicationLauncher::Mode runMode);
|
||||||
@@ -95,13 +93,11 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void baseWorkingDirectoryChanged(const QString&);
|
void baseWorkingDirectoryChanged(const QString&);
|
||||||
void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode);
|
|
||||||
void targetInformationChanged();
|
void targetInformationChanged();
|
||||||
void usingDyldImageSuffixChanged(bool);
|
void usingDyldImageSuffixChanged(bool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QbsRunConfiguration(ProjectExplorer::Target *parent, QbsRunConfiguration *source);
|
QbsRunConfiguration(ProjectExplorer::Target *parent, QbsRunConfiguration *source);
|
||||||
bool fromMap(const QVariantMap &map);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void installStepChanged();
|
void installStepChanged();
|
||||||
@@ -121,8 +117,6 @@ private:
|
|||||||
QString m_uniqueProductName;
|
QString m_uniqueProductName;
|
||||||
|
|
||||||
// Cached startup sub project information
|
// Cached startup sub project information
|
||||||
ProjectExplorer::ApplicationLauncher::Mode m_runMode;
|
|
||||||
bool m_runModeForced;
|
|
||||||
|
|
||||||
QbsInstallStep *m_currentInstallStep; // We do not take ownership!
|
QbsInstallStep *m_currentInstallStep; // We do not take ownership!
|
||||||
ProjectExplorer::BuildStepList *m_currentBuildStepList; // We do not take ownership!
|
ProjectExplorer::BuildStepList *m_currentBuildStepList; // We do not take ownership!
|
||||||
@@ -137,11 +131,6 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void runConfigurationEnabledChange();
|
void runConfigurationEnabledChange();
|
||||||
void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode);
|
|
||||||
|
|
||||||
void termToggled(bool);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void targetInformationHasChanged();
|
void targetInformationHasChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -152,7 +141,6 @@ private:
|
|||||||
QLabel *m_disabledIcon;
|
QLabel *m_disabledIcon;
|
||||||
QLabel *m_disabledReason;
|
QLabel *m_disabledReason;
|
||||||
QLabel *m_executableLineLabel;
|
QLabel *m_executableLineLabel;
|
||||||
QCheckBox *m_useTerminalCheck;
|
|
||||||
QCheckBox *m_usingDyldImageSuffix;
|
QCheckBox *m_usingDyldImageSuffix;
|
||||||
QLineEdit *m_qmlDebugPort;
|
QLineEdit *m_qmlDebugPort;
|
||||||
Utils::DetailsWidget *m_detailsContainer;
|
Utils::DetailsWidget *m_detailsContainer;
|
||||||
|
|||||||
Reference in New Issue
Block a user