From f2374c245bcc64f74f8a05ee864ce1e64f1eb098 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Fri, 6 Oct 2023 17:38:14 +0300 Subject: [PATCH] Use fixed size layout constraint WE2-797 Signed-off-by: Raul Metsma --- src/ui/dialog.ui | 39 +++++++++++++++++++++++++++++++++------ src/ui/webeiddialog.cpp | 20 ++++---------------- src/ui/webeiddialog.hpp | 1 - 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui index 19bfd744..76753287 100644 --- a/src/ui/dialog.ui +++ b/src/ui/dialog.ui @@ -10,12 +10,6 @@ 510 - - - 550 - 0 - - Web eID @@ -199,6 +193,9 @@ height: 24px; 30 + + QLayout::SetFixedSize + 20 @@ -235,6 +232,12 @@ height: 24px; + + + 510 + 0 + + Qt::TabFocus @@ -306,6 +309,12 @@ height: 24px; + + + 510 + 0 + + Qt::TabFocus @@ -441,6 +450,12 @@ height: 24px; + + + 510 + 0 + + Qt::TabFocus @@ -523,6 +538,12 @@ height: 24px; + + + 510 + 0 + + Qt::TabFocus @@ -773,6 +794,12 @@ height: 24px; + + + 510 + 0 + + 10 diff --git a/src/ui/webeiddialog.cpp b/src/ui/webeiddialog.cpp index 7b8a53e0..9b075b5c 100644 --- a/src/ui/webeiddialog.cpp +++ b/src/ui/webeiddialog.cpp @@ -159,7 +159,9 @@ WebEidDialog::WebEidDialog(QWidget* parent) : WebEidUI(parent), ui(new Private) ui->fatalHelp->hide(); ui->selectAnotherCertificate->hide(); - connect(ui->pageStack, &QStackedWidget::currentChanged, this, &WebEidDialog::resizeHeight); + connect(ui->pageStack, &QStackedWidget::currentChanged, this, [this]{ + ui->pageStack->setFixedHeight(ui->pageStack->currentWidget()->sizeHint().height()); + }); connect(ui->selectionGroup, qOverload(&QButtonGroup::buttonClicked), this, [this] { ui->okButton->setEnabled(true); @@ -243,16 +245,12 @@ void WebEidDialog::showAboutPage() if (app->isSafariExtensionContainingApp()) { d->setupOK([app] { app->showSafariSettings(); }, QT_TR_NOOP("Open Safari settings..."), true); - connect(app, &Application::safariExtensionEnabled, d, [d](bool value) { - d->ui->aboutAlert->setHidden(value); - d->resizeHeight(); - }); + connect(app, &Application::safariExtensionEnabled, d->ui->aboutAlert, &QWidget::setHidden); app->requestSafariExtensionState(); } else { d->ui->okButton->hide(); } d->ui->pageStack->setCurrentIndex(int(Page::ABOUT)); - d->resizeHeight(); d->open(); connect(d, &WebEidDialog::finished, qApp, &QApplication::quit); } @@ -269,7 +267,6 @@ void WebEidDialog::showFatalErrorPage() d->ui->cancelButton->show(); d->ui->okButton->hide(); d->ui->pageStack->setCurrentIndex(int(Page::ALERT)); - d->resizeHeight(); d->exec(); } @@ -457,7 +454,6 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const break; case Status::PIN_BLOCKED: displayPinBlockedError(); - resizeHeight(); return; case Status::INVALID_PIN_LENGTH: message = [] { return tr("Invalid PIN length"); }; @@ -485,7 +481,6 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const ui->pinTitleLabel->show(); ui->okButton->setDisabled(true); ui->cancelButton->setEnabled(true); - resizeHeight(); } } @@ -502,7 +497,6 @@ bool WebEidDialog::event(QEvent* event) case QEvent::LanguageChange: ui->retranslateUi(this); emit languageChange(); - resizeHeight(); break; case QEvent::MouseButtonRelease: if (auto* w = findChild(QStringLiteral("langMenu"))) { @@ -689,12 +683,6 @@ void WebEidDialog::showPinInputWarning(bool show) style()->polish(ui->pinInput); } -void WebEidDialog::resizeHeight() -{ - ui->pageStack->setFixedHeight(ui->pageStack->currentWidget()->sizeHint().height()); - adjustSize(); -} - QPixmap WebEidDialog::pixmap(QLatin1String name) { return {QStringLiteral(":/images/%1%2.svg") diff --git a/src/ui/webeiddialog.hpp b/src/ui/webeiddialog.hpp index cdbe2c0b..726558e8 100644 --- a/src/ui/webeiddialog.hpp +++ b/src/ui/webeiddialog.hpp @@ -106,7 +106,6 @@ class WebEidDialog final : public WebEidUI void displayPinBlockedError(); void showPinInputWarning(bool show); - void resizeHeight(); static QPixmap pixmap(QLatin1String name); constexpr static std::tuple