forked from qt-creator/qt-creator
iOS: inline createsimulatordialog.ui
Change-Id: I40c6269a3d0ba61dfbdcc2ac55f4608b9c893e8c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -2,7 +2,7 @@ add_qtc_plugin(Ios
|
||||
DEPENDS QmlDebug Qt5::Xml
|
||||
PLUGIN_DEPENDS Core Debugger ProjectExplorer QmakeProjectManager CMakeProjectManager
|
||||
SOURCES
|
||||
createsimulatordialog.cpp createsimulatordialog.h createsimulatordialog.ui
|
||||
createsimulatordialog.cpp createsimulatordialog.h
|
||||
ios.qrc
|
||||
iosbuildconfiguration.cpp iosbuildconfiguration.h
|
||||
iosbuildstep.cpp iosbuildstep.h
|
||||
|
||||
@@ -24,38 +24,60 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "createsimulatordialog.h"
|
||||
#include "ui_createsimulatordialog.h"
|
||||
|
||||
#include "simulatorcontrol.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/runextensions.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QVariant>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
using namespace std::placeholders;
|
||||
namespace Ios::Internal {
|
||||
|
||||
CreateSimulatorDialog::CreateSimulatorDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::CreateSimulatorDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
resize(320, 160);
|
||||
setWindowTitle(tr("Create Simulator"));
|
||||
|
||||
const auto enableOk = [this] {
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
|
||||
!m_ui->nameEdit->text().isEmpty() &&
|
||||
m_ui->deviceTypeCombo->currentIndex() > 0 &&
|
||||
m_ui->runtimeCombo->currentIndex() > 0);
|
||||
m_nameEdit = new QLineEdit(this);
|
||||
m_deviceTypeCombo = new QComboBox(this);
|
||||
m_runtimeCombo = new QComboBox(this);
|
||||
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
using namespace Utils::Layouting;
|
||||
|
||||
Column {
|
||||
Form {
|
||||
tr("Simulator name:"), m_nameEdit, br,
|
||||
tr("Device type:"), m_deviceTypeCombo, br,
|
||||
tr("OS version:"), m_runtimeCombo, br,
|
||||
},
|
||||
buttonBox
|
||||
}.attachTo(this);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
const auto enableOk = [this, buttonBox] {
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
|
||||
!m_nameEdit->text().isEmpty() &&
|
||||
m_deviceTypeCombo->currentIndex() > 0 &&
|
||||
m_runtimeCombo->currentIndex() > 0);
|
||||
};
|
||||
|
||||
connect(m_ui->nameEdit, &QLineEdit::textChanged, this, enableOk);
|
||||
connect(m_ui->runtimeCombo, &QComboBox::currentIndexChanged, this, enableOk);
|
||||
connect(m_ui->deviceTypeCombo, &QComboBox::currentIndexChanged, this, [this, enableOk] {
|
||||
populateRuntimes(m_ui->deviceTypeCombo->currentData().value<DeviceTypeInfo>());
|
||||
connect(m_nameEdit, &QLineEdit::textChanged, this, enableOk);
|
||||
connect(m_runtimeCombo, &QComboBox::currentIndexChanged, this, enableOk);
|
||||
connect(m_deviceTypeCombo, &QComboBox::currentIndexChanged, this, [this, enableOk] {
|
||||
populateRuntimes(m_deviceTypeCombo->currentData().value<DeviceTypeInfo>());
|
||||
enableOk();
|
||||
});
|
||||
|
||||
@@ -74,7 +96,6 @@ CreateSimulatorDialog::CreateSimulatorDialog(QWidget *parent)
|
||||
CreateSimulatorDialog::~CreateSimulatorDialog()
|
||||
{
|
||||
m_futureSync.waitForFinished();
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -82,7 +103,7 @@ CreateSimulatorDialog::~CreateSimulatorDialog()
|
||||
*/
|
||||
QString CreateSimulatorDialog::name() const
|
||||
{
|
||||
return m_ui->nameEdit->text();
|
||||
return m_nameEdit->text();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -94,7 +115,7 @@ QString CreateSimulatorDialog::name() const
|
||||
*/
|
||||
RuntimeInfo CreateSimulatorDialog::runtime() const
|
||||
{
|
||||
return m_ui->runtimeCombo->currentData().value<RuntimeInfo>();
|
||||
return m_runtimeCombo->currentData().value<RuntimeInfo>();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -102,7 +123,7 @@ RuntimeInfo CreateSimulatorDialog::runtime() const
|
||||
*/
|
||||
DeviceTypeInfo CreateSimulatorDialog::deviceType() const
|
||||
{
|
||||
return m_ui->deviceTypeCombo->currentData().value<DeviceTypeInfo>();
|
||||
return m_deviceTypeCombo->currentData().value<DeviceTypeInfo>();
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -110,30 +131,30 @@ DeviceTypeInfo CreateSimulatorDialog::deviceType() const
|
||||
*/
|
||||
void CreateSimulatorDialog::populateDeviceTypes(const QList<DeviceTypeInfo> &deviceTypes)
|
||||
{
|
||||
m_ui->deviceTypeCombo->clear();
|
||||
m_ui->deviceTypeCombo->addItem(tr("None"));
|
||||
m_deviceTypeCombo->clear();
|
||||
m_deviceTypeCombo->addItem(tr("None"));
|
||||
|
||||
if (deviceTypes.isEmpty())
|
||||
return;
|
||||
|
||||
m_ui->deviceTypeCombo->insertSeparator(1);
|
||||
m_deviceTypeCombo->insertSeparator(1);
|
||||
|
||||
auto addItems = [this, deviceTypes](const QString &filter) {
|
||||
const auto filteredTypes = Utils::filtered(deviceTypes, [filter](const DeviceTypeInfo &type){
|
||||
return type.name.contains(filter, Qt::CaseInsensitive);
|
||||
});
|
||||
for (auto type : filteredTypes) {
|
||||
m_ui->deviceTypeCombo->addItem(type.name, QVariant::fromValue<DeviceTypeInfo>(type));
|
||||
m_deviceTypeCombo->addItem(type.name, QVariant::fromValue<DeviceTypeInfo>(type));
|
||||
}
|
||||
return filteredTypes.count();
|
||||
};
|
||||
|
||||
if (addItems(QStringLiteral("iPhone")) > 0)
|
||||
m_ui->deviceTypeCombo->insertSeparator(m_ui->deviceTypeCombo->count());
|
||||
m_deviceTypeCombo->insertSeparator(m_deviceTypeCombo->count());
|
||||
if (addItems(QStringLiteral("iPad")) > 0)
|
||||
m_ui->deviceTypeCombo->insertSeparator(m_ui->deviceTypeCombo->count());
|
||||
m_deviceTypeCombo->insertSeparator(m_deviceTypeCombo->count());
|
||||
if (addItems(QStringLiteral("TV")) > 0)
|
||||
m_ui->deviceTypeCombo->insertSeparator(m_ui->deviceTypeCombo->count());
|
||||
m_deviceTypeCombo->insertSeparator(m_deviceTypeCombo->count());
|
||||
addItems(QStringLiteral("Watch"));
|
||||
}
|
||||
|
||||
@@ -146,20 +167,20 @@ void CreateSimulatorDialog::populateDeviceTypes(const QList<DeviceTypeInfo> &dev
|
||||
*/
|
||||
void CreateSimulatorDialog::populateRuntimes(const DeviceTypeInfo &deviceType)
|
||||
{
|
||||
m_ui->runtimeCombo->clear();
|
||||
m_ui->runtimeCombo->addItem(tr("None"));
|
||||
m_runtimeCombo->clear();
|
||||
m_runtimeCombo->addItem(tr("None"));
|
||||
|
||||
if (deviceType.name.isEmpty())
|
||||
return;
|
||||
|
||||
m_ui->runtimeCombo->insertSeparator(1);
|
||||
m_runtimeCombo->insertSeparator(1);
|
||||
|
||||
auto addItems = [this](const QString &filter) {
|
||||
const auto filteredTypes = Utils::filtered(m_runtimes, [filter](const RuntimeInfo &runtime){
|
||||
return runtime.name.contains(filter, Qt::CaseInsensitive);
|
||||
});
|
||||
for (auto runtime : filteredTypes) {
|
||||
m_ui->runtimeCombo->addItem(runtime.name, QVariant::fromValue<RuntimeInfo>(runtime));
|
||||
m_runtimeCombo->addItem(runtime.name, QVariant::fromValue<RuntimeInfo>(runtime));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -173,5 +194,4 @@ void CreateSimulatorDialog::populateRuntimes(const DeviceTypeInfo &deviceType)
|
||||
addItems(QStringLiteral("watchOS"));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -25,17 +25,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include <utils/futuresynchronizer.h>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Ios::Internal {
|
||||
|
||||
namespace Ui { class CreateSimulatorDialog; }
|
||||
class SimulatorControl;
|
||||
class RuntimeInfo;
|
||||
class DeviceTypeInfo;
|
||||
class RuntimeInfo;
|
||||
|
||||
/*!
|
||||
A dialog to select the iOS Device type and the runtime for a new
|
||||
@@ -57,11 +59,12 @@ private:
|
||||
void populateDeviceTypes(const QList<DeviceTypeInfo> &deviceTypes);
|
||||
void populateRuntimes(const DeviceTypeInfo &deviceType);
|
||||
|
||||
private:
|
||||
Utils::FutureSynchronizer m_futureSync;
|
||||
Ui::CreateSimulatorDialog *m_ui = nullptr;
|
||||
QList<RuntimeInfo> m_runtimes;
|
||||
|
||||
QLineEdit *m_nameEdit;
|
||||
QComboBox *m_deviceTypeCombo;
|
||||
QComboBox *m_runtimeCombo;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Ios::Internal::CreateSimulatorDialog</class>
|
||||
<widget class="QDialog" name="Ios::Internal::CreateSimulatorDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>320</width>
|
||||
<height>160</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create Simulator</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Simulator name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="nameEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Device type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="deviceTypeCombo"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>OS version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="runtimeCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Ios::Internal::CreateSimulatorDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Ios::Internal::CreateSimulatorDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -17,7 +17,6 @@ QtcPlugin {
|
||||
files: [
|
||||
"createsimulatordialog.cpp",
|
||||
"createsimulatordialog.h",
|
||||
"createsimulatordialog.ui",
|
||||
"ios.qrc",
|
||||
"iosbuildconfiguration.cpp",
|
||||
"iosbuildconfiguration.h",
|
||||
|
||||
Reference in New Issue
Block a user