2013-04-25 16:02:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2013-04-25 16:02:17 +02:00
|
|
|
**
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
**
|
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2013-04-25 16:02:17 +02:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-04-25 16:02:17 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2013-04-25 16:02:17 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "iosrunconfiguration.h"
|
2014-07-07 09:24:17 +02:00
|
|
|
#include "iosconstants.h"
|
2013-04-25 16:02:17 +02:00
|
|
|
#include "iosmanager.h"
|
|
|
|
#include "iosdeploystep.h"
|
|
|
|
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
2014-02-14 01:02:30 +01:00
|
|
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <projectexplorer/buildstep.h>
|
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2016-01-05 17:13:35 +01:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2013-10-29 16:19:24 +01:00
|
|
|
#include <qmakeprojectmanager/qmakebuildconfiguration.h>
|
|
|
|
#include <qmakeprojectmanager/qmakeproject.h>
|
|
|
|
#include <qmakeprojectmanager/qmakenodes.h>
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
|
|
|
|
2015-01-10 23:40:32 +02:00
|
|
|
#include <utils/fileutils.h>
|
2015-12-18 15:51:23 +01:00
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
#include <utils/qtcassert.h>
|
2015-01-10 23:40:32 +02:00
|
|
|
|
2015-12-18 15:51:23 +01:00
|
|
|
#include <QAction>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
2013-04-25 16:02:17 +02:00
|
|
|
#include <QList>
|
2014-11-12 19:41:59 +01:00
|
|
|
#include <QStandardItemModel>
|
2015-12-18 15:51:23 +01:00
|
|
|
#include <QVariant>
|
|
|
|
#include <QWidget>
|
2013-04-25 16:02:17 +02:00
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2013-10-16 11:02:37 +02:00
|
|
|
using namespace QmakeProjectManager;
|
2014-02-05 10:43:21 +01:00
|
|
|
using namespace Utils;
|
2013-04-25 16:02:17 +02:00
|
|
|
|
|
|
|
namespace Ios {
|
|
|
|
namespace Internal {
|
|
|
|
|
2014-03-28 19:05:35 +01:00
|
|
|
static const QLatin1String deviceTypeKey("Ios.device_type");
|
2014-01-16 18:35:36 +01:00
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
class IosRunConfigurationWidget : public RunConfigWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IosRunConfigurationWidget(IosRunConfiguration *runConfiguration);
|
2015-12-18 15:51:23 +01:00
|
|
|
QString displayName() const override;
|
2013-04-25 16:02:17 +02:00
|
|
|
|
2015-12-18 15:51:23 +01:00
|
|
|
private:
|
2013-04-25 16:02:17 +02:00
|
|
|
void argumentsLineEditTextEdited();
|
|
|
|
void updateValues();
|
2014-03-28 19:05:35 +01:00
|
|
|
void setDeviceTypeIndex(int devIndex);
|
2015-12-18 15:51:23 +01:00
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
IosRunConfiguration *m_runConfiguration;
|
2014-11-12 19:41:59 +01:00
|
|
|
QStandardItemModel m_deviceTypeModel;
|
2015-12-18 15:51:23 +01:00
|
|
|
QLabel *m_deviceTypeLabel;
|
|
|
|
QLineEdit *m_executableLineEdit;
|
|
|
|
QComboBox *m_deviceTypeComboBox;
|
2013-04-25 16:02:17 +02:00
|
|
|
};
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
IosRunConfiguration::IosRunConfiguration(Target *parent, Core::Id id, const FileName &path)
|
2013-04-25 16:02:17 +02:00
|
|
|
: RunConfiguration(parent, id)
|
|
|
|
, m_profilePath(path)
|
|
|
|
{
|
2016-01-05 17:13:35 +01:00
|
|
|
addExtraAspect(new ArgumentsAspect(this, QLatin1String("Ios.run_arguments")));
|
2013-04-25 16:02:17 +02:00
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
IosRunConfiguration::IosRunConfiguration(Target *parent, IosRunConfiguration *source)
|
|
|
|
: RunConfiguration(parent, source)
|
|
|
|
, m_profilePath(source->m_profilePath)
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IosRunConfiguration::init()
|
|
|
|
{
|
2014-02-14 01:02:30 +01:00
|
|
|
QmakeProject *project = static_cast<QmakeProject *>(target()->project());
|
|
|
|
m_parseSuccess = project->validParse(m_profilePath);
|
|
|
|
m_parseInProgress = project->parseInProgress(m_profilePath);
|
|
|
|
m_lastIsEnabled = isEnabled();
|
|
|
|
m_lastDisabledReason = disabledReason();
|
2014-03-26 16:50:12 +01:00
|
|
|
updateDisplayNames();
|
2015-12-18 15:51:23 +01:00
|
|
|
connect(DeviceManager::instance(), &DeviceManager::updated,
|
|
|
|
this, &IosRunConfiguration::deviceChanges);
|
|
|
|
connect(KitManager::instance(), &KitManager::kitsChanged,
|
|
|
|
this, &IosRunConfiguration::deviceChanges);
|
|
|
|
connect(project, &QmakeProject::proFileUpdated,
|
|
|
|
this, &IosRunConfiguration::proFileUpdated);
|
2014-02-14 01:02:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void IosRunConfiguration::enabledCheck()
|
|
|
|
{
|
|
|
|
bool newIsEnabled = isEnabled();
|
|
|
|
QString newDisabledReason = disabledReason();
|
|
|
|
if (newDisabledReason != m_lastDisabledReason || newIsEnabled != m_lastIsEnabled) {
|
|
|
|
m_lastDisabledReason = newDisabledReason;
|
|
|
|
m_lastIsEnabled = newIsEnabled;
|
|
|
|
emit enabledChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IosRunConfiguration::deviceChanges() {
|
2014-03-26 16:50:12 +01:00
|
|
|
updateDisplayNames();
|
2014-02-14 01:02:30 +01:00
|
|
|
enabledCheck();
|
|
|
|
}
|
|
|
|
|
2015-02-03 23:49:46 +02:00
|
|
|
void IosRunConfiguration::proFileUpdated(QmakeProFileNode *pro, bool success,
|
2014-02-14 01:02:30 +01:00
|
|
|
bool parseInProgress)
|
|
|
|
{
|
2015-10-29 17:53:47 +01:00
|
|
|
if (m_profilePath != pro->filePath())
|
2014-02-14 01:02:30 +01:00
|
|
|
return;
|
|
|
|
m_parseSuccess = success;
|
|
|
|
m_parseInProgress = parseInProgress;
|
2014-03-27 18:50:08 +01:00
|
|
|
if (success && !parseInProgress) {
|
2014-03-26 16:50:12 +01:00
|
|
|
updateDisplayNames();
|
2014-03-27 18:50:08 +01:00
|
|
|
emit localExecutableChanged();
|
|
|
|
}
|
2014-02-14 01:02:30 +01:00
|
|
|
enabledCheck();
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *IosRunConfiguration::createConfigurationWidget()
|
|
|
|
{
|
|
|
|
return new IosRunConfigurationWidget(this);
|
|
|
|
}
|
|
|
|
|
2015-02-03 23:49:46 +02:00
|
|
|
OutputFormatter *IosRunConfiguration::createOutputFormatter() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
|
|
|
return new QtSupport::QtOutputFormatter(target()->project());
|
|
|
|
}
|
|
|
|
|
2016-01-05 17:13:35 +01:00
|
|
|
QString IosRunConfiguration::commandLineArguments() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2016-01-05 17:13:35 +01:00
|
|
|
return extraAspect<ArgumentsAspect>()->arguments();
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2014-03-26 16:50:12 +01:00
|
|
|
void IosRunConfiguration::updateDisplayNames()
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2014-04-01 18:40:56 +02:00
|
|
|
if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) == Constants::IOS_DEVICE_TYPE)
|
2014-12-01 11:44:14 +01:00
|
|
|
m_deviceType = IosDeviceType(IosDeviceType::IosDevice);
|
2014-11-12 19:41:59 +01:00
|
|
|
else if (m_deviceType.type == IosDeviceType::IosDevice)
|
|
|
|
m_deviceType = IosDeviceType(IosDeviceType::SimulatedDevice);
|
2014-05-26 22:13:14 +03:00
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit());
|
2013-11-04 15:08:41 +01:00
|
|
|
const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName();
|
2014-03-26 16:50:12 +01:00
|
|
|
setDefaultDisplayName(tr("Run on %1").arg(devName));
|
2014-04-10 11:35:36 +02:00
|
|
|
setDisplayName(tr("Run %1 on %2").arg(applicationName()).arg(devName));
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IosDeployStep *IosRunConfiguration::deployStep() const
|
|
|
|
{
|
|
|
|
IosDeployStep * step = 0;
|
|
|
|
DeployConfiguration *config = target()->activeDeployConfiguration();
|
2014-05-26 22:13:14 +03:00
|
|
|
BuildStepList *bsl = config->stepList();
|
2013-04-25 16:02:17 +02:00
|
|
|
if (bsl) {
|
2014-05-26 22:13:14 +03:00
|
|
|
const QList<BuildStep *> &buildSteps = bsl->steps();
|
2013-04-25 16:02:17 +02:00
|
|
|
for (int i = buildSteps.count() - 1; i >= 0; --i) {
|
|
|
|
step = qobject_cast<IosDeployStep *>(buildSteps.at(i));
|
|
|
|
if (step)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Q_ASSERT_X(step, Q_FUNC_INFO, "Impossible: iOS build configuration without deploy step.");
|
|
|
|
return step;
|
|
|
|
}
|
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
FileName IosRunConfiguration::profilePath() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
|
|
|
return m_profilePath;
|
|
|
|
}
|
|
|
|
|
2014-04-10 11:35:36 +02:00
|
|
|
QString IosRunConfiguration::applicationName() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2013-10-29 14:22:31 +01:00
|
|
|
QmakeProject *pro = qobject_cast<QmakeProject *>(target()->project());
|
2014-03-26 16:57:57 +01:00
|
|
|
const QmakeProFileNode *node = 0;
|
|
|
|
if (pro)
|
2016-01-08 12:49:00 +01:00
|
|
|
node = pro->rootProjectNode();
|
2014-03-26 16:57:57 +01:00
|
|
|
if (node)
|
|
|
|
node = node->findProFileFor(profilePath());
|
|
|
|
if (node) {
|
|
|
|
TargetInformation ti = node->targetInformation();
|
|
|
|
if (ti.valid)
|
|
|
|
return ti.target;
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2015-02-03 23:49:46 +02:00
|
|
|
FileName IosRunConfiguration::bundleDirectory() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2015-02-03 23:49:46 +02:00
|
|
|
FileName res;
|
2014-05-26 22:13:14 +03:00
|
|
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
2013-04-25 16:02:17 +02:00
|
|
|
bool isDevice = (devType == Constants::IOS_DEVICE_TYPE);
|
|
|
|
if (!isDevice && devType != Constants::IOS_SIMULATOR_TYPE) {
|
2014-07-07 09:24:17 +02:00
|
|
|
qCWarning(iosLog) << "unexpected device type in bundleDirForTarget: " << devType.toString();
|
2013-04-25 16:02:17 +02:00
|
|
|
return res;
|
|
|
|
}
|
2013-10-16 14:00:45 +02:00
|
|
|
QmakeBuildConfiguration *bc =
|
|
|
|
qobject_cast<QmakeBuildConfiguration *>(target()->activeBuildConfiguration());
|
2013-04-25 16:02:17 +02:00
|
|
|
if (bc) {
|
2014-03-10 16:30:32 +01:00
|
|
|
QmakeProject *pro = qobject_cast<QmakeProject *>(target()->project());
|
2014-03-26 16:57:57 +01:00
|
|
|
const QmakeProFileNode *node = 0;
|
|
|
|
if (pro)
|
2016-01-08 12:49:00 +01:00
|
|
|
node = pro->rootProjectNode();
|
2014-03-26 16:57:57 +01:00
|
|
|
if (node)
|
|
|
|
node = node->findProFileFor(profilePath());
|
2014-03-10 16:30:32 +01:00
|
|
|
if (node) {
|
|
|
|
TargetInformation ti = node->targetInformation();
|
|
|
|
if (ti.valid)
|
|
|
|
res = FileName::fromString(ti.buildDir);
|
|
|
|
}
|
|
|
|
if (res.isEmpty())
|
|
|
|
res = bc->buildDirectory();
|
2013-04-25 16:02:17 +02:00
|
|
|
switch (bc->buildType()) {
|
|
|
|
case BuildConfiguration::Debug :
|
|
|
|
case BuildConfiguration::Unknown :
|
|
|
|
if (isDevice)
|
|
|
|
res.appendPath(QLatin1String("Debug-iphoneos"));
|
|
|
|
else
|
|
|
|
res.appendPath(QLatin1String("Debug-iphonesimulator"));
|
|
|
|
break;
|
2015-02-20 15:10:56 +01:00
|
|
|
case BuildConfiguration::Profile :
|
2013-04-25 16:02:17 +02:00
|
|
|
case BuildConfiguration::Release :
|
|
|
|
if (isDevice)
|
|
|
|
res.appendPath(QLatin1String("Release-iphoneos"));
|
|
|
|
else
|
2014-03-11 11:34:39 +01:00
|
|
|
res.appendPath(QLatin1String("Release-iphonesimulator"));
|
2013-04-25 16:02:17 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-07-07 09:24:17 +02:00
|
|
|
qCWarning(iosLog) << "IosBuildStep had an unknown buildType "
|
2013-04-25 16:02:17 +02:00
|
|
|
<< target()->activeBuildConfiguration()->buildType();
|
|
|
|
}
|
|
|
|
}
|
2014-04-10 11:35:36 +02:00
|
|
|
res.appendPath(applicationName() + QLatin1String(".app"));
|
2013-04-25 16:02:17 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-02-03 23:49:46 +02:00
|
|
|
FileName IosRunConfiguration::localExecutable() const
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2014-04-10 11:35:36 +02:00
|
|
|
return bundleDirectory().appendPath(applicationName());
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
2014-01-16 18:35:36 +01:00
|
|
|
bool IosRunConfiguration::fromMap(const QVariantMap &map)
|
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
bool deviceTypeIsInt;
|
|
|
|
map.value(deviceTypeKey).toInt(&deviceTypeIsInt);
|
|
|
|
if (deviceTypeIsInt || !m_deviceType.fromMap(map.value(deviceTypeKey).toMap())) {
|
|
|
|
if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) == Constants::IOS_DEVICE_TYPE)
|
|
|
|
m_deviceType = IosDeviceType(IosDeviceType::IosDevice);
|
|
|
|
else
|
|
|
|
m_deviceType = IosDeviceType(IosDeviceType::SimulatedDevice);
|
|
|
|
}
|
2014-01-16 18:35:36 +01:00
|
|
|
return RunConfiguration::fromMap(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariantMap IosRunConfiguration::toMap() const
|
|
|
|
{
|
|
|
|
QVariantMap res = RunConfiguration::toMap();
|
2014-11-12 19:41:59 +01:00
|
|
|
res[deviceTypeKey] = deviceType().toMap();
|
2014-01-16 18:35:36 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-02-14 01:02:30 +01:00
|
|
|
bool IosRunConfiguration::isEnabled() const
|
|
|
|
{
|
|
|
|
if (m_parseInProgress || !m_parseSuccess)
|
|
|
|
return false;
|
2014-05-26 22:13:14 +03:00
|
|
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
2014-02-14 01:02:30 +01:00
|
|
|
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
|
|
|
return false;
|
2014-05-26 22:13:14 +03:00
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit());
|
2014-02-14 01:02:30 +01:00
|
|
|
if (dev.isNull() || dev->deviceState() != IDevice::DeviceReadyToUse)
|
|
|
|
return false;
|
|
|
|
return RunConfiguration::isEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString IosRunConfiguration::disabledReason() const
|
|
|
|
{
|
|
|
|
if (m_parseInProgress)
|
2015-02-02 00:37:38 +02:00
|
|
|
return tr("The .pro file \"%1\" is currently being parsed.").arg(m_profilePath.fileName());
|
2014-02-14 01:02:30 +01:00
|
|
|
if (!m_parseSuccess)
|
|
|
|
return static_cast<QmakeProject *>(target()->project())
|
|
|
|
->disabledReasonForRunConfiguration(m_profilePath);
|
2014-05-26 22:13:14 +03:00
|
|
|
Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit());
|
2014-02-14 01:02:30 +01:00
|
|
|
if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE)
|
|
|
|
return tr("Kit has incorrect device type for running on iOS devices.");
|
2014-05-26 22:13:14 +03:00
|
|
|
IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit());
|
2014-02-14 01:02:30 +01:00
|
|
|
QString validDevName;
|
|
|
|
bool hasConncetedDev = false;
|
|
|
|
if (devType == Constants::IOS_DEVICE_TYPE) {
|
|
|
|
DeviceManager *dm = DeviceManager::instance();
|
|
|
|
for (int idev = 0; idev < dm->deviceCount(); ++idev) {
|
|
|
|
IDevice::ConstPtr availDev = dm->deviceAt(idev);
|
|
|
|
if (!availDev.isNull() && availDev->type() == Constants::IOS_DEVICE_TYPE) {
|
|
|
|
if (availDev->deviceState() == IDevice::DeviceReadyToUse) {
|
2014-08-29 14:00:18 +02:00
|
|
|
validDevName += QLatin1Char(' ');
|
2014-02-14 01:02:30 +01:00
|
|
|
validDevName += availDev->displayName();
|
|
|
|
} else if (availDev->deviceState() == IDevice::DeviceConnected) {
|
|
|
|
hasConncetedDev = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dev.isNull()) {
|
|
|
|
if (!validDevName.isEmpty())
|
|
|
|
return tr("No device chosen. Select %1.").arg(validDevName); // should not happen
|
|
|
|
else if (hasConncetedDev)
|
|
|
|
return tr("No device chosen. Enable developer mode on a device."); // should not happen
|
|
|
|
else
|
|
|
|
return tr("No device available.");
|
|
|
|
} else {
|
|
|
|
switch (dev->deviceState()) {
|
|
|
|
case IDevice::DeviceReadyToUse:
|
|
|
|
break;
|
|
|
|
case IDevice::DeviceConnected:
|
|
|
|
return tr("To use this device you need to enable developer mode on it.");
|
|
|
|
case IDevice::DeviceDisconnected:
|
|
|
|
case IDevice::DeviceStateUnknown:
|
|
|
|
if (!validDevName.isEmpty())
|
|
|
|
return tr("%1 is not connected. Select %2?")
|
|
|
|
.arg(dev->displayName(), validDevName);
|
|
|
|
else if (hasConncetedDev)
|
|
|
|
return tr("%1 is not connected. Enable developer mode on a device?")
|
|
|
|
.arg(dev->displayName());
|
|
|
|
else
|
|
|
|
return tr("%1 is not connected.").arg(dev->displayName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return RunConfiguration::disabledReason();
|
|
|
|
}
|
|
|
|
|
2014-11-12 19:41:59 +01:00
|
|
|
IosDeviceType IosRunConfiguration::deviceType() const
|
2014-03-28 19:05:35 +01:00
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
QList<IosDeviceType> availableSimulators;
|
|
|
|
if (m_deviceType.type == IosDeviceType::SimulatedDevice)
|
|
|
|
availableSimulators = IosSimulator::availableDevices();
|
|
|
|
if (!availableSimulators.isEmpty()) {
|
|
|
|
QList<IosDeviceType> elegibleDevices;
|
|
|
|
QString devname = m_deviceType.identifier.split(QLatin1Char(',')).value(0);
|
|
|
|
foreach (const IosDeviceType &dType, availableSimulators) {
|
|
|
|
if (dType == m_deviceType)
|
|
|
|
return m_deviceType;
|
|
|
|
if (!devname.isEmpty() && dType.identifier.startsWith(devname)
|
|
|
|
&& dType.identifier.split(QLatin1Char(',')).value(0) == devname)
|
|
|
|
elegibleDevices << dType;
|
|
|
|
}
|
|
|
|
if (!elegibleDevices.isEmpty())
|
|
|
|
return elegibleDevices.last();
|
|
|
|
return availableSimulators.last();
|
|
|
|
}
|
2014-03-28 19:05:35 +01:00
|
|
|
return m_deviceType;
|
|
|
|
}
|
|
|
|
|
2014-11-12 19:41:59 +01:00
|
|
|
void IosRunConfiguration::setDeviceType(const IosDeviceType &deviceType)
|
2014-03-28 19:05:35 +01:00
|
|
|
{
|
|
|
|
m_deviceType = deviceType;
|
|
|
|
}
|
|
|
|
|
2015-12-18 15:51:23 +01:00
|
|
|
IosRunConfigurationWidget::IosRunConfigurationWidget(IosRunConfiguration *runConfiguration)
|
|
|
|
: m_runConfiguration(runConfiguration)
|
2013-04-25 16:02:17 +02:00
|
|
|
{
|
2015-12-18 15:51:23 +01:00
|
|
|
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
sizePolicy.setHorizontalStretch(0);
|
|
|
|
sizePolicy.setVerticalStretch(0);
|
|
|
|
setSizePolicy(sizePolicy);
|
|
|
|
|
|
|
|
m_executableLineEdit = new QLineEdit(this);
|
|
|
|
m_executableLineEdit->setReadOnly(true);
|
|
|
|
|
|
|
|
m_deviceTypeComboBox = new QComboBox(this);
|
|
|
|
m_deviceTypeComboBox->setModel(&m_deviceTypeModel);
|
|
|
|
|
|
|
|
m_deviceTypeLabel = new QLabel(IosRunConfiguration::tr("Device type:"), this);
|
|
|
|
|
|
|
|
auto layout = new QFormLayout(this);
|
2016-01-05 17:13:35 +01:00
|
|
|
runConfiguration->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, layout);
|
2015-12-18 15:51:23 +01:00
|
|
|
layout->addRow(IosRunConfiguration::tr("Executable:"), m_executableLineEdit);
|
|
|
|
layout->addRow(m_deviceTypeLabel, m_deviceTypeComboBox);
|
2013-04-25 16:02:17 +02:00
|
|
|
|
|
|
|
updateValues();
|
|
|
|
|
2015-12-18 15:51:23 +01:00
|
|
|
connect(m_deviceTypeComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
this, &IosRunConfigurationWidget::setDeviceTypeIndex);
|
|
|
|
connect(runConfiguration, &IosRunConfiguration::localExecutableChanged,
|
|
|
|
this, &IosRunConfigurationWidget::updateValues);
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString IosRunConfigurationWidget::displayName() const
|
|
|
|
{
|
|
|
|
return tr("iOS run settings");
|
|
|
|
}
|
|
|
|
|
2014-03-28 19:05:35 +01:00
|
|
|
void IosRunConfigurationWidget::setDeviceTypeIndex(int devIndex)
|
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
QVariant selectedDev = m_deviceTypeModel.data(m_deviceTypeModel.index(devIndex, 0), Qt::UserRole + 1);
|
|
|
|
if (selectedDev.isValid())
|
|
|
|
m_runConfiguration->setDeviceType(selectedDev.value<IosDeviceType>());
|
2014-03-28 19:05:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-25 16:02:17 +02:00
|
|
|
void IosRunConfigurationWidget::updateValues()
|
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
bool showDeviceSelector = m_runConfiguration->deviceType().type != IosDeviceType::IosDevice;
|
2015-12-18 15:51:23 +01:00
|
|
|
m_deviceTypeLabel->setVisible(showDeviceSelector);
|
|
|
|
m_deviceTypeComboBox->setVisible(showDeviceSelector);
|
2014-11-12 19:41:59 +01:00
|
|
|
if (showDeviceSelector && m_deviceTypeModel.rowCount() == 0) {
|
|
|
|
foreach (const IosDeviceType &dType, IosSimulator::availableDevices()) {
|
|
|
|
QStandardItem *item = new QStandardItem(dType.displayName);
|
|
|
|
QVariant v;
|
|
|
|
v.setValue(dType);
|
|
|
|
item->setData(v);
|
|
|
|
m_deviceTypeModel.appendRow(item);
|
|
|
|
}
|
|
|
|
}
|
2014-03-28 19:05:35 +01:00
|
|
|
|
2014-11-12 19:41:59 +01:00
|
|
|
IosDeviceType currentDType = m_runConfiguration->deviceType();
|
2014-12-01 11:44:14 +01:00
|
|
|
if (currentDType.type == IosDeviceType::SimulatedDevice && !currentDType.identifier.isEmpty()
|
2015-12-18 15:51:23 +01:00
|
|
|
&& (!m_deviceTypeComboBox->currentData().isValid()
|
|
|
|
|| currentDType != m_deviceTypeComboBox->currentData().value<IosDeviceType>()))
|
2014-12-01 11:44:14 +01:00
|
|
|
{
|
2014-11-12 19:41:59 +01:00
|
|
|
bool didSet = false;
|
|
|
|
for (int i = 0; m_deviceTypeModel.hasIndex(i, 0); ++i) {
|
|
|
|
QVariant vData = m_deviceTypeModel.data(m_deviceTypeModel.index(i, 0), Qt::UserRole + 1);
|
|
|
|
IosDeviceType dType = vData.value<IosDeviceType>();
|
|
|
|
if (dType == currentDType) {
|
2015-12-18 15:51:23 +01:00
|
|
|
m_deviceTypeComboBox->setCurrentIndex(i);
|
2014-11-12 19:41:59 +01:00
|
|
|
didSet = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!didSet) {
|
|
|
|
qCWarning(iosLog) << "could not set " << currentDType << " as it is not in model";
|
|
|
|
}
|
|
|
|
}
|
2015-12-18 15:51:23 +01:00
|
|
|
m_executableLineEdit->setText(m_runConfiguration->localExecutable().toUserOutput());
|
2013-04-25 16:02:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
} // namespace Ios
|