forked from qt-creator/qt-creator
Ios: use ArgumentsAspect in IosRunConfiguration
Change-Id: I9f2f0eacf5fca155912eb4417d2ac89afcf64901 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
@@ -81,7 +81,7 @@ RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runC
|
|||||||
return 0;
|
return 0;
|
||||||
AnalyzerStartParameters params;
|
AnalyzerStartParameters params;
|
||||||
params.debuggee = runConfig->localExecutable().toUserOutput();
|
params.debuggee = runConfig->localExecutable().toUserOutput();
|
||||||
params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments());
|
params.debuggeeArgs = runConfig->commandLineArguments();
|
||||||
params.analyzerHost = QLatin1String("localhost");
|
params.analyzerHost = QLatin1String("localhost");
|
||||||
if (device->type() == Core::Id(Ios::Constants::IOS_DEVICE_TYPE)) {
|
if (device->type() == Core::Id(Ios::Constants::IOS_DEVICE_TYPE)) {
|
||||||
IosDevice::ConstPtr iosDevice = device.dynamicCast<const IosDevice>();
|
IosDevice::ConstPtr iosDevice = device.dynamicCast<const IosDevice>();
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||||
#include <projectexplorer/buildstep.h>
|
#include <projectexplorer/buildstep.h>
|
||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
#include <qmakeprojectmanager/qmakebuildconfiguration.h>
|
#include <qmakeprojectmanager/qmakebuildconfiguration.h>
|
||||||
#include <qmakeprojectmanager/qmakeproject.h>
|
#include <qmakeprojectmanager/qmakeproject.h>
|
||||||
#include <qmakeprojectmanager/qmakenodes.h>
|
#include <qmakeprojectmanager/qmakenodes.h>
|
||||||
@@ -68,15 +69,12 @@ using namespace Utils;
|
|||||||
namespace Ios {
|
namespace Ios {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static const QLatin1String runConfigurationKey("Ios.run_arguments");
|
|
||||||
static const QLatin1String deviceTypeKey("Ios.device_type");
|
static const QLatin1String deviceTypeKey("Ios.device_type");
|
||||||
|
|
||||||
class IosRunConfigurationWidget : public RunConfigWidget
|
class IosRunConfigurationWidget : public RunConfigWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IosRunConfigurationWidget(IosRunConfiguration *runConfiguration);
|
IosRunConfigurationWidget(IosRunConfiguration *runConfiguration);
|
||||||
QString argListToString(const QStringList &args) const;
|
|
||||||
QStringList stringToArgList(const QString &args) const;
|
|
||||||
QString displayName() const override;
|
QString displayName() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -88,7 +86,6 @@ private:
|
|||||||
QStandardItemModel m_deviceTypeModel;
|
QStandardItemModel m_deviceTypeModel;
|
||||||
QLabel *m_deviceTypeLabel;
|
QLabel *m_deviceTypeLabel;
|
||||||
QLineEdit *m_executableLineEdit;
|
QLineEdit *m_executableLineEdit;
|
||||||
QLineEdit *m_argumentsLineEdit;
|
|
||||||
QComboBox *m_deviceTypeComboBox;
|
QComboBox *m_deviceTypeComboBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -96,13 +93,13 @@ IosRunConfiguration::IosRunConfiguration(Target *parent, Core::Id id, const File
|
|||||||
: RunConfiguration(parent, id)
|
: RunConfiguration(parent, id)
|
||||||
, m_profilePath(path)
|
, m_profilePath(path)
|
||||||
{
|
{
|
||||||
|
addExtraAspect(new ArgumentsAspect(this, QLatin1String("Ios.run_arguments")));
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
IosRunConfiguration::IosRunConfiguration(Target *parent, IosRunConfiguration *source)
|
IosRunConfiguration::IosRunConfiguration(Target *parent, IosRunConfiguration *source)
|
||||||
: RunConfiguration(parent, source)
|
: RunConfiguration(parent, source)
|
||||||
, m_profilePath(source->m_profilePath)
|
, m_profilePath(source->m_profilePath)
|
||||||
, m_arguments(source->m_arguments)
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -163,9 +160,9 @@ OutputFormatter *IosRunConfiguration::createOutputFormatter() const
|
|||||||
return new QtSupport::QtOutputFormatter(target()->project());
|
return new QtSupport::QtOutputFormatter(target()->project());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList IosRunConfiguration::commandLineArguments()
|
QString IosRunConfiguration::commandLineArguments() const
|
||||||
{
|
{
|
||||||
return m_arguments;
|
return extraAspect<ArgumentsAspect>()->arguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IosRunConfiguration::updateDisplayNames()
|
void IosRunConfiguration::updateDisplayNames()
|
||||||
@@ -274,7 +271,6 @@ FileName IosRunConfiguration::localExecutable() const
|
|||||||
|
|
||||||
bool IosRunConfiguration::fromMap(const QVariantMap &map)
|
bool IosRunConfiguration::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_arguments = map.value(runConfigurationKey).toStringList();
|
|
||||||
bool deviceTypeIsInt;
|
bool deviceTypeIsInt;
|
||||||
map.value(deviceTypeKey).toInt(&deviceTypeIsInt);
|
map.value(deviceTypeKey).toInt(&deviceTypeIsInt);
|
||||||
if (deviceTypeIsInt || !m_deviceType.fromMap(map.value(deviceTypeKey).toMap())) {
|
if (deviceTypeIsInt || !m_deviceType.fromMap(map.value(deviceTypeKey).toMap())) {
|
||||||
@@ -289,7 +285,6 @@ bool IosRunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
QVariantMap IosRunConfiguration::toMap() const
|
QVariantMap IosRunConfiguration::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap res = RunConfiguration::toMap();
|
QVariantMap res = RunConfiguration::toMap();
|
||||||
res[runConfigurationKey] = m_arguments;
|
|
||||||
res[deviceTypeKey] = deviceType().toMap();
|
res[deviceTypeKey] = deviceType().toMap();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -398,8 +393,6 @@ IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runCon
|
|||||||
sizePolicy.setVerticalStretch(0);
|
sizePolicy.setVerticalStretch(0);
|
||||||
setSizePolicy(sizePolicy);
|
setSizePolicy(sizePolicy);
|
||||||
|
|
||||||
m_argumentsLineEdit = new QLineEdit(this);
|
|
||||||
|
|
||||||
m_executableLineEdit = new QLineEdit(this);
|
m_executableLineEdit = new QLineEdit(this);
|
||||||
m_executableLineEdit->setReadOnly(true);
|
m_executableLineEdit->setReadOnly(true);
|
||||||
|
|
||||||
@@ -409,7 +402,7 @@ IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runCon
|
|||||||
m_deviceTypeLabel = new QLabel(IosRunConfiguration::tr("Device type:"), this);
|
m_deviceTypeLabel = new QLabel(IosRunConfiguration::tr("Device type:"), this);
|
||||||
|
|
||||||
auto layout = new QFormLayout(this);
|
auto layout = new QFormLayout(this);
|
||||||
layout->addRow(IosRunConfiguration::tr("Arguments:"), m_argumentsLineEdit);
|
runConfiguration->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, layout);
|
||||||
layout->addRow(IosRunConfiguration::tr("Executable:"), m_executableLineEdit);
|
layout->addRow(IosRunConfiguration::tr("Executable:"), m_executableLineEdit);
|
||||||
layout->addRow(m_deviceTypeLabel, m_deviceTypeComboBox);
|
layout->addRow(m_deviceTypeLabel, m_deviceTypeComboBox);
|
||||||
|
|
||||||
@@ -417,59 +410,15 @@ IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runCon
|
|||||||
|
|
||||||
connect(m_deviceTypeComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(m_deviceTypeComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
this, &IosRunConfigurationWidget::setDeviceTypeIndex);
|
this, &IosRunConfigurationWidget::setDeviceTypeIndex);
|
||||||
connect(m_argumentsLineEdit, &QLineEdit::editingFinished,
|
|
||||||
this, &IosRunConfigurationWidget::argumentsLineEditTextEdited);
|
|
||||||
connect(runConfiguration, &IosRunConfiguration::localExecutableChanged,
|
connect(runConfiguration, &IosRunConfiguration::localExecutableChanged,
|
||||||
this, &IosRunConfigurationWidget::updateValues);
|
this, &IosRunConfigurationWidget::updateValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IosRunConfigurationWidget::argListToString(const QStringList &args) const
|
|
||||||
{
|
|
||||||
return QtcProcess::joinArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList IosRunConfigurationWidget::stringToArgList(const QString &args) const
|
|
||||||
{
|
|
||||||
QtcProcess::SplitError err;
|
|
||||||
QStringList res = QtcProcess::splitArgs(args, OsTypeMac, false, &err);
|
|
||||||
switch (err) {
|
|
||||||
case QtcProcess::SplitOk:
|
|
||||||
break;
|
|
||||||
case QtcProcess::BadQuoting:
|
|
||||||
if (args.at(args.size()-1) == QLatin1Char('\\')) {
|
|
||||||
res = QtcProcess::splitArgs(args + QLatin1Char('\\'), OsTypeMac, false, &err);
|
|
||||||
if (err != QtcProcess::SplitOk)
|
|
||||||
res = QtcProcess::splitArgs(args + QLatin1Char('\\') + QLatin1Char('\''),
|
|
||||||
OsTypeMac, false, &err);
|
|
||||||
if (err != QtcProcess::SplitOk)
|
|
||||||
res = QtcProcess::splitArgs(args + QLatin1Char('\\') + QLatin1Char('\"'),
|
|
||||||
OsTypeMac, false, &err);
|
|
||||||
}
|
|
||||||
if (err != QtcProcess::SplitOk)
|
|
||||||
res = QtcProcess::splitArgs(args + QLatin1Char('\''), OsTypeMac, false, &err);
|
|
||||||
if (err != QtcProcess::SplitOk)
|
|
||||||
res = QtcProcess::splitArgs(args + QLatin1Char('\"'), OsTypeMac, false, &err);
|
|
||||||
break;
|
|
||||||
case QtcProcess::FoundMeta:
|
|
||||||
qCWarning(iosLog) << "IosRunConfigurationWidget FoundMeta (should not happen)";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString IosRunConfigurationWidget::displayName() const
|
QString IosRunConfigurationWidget::displayName() const
|
||||||
{
|
{
|
||||||
return tr("iOS run settings");
|
return tr("iOS run settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IosRunConfigurationWidget::argumentsLineEditTextEdited()
|
|
||||||
{
|
|
||||||
QString argsString = m_argumentsLineEdit->text();
|
|
||||||
QStringList args = stringToArgList(argsString);
|
|
||||||
m_runConfiguration->m_arguments = args;
|
|
||||||
m_argumentsLineEdit->setText(argListToString(args));
|
|
||||||
}
|
|
||||||
|
|
||||||
void IosRunConfigurationWidget::setDeviceTypeIndex(int devIndex)
|
void IosRunConfigurationWidget::setDeviceTypeIndex(int devIndex)
|
||||||
{
|
{
|
||||||
QVariant selectedDev = m_deviceTypeModel.data(m_deviceTypeModel.index(devIndex, 0), Qt::UserRole + 1);
|
QVariant selectedDev = m_deviceTypeModel.data(m_deviceTypeModel.index(devIndex, 0), Qt::UserRole + 1);
|
||||||
@@ -492,8 +441,6 @@ void IosRunConfigurationWidget::updateValues()
|
|||||||
m_deviceTypeModel.appendRow(item);
|
m_deviceTypeModel.appendRow(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QStringList args = m_runConfiguration->commandLineArguments();
|
|
||||||
QString argsString = argListToString(args);
|
|
||||||
|
|
||||||
IosDeviceType currentDType = m_runConfiguration->deviceType();
|
IosDeviceType currentDType = m_runConfiguration->deviceType();
|
||||||
if (currentDType.type == IosDeviceType::SimulatedDevice && !currentDType.identifier.isEmpty()
|
if (currentDType.type == IosDeviceType::SimulatedDevice && !currentDType.identifier.isEmpty()
|
||||||
@@ -514,7 +461,6 @@ void IosRunConfigurationWidget::updateValues()
|
|||||||
qCWarning(iosLog) << "could not set " << currentDType << " as it is not in model";
|
qCWarning(iosLog) << "could not set " << currentDType << " as it is not in model";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_argumentsLineEdit->setText(argsString);
|
|
||||||
m_executableLineEdit->setText(m_runConfiguration->localExecutable().toUserOutput());
|
m_executableLineEdit->setText(m_runConfiguration->localExecutable().toUserOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,7 +60,7 @@ public:
|
|||||||
Utils::OutputFormatter *createOutputFormatter() const override;
|
Utils::OutputFormatter *createOutputFormatter() const override;
|
||||||
IosDeployStep *deployStep() const;
|
IosDeployStep *deployStep() const;
|
||||||
|
|
||||||
QStringList commandLineArguments();
|
QString commandLineArguments() const;
|
||||||
Utils::FileName profilePath() const;
|
Utils::FileName profilePath() const;
|
||||||
QString applicationName() const;
|
QString applicationName() const;
|
||||||
Utils::FileName bundleDirectory() const;
|
Utils::FileName bundleDirectory() const;
|
||||||
@@ -88,7 +88,6 @@ private:
|
|||||||
void updateDisplayNames();
|
void updateDisplayNames();
|
||||||
|
|
||||||
Utils::FileName m_profilePath;
|
Utils::FileName m_profilePath;
|
||||||
QStringList m_arguments;
|
|
||||||
QString m_lastDisabledReason;
|
QString m_lastDisabledReason;
|
||||||
bool m_lastIsEnabled;
|
bool m_lastIsEnabled;
|
||||||
bool m_parseInProgress;
|
bool m_parseInProgress;
|
||||||
|
Reference in New Issue
Block a user