forked from qt-creator/qt-creator
iOS: inline iossettingswidget.ui
Change-Id: Ibed7608fa23fb147a8049a5701b233b3b802f894 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -17,7 +17,7 @@ add_qtc_plugin(Ios
|
||||
iosrunconfiguration.cpp iosrunconfiguration.h
|
||||
iosrunner.cpp iosrunner.h
|
||||
iossettingspage.cpp iossettingspage.h
|
||||
iossettingswidget.cpp iossettingswidget.h iossettingswidget.ui
|
||||
iossettingswidget.cpp iossettingswidget.h
|
||||
iossimulator.cpp iossimulator.h
|
||||
iostoolhandler.cpp iostoolhandler.h
|
||||
simulatorcontrol.cpp simulatorcontrol.h
|
||||
|
||||
@@ -45,7 +45,6 @@ QtcPlugin {
|
||||
"iossettingspage.h",
|
||||
"iossettingswidget.cpp",
|
||||
"iossettingswidget.h",
|
||||
"iossettingswidget.ui",
|
||||
"iossimulator.cpp",
|
||||
"iossimulator.h",
|
||||
"iostoolhandler.cpp",
|
||||
|
||||
@@ -24,26 +24,37 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "iossettingswidget.h"
|
||||
#include "ui_iossettingswidget.h"
|
||||
|
||||
#include "createsimulatordialog.h"
|
||||
#include "iosconfigurations.h"
|
||||
|
||||
#include "iosconfigurations.h"
|
||||
#include "simulatorcontrol.h"
|
||||
#include "simulatorinfomodel.h"
|
||||
#include "simulatoroperationdialog.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/runextensions.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCheckBox>
|
||||
#include <QDateTime>
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
#include <QHeaderView>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QTreeView>
|
||||
|
||||
static const int simStartWarnCount = 4;
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
namespace Ios::Internal {
|
||||
|
||||
using namespace std::placeholders;
|
||||
|
||||
@@ -63,35 +74,92 @@ static void onSimOperation(const SimulatorInfo &simInfo, SimulatorOperationDialo
|
||||
}
|
||||
|
||||
IosSettingsWidget::IosSettingsWidget()
|
||||
: m_ui(new Ui::IosSettingsWidget)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
resize(622, 456);
|
||||
setWindowTitle(tr("iOS Configuration"));
|
||||
|
||||
m_deviceAskCheckBox = new QCheckBox(tr("Ask about devices not in developer mode"));
|
||||
m_deviceAskCheckBox->setChecked(!IosConfigurations::ignoreAllDevices());
|
||||
|
||||
m_renameButton = new QPushButton(tr("Rename"));
|
||||
m_renameButton->setEnabled(false);
|
||||
m_renameButton->setToolTip(tr("Rename a simulator device."));
|
||||
|
||||
m_deleteButton = new QPushButton(tr("Delete"));
|
||||
m_deleteButton->setEnabled(false);
|
||||
m_deleteButton->setToolTip(tr("Delete simulator devices."));
|
||||
|
||||
m_resetButton = new QPushButton(tr("Reset"));
|
||||
m_resetButton->setEnabled(false);
|
||||
m_resetButton->setToolTip(tr("Reset contents and settings of simulator devices."));
|
||||
|
||||
auto line = new QFrame;
|
||||
line->setFrameShadow(QFrame::Raised);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
|
||||
auto createButton = new QPushButton(tr("Create"));
|
||||
createButton->setToolTip(tr("Create a new simulator device."));
|
||||
|
||||
m_startButton = new QPushButton(tr("Start"));
|
||||
m_startButton->setEnabled(false);
|
||||
m_startButton->setToolTip(tr("Start simulator devices."));
|
||||
|
||||
auto proxyModel = new QSortFilterProxyModel(this);
|
||||
proxyModel->setSourceModel(new SimulatorInfoModel(this));
|
||||
m_ui->deviceView->setModel(proxyModel);
|
||||
m_ui->deviceView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_ui->pathWidget->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||
m_ui->pathWidget->lineEdit()->setReadOnly(true);
|
||||
m_ui->pathWidget->setFilePath(IosConfigurations::screenshotDir());
|
||||
m_ui->pathWidget->addButton(tr("Screenshot"), this,
|
||||
|
||||
m_deviceView = new QTreeView;
|
||||
m_deviceView->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
|
||||
m_deviceView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_deviceView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_deviceView->setSortingEnabled(true);
|
||||
m_deviceView->setModel(proxyModel);
|
||||
m_deviceView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
|
||||
m_pathWidget = new Utils::PathChooser;
|
||||
m_pathWidget->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||
m_pathWidget->lineEdit()->setReadOnly(true);
|
||||
m_pathWidget->setFilePath(IosConfigurations::screenshotDir());
|
||||
m_pathWidget->addButton(tr("Screenshot"), this,
|
||||
std::bind(&IosSettingsWidget::onScreenshot, this));
|
||||
|
||||
m_ui->deviceAskCheckBox->setChecked(!IosConfigurations::ignoreAllDevices());
|
||||
using namespace Utils::Layouting;
|
||||
Column {
|
||||
Group {
|
||||
title(tr("Devices")),
|
||||
Row { m_deviceAskCheckBox }
|
||||
},
|
||||
Group {
|
||||
title(tr("Simulator")),
|
||||
Column {
|
||||
Row {
|
||||
m_deviceView,
|
||||
Column {
|
||||
createButton,
|
||||
st, // FIXME: Better some fixed space?
|
||||
m_startButton,
|
||||
m_renameButton,
|
||||
m_resetButton,
|
||||
m_deleteButton,
|
||||
st
|
||||
},
|
||||
},
|
||||
line,
|
||||
Row { tr("Screenshot directory:"), m_pathWidget }
|
||||
}
|
||||
}
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_ui->startButton, &QPushButton::clicked, this, &IosSettingsWidget::onStart);
|
||||
connect(m_ui->createButton, &QPushButton::clicked, this, &IosSettingsWidget::onCreate);
|
||||
connect(m_ui->renameButton, &QPushButton::clicked, this, &IosSettingsWidget::onRename);
|
||||
connect(m_ui->resetButton, &QPushButton::clicked, this, &IosSettingsWidget::onReset);
|
||||
connect(m_ui->deleteButton, &QPushButton::clicked, this, &IosSettingsWidget::onDelete);
|
||||
connect(m_startButton, &QPushButton::clicked, this, &IosSettingsWidget::onStart);
|
||||
connect(createButton, &QPushButton::clicked, this, &IosSettingsWidget::onCreate);
|
||||
connect(m_renameButton, &QPushButton::clicked, this, &IosSettingsWidget::onRename);
|
||||
connect(m_resetButton, &QPushButton::clicked, this, &IosSettingsWidget::onReset);
|
||||
connect(m_deleteButton, &QPushButton::clicked, this, &IosSettingsWidget::onDelete);
|
||||
|
||||
connect(m_ui->deviceView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&IosSettingsWidget::onSelectionChanged);
|
||||
connect(m_deviceView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, &IosSettingsWidget::onSelectionChanged);
|
||||
}
|
||||
|
||||
IosSettingsWidget::~IosSettingsWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
IosSettingsWidget::~IosSettingsWidget() = default;
|
||||
|
||||
void IosSettingsWidget::apply()
|
||||
{
|
||||
@@ -105,7 +173,7 @@ void IosSettingsWidget::apply()
|
||||
*/
|
||||
void IosSettingsWidget::onStart()
|
||||
{
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_ui->deviceView);
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_deviceView);
|
||||
if (simulatorInfoList.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -182,7 +250,7 @@ void IosSettingsWidget::onCreate()
|
||||
*/
|
||||
void IosSettingsWidget::onReset()
|
||||
{
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_ui->deviceView);
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_deviceView);
|
||||
if (simulatorInfoList.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -214,7 +282,7 @@ void IosSettingsWidget::onReset()
|
||||
*/
|
||||
void IosSettingsWidget::onRename()
|
||||
{
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_ui->deviceView);
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_deviceView);
|
||||
if (simulatorInfoList.isEmpty() || simulatorInfoList.count() > 1)
|
||||
return;
|
||||
|
||||
@@ -240,7 +308,7 @@ void IosSettingsWidget::onRename()
|
||||
*/
|
||||
void IosSettingsWidget::onDelete()
|
||||
{
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_ui->deviceView);
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_deviceView);
|
||||
if (simulatorInfoList.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -271,14 +339,14 @@ void IosSettingsWidget::onDelete()
|
||||
*/
|
||||
void IosSettingsWidget::onScreenshot()
|
||||
{
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_ui->deviceView);
|
||||
const SimulatorInfoList simulatorInfoList = selectedSimulators(m_deviceView);
|
||||
if (simulatorInfoList.isEmpty())
|
||||
return;
|
||||
|
||||
const auto generatePath = [this](const SimulatorInfo &info) {
|
||||
const QString fileName = QString("%1_%2_%3.png").arg(info.name).arg(info.runtimeName)
|
||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_HH-mm-ss-z")).replace(' ', '_');
|
||||
return m_ui->pathWidget->filePath().pathAppended(fileName).toString();
|
||||
return m_pathWidget->filePath().pathAppended(fileName).toString();
|
||||
};
|
||||
|
||||
QPointer<SimulatorOperationDialog> statusDialog = new SimulatorOperationDialog(this);
|
||||
@@ -298,26 +366,25 @@ void IosSettingsWidget::onScreenshot()
|
||||
|
||||
void IosSettingsWidget::onSelectionChanged()
|
||||
{
|
||||
const SimulatorInfoList infoList = selectedSimulators(m_ui->deviceView);
|
||||
const SimulatorInfoList infoList = selectedSimulators(m_deviceView);
|
||||
const bool hasRunning = Utils::anyOf(infoList, [](const SimulatorInfo &info) {
|
||||
return info.isBooted();
|
||||
});
|
||||
const bool hasShutdown = Utils::anyOf(infoList, [](const SimulatorInfo &info) {
|
||||
return info.isShutdown();
|
||||
});
|
||||
m_ui->startButton->setEnabled(hasShutdown);
|
||||
m_ui->deleteButton->setEnabled(hasShutdown);
|
||||
m_ui->resetButton->setEnabled(hasShutdown);
|
||||
m_ui->renameButton->setEnabled(infoList.count() == 1 && hasShutdown);
|
||||
m_ui->pathWidget->buttonAtIndex(1)->setEnabled(hasRunning); // Screenshot button
|
||||
m_startButton->setEnabled(hasShutdown);
|
||||
m_deleteButton->setEnabled(hasShutdown);
|
||||
m_resetButton->setEnabled(hasShutdown);
|
||||
m_renameButton->setEnabled(infoList.count() == 1 && hasShutdown);
|
||||
m_pathWidget->buttonAtIndex(1)->setEnabled(hasRunning); // Screenshot button
|
||||
}
|
||||
|
||||
void IosSettingsWidget::saveSettings()
|
||||
{
|
||||
IosConfigurations::setIgnoreAllDevices(!m_ui->deviceAskCheckBox->isChecked());
|
||||
IosConfigurations::setScreenshotDir(m_ui->pathWidget->filePath());
|
||||
IosConfigurations::setIgnoreAllDevices(!m_deviceAskCheckBox->isChecked());
|
||||
IosConfigurations::setScreenshotDir(m_pathWidget->filePath());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Ios::Internal
|
||||
|
||||
|
||||
@@ -26,14 +26,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "iosconfigurations.h"
|
||||
#include "simulatorcontrol.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace Ui { class IosSettingsWidget; }
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
class QTreeView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class PathChooser; }
|
||||
|
||||
namespace Ios::Internal {
|
||||
|
||||
class IosSettingsWidget final : public Core::IOptionsPageWidget
|
||||
{
|
||||
@@ -57,8 +63,13 @@ private:
|
||||
void onSelectionChanged();
|
||||
|
||||
private:
|
||||
Ui::IosSettingsWidget *m_ui = nullptr;
|
||||
Utils::PathChooser *m_pathWidget;
|
||||
QPushButton *m_startButton;
|
||||
QPushButton *m_renameButton;
|
||||
QPushButton *m_deleteButton;
|
||||
QPushButton *m_resetButton;
|
||||
QTreeView *m_deviceView;
|
||||
QCheckBox *m_deviceAskCheckBox;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Ios
|
||||
} // Ios::Internal
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Ios::Internal::IosSettingsWidget</class>
|
||||
<widget class="QWidget" name="Ios::Internal::IosSettingsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>622</width>
|
||||
<height>456</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>iOS Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Devices</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="deviceAskCheckBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ask about devices not in developer mode</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Simulator</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="renameButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Rename a simulator device.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rename</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="deleteButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete simulator devices.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="resetButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset contents and settings of simulator devices.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="7">
|
||||
<widget class="QTreeView" name="deviceView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Screenshot directory:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Utils::PathChooser" name="pathWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="createButton">
|
||||
<property name="toolTip">
|
||||
<string>Create a new simulator device.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="startButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Start simulator devices.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user