Gitlab: Some layout code cosmetics

Take advantage of the aspects' setLabelText.

Change-Id: I00060a02393fb90557f0f4dd01411fd3928c4c19
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-06-08 11:17:54 +02:00
parent 6aa94e1e17
commit b6db9d8152

View File

@@ -64,35 +64,38 @@ GitLabServerWidget::GitLabServerWidget(Mode m, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, m_mode(m) , m_mode(m)
{ {
using namespace Utils::Layouting; m_host.setLabelText(tr("Host:"));
auto hostLabel = new QLabel(tr("Host:"), this);
m_host.setDisplayStyle(m == Display ? Utils::StringAspect::LabelDisplay m_host.setDisplayStyle(m == Display ? Utils::StringAspect::LabelDisplay
: Utils::StringAspect::LineEditDisplay); : Utils::StringAspect::LineEditDisplay);
m_host.setValidationFunction([](Utils::FancyLineEdit *l, QString *) { m_host.setValidationFunction([](Utils::FancyLineEdit *l, QString *) {
return hostValid(l->text()); return hostValid(l->text());
}); });
auto descriptionLabel = new QLabel(tr("Description:"), this);
m_description.setLabelText(tr("Description:"));
m_description.setDisplayStyle(m == Display ? Utils::StringAspect::LabelDisplay m_description.setDisplayStyle(m == Display ? Utils::StringAspect::LabelDisplay
: Utils::StringAspect::LineEditDisplay); : Utils::StringAspect::LineEditDisplay);
auto tokenLabel = new QLabel(tr("Access token:"), this);
m_token.setLabelText(tr("Access token:"));
m_token.setDisplayStyle(m == Display ? Utils::StringAspect::LabelDisplay m_token.setDisplayStyle(m == Display ? Utils::StringAspect::LabelDisplay
: Utils::StringAspect::LineEditDisplay); : Utils::StringAspect::LineEditDisplay);
m_token.setVisible(m == Edit); m_token.setVisible(m == Edit);
tokenLabel->setVisible(m == Edit);
m_port.setRange(1, 65535); m_port.setRange(1, 65535);
auto portLabel = new QLabel(tr("Port:"), this);
m_port.setDefaultValue(GitLabServer::defaultPort); m_port.setDefaultValue(GitLabServer::defaultPort);
m_port.setEnabled(m == Edit); m_port.setEnabled(m == Edit);
m_port.setLabelText(tr("Port:"));
using namespace Utils::Layouting; using namespace Utils::Layouting;
const Break nl; const Break nl;
Form { Row {
hostLabel, m_host, nl, Form {
descriptionLabel, m_description, nl, m_host,
tokenLabel, m_token, nl, m_description,
portLabel, Span(1, Row { m_port, Stretch() }), nl, m_token,
m_port
},
Stretch()
}.attachTo(this, m == Edit); }.attachTo(this, m == Edit);
} }