forked from qt-creator/qt-creator
ios: make device simulated configurable in runconfiguration
Change-Id: I54bcbd7f2142ab95618005f1f108a122bfe18d32 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -56,7 +56,8 @@ using namespace Utils;
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
const QLatin1String runConfigurationKey("Ios.run_arguments");
|
||||
static const QLatin1String runConfigurationKey("Ios.run_arguments");
|
||||
static const QLatin1String deviceTypeKey("Ios.device_type");
|
||||
|
||||
class IosRunConfigurationWidget : public RunConfigWidget
|
||||
{
|
||||
@@ -72,7 +73,7 @@ public:
|
||||
private slots:
|
||||
void argumentsLineEditTextEdited();
|
||||
void updateValues();
|
||||
|
||||
void setDeviceTypeIndex(int devIndex);
|
||||
private:
|
||||
Ui::IosRunConfiguration *m_ui;
|
||||
IosRunConfiguration *m_runConfiguration;
|
||||
@@ -100,6 +101,10 @@ void IosRunConfiguration::init()
|
||||
m_parseInProgress = project->parseInProgress(m_profilePath);
|
||||
m_lastIsEnabled = isEnabled();
|
||||
m_lastDisabledReason = disabledReason();
|
||||
if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) == Constants::IOS_DEVICE_TYPE)
|
||||
m_deviceType = IosDeviceType::IosDevice;
|
||||
else
|
||||
m_deviceType = IosDeviceType::SimulatedIphoneRetina4Inch;
|
||||
updateDisplayNames();
|
||||
connect(DeviceManager::instance(), SIGNAL(updated()),
|
||||
SLOT(deviceChanges()));
|
||||
@@ -255,6 +260,15 @@ Utils::FileName IosRunConfiguration::exePath() const
|
||||
bool IosRunConfiguration::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_arguments = map.value(runConfigurationKey).toStringList();
|
||||
IosDeviceType::Enum deviceType = static_cast<IosDeviceType::Enum>(map.value(deviceTypeKey)
|
||||
.toInt());
|
||||
bool valid = false;
|
||||
for (int i = 0 ; i < nSimulatedDevices; ++i)
|
||||
if (simulatedDevices[i] == m_deviceType)
|
||||
valid = true;
|
||||
if (valid)
|
||||
m_deviceType = deviceType;
|
||||
|
||||
return RunConfiguration::fromMap(map);
|
||||
}
|
||||
|
||||
@@ -262,6 +276,7 @@ QVariantMap IosRunConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap res = RunConfiguration::toMap();
|
||||
res[runConfigurationKey] = m_arguments;
|
||||
res[deviceTypeKey] = m_deviceType;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -335,12 +350,28 @@ QString IosRunConfiguration::disabledReason() const
|
||||
return RunConfiguration::disabledReason();
|
||||
}
|
||||
|
||||
IosDeviceType::Enum IosRunConfiguration::deviceType() const
|
||||
{
|
||||
return m_deviceType;
|
||||
}
|
||||
|
||||
void IosRunConfiguration::setDeviceType(IosDeviceType::Enum deviceType)
|
||||
{
|
||||
m_deviceType = deviceType;
|
||||
}
|
||||
|
||||
IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runConfiguration) :
|
||||
m_ui(new Ui::IosRunConfiguration), m_runConfiguration(runConfiguration)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
if (m_runConfiguration->deviceType() == IosDeviceType::IosDevice) {
|
||||
m_ui->deviceTypeLabel->setVisible(false);
|
||||
m_ui->deviceTypeComboBox->setVisible(false);
|
||||
}
|
||||
|
||||
updateValues();
|
||||
connect(m_ui->deviceTypeComboBox, SIGNAL(currentIndexChanged(int)),
|
||||
SLOT(setDeviceTypeIndex(int)));
|
||||
connect(m_ui->argumentsLineEdit, SIGNAL(editingFinished()),
|
||||
SLOT(argumentsLineEditTextEdited()));
|
||||
connect(runConfiguration->target(), SIGNAL(buildDirectoryChanged()),
|
||||
@@ -399,10 +430,24 @@ void IosRunConfigurationWidget::argumentsLineEditTextEdited()
|
||||
m_ui->argumentsLineEdit->setText(argListToString(args));
|
||||
}
|
||||
|
||||
void IosRunConfigurationWidget::setDeviceTypeIndex(int devIndex)
|
||||
{
|
||||
if (devIndex >= 0 && devIndex < nSimulatedDevices)
|
||||
m_runConfiguration->setDeviceType(simulatedDevices[devIndex]);
|
||||
else
|
||||
m_runConfiguration->setDeviceType(IosDeviceType::SimulatedIphoneRetina4Inch);
|
||||
}
|
||||
|
||||
|
||||
void IosRunConfigurationWidget::updateValues()
|
||||
{
|
||||
QStringList args = m_runConfiguration->m_arguments;
|
||||
QStringList args = m_runConfiguration->commandLineArguments();
|
||||
QString argsString = argListToString(args);
|
||||
|
||||
if (m_runConfiguration->deviceType() == IosDeviceType::IosDevice)
|
||||
for (int i = 0; i < nSimulatedDevices; ++i)
|
||||
if (simulatedDevices[i] == m_runConfiguration->deviceType())
|
||||
m_ui->deviceTypeComboBox->setCurrentIndex(i);
|
||||
m_ui->argumentsLineEdit->setText(argsString);
|
||||
m_ui->executableLineEdit->setText(m_runConfiguration->exePath().toUserOutput());
|
||||
}
|
||||
|
Reference in New Issue
Block a user