ProjectExplorer: Bring back ability to customize the Desktop port range

This reverts 753dd85162 and
fe6b954304.

Fixes: QTCREATORBUG-31406
Change-Id: Ic8a2ced6f6bf3638176a95af29ea37ff340e5530
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Christian Kandeler
2024-09-09 16:38:59 +02:00
parent d0ec82f54d
commit 9a8b493afa
6 changed files with 211 additions and 5 deletions

View File

@@ -47,6 +47,7 @@ add_qtc_plugin(ProjectExplorer
deploymentdataview.cpp deploymentdataview.h
desktoprunconfiguration.cpp desktoprunconfiguration.h
devicesupport/desktopdevice.cpp devicesupport/desktopdevice.h
devicesupport/desktopdeviceconfigurationwidget.cpp devicesupport/desktopdeviceconfigurationwidget.h devicesupport/desktopdeviceconfigurationwidget.ui
devicesupport/desktopdevicefactory.cpp devicesupport/desktopdevicefactory.h
devicesupport/desktopprocesssignaloperation.cpp devicesupport/desktopprocesssignaloperation.h
devicesupport/devicecheckbuildstep.cpp devicesupport/devicecheckbuildstep.h

View File

@@ -5,6 +5,7 @@
#include "../projectexplorerconstants.h"
#include "../projectexplorertr.h"
#include "desktopdeviceconfigurationwidget.h"
#include "desktopprocesssignaloperation.h"
#include <coreplugin/fileutils.h>
@@ -80,10 +81,7 @@ IDevice::DeviceInfo DesktopDevice::deviceInformation() const
IDeviceWidget *DesktopDevice::createWidget()
{
return nullptr;
// DesktopDeviceConfigurationWidget currently has just one editable field viz. free ports.
// Querying for an available port is quite straightforward. Having a field for the port
// range can be confusing to the user. Hence, disabling the widget for now.
return new DesktopDeviceConfigurationWidget(shared_from_this());
}
bool DesktopDevice::canCreateProcessModel() const

View File

@@ -0,0 +1,87 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "desktopdeviceconfigurationwidget.h"
#include "ui_desktopdeviceconfigurationwidget.h"
#include "../projectexplorerconstants.h"
#include "idevice.h"
#include <utils/utilsicons.h>
#include <utils/portlist.h>
#include <utils/qtcassert.h>
#include <QRegularExpressionValidator>
using namespace ProjectExplorer::Constants;
namespace ProjectExplorer {
DesktopDeviceConfigurationWidget::DesktopDeviceConfigurationWidget(const IDevicePtr &device) :
IDeviceWidget(device),
m_ui(new Ui::DesktopDeviceConfigurationWidget)
{
m_ui->setupUi(this);
connect(m_ui->freePortsLineEdit, &QLineEdit::textChanged,
this, &DesktopDeviceConfigurationWidget::updateFreePorts);
initGui();
}
DesktopDeviceConfigurationWidget::~DesktopDeviceConfigurationWidget()
{
delete m_ui;
}
void DesktopDeviceConfigurationWidget::updateDeviceFromUi()
{
updateFreePorts();
}
void DesktopDeviceConfigurationWidget::updateFreePorts()
{
device()->setFreePorts(Utils::PortList::fromString(m_ui->freePortsLineEdit->text()));
m_ui->portsWarningLabel->setVisible(!device()->freePorts().hasMore());
}
void DesktopDeviceConfigurationWidget::initGui()
{
QTC_CHECK(device()->machineType() == IDevice::Hardware);
m_ui->machineTypeValueLabel->setText(tr("Physical Device"));
m_ui->freePortsLineEdit->setPlaceholderText(
QString::fromLatin1("eg: %1-%2").arg(DESKTOP_PORT_START).arg(DESKTOP_PORT_END));
m_ui->portsWarningLabel->setPixmap(Utils::Icons::WARNING.pixmap());
m_ui->portsWarningLabel->setToolTip(QLatin1String("<font color=\"red\">")
+ tr("You will need at least one port for QML debugging.")
+ QLatin1String("</font>"));
const auto portsValidator = new QRegularExpressionValidator(
QRegularExpression(Utils::PortList::regularExpression()), this);
m_ui->freePortsLineEdit->setValidator(portsValidator);
m_ui->freePortsLineEdit->setText(device()->freePorts().toString());
updateFreePorts();
}
} // namespace ProjectExplorer

View File

@@ -0,0 +1,50 @@
/****************************************************************************
**
** Copyright (C) 2016 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 "idevicewidget.h"
namespace ProjectExplorer {
namespace Ui { class DesktopDeviceConfigurationWidget; }
class DesktopDeviceConfigurationWidget : public IDeviceWidget
{
public:
explicit DesktopDeviceConfigurationWidget(const IDevicePtr &device);
~DesktopDeviceConfigurationWidget() override;
void updateDeviceFromUi() override;
private:
void updateFreePorts();
void initGui();
private:
Ui::DesktopDeviceConfigurationWidget *m_ui;
};
} // namespace ProjectExplorer

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectExplorer::DesktopDeviceConfigurationWidget</class>
<widget class="QWidget" name="ProjectExplorer::DesktopDeviceConfigurationWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>265</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="machineTypeLabel">
<property name="text">
<string>Machine type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="machineTypeValueLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="freePortsLabel">
<property name="text">
<string>Free ports:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="freePortsLineEdit"/>
</item>
<item>
<widget class="QLabel" name="portsWarningLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -223,7 +223,8 @@ QtcPlugin {
"sshparameters.cpp", "sshparameters.h",
"sshsettings.cpp", "sshsettings.h",
"sshsettingspage.cpp", "sshsettingspage.h",
"desktopprocesssignaloperation.cpp", "desktopprocesssignaloperation.h"
"desktopdeviceconfigurationwidget.cpp", "desktopdeviceconfigurationwidget.h", "desktopdeviceconfigurationwidget.ui",
"desktopprocesssignaloperation.cpp", "desktopprocesssignaloperation.h",
]
}