diff --git a/src/plugins/projectexplorer/CMakeLists.txt b/src/plugins/projectexplorer/CMakeLists.txt index 9643a33dada..46b7ebf8c2f 100644 --- a/src/plugins/projectexplorer/CMakeLists.txt +++ b/src/plugins/projectexplorer/CMakeLists.txt @@ -57,7 +57,7 @@ add_qtc_plugin(ProjectExplorer devicesupport/deviceprocessesdialog.cpp devicesupport/deviceprocessesdialog.h devicesupport/deviceprocesslist.cpp devicesupport/deviceprocesslist.h devicesupport/devicesettingspage.cpp devicesupport/devicesettingspage.h - devicesupport/devicesettingswidget.cpp devicesupport/devicesettingswidget.h devicesupport/devicesettingswidget.ui + devicesupport/devicesettingswidget.cpp devicesupport/devicesettingswidget.h devicesupport/devicetestdialog.cpp devicesupport/devicetestdialog.h devicesupport/deviceusedportsgatherer.cpp devicesupport/deviceusedportsgatherer.h devicesupport/filetransfer.cpp devicesupport/filetransfer.h diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp index aa90e5b963e..722a8517c83 100644 --- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "devicesettingswidget.h" -#include "ui_devicesettingswidget.h" #include "devicefactoryselectiondialog.h" #include "devicemanager.h" @@ -17,12 +16,19 @@ #include -#include #include +#include +#include -#include +#include +#include +#include +#include #include +#include #include +#include +#include #include @@ -64,8 +70,7 @@ private: }; DeviceSettingsWidget::DeviceSettingsWidget() - : m_ui(new Ui::DeviceSettingsWidget), - m_deviceManager(DeviceManager::cloneInstance()), + : m_deviceManager(DeviceManager::cloneInstance()), m_deviceManagerModel(new DeviceManagerModel(m_deviceManager, this)), m_nameValidator(new NameValidator(m_deviceManager, this)), m_configWidget(nullptr) @@ -79,36 +84,85 @@ DeviceSettingsWidget::~DeviceSettingsWidget() { DeviceManager::removeClonedInstance(); delete m_configWidget; - delete m_ui; } void DeviceSettingsWidget::initGui() { - m_ui->setupUi(this); - m_ui->configurationComboBox->setModel(m_deviceManagerModel); - m_ui->nameLineEdit->setValidator(m_nameValidator); + m_configurationLabel = new QLabel(tr("&Device:")); + m_configurationComboBox = new QComboBox; + m_configurationComboBox->setModel(m_deviceManagerModel); + m_generalGroupBox = new QGroupBox(tr("General")); + m_nameLineEdit = new QLineEdit; + m_nameLineEdit->setValidator(m_nameValidator); + m_osTypeValueLabel = new QLabel; + m_autoDetectionLabel = new QLabel; + m_deviceStateIconLabel = new QLabel; + m_deviceStateTextLabel = new QLabel; + m_osSpecificGroupBox = new QGroupBox(tr("Type Specific")); + m_osSpecificGroupBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + m_addConfigButton = new QPushButton(tr("&Add...")); + m_removeConfigButton = new QPushButton(tr("&Remove")); + m_defaultDeviceButton = new QPushButton(tr("Set As Default")); + auto line = new QFrame; + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + auto customButtonsContainer = new QWidget; + m_buttonsLayout = new QVBoxLayout(customButtonsContainer); + m_buttonsLayout->setContentsMargins({}); + auto scrollAreaWidget = new QWidget; + auto scrollArea = new QScrollArea; + scrollArea->setWidgetResizable(true); + scrollArea->setWidget(scrollAreaWidget); + + using namespace Utils::Layouting; + Column { + m_generalGroupBox, + m_osSpecificGroupBox, + }.attachTo(scrollAreaWidget); + + Form { + tr("&Name:"), m_nameLineEdit, br, + tr("Type:"), m_osTypeValueLabel, br, + tr("Auto-detected:"), m_autoDetectionLabel, br, + tr("Current state:"), Row { m_deviceStateIconLabel, m_deviceStateTextLabel, st, }, br, + }.attachTo(m_generalGroupBox); + + Row { + Column { + Form { m_configurationLabel, m_configurationComboBox, br, }, + scrollArea, + }, + Column { + m_addConfigButton, + m_removeConfigButton, + m_defaultDeviceButton, + line, + customButtonsContainer, + st, + }, + }.attachTo(this); bool hasDeviceFactories = Utils::anyOf(IDeviceFactory::allDeviceFactories(), &IDeviceFactory::canCreate); - m_ui->addConfigButton->setEnabled(hasDeviceFactories); + m_addConfigButton->setEnabled(hasDeviceFactories); int lastIndex = ICore::settings() ->value(QLatin1String(LastDeviceIndexKey), 0).toInt(); if (lastIndex == -1) lastIndex = 0; - if (lastIndex < m_ui->configurationComboBox->count()) - m_ui->configurationComboBox->setCurrentIndex(lastIndex); - connect(m_ui->configurationComboBox, &QComboBox::currentIndexChanged, + if (lastIndex < m_configurationComboBox->count()) + m_configurationComboBox->setCurrentIndex(lastIndex); + connect(m_configurationComboBox, &QComboBox::currentIndexChanged, this, &DeviceSettingsWidget::currentDeviceChanged); currentDeviceChanged(currentIndex()); - connect(m_ui->defaultDeviceButton, &QAbstractButton::clicked, + connect(m_defaultDeviceButton, &QAbstractButton::clicked, this, &DeviceSettingsWidget::setDefaultDevice); - connect(m_ui->removeConfigButton, &QAbstractButton::clicked, + connect(m_removeConfigButton, &QAbstractButton::clicked, this, &DeviceSettingsWidget::removeDevice); - connect(m_ui->nameLineEdit, &QLineEdit::editingFinished, + connect(m_nameLineEdit, &QLineEdit::editingFinished, this, &DeviceSettingsWidget::deviceNameEditingFinished); - connect(m_ui->addConfigButton, &QAbstractButton::clicked, + connect(m_addConfigButton, &QAbstractButton::clicked, this, &DeviceSettingsWidget::addDevice); } @@ -129,8 +183,8 @@ void DeviceSettingsWidget::addDevice() return; m_deviceManager->addDevice(device); - m_ui->removeConfigButton->setEnabled(true); - m_ui->configurationComboBox->setCurrentIndex(m_deviceManagerModel->indexOf(device)); + m_removeConfigButton->setEnabled(true); + m_configurationComboBox->setCurrentIndex(m_deviceManagerModel->indexOf(device)); saveSettings(); if (device->hasDeviceTester()) testDevice(); @@ -146,46 +200,46 @@ void DeviceSettingsWidget::removeDevice() void DeviceSettingsWidget::displayCurrent() { const IDevice::ConstPtr ¤t = currentDevice(); - m_ui->defaultDeviceButton->setEnabled( + m_defaultDeviceButton->setEnabled( m_deviceManager->defaultDevice(current->type()) != current); - m_ui->osTypeValueLabel->setText(current->displayType()); - m_ui->autoDetectionValueLabel->setText(current->isAutoDetected() + m_osTypeValueLabel->setText(current->displayType()); + m_autoDetectionLabel->setText(current->isAutoDetected() ? tr("Yes (id is \"%1\")").arg(current->id().toString()) : tr("No")); m_nameValidator->setDisplayName(current->displayName()); - m_ui->deviceStateValueIconLabel->show(); + m_deviceStateIconLabel->show(); switch (current->deviceState()) { case IDevice::DeviceReadyToUse: - m_ui->deviceStateValueIconLabel->setPixmap(Icons::DEVICE_READY_INDICATOR.pixmap()); + m_deviceStateIconLabel->setPixmap(Icons::DEVICE_READY_INDICATOR.pixmap()); break; case IDevice::DeviceConnected: - m_ui->deviceStateValueIconLabel->setPixmap(Icons::DEVICE_CONNECTED_INDICATOR.pixmap()); + m_deviceStateIconLabel->setPixmap(Icons::DEVICE_CONNECTED_INDICATOR.pixmap()); break; case IDevice::DeviceDisconnected: - m_ui->deviceStateValueIconLabel->setPixmap(Icons::DEVICE_DISCONNECTED_INDICATOR.pixmap()); + m_deviceStateIconLabel->setPixmap(Icons::DEVICE_DISCONNECTED_INDICATOR.pixmap()); break; case IDevice::DeviceStateUnknown: - m_ui->deviceStateValueIconLabel->hide(); + m_deviceStateIconLabel->hide(); break; } - m_ui->deviceStateValueTextLabel->setText(current->deviceStateToString()); + m_deviceStateTextLabel->setText(current->deviceStateToString()); - m_ui->removeConfigButton->setEnabled(!current->isAutoDetected() + m_removeConfigButton->setEnabled(!current->isAutoDetected() || current->deviceState() == IDevice::DeviceDisconnected); fillInValues(); } void DeviceSettingsWidget::setDeviceInfoWidgetsEnabled(bool enable) { - m_ui->configurationLabel->setEnabled(enable); - m_ui->configurationComboBox->setEnabled(enable); - m_ui->generalGroupBox->setEnabled(enable); - m_ui->osSpecificGroupBox->setEnabled(enable); + m_configurationLabel->setEnabled(enable); + m_configurationComboBox->setEnabled(enable); + m_generalGroupBox->setEnabled(enable); + m_osSpecificGroupBox->setEnabled(enable); } void DeviceSettingsWidget::fillInValues() { const IDevice::ConstPtr ¤t = currentDevice(); - m_ui->nameLineEdit->setText(current->displayName()); + m_nameLineEdit->setText(current->displayName()); } void DeviceSettingsWidget::updateDeviceFromUi() @@ -203,7 +257,7 @@ void DeviceSettingsWidget::saveSettings() int DeviceSettingsWidget::currentIndex() const { - return m_ui->configurationComboBox->currentIndex(); + return m_configurationComboBox->currentIndex(); } IDevice::ConstPtr DeviceSettingsWidget::currentDevice() const @@ -214,10 +268,10 @@ IDevice::ConstPtr DeviceSettingsWidget::currentDevice() const void DeviceSettingsWidget::deviceNameEditingFinished() { - if (m_ui->configurationComboBox->count() == 0) + if (m_configurationComboBox->count() == 0) return; - const QString &newName = m_ui->nameLineEdit->text(); + const QString &newName = m_nameLineEdit->text(); m_deviceManager->mutableDevice(currentDevice()->id())->setDisplayName(newName); m_nameValidator->setDisplayName(newName); m_deviceManagerModel->updateDevice(currentDevice()->id()); @@ -226,7 +280,7 @@ void DeviceSettingsWidget::deviceNameEditingFinished() void DeviceSettingsWidget::setDefaultDevice() { m_deviceManager->setDefaultDevice(currentDevice()->id()); - m_ui->defaultDeviceButton->setEnabled(false); + m_defaultDeviceButton->setEnabled(false); } void DeviceSettingsWidget::testDevice() @@ -255,19 +309,19 @@ void DeviceSettingsWidget::currentDeviceChanged(int index) const IDevice::ConstPtr device = m_deviceManagerModel->device(index); if (device.isNull()) { setDeviceInfoWidgetsEnabled(false); - m_ui->removeConfigButton->setEnabled(false); + m_removeConfigButton->setEnabled(false); clearDetails(); - m_ui->defaultDeviceButton->setEnabled(false); + m_defaultDeviceButton->setEnabled(false); return; } setDeviceInfoWidgetsEnabled(true); - m_ui->removeConfigButton->setEnabled(true); + m_removeConfigButton->setEnabled(true); if (device->hasDeviceTester()) { QPushButton * const button = new QPushButton(tr("Test")); m_additionalActionButtons << button; connect(button, &QAbstractButton::clicked, this, &DeviceSettingsWidget::testDevice); - m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button); + m_buttonsLayout->insertWidget(m_buttonsLayout->count() - 1, button); } if (device->canCreateProcessModel()) { @@ -275,7 +329,7 @@ void DeviceSettingsWidget::currentDeviceChanged(int index) m_additionalActionButtons << button; connect(button, &QAbstractButton::clicked, this, &DeviceSettingsWidget::handleProcessListRequested); - m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button); + m_buttonsLayout->insertWidget(m_buttonsLayout->count() - 1, button); } for (const IDevice::DeviceAction &deviceAction : device->deviceActions()) { @@ -291,22 +345,22 @@ void DeviceSettingsWidget::currentDeviceChanged(int index) currentDeviceChanged(currentIndex()); }); - m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button); + m_buttonsLayout->insertWidget(m_buttonsLayout->count() - 1, button); } - if (!m_ui->osSpecificGroupBox->layout()) - new QVBoxLayout(m_ui->osSpecificGroupBox); + if (!m_osSpecificGroupBox->layout()) + new QVBoxLayout(m_osSpecificGroupBox); m_configWidget = m_deviceManager->mutableDevice(device->id())->createWidget(); if (m_configWidget) - m_ui->osSpecificGroupBox->layout()->addWidget(m_configWidget); + m_osSpecificGroupBox->layout()->addWidget(m_configWidget); displayCurrent(); } void DeviceSettingsWidget::clearDetails() { - m_ui->nameLineEdit->clear(); - m_ui->osTypeValueLabel->clear(); - m_ui->autoDetectionValueLabel->clear(); + m_nameLineEdit->clear(); + m_osTypeValueLabel->clear(); + m_autoDetectionLabel->clear(); } void DeviceSettingsWidget::handleProcessListRequested() diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h index 00d4bce79f5..ceaf349ff2e 100644 --- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h +++ b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.h @@ -12,7 +12,12 @@ #include QT_BEGIN_NAMESPACE +class QComboBox; +class QGroupBox; +class QLabel; +class QLineEdit; class QPushButton; +class QVBoxLayout; QT_END_NAMESPACE namespace ProjectExplorer { @@ -61,6 +66,20 @@ private: NameValidator * const m_nameValidator; QList m_additionalActionButtons; IDeviceWidget *m_configWidget; + + QLabel *m_configurationLabel; + QComboBox *m_configurationComboBox; + QGroupBox *m_generalGroupBox; + QLineEdit *m_nameLineEdit; + QLabel *m_osTypeValueLabel; + QLabel *m_autoDetectionLabel; + QLabel *m_deviceStateIconLabel; + QLabel *m_deviceStateTextLabel; + QGroupBox *m_osSpecificGroupBox; + QPushButton *m_addConfigButton; + QPushButton *m_removeConfigButton; + QPushButton *m_defaultDeviceButton; + QVBoxLayout *m_buttonsLayout; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.ui b/src/plugins/projectexplorer/devicesupport/devicesettingswidget.ui deleted file mode 100644 index 83e1eb4a718..00000000000 --- a/src/plugins/projectexplorer/devicesupport/devicesettingswidget.ui +++ /dev/null @@ -1,237 +0,0 @@ - - - ProjectExplorer::Internal::DeviceSettingsWidget - - - - 0 - 0 - 728 - 429 - - - - Linux Device Configurations - - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - &Device: - - - configurationComboBox - - - - - - - - 0 - 0 - - - - false - - - - - - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 564 - 360 - - - - - - - General - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - &Name: - - - nameLineEdit - - - - - - - - - - Type: - - - - - - - - - - - - - - Auto-detected: - - - - - - - - - - - - - - Current state: - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - 0 - 0 - - - - Type Specific - - - - - - - - - - - - - - - Qt::StrongFocus - - - &Add... - - - - - - - false - - - Qt::StrongFocus - - - &Remove - - - - - - - false - - - Qt::StrongFocus - - - Set As Default - - - - - - - Qt::Horizontal - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 22de85caa9f..62512aa7d4c 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -217,7 +217,7 @@ Project { "deviceprocessesdialog.cpp", "deviceprocessesdialog.h", "deviceprocesslist.cpp", "deviceprocesslist.h", "devicesettingspage.cpp", "devicesettingspage.h", - "devicesettingswidget.cpp", "devicesettingswidget.h", "devicesettingswidget.ui", + "devicesettingswidget.cpp", "devicesettingswidget.h", "devicetestdialog.cpp", "devicetestdialog.h", "deviceusedportsgatherer.cpp", "deviceusedportsgatherer.h", "filetransfer.cpp", "filetransfer.h",