Boot2Qt: Merge QdbDeviceWizard file triple into device files

Change-Id: I22abfb0355667000278f8a4e2cd6f8d0f0834a94
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-06-13 09:26:45 +02:00
parent 467154e54a
commit 8ec882a6e6
6 changed files with 86 additions and 258 deletions

View File

@@ -11,7 +11,6 @@ HEADERS += \
qdbdevice.h \
qdbqtversion.h \
qdbdeployconfigurationfactory.h \
qdbdevicewizard.h \
qdbrunconfiguration.h \
qdbmakedefaultappstep.h \
qdbmakedefaultappservice.h \
@@ -28,7 +27,6 @@ SOURCES += \
qdbdevice.cpp \
qdbqtversion.cpp \
qdbdeployconfigurationfactory.cpp \
qdbdevicewizard.cpp \
qdbrunconfiguration.cpp \
qdbmakedefaultappstep.cpp \
qdbmakedefaultappservice.cpp \
@@ -38,8 +36,5 @@ SOURCES += \
qdbdevicedebugsupport.cpp \
qdbplugin.cpp \
FORMS += \
qdbdevicewizardsettingspage.ui
RESOURCES += \
qdb.qrc

View File

@@ -29,9 +29,6 @@ QtcPlugin {
"qdbdevice.h",
"qdbdevicedebugsupport.cpp",
"qdbdevicedebugsupport.h",
"qdbdevicewizard.cpp",
"qdbdevicewizard.h",
"qdbdevicewizardsettingspage.ui",
"qdbmakedefaultappservice.cpp",
"qdbmakedefaultappservice.h",
"qdbmakedefaultappstep.cpp",

View File

@@ -28,7 +28,6 @@
#include "qdbutils.h"
#include "qdbconstants.h"
#include "qdbdevicedebugsupport.h"
#include "qdbdevicewizard.h"
#include <coreplugin/icore.h>
@@ -44,6 +43,11 @@
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QWizard>
using namespace ProjectExplorer;
using namespace Utils;
@@ -213,16 +217,85 @@ std::function<ProjectExplorer::RunWorker *(ProjectExplorer::RunControl *)>
}
// Device factory
// QdbDeviceWizard
static IDevice::Ptr createDevice(QdbDeviceWizard::DeviceType deviceType)
class QdbSettingsPage : public QWizardPage
{
QdbDeviceWizard wizard(deviceType, Core::ICore::mainWindow());
public:
QdbSettingsPage()
{
setWindowTitle(QdbDevice::tr("WizardPage"));
setTitle(QdbDevice::tr("Device Settings"));
if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr();
return wizard.device();
}
nameLineEdit = new QLineEdit(this);
nameLineEdit->setPlaceholderText(QdbDevice::tr("A short, free-text description"));
addressLineEdit = new QLineEdit(this);
addressLineEdit->setPlaceholderText(QdbDevice::tr("Host name or IP address"));
auto usbWarningLabel = new QLabel(this);
usbWarningLabel->setText(QString("<html><head/><body><it><b>%1</it><p>%2</p></body></html>")
.arg("Note:")
.arg("Do not use this wizard for devices connected via USB.<br/>"
"Those will be auto-detected.</p>"
"<p>The connectivity to the device is tested after finishing."));
auto formLayout = new QFormLayout(this);
formLayout->addRow(QdbDevice::tr("Device name:"), nameLineEdit);
formLayout->addRow(QdbDevice::tr("Device address:"), addressLineEdit);
formLayout->addRow(usbWarningLabel);
connect(nameLineEdit, &QLineEdit::textChanged, this, &QWizardPage::completeChanged);
connect(addressLineEdit, &QLineEdit::textChanged, this, &QWizardPage::completeChanged);
}
QString deviceName() const { return nameLineEdit->text().trimmed(); }
QString deviceAddress() const { return addressLineEdit->text().trimmed(); }
private:
bool isComplete() const final {
return !deviceName().isEmpty() && !deviceAddress().isEmpty();
}
QLineEdit *nameLineEdit;
QLineEdit *addressLineEdit;
};
class QdbDeviceWizard : public QWizard
{
public:
QdbDeviceWizard(QWidget *parent)
: QWizard(parent)
{
setWindowTitle(QdbDeviceWizard::tr("Boot2Qt Network Device Setup"));
settingsPage.setCommitPage(true);
enum { SettingsPageId };
setPage(SettingsPageId, &settingsPage);
}
ProjectExplorer::IDevice::Ptr device()
{
QdbDevice::Ptr device = QdbDevice::create();
device->setDisplayName(settingsPage.deviceName());
device->setupId(ProjectExplorer::IDevice::ManuallyAdded, Core::Id());
device->setType(Constants::QdbLinuxOsType);
device->setMachineType(ProjectExplorer::IDevice::Hardware);
device->setupDefaultNetworkSettings(settingsPage.deviceAddress());
return device;
}
private:
QdbSettingsPage settingsPage;
};
// Device factory
QdbLinuxDeviceFactory::QdbLinuxDeviceFactory()
: IDeviceFactory(Constants::QdbLinuxOsType)
@@ -235,7 +308,11 @@ QdbLinuxDeviceFactory::QdbLinuxDeviceFactory()
IDevice::Ptr QdbLinuxDeviceFactory::create() const
{
return createDevice(QdbDeviceWizard::HardwareDevice);
QdbDeviceWizard wizard(Core::ICore::mainWindow());
if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr();
return wizard.device();
}
} // namespace Internal

View File

@@ -1,113 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** 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
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "qdbdevicewizard.h"
#include "ui_qdbdevicewizardsettingspage.h"
#include "qdbconstants.h"
#include "qdbdevice.h"
#include <utils/qtcassert.h>
#include <QString>
#include <QWizardPage>
namespace {
enum PageId { SettingsPageId };
} // anonymous namespace
namespace Qdb {
namespace Internal {
class QdbSettingsPage : public QWizardPage
{
Q_OBJECT
public:
QdbSettingsPage(QdbDeviceWizard::DeviceType deviceType, QWidget *parent = 0)
: QWizardPage(parent), m_deviceType(deviceType)
{
m_ui.setupUi(this);
setTitle(tr("Device Settings"));
connect(m_ui.nameLineEdit, &QLineEdit::textChanged, this, &QWizardPage::completeChanged);
connect(m_ui.addressLineEdit, &QLineEdit::textChanged,
this, &QWizardPage::completeChanged);
}
QdbDeviceWizard::DeviceType deviceType() const { return m_deviceType; }
QString deviceName() const { return m_ui.nameLineEdit->text().trimmed(); }
QString deviceAddress() const { return m_ui.addressLineEdit->text().trimmed(); }
private:
bool isComplete() const final {
return !deviceName().isEmpty() && !deviceAddress().isEmpty();
}
QdbDeviceWizard::DeviceType m_deviceType;
Ui::QdbDeviceWizardSettingsPage m_ui;
};
class QdbDeviceWizard::DeviceWizardPrivate
{
public:
DeviceWizardPrivate(DeviceType deviceType)
: settingsPage(deviceType)
{
}
QdbSettingsPage settingsPage;
};
QdbDeviceWizard::QdbDeviceWizard(DeviceType deviceType, QWidget *parent)
: QWizard(parent), d(new DeviceWizardPrivate(deviceType))
{
setWindowTitle(tr("Boot2Qt Network Device Setup"));
d->settingsPage.setCommitPage(true);
setPage(SettingsPageId, &d->settingsPage);
}
QdbDeviceWizard::~QdbDeviceWizard()
{
delete d;
}
ProjectExplorer::IDevice::Ptr QdbDeviceWizard::device()
{
QdbDevice::Ptr device = QdbDevice::create();
device->setDisplayName(d->settingsPage.deviceName());
device->setupId(ProjectExplorer::IDevice::ManuallyAdded, Core::Id());
device->setType(Constants::QdbLinuxOsType);
device->setMachineType(ProjectExplorer::IDevice::Hardware);
device->setupDefaultNetworkSettings(d->settingsPage.deviceAddress());
return device;
}
} // namespace Internal
} // namespace Qdb
#include "qdbdevicewizard.moc"

View File

@@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** 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
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/devicesupport/idevice.h>
#include <QWizard>
namespace Qdb {
namespace Internal {
class QdbDeviceWizard : public QWizard
{
Q_OBJECT
public:
enum DeviceType
{
HardwareDevice
};
QdbDeviceWizard(DeviceType deviceType, QWidget *parent = 0);
~QdbDeviceWizard();
ProjectExplorer::IDevice::Ptr device();
private:
class DeviceWizardPrivate;
DeviceWizardPrivate * const d;
};
} // namespace Internal
} // namespace Qdb

View File

@@ -1,73 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Qdb::Internal::QdbDeviceWizardSettingsPage</class>
<widget class="QWizardPage" name="Qdb::Internal::QdbDeviceWizardSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>669</width>
<height>308</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Device name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameLineEdit">
<property name="placeholderText">
<string>A short, free-text description</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="addressLabel">
<property name="text">
<string>Device address:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="addressLineEdit">
<property name="placeholderText">
<string>Host name or IP address</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="usbWarningLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; Do not use this wizard for devices connected via USB.&lt;br/&gt;Those will be auto-detected.&lt;/p&gt;&lt;p&gt;The connectivity to the device is tested after finishing.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<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>
</layout>
</widget>
<resources/>
<connections/>
</ui>