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:
@@ -34,16 +34,19 @@
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
enum IosQemuStatus {
|
||||
IosQemuStarting,
|
||||
IosQemuFailedToStart,
|
||||
IosQemuFinished,
|
||||
IosQemuCrashed,
|
||||
IosQemuUserReason
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
namespace IosDeviceType {
|
||||
enum Enum {
|
||||
IosDevice,
|
||||
SimulatedIphone,
|
||||
SimulatedIpad,
|
||||
SimulatedIphoneRetina4Inch,
|
||||
SimulatedIphoneRetina3_5Inch,
|
||||
SimulatedIpadRetina
|
||||
};
|
||||
}
|
||||
|
||||
namespace Constants {
|
||||
const char IOS_SETTINGS_ID[] = "ZZ.Ios Configurations";
|
||||
const char IOS_SETTINGS_CATEGORY[] = "XA.Ios";
|
||||
|
||||
@@ -113,7 +113,7 @@ void IosDeployStep::run(QFutureInterface<bool> &fi)
|
||||
}
|
||||
m_transferStatus = TransferInProgress;
|
||||
QTC_CHECK(m_toolHandler == 0);
|
||||
m_toolHandler = new IosToolHandler(IosToolHandler::IosDeviceType, this);
|
||||
m_toolHandler = new IosToolHandler(IosDeviceType::IosDevice, this);
|
||||
m_futureInterface.setProgressRange(0, 200);
|
||||
m_futureInterface.setProgressValueAndText(0, QLatin1String("Transferring application"));
|
||||
m_futureInterface.reportStarted();
|
||||
|
||||
@@ -292,7 +292,7 @@ void IosDeviceManager::deviceDisconnected(const QString &uid)
|
||||
|
||||
void IosDeviceManager::updateInfo(const QString &devId)
|
||||
{
|
||||
IosToolHandler *requester = new IosToolHandler(IosToolHandler::IosDeviceType, this);
|
||||
IosToolHandler *requester = new IosToolHandler(IosDeviceType::IosDevice, this);
|
||||
connect(requester, SIGNAL(deviceInfo(Ios::IosToolHandler*,QString,Ios::IosToolHandler::Dict)),
|
||||
SLOT(deviceInfo(Ios::IosToolHandler*,QString,Ios::IosToolHandler::Dict)), Qt::QueuedConnection);
|
||||
connect(requester, SIGNAL(finished(Ios::IosToolHandler*)),
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -43,6 +43,16 @@ class QmakeProFileNode;
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
enum { nSimulatedDevices = 4 };
|
||||
static const IosDeviceType::Enum simulatedDevices[nSimulatedDevices] = {
|
||||
// skip iPhone as it does not support iOS7
|
||||
// TODO: clean solution would be to check also sdk version or make it configurable
|
||||
IosDeviceType::SimulatedIphoneRetina3_5Inch,
|
||||
IosDeviceType::SimulatedIphoneRetina4Inch,
|
||||
IosDeviceType::SimulatedIpad,
|
||||
IosDeviceType::SimulatedIpadRetina
|
||||
};
|
||||
|
||||
class IosDeployStep;
|
||||
class IosRunConfigurationFactory;
|
||||
class IosRunConfigurationWidget;
|
||||
@@ -66,6 +76,8 @@ public:
|
||||
Utils::FileName exePath() const;
|
||||
bool isEnabled() const;
|
||||
QString disabledReason() const;
|
||||
IosDeviceType::Enum deviceType() const;
|
||||
void setDeviceType(IosDeviceType::Enum deviceType);
|
||||
|
||||
bool fromMap(const QVariantMap &map) QTC_OVERRIDE;
|
||||
QVariantMap toMap() const QTC_OVERRIDE;
|
||||
@@ -88,6 +100,7 @@ private:
|
||||
bool m_lastIsEnabled;
|
||||
bool m_parseInProgress;
|
||||
bool m_parseSuccess;
|
||||
IosDeviceType::Enum m_deviceType;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>571</width>
|
||||
<height>76</height>
|
||||
<height>106</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -23,6 +23,13 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="argumentsLineEdit"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="executableLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="argumentsLabel">
|
||||
<property name="text">
|
||||
@@ -37,10 +44,34 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="executableLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="deviceTypeComboBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>iPhone 3.5-inch Retina display</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>iPhone 4-inch Retina display</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>iPad</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>iPad Retina display</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="deviceTypeLabel">
|
||||
<property name="text">
|
||||
<string>Device Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "iosrunconfiguration.h"
|
||||
#include "iosrunner.h"
|
||||
#include "iossimulator.h"
|
||||
#include "iosconstants.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/deviceapplicationrunner.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
@@ -61,6 +62,7 @@ IosRunner::IosRunner(QObject *parent, IosRunConfiguration *runConfig, bool cppDe
|
||||
m_cppDebug(cppDebug), m_qmlDebug(qmlDebug), m_cleanExit(false),
|
||||
m_qmlPort(0), m_pid(0)
|
||||
{
|
||||
m_deviceType = runConfig->deviceType();
|
||||
}
|
||||
|
||||
IosRunner::~IosRunner()
|
||||
@@ -121,7 +123,6 @@ void IosRunner::start()
|
||||
emit finished(m_cleanExit);
|
||||
return;
|
||||
}
|
||||
IosToolHandler::DeviceType devType = IosToolHandler::IosDeviceType;
|
||||
if (m_device->type() == Ios::Constants::IOS_DEVICE_TYPE) {
|
||||
IosDevice::ConstPtr iosDevice = m_device.dynamicCast<const IosDevice>();
|
||||
if (m_device.isNull()) {
|
||||
@@ -136,12 +137,11 @@ void IosRunner::start()
|
||||
emit finished(m_cleanExit);
|
||||
return;
|
||||
}
|
||||
devType = IosToolHandler::IosSimulatedIphoneRetina4InchType; // store type in sim?
|
||||
if (m_qmlDebug)
|
||||
m_qmlPort = sim->nextPort();
|
||||
}
|
||||
|
||||
m_toolHandler = new IosToolHandler(devType, this);
|
||||
m_toolHandler = new IosToolHandler(m_deviceType, this);
|
||||
connect(m_toolHandler, SIGNAL(appOutput(Ios::IosToolHandler*,QString)),
|
||||
SLOT(handleAppOutput(Ios::IosToolHandler*,QString)));
|
||||
connect(m_toolHandler,
|
||||
|
||||
@@ -30,14 +30,16 @@
|
||||
#define IOSRUNNER_H
|
||||
|
||||
#include "iosconfigurations.h"
|
||||
#include "iostoolhandler.h"
|
||||
#include "iosconstants.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
#include <QProcess>
|
||||
#include <QMutex>
|
||||
#include "iostoolhandler.h"
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
@@ -87,6 +89,7 @@ private:
|
||||
QString m_bundleDir;
|
||||
QStringList m_arguments;
|
||||
ProjectExplorer::IDevice::ConstPtr m_device;
|
||||
IosDeviceType::Enum m_deviceType;
|
||||
bool m_cppDebug;
|
||||
bool m_qmlDebug;
|
||||
bool m_cleanExit;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "iostoolhandler.h"
|
||||
#include "iosconfigurations.h"
|
||||
#include "iosconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -124,7 +125,7 @@ public:
|
||||
OpAppRun
|
||||
};
|
||||
|
||||
explicit IosToolHandlerPrivate(IosToolHandler::DeviceType devType, IosToolHandler *q);
|
||||
explicit IosToolHandlerPrivate(IosDeviceType::Enum devType, IosToolHandler *q);
|
||||
virtual ~IosToolHandlerPrivate() {}
|
||||
virtual void requestTransferApp(const QString &bundlePath, const QString &deviceId,
|
||||
int timeout = 1000) = 0;
|
||||
@@ -168,7 +169,7 @@ protected:
|
||||
IosToolHandler::RunKind runKind;
|
||||
State state;
|
||||
Op op;
|
||||
IosToolHandler::DeviceType devType;
|
||||
IosDeviceType::Enum devType;
|
||||
static const int lookaheadSize = 67;
|
||||
int iBegin, iEnd, gdbSocket;
|
||||
QList<ParserState> stack;
|
||||
@@ -177,7 +178,7 @@ protected:
|
||||
class IosDeviceToolHandlerPrivate : public IosToolHandlerPrivate
|
||||
{
|
||||
public:
|
||||
explicit IosDeviceToolHandlerPrivate(IosToolHandler::DeviceType devType, IosToolHandler *q);
|
||||
explicit IosDeviceToolHandlerPrivate(IosDeviceType::Enum devType, IosToolHandler *q);
|
||||
virtual void requestTransferApp(const QString &bundlePath, const QString &deviceId,
|
||||
int timeout = 1000);
|
||||
virtual void requestRunApp(const QString &bundlePath, const QStringList &extraArgs,
|
||||
@@ -190,7 +191,7 @@ public:
|
||||
class IosSimulatorToolHandlerPrivate : public IosToolHandlerPrivate
|
||||
{
|
||||
public:
|
||||
explicit IosSimulatorToolHandlerPrivate(IosToolHandler::DeviceType devType, IosToolHandler *q);
|
||||
explicit IosSimulatorToolHandlerPrivate(IosDeviceType::Enum devType, IosToolHandler *q);
|
||||
virtual void requestTransferApp(const QString &bundlePath, const QString &deviceId,
|
||||
int timeout = 1000);
|
||||
virtual void requestRunApp(const QString &bundlePath, const QStringList &extraArgs,
|
||||
@@ -202,7 +203,7 @@ private:
|
||||
void addDeviceArguments(QStringList &args) const;
|
||||
};
|
||||
|
||||
IosToolHandlerPrivate::IosToolHandlerPrivate(IosToolHandler::DeviceType devType,
|
||||
IosToolHandlerPrivate::IosToolHandlerPrivate(IosDeviceType::Enum devType,
|
||||
Ios::IosToolHandler *q) :
|
||||
q(q), state(NonStarted), devType(devType), iBegin(0), iEnd(0),
|
||||
gdbSocket(-1)
|
||||
@@ -576,7 +577,7 @@ void IosToolHandlerPrivate::subprocessHasData()
|
||||
|
||||
// IosDeviceToolHandlerPrivate
|
||||
|
||||
IosDeviceToolHandlerPrivate::IosDeviceToolHandlerPrivate(IosToolHandler::DeviceType devType,
|
||||
IosDeviceToolHandlerPrivate::IosDeviceToolHandlerPrivate(IosDeviceType::Enum devType,
|
||||
IosToolHandler *q)
|
||||
: IosToolHandlerPrivate(devType, q)
|
||||
{ }
|
||||
@@ -635,7 +636,7 @@ bool IosDeviceToolHandlerPrivate::expectsFileDescriptor()
|
||||
|
||||
// IosSimulatorToolHandlerPrivate
|
||||
|
||||
IosSimulatorToolHandlerPrivate::IosSimulatorToolHandlerPrivate(IosToolHandler::DeviceType devType,
|
||||
IosSimulatorToolHandlerPrivate::IosSimulatorToolHandlerPrivate(IosDeviceType::Enum devType,
|
||||
IosToolHandler *q)
|
||||
: IosToolHandlerPrivate(devType, q)
|
||||
{ }
|
||||
@@ -695,23 +696,23 @@ bool IosSimulatorToolHandlerPrivate::expectsFileDescriptor()
|
||||
void IosSimulatorToolHandlerPrivate::addDeviceArguments(QStringList &args) const
|
||||
{
|
||||
switch (devType) {
|
||||
case IosToolHandler::IosDeviceType:
|
||||
case IosDeviceType::IosDevice:
|
||||
qDebug() << "IosSimulatorToolHandlerPrivate has device type IosDeviceType";
|
||||
break;
|
||||
case IosToolHandler::IosSimulatedIphoneType:
|
||||
case IosDeviceType::SimulatedIphone:
|
||||
args << QLatin1String("--family") << QLatin1String("iphone");
|
||||
break;
|
||||
case IosToolHandler::IosSimulatedIpadType:
|
||||
case IosDeviceType::SimulatedIpad:
|
||||
args << QLatin1String("--family") << QLatin1String("ipad");
|
||||
break;
|
||||
case IosToolHandler::IosSimulatedIphoneRetina4InchType:
|
||||
case IosDeviceType::SimulatedIphoneRetina4Inch:
|
||||
args << QLatin1String("--family") << QLatin1String("iphone")
|
||||
<< QLatin1String("--retina") << QLatin1String("--tall");
|
||||
break;
|
||||
case IosToolHandler::IosSimulatedIphoneRetina3_5InchType:
|
||||
case IosDeviceType::SimulatedIphoneRetina3_5Inch:
|
||||
args << QLatin1String("--family") << QLatin1String("iphone") << QLatin1String("--retina");
|
||||
break;
|
||||
case IosToolHandler::IosSimulatedIpadRetinaType:
|
||||
case IosDeviceType::SimulatedIpadRetina:
|
||||
args << QLatin1String("--family") << QLatin1String("ipad") << QLatin1String("--retina");
|
||||
break;
|
||||
}
|
||||
@@ -743,10 +744,10 @@ QString IosToolHandler::iosSimulatorToolPath()
|
||||
return res;
|
||||
}
|
||||
|
||||
IosToolHandler::IosToolHandler(DeviceType devType, QObject *parent) :
|
||||
IosToolHandler::IosToolHandler(IosDeviceType::Enum devType, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
if (devType == IosDeviceType)
|
||||
if (devType == IosDeviceType::IosDevice)
|
||||
d = new Internal::IosDeviceToolHandlerPrivate(devType, this);
|
||||
else
|
||||
d = new Internal::IosSimulatorToolHandlerPrivate(devType, this);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef IOSTOOLHANDLER_H
|
||||
#define IOSTOOLHANDLER_H
|
||||
|
||||
#include "iosconstants.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
@@ -54,19 +56,11 @@ public:
|
||||
Unknown = 1,
|
||||
Failure = 2
|
||||
};
|
||||
enum DeviceType {
|
||||
IosDeviceType,
|
||||
IosSimulatedIphoneType,
|
||||
IosSimulatedIpadType,
|
||||
IosSimulatedIphoneRetina4InchType,
|
||||
IosSimulatedIphoneRetina3_5InchType,
|
||||
IosSimulatedIpadRetinaType
|
||||
};
|
||||
|
||||
static QString iosDeviceToolPath();
|
||||
static QString iosSimulatorToolPath();
|
||||
|
||||
explicit IosToolHandler(DeviceType = IosDeviceType, QObject *parent = 0);
|
||||
explicit IosToolHandler(IosDeviceType::Enum = IosDeviceType::IosDevice, QObject *parent = 0);
|
||||
~IosToolHandler();
|
||||
void requestTransferApp(const QString &bundlePath, const QString &deviceId, int timeout = 1000);
|
||||
void requestRunApp(const QString &bundlePath, const QStringList &extraArgs, RunKind runType,
|
||||
|
||||
Reference in New Issue
Block a user