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;
|
||||
emit useTerminalChanged(useTerminal);
|
||||
}
|
||||
if (m_checkBox)
|
||||
m_checkBox->setChecked(m_useTerminal);
|
||||
}
|
||||
|
||||
bool TerminalAspect::isUserSet() const
|
||||
{
|
||||
return m_userSet;
|
||||
}
|
||||
|
||||
ApplicationLauncher::Mode TerminalAspect::runMode() const
|
||||
@@ -122,8 +129,6 @@ ApplicationLauncher::Mode TerminalAspect::runMode() const
|
||||
void TerminalAspect::setRunMode(ApplicationLauncher::Mode runMode)
|
||||
{
|
||||
setUseTerminal(runMode == ApplicationLauncher::Console);
|
||||
if (m_checkBox)
|
||||
m_checkBox->setChecked(m_useTerminal);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -65,6 +65,8 @@ public:
|
||||
ApplicationLauncher::Mode runMode() const;
|
||||
void setRunMode(ApplicationLauncher::Mode runMode);
|
||||
|
||||
bool isUserSet() const;
|
||||
|
||||
signals:
|
||||
void useTerminalChanged(bool);
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:";
|
||||
const char USE_TERMINAL_KEY[] = "Qbs.RunConfiguration.UseTerminal";
|
||||
|
||||
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) :
|
||||
LocalApplicationRunConfiguration(parent, id),
|
||||
m_uniqueProductName(uniqueProductNameFromId(id)),
|
||||
m_runMode(ApplicationLauncher::Gui),
|
||||
m_currentInstallStep(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 WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory")));
|
||||
|
||||
m_runModeForced = false;
|
||||
m_runMode = isConsoleApplication() ? ApplicationLauncher::Console : ApplicationLauncher::Gui;
|
||||
addExtraAspect(new TerminalAspect(this,
|
||||
QStringLiteral("Qbs.RunConfiguration.UseTerminal"),
|
||||
isConsoleApplication()));
|
||||
|
||||
ctor();
|
||||
}
|
||||
@@ -130,8 +129,6 @@ QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) :
|
||||
QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) :
|
||||
LocalApplicationRunConfiguration(parent, source),
|
||||
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_currentBuildStepList(0) // ditto
|
||||
{
|
||||
@@ -162,9 +159,9 @@ void QbsRunConfiguration::ctor()
|
||||
QbsProject *project = static_cast<QbsProject *>(target()->project());
|
||||
connect(project, &QbsProject::projectParsingStarted, this, &RunConfiguration::enabledChanged);
|
||||
connect(project, &QbsProject::projectParsingDone, this, [this](bool success) {
|
||||
if (success && !m_runModeForced)
|
||||
m_runMode = isConsoleApplication() ? ApplicationLauncher::Console
|
||||
: ApplicationLauncher::Gui;
|
||||
auto terminalAspect = extraAspect<TerminalAspect>();
|
||||
if (success && !terminalAspect->isUserSet())
|
||||
terminalAspect->setUseTerminal(isConsoleApplication());
|
||||
emit enabledChanged();
|
||||
});
|
||||
|
||||
@@ -178,25 +175,6 @@ QWidget *QbsRunConfiguration::createConfigurationWidget()
|
||||
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()
|
||||
{
|
||||
if (m_currentInstallStep)
|
||||
@@ -249,7 +227,7 @@ QString QbsRunConfiguration::executable() const
|
||||
|
||||
ApplicationLauncher::Mode QbsRunConfiguration::runMode() const
|
||||
{
|
||||
return m_runMode;
|
||||
return extraAspect<TerminalAspect>()->runMode();
|
||||
}
|
||||
|
||||
bool QbsRunConfiguration::isConsoleApplication() const
|
||||
@@ -301,12 +279,7 @@ void QbsRunConfiguration::setBaseWorkingDirectory(const QString &wd)
|
||||
|
||||
void QbsRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode)
|
||||
{
|
||||
if (m_runMode == runMode)
|
||||
return;
|
||||
|
||||
m_runModeForced = true;
|
||||
m_runMode = runMode;
|
||||
emit runModeChanged(runMode);
|
||||
extraAspect<TerminalAspect>()->setRunMode(runMode);
|
||||
}
|
||||
|
||||
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<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, toplayout);
|
||||
|
||||
QHBoxLayout *innerBox = new QHBoxLayout();
|
||||
m_useTerminalCheck = new QCheckBox(tr("Run in terminal"), this);
|
||||
innerBox->addWidget(m_useTerminalCheck);
|
||||
|
||||
innerBox->addStretch();
|
||||
toplayout->addRow(QString(), innerBox);
|
||||
m_rc->extraAspect<TerminalAspect>()->addToMainConfigurationWidget(this, toplayout);
|
||||
|
||||
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()),
|
||||
this, SLOT(targetInformationHasChanged()), Qt::QueuedConnection);
|
||||
|
||||
@@ -434,17 +397,9 @@ void QbsRunConfigurationWidget::runConfigurationEnabledChange()
|
||||
m_disabledReason->setVisible(!enabled);
|
||||
m_disabledReason->setText(m_rc->disabledReason());
|
||||
|
||||
m_useTerminalCheck->setChecked(m_rc->runMode() == ApplicationLauncher::Console);
|
||||
targetInformationHasChanged();
|
||||
}
|
||||
|
||||
void QbsRunConfigurationWidget::termToggled(bool on)
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
m_rc->setRunMode(on ? ApplicationLauncher::Console : ApplicationLauncher::Gui);
|
||||
m_ignoreChange = false;
|
||||
}
|
||||
|
||||
void QbsRunConfigurationWidget::targetInformationHasChanged()
|
||||
{
|
||||
m_ignoreChange = true;
|
||||
@@ -462,12 +417,6 @@ void QbsRunConfigurationWidget::setExecutableLineText(const QString &text)
|
||||
m_executableLineLabel->setText(newText);
|
||||
}
|
||||
|
||||
void QbsRunConfigurationWidget::runModeChanged(ApplicationLauncher::Mode runMode)
|
||||
{
|
||||
if (!m_ignoreChange)
|
||||
m_useTerminalCheck->setChecked(runMode == ApplicationLauncher::Console);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// QbsRunConfigurationFactory:
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -82,8 +82,6 @@ public:
|
||||
QString workingDirectory() const;
|
||||
QString commandLineArguments() const;
|
||||
|
||||
QVariantMap toMap() const;
|
||||
|
||||
Utils::OutputFormatter *createOutputFormatter() const;
|
||||
|
||||
void setRunMode(ProjectExplorer::ApplicationLauncher::Mode runMode);
|
||||
@@ -95,13 +93,11 @@ public:
|
||||
|
||||
signals:
|
||||
void baseWorkingDirectoryChanged(const QString&);
|
||||
void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode);
|
||||
void targetInformationChanged();
|
||||
void usingDyldImageSuffixChanged(bool);
|
||||
|
||||
protected:
|
||||
QbsRunConfiguration(ProjectExplorer::Target *parent, QbsRunConfiguration *source);
|
||||
bool fromMap(const QVariantMap &map);
|
||||
|
||||
private slots:
|
||||
void installStepChanged();
|
||||
@@ -121,8 +117,6 @@ private:
|
||||
QString m_uniqueProductName;
|
||||
|
||||
// Cached startup sub project information
|
||||
ProjectExplorer::ApplicationLauncher::Mode m_runMode;
|
||||
bool m_runModeForced;
|
||||
|
||||
QbsInstallStep *m_currentInstallStep; // We do not take ownership!
|
||||
ProjectExplorer::BuildStepList *m_currentBuildStepList; // We do not take ownership!
|
||||
@@ -137,11 +131,6 @@ public:
|
||||
|
||||
private slots:
|
||||
void runConfigurationEnabledChange();
|
||||
void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode);
|
||||
|
||||
void termToggled(bool);
|
||||
|
||||
private slots:
|
||||
void targetInformationHasChanged();
|
||||
|
||||
private:
|
||||
@@ -152,7 +141,6 @@ private:
|
||||
QLabel *m_disabledIcon;
|
||||
QLabel *m_disabledReason;
|
||||
QLabel *m_executableLineLabel;
|
||||
QCheckBox *m_useTerminalCheck;
|
||||
QCheckBox *m_usingDyldImageSuffix;
|
||||
QLineEdit *m_qmlDebugPort;
|
||||
Utils::DetailsWidget *m_detailsContainer;
|
||||
|
||||
Reference in New Issue
Block a user