BareMetal: Share HostWidget for all debug providers

Change-Id: Ie1db80987c8f3cacdae49daff3969228105c08ea
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Denis Shienkov
2019-11-28 14:49:42 +03:00
parent 6fdbd6d784
commit b31f6aa502
4 changed files with 60 additions and 59 deletions

View File

@@ -344,43 +344,5 @@ GdbServerProviderRunner::GdbServerProviderRunner(ProjectExplorer::RunControl *ru
setStarter([this, runnable] { doStart(runnable, {}); }); setStarter([this, runnable] { doStart(runnable, {}); });
} }
// HostWidget
HostWidget::HostWidget(QWidget *parent)
: QWidget(parent)
{
m_hostLineEdit = new QLineEdit(this);
m_hostLineEdit->setToolTip(tr("Enter TCP/IP hostname of the GDB server provider, "
"like \"localhost\" or \"192.0.2.1\"."));
m_portSpinBox = new QSpinBox(this);
m_portSpinBox->setRange(0, 65535);
m_portSpinBox->setToolTip(tr("Enter TCP/IP port which will be listened by "
"the GDB server provider."));
const auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_hostLineEdit);
layout->addWidget(m_portSpinBox);
connect(m_hostLineEdit, &QLineEdit::textChanged,
this, &HostWidget::dataChanged);
connect(m_portSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
this, &HostWidget::dataChanged);
}
void HostWidget::setChannel(const QUrl &channel)
{
const QSignalBlocker blocker(this);
m_hostLineEdit->setText(channel.host());
m_portSpinBox->setValue(channel.port());
}
QUrl HostWidget::channel() const
{
QUrl url;
url.setHost(m_hostLineEdit->text());
url.setPort(m_portSpinBox->value());
return url;
}
} // namespace Internal } // namespace Internal
} // namespace BareMetal } // namespace BareMetal

View File

@@ -33,7 +33,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QComboBox; class QComboBox;
class QSpinBox;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace BareMetal { namespace BareMetal {
@@ -129,25 +128,5 @@ public:
const ProjectExplorer::Runnable &runnable); const ProjectExplorer::Runnable &runnable);
}; };
// HostWidget
class HostWidget final : public QWidget
{
Q_OBJECT
public:
explicit HostWidget(QWidget *parent = nullptr);
void setChannel(const QUrl &host);
QUrl channel() const;
signals:
void dataChanged();
protected:
QLineEdit *m_hostLineEdit = nullptr;
QSpinBox *m_portSpinBox = nullptr;
};
} // namespace Internal } // namespace Internal
} // namespace BareMetal } // namespace BareMetal

View File

@@ -34,6 +34,7 @@
#include <QFormLayout> #include <QFormLayout>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QSpinBox>
#include <QUuid> #include <QUuid>
namespace BareMetal { namespace BareMetal {
@@ -260,5 +261,43 @@ void IDebugServerProviderConfigWidget::setFromProvider()
m_nameLineEdit->setText(m_provider->displayName()); m_nameLineEdit->setText(m_provider->displayName());
} }
// HostWidget
HostWidget::HostWidget(QWidget *parent)
: QWidget(parent)
{
m_hostLineEdit = new QLineEdit(this);
m_hostLineEdit->setToolTip(tr("Enter TCP/IP hostname of the GDB server provider, "
"like \"localhost\" or \"192.0.2.1\"."));
m_portSpinBox = new QSpinBox(this);
m_portSpinBox->setRange(0, 65535);
m_portSpinBox->setToolTip(tr("Enter TCP/IP port which will be listened by "
"the GDB server provider."));
const auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_hostLineEdit);
layout->addWidget(m_portSpinBox);
connect(m_hostLineEdit, &QLineEdit::textChanged,
this, &HostWidget::dataChanged);
connect(m_portSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
this, &HostWidget::dataChanged);
}
void HostWidget::setChannel(const QUrl &channel)
{
const QSignalBlocker blocker(this);
m_hostLineEdit->setText(channel.host());
m_portSpinBox->setValue(channel.port());
}
QUrl HostWidget::channel() const
{
QUrl url;
url.setHost(m_hostLineEdit->text());
url.setPort(m_portSpinBox->value());
return url;
}
} // namespace Internal } // namespace Internal
} // namespace BareMetal } // namespace BareMetal

View File

@@ -38,6 +38,7 @@ QT_BEGIN_NAMESPACE
class QFormLayout; class QFormLayout;
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
class QSpinBox;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Debugger { namespace Debugger {
@@ -162,5 +163,25 @@ protected:
QLabel *m_errorLabel = nullptr; QLabel *m_errorLabel = nullptr;
}; };
// HostWidget
class HostWidget final : public QWidget
{
Q_OBJECT
public:
explicit HostWidget(QWidget *parent = nullptr);
void setChannel(const QUrl &host);
QUrl channel() const;
signals:
void dataChanged();
protected:
QLineEdit *m_hostLineEdit = nullptr;
QSpinBox *m_portSpinBox = nullptr;
};
} // namespace Internal } // namespace Internal
} // namespace BareMetal } // namespace BareMetal