forked from qt-creator/qt-creator
ProjectExplorer: inline devicefactoryselectiondialog.ui
Change-Id: Ia89fe74552236ec6400e9dd08624279f55800945 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -50,7 +50,7 @@ add_qtc_plugin(ProjectExplorer
|
||||
devicesupport/desktopdevicefactory.cpp devicesupport/desktopdevicefactory.h
|
||||
devicesupport/desktopprocesssignaloperation.cpp devicesupport/desktopprocesssignaloperation.h
|
||||
devicesupport/devicecheckbuildstep.cpp devicesupport/devicecheckbuildstep.h
|
||||
devicesupport/devicefactoryselectiondialog.cpp devicesupport/devicefactoryselectiondialog.h devicesupport/devicefactoryselectiondialog.ui
|
||||
devicesupport/devicefactoryselectiondialog.cpp devicesupport/devicefactoryselectiondialog.h
|
||||
devicesupport/devicefilesystemmodel.cpp devicesupport/devicefilesystemmodel.h
|
||||
devicesupport/devicemanager.cpp devicesupport/devicemanager.h
|
||||
devicesupport/devicemanagermodel.cpp devicesupport/devicemanagermodel.h
|
||||
|
@@ -2,48 +2,56 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "devicefactoryselectiondialog.h"
|
||||
#include "ui_devicefactoryselectiondialog.h"
|
||||
|
||||
#include "idevice.h"
|
||||
#include "idevicefactory.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
DeviceFactorySelectionDialog::DeviceFactorySelectionDialog(QWidget *parent) :
|
||||
QDialog(parent), ui(new Ui::DeviceFactorySelectionDialog)
|
||||
QDialog(parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start Wizard"));
|
||||
resize(420, 330);
|
||||
m_listWidget = new QListWidget;
|
||||
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
m_buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start Wizard"));
|
||||
|
||||
using namespace Utils::Layouting;
|
||||
Column {
|
||||
tr("Available device types:"),
|
||||
m_listWidget,
|
||||
m_buttonBox,
|
||||
}.attachTo(this);
|
||||
|
||||
for (const IDeviceFactory * const factory : IDeviceFactory::allDeviceFactories()) {
|
||||
if (!factory->canCreate())
|
||||
continue;
|
||||
QListWidgetItem *item = new QListWidgetItem(factory->displayName());
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(factory->deviceType()));
|
||||
ui->listWidget->addItem(item);
|
||||
m_listWidget->addItem(item);
|
||||
}
|
||||
|
||||
connect(ui->listWidget, &QListWidget::itemSelectionChanged,
|
||||
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &DeviceFactorySelectionDialog::accept);
|
||||
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &DeviceFactorySelectionDialog::reject);
|
||||
connect(m_listWidget, &QListWidget::itemSelectionChanged,
|
||||
this, &DeviceFactorySelectionDialog::handleItemSelectionChanged);
|
||||
connect(ui->listWidget, &QListWidget::itemDoubleClicked,
|
||||
connect(m_listWidget, &QListWidget::itemDoubleClicked,
|
||||
this, &DeviceFactorySelectionDialog::handleItemDoubleClicked);
|
||||
handleItemSelectionChanged();
|
||||
}
|
||||
|
||||
DeviceFactorySelectionDialog::~DeviceFactorySelectionDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DeviceFactorySelectionDialog::handleItemSelectionChanged()
|
||||
{
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)
|
||||
->setEnabled(!ui->listWidget->selectedItems().isEmpty());
|
||||
m_buttonBox->button(QDialogButtonBox::Ok)
|
||||
->setEnabled(!m_listWidget->selectedItems().isEmpty());
|
||||
}
|
||||
|
||||
void DeviceFactorySelectionDialog::handleItemDoubleClicked()
|
||||
@@ -53,7 +61,7 @@ void DeviceFactorySelectionDialog::handleItemDoubleClicked()
|
||||
|
||||
Utils::Id DeviceFactorySelectionDialog::selectedId() const
|
||||
{
|
||||
QList<QListWidgetItem *> selected = ui->listWidget->selectedItems();
|
||||
QList<QListWidgetItem *> selected = m_listWidget->selectedItems();
|
||||
if (selected.isEmpty())
|
||||
return Utils::Id();
|
||||
return selected.at(0)->data(Qt::UserRole).value<Utils::Id>();
|
||||
|
@@ -7,11 +7,15 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDialogButtonBox;
|
||||
class QListWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class IDeviceFactory;
|
||||
|
||||
namespace Internal {
|
||||
namespace Ui { class DeviceFactorySelectionDialog; }
|
||||
|
||||
class DeviceFactorySelectionDialog : public QDialog
|
||||
{
|
||||
@@ -19,13 +23,14 @@ class DeviceFactorySelectionDialog : public QDialog
|
||||
|
||||
public:
|
||||
explicit DeviceFactorySelectionDialog(QWidget *parent = nullptr);
|
||||
~DeviceFactorySelectionDialog() override;
|
||||
Utils::Id selectedId() const;
|
||||
|
||||
private:
|
||||
void handleItemSelectionChanged();
|
||||
void handleItemDoubleClicked();
|
||||
Ui::DeviceFactorySelectionDialog *ui;
|
||||
|
||||
QListWidget *m_listWidget;
|
||||
QDialogButtonBox *m_buttonBox;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -1,87 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ProjectExplorer::Internal::DeviceFactorySelectionDialog</class>
|
||||
<widget class="QDialog" name="ProjectExplorer::Internal::DeviceFactorySelectionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>414</width>
|
||||
<height>331</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Device Configuration Wizard Selection</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Available device types:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>QListView::Adjust</enum>
|
||||
</property>
|
||||
<property name="uniformItemSizes">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</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>ProjectExplorer::Internal::DeviceFactorySelectionDialog</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>ProjectExplorer::Internal::DeviceFactorySelectionDialog</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>
|
@@ -210,7 +210,7 @@ Project {
|
||||
"desktopdevice.cpp", "desktopdevice.h",
|
||||
"desktopdevicefactory.cpp", "desktopdevicefactory.h",
|
||||
"devicecheckbuildstep.cpp", "devicecheckbuildstep.h",
|
||||
"devicefactoryselectiondialog.cpp", "devicefactoryselectiondialog.h", "devicefactoryselectiondialog.ui",
|
||||
"devicefactoryselectiondialog.cpp", "devicefactoryselectiondialog.h",
|
||||
"devicefilesystemmodel.cpp", "devicefilesystemmodel.h",
|
||||
"devicemanager.cpp", "devicemanager.h",
|
||||
"devicemanagermodel.cpp", "devicemanagermodel.h",
|
||||
|
Reference in New Issue
Block a user