Core: Use LayoutBuilder in the About dialog

The GridLayout code was hard to read. Let's use LayoutBuilder.

Change-Id: I90a2113e12541061fbf699f36328bb326bd1ebd9
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2023-11-13 17:26:26 +01:00
parent f96feadad0
commit f25702ec0d

View File

@@ -11,6 +11,7 @@
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/appinfo.h> #include <utils/appinfo.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
@@ -33,8 +34,6 @@ VersionDialog::VersionDialog(QWidget *parent)
setWindowIcon(Icons::QTCREATORLOGO_BIG.icon()); setWindowIcon(Icons::QTCREATORLOGO_BIG.icon());
setWindowTitle(Tr::tr("About %1").arg(QGuiApplication::applicationDisplayName())); setWindowTitle(Tr::tr("About %1").arg(QGuiApplication::applicationDisplayName()));
auto layout = new QGridLayout(this);
layout->setSizeConstraint(QLayout::SetFixedSize);
const Utils::AppInfo appInfo = Utils::appInfo(); const Utils::AppInfo appInfo = Utils::appInfo();
QString ideRev; QString ideRev;
@@ -78,22 +77,29 @@ VersionDialog::VersionDialog(QWidget *parent)
"Qt Quick Compiler®, Qt Enterprise®, Qt Mobile® and Qt Embedded® are " "Qt Quick Compiler®, Qt Enterprise®, Qt Mobile® and Qt Embedded® are "
"registered trademarks of The Qt Company Ltd."); "registered trademarks of The Qt Company Ltd.");
QLabel *copyRightLabel = new QLabel(description); auto logoLabel = new QLabel;
logoLabel->setPixmap(Icons::QTCREATORLOGO_BIG.pixmap());
auto copyRightLabel = new QLabel(description);
copyRightLabel->setWordWrap(true); copyRightLabel->setWordWrap(true);
copyRightLabel->setOpenExternalLinks(true); copyRightLabel->setOpenExternalLinks(true);
copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
QPushButton *closeButton = buttonBox->button(QDialogButtonBox::Close);
QTC_CHECK(closeButton);
buttonBox->addButton(closeButton, QDialogButtonBox::ButtonRole(QDialogButtonBox::RejectRole | QDialogButtonBox::AcceptRole));
connect(buttonBox , &QDialogButtonBox::rejected, this, &QDialog::reject);
QLabel *logoLabel = new QLabel; using namespace Layouting;
logoLabel->setPixmap(Icons::QTCREATORLOGO_BIG.pixmap()); Column {
layout->addWidget(logoLabel , 0, 0, 1, 1); Row {
layout->addWidget(copyRightLabel, 0, 1, 4, 4); Column { logoLabel, st },
layout->addWidget(buttonBox, 4, 0, 1, 5); Column { copyRightLabel },
},
buttonBox,
}.attachTo(this);
layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
} }
bool VersionDialog::event(QEvent *event) bool VersionDialog::event(QEvent *event)