Commit ef5c1059 authored by hjk's avatar hjk

BareMetal: Use ArgumentsAspect in run configuration subclasses

Change-Id: I1d83ec427c5f249836c3a727e4b4fa0465fe970c
Reviewed-by: default avatarTim Sander <tim@krieglstein.org>
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent e7243809
......@@ -31,6 +31,7 @@
#include "baremetalcustomrunconfiguration.h"
#include <projectexplorer/target.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <qtsupport/qtoutputformatter.h>
#include <utils/detailswidget.h>
#include <utils/qtcprocess.h>
......@@ -38,19 +39,22 @@
#include <QDir>
#include <QFileInfo>
#include <QFormLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QString>
#include <QLineEdit>
using namespace Utils;
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
class BareMetalCustomRunConfigWidget : public ProjectExplorer::RunConfigWidget
class BareMetalCustomRunConfigWidget : public RunConfigWidget
{
Q_OBJECT
public:
BareMetalCustomRunConfigWidget(BareMetalCustomRunConfiguration *runConfig)
: m_runConfig(runConfig)
......@@ -67,28 +71,21 @@ public:
auto executableChooser = new PathChooser;
executableChooser->setExpectedKind(PathChooser::File);
executableChooser->setPath(m_runConfig->localExecutableFilePath());
auto argumentsLabel = new QLabel(tr("Arguments:"));
auto arguments = new QLineEdit();
arguments->setText(m_runConfig->arguments());
auto wdirLabel = new QLabel(tr("Work directory:"));
auto workdirChooser = new PathChooser;
workdirChooser->setExpectedKind(PathChooser::Directory);
workdirChooser->setPath(m_runConfig->workingDirectory());
auto clayout = new QGridLayout(this);
auto clayout = new QFormLayout(this);
detailsWidget->setLayout(clayout);
clayout->addWidget(exeLabel, 0, 0);
clayout->addWidget(executableChooser, 0, 1);
clayout->addWidget(argumentsLabel, 1, 0);
clayout->addWidget(arguments, 1, 1);
clayout->addWidget(wdirLabel, 2, 0);
clayout->addWidget(workdirChooser, 2, 1);
clayout->addRow(exeLabel, executableChooser);
runConfig->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, clayout);
clayout->addRow(wdirLabel, workdirChooser);
connect(executableChooser, &PathChooser::pathChanged,
this, &BareMetalCustomRunConfigWidget::handleLocalExecutableChanged);
connect(arguments, &QLineEdit::textChanged,
this, &BareMetalCustomRunConfigWidget::handleArgumentsChanged);
connect(workdirChooser, &PathChooser::pathChanged,
this, &BareMetalCustomRunConfigWidget::handleWorkingDirChanged);
connect(this, &BareMetalCustomRunConfigWidget::setWorkdir,
......@@ -109,11 +106,6 @@ private:
}
}
void handleArgumentsChanged(const QString &arguments)
{
m_runConfig->setArguments(arguments.trimmed());
}
void handleWorkingDirChanged(const QString &wd)
{
m_runConfig->setWorkingDirectory(wd.trimmed());
......
......@@ -36,6 +36,7 @@
#include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/deploymentdata.h>
#include <projectexplorer/project.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtoutputformatter.h>
......@@ -45,7 +46,6 @@ using namespace Utils;
namespace BareMetal {
namespace Internal {
const char ArgumentsKey[] = "Qt4ProjectManager.MaemoRunConfiguration.Arguments";
const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile";
const char WorkingDirectoryKey[] = "BareMetal.RunConfig.WorkingDirectory";
......@@ -53,7 +53,6 @@ const char WorkingDirectoryKey[] = "BareMetal.RunConfig.WorkingDirectory";
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRunConfiguration *other)
: RunConfiguration(parent, other),
m_projectFilePath(other->m_projectFilePath),
m_arguments(other->m_arguments),
m_workingDirectory(other->m_workingDirectory)
{
init();
......@@ -65,6 +64,7 @@ BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent,
: RunConfiguration(parent, id),
m_projectFilePath(projectFilePath)
{
addExtraAspect(new ArgumentsAspect(this, QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.Arguments")));
init();
}
......@@ -104,7 +104,6 @@ OutputFormatter *BareMetalRunConfiguration::createOutputFormatter() const
QVariantMap BareMetalRunConfiguration::toMap() const
{
QVariantMap map(RunConfiguration::toMap());
map.insert(QLatin1String(ArgumentsKey), m_arguments);
const QDir dir = QDir(target()->project()->projectDirectory().toString());
map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(m_projectFilePath));
map.insert(QLatin1String(WorkingDirectoryKey), m_workingDirectory);
......@@ -116,7 +115,6 @@ bool BareMetalRunConfiguration::fromMap(const QVariantMap &map)
if (!RunConfiguration::fromMap(map))
return false;
m_arguments = map.value(QLatin1String(ArgumentsKey)).toString();
const QDir dir = QDir(target()->project()->projectDirectory().toString());
m_projectFilePath
= QDir::cleanPath(dir.filePath(map.value(QLatin1String(ProFileKey)).toString()));
......@@ -144,12 +142,7 @@ QString BareMetalRunConfiguration::localExecutableFilePath() const
QString BareMetalRunConfiguration::arguments() const
{
return m_arguments;
}
void BareMetalRunConfiguration::setArguments(const QString &args)
{
m_arguments = args;
return extraAspect<ArgumentsAspect>()->arguments();
}
QString BareMetalRunConfiguration::workingDirectory() const
......
......@@ -57,7 +57,6 @@ public:
virtual QString localExecutableFilePath() const;
QString arguments() const;
void setArguments(const QString &args);
QString workingDirectory() const;
void setWorkingDirectory(const QString &wd);
......@@ -87,7 +86,6 @@ private:
void init();
QString m_projectFilePath;
QString m_arguments;
mutable QString m_disabledReason;
QString m_workingDirectory;
};
......
......@@ -32,6 +32,7 @@
#include "baremetalrunconfiguration.h"
#include <coreplugin/coreicons.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <utils/detailswidget.h>
#include <QLineEdit>
......@@ -40,6 +41,8 @@
#include <QCoreApplication>
#include <QDir>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
......@@ -54,7 +57,6 @@ public:
QWidget topWidget;
QLabel disabledIcon;
QLabel disabledReason;
QLineEdit argsLineEdit;
QLineEdit workingDirLineEdit;
QLabel localExecutableLabel;
QFormLayout genericWidgetsLayout;
......@@ -74,32 +76,7 @@ BareMetalRunConfigurationWidget::BareMetalRunConfigurationWidget(BareMetalRunCon
topLayout->addWidget(&d->topWidget);
QVBoxLayout *mainLayout = new QVBoxLayout(&d->topWidget);
mainLayout->setMargin(0);
addGenericWidgets(mainLayout);
connect(d->runConfiguration, &ProjectExplorer::RunConfiguration::enabledChanged,
this, &BareMetalRunConfigurationWidget::runConfigurationEnabledChange);
runConfigurationEnabledChange();
}
BareMetalRunConfigurationWidget::~BareMetalRunConfigurationWidget()
{
delete d;
}
void BareMetalRunConfigurationWidget::addDisabledLabel(QVBoxLayout *topLayout)
{
QHBoxLayout * const hl = new QHBoxLayout;
hl->addStretch();
d->disabledIcon.setPixmap(Core::Icons::WARNING.pixmap());
hl->addWidget(&d->disabledIcon);
d->disabledReason.setVisible(false);
hl->addWidget(&d->disabledReason);
hl->addStretch();
topLayout->addLayout(hl);
}
void BareMetalRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
{
Utils::DetailsWidget *detailsContainer = new Utils::DetailsWidget(this);
detailsContainer->setState(Utils::DetailsWidget::NoSummary);
......@@ -116,23 +93,35 @@ void BareMetalRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
//d->genericWidgetsLayout.addRow(tr("Debugger host:"),d->runConfiguration);
//d->genericWidgetsLayout.addRow(tr("Debugger port:"),d->runConfiguration);
d->argsLineEdit.setText(d->runConfiguration->arguments());
d->genericWidgetsLayout.addRow(tr("Arguments:"), &d->argsLineEdit);
runConfiguration->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, &d->genericWidgetsLayout);
d->workingDirLineEdit.setPlaceholderText(tr("<default>"));
d->workingDirLineEdit.setText(d->runConfiguration->workingDirectory());
d->genericWidgetsLayout.addRow(tr("Working directory:"), &d->workingDirLineEdit);
connect(&d->argsLineEdit, &QLineEdit::textEdited,
this, &BareMetalRunConfigurationWidget::argumentsEdited);
connect(d->runConfiguration, &BareMetalRunConfiguration::targetInformationChanged,
this, &BareMetalRunConfigurationWidget::updateTargetInformation);
connect(&d->workingDirLineEdit, &QLineEdit::textEdited,
this, &BareMetalRunConfigurationWidget::handleWorkingDirectoryChanged);
connect(d->runConfiguration, &ProjectExplorer::RunConfiguration::enabledChanged,
this, &BareMetalRunConfigurationWidget::runConfigurationEnabledChange);
runConfigurationEnabledChange();
}
BareMetalRunConfigurationWidget::~BareMetalRunConfigurationWidget()
{
delete d;
}
void BareMetalRunConfigurationWidget::argumentsEdited(const QString &args)
void BareMetalRunConfigurationWidget::addDisabledLabel(QVBoxLayout *topLayout)
{
d->runConfiguration->setArguments(args);
QHBoxLayout * const hl = new QHBoxLayout;
hl->addStretch();
d->disabledIcon.setPixmap(Core::Icons::WARNING.pixmap());
hl->addWidget(&d->disabledIcon);
d->disabledReason.setVisible(false);
hl->addWidget(&d->disabledReason);
hl->addStretch();
topLayout->addLayout(hl);
}
void BareMetalRunConfigurationWidget::updateTargetInformation()
......
......@@ -57,12 +57,10 @@ public:
Q_SLOT void runConfigurationEnabledChange();
private slots:
void argumentsEdited(const QString &args);
void updateTargetInformation();
void handleWorkingDirectoryChanged();
private:
void addGenericWidgets(QVBoxLayout *mainLayout);
void setLabelText(QLabel &label, const QString &regularText, const QString &errorText);
BareMetalRunConfigurationWidgetPrivate * const d;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment