From f25702ec0d2508594411ccfc820587f8c30b19c6 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 13 Nov 2023 17:26:26 +0100 Subject: [PATCH] Core: Use LayoutBuilder in the About dialog The GridLayout code was hard to read. Let's use LayoutBuilder. Change-Id: I90a2113e12541061fbf699f36328bb326bd1ebd9 Reviewed-by: hjk --- src/plugins/coreplugin/versiondialog.cpp | 32 ++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/plugins/coreplugin/versiondialog.cpp b/src/plugins/coreplugin/versiondialog.cpp index 8e68172de2c..833fc0a7071 100644 --- a/src/plugins/coreplugin/versiondialog.cpp +++ b/src/plugins/coreplugin/versiondialog.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -33,8 +34,6 @@ VersionDialog::VersionDialog(QWidget *parent) setWindowIcon(Icons::QTCREATORLOGO_BIG.icon()); setWindowTitle(Tr::tr("About %1").arg(QGuiApplication::applicationDisplayName())); - auto layout = new QGridLayout(this); - layout->setSizeConstraint(QLayout::SetFixedSize); const Utils::AppInfo appInfo = Utils::appInfo(); QString ideRev; @@ -78,22 +77,29 @@ VersionDialog::VersionDialog(QWidget *parent) "Qt Quick Compiler®, Qt Enterprise®, Qt Mobile® and Qt Embedded® are " "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->setOpenExternalLinks(true); copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - QDialogButtonBox *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); + auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); - QLabel *logoLabel = new QLabel; - logoLabel->setPixmap(Icons::QTCREATORLOGO_BIG.pixmap()); - layout->addWidget(logoLabel , 0, 0, 1, 1); - layout->addWidget(copyRightLabel, 0, 1, 4, 4); - layout->addWidget(buttonBox, 4, 0, 1, 5); + using namespace Layouting; + Column { + Row { + Column { logoLabel, st }, + 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)