Skip to content

Commit

Permalink
Use fixed size layout constraint
Browse files Browse the repository at this point in the history
WE2-797

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Jun 5, 2024
1 parent e056d29 commit b7db49a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Description: Web eID application suite (metapackage)

Package: web-eid-native
Architecture: any
Multi-Arch: foreign
Depends: pcscd, ${shlibs:Depends}, ${misc:Depends}
Replaces: token-signing-native
Breaks: token-signing-native
Expand Down
39 changes: 33 additions & 6 deletions src/ui/dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
<height>510</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>550</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Web eID</string>
</property>
Expand Down Expand Up @@ -199,6 +193,9 @@ height: 24px;
<property name="spacing">
<number>30</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>20</number>
</property>
Expand Down Expand Up @@ -235,6 +232,12 @@ height: 24px;
</property>
<item>
<widget class="QLabel" name="waitingPageTitleLabel">
<property name="minimumSize">
<size>
<width>510</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
Expand Down Expand Up @@ -306,6 +309,12 @@ height: 24px;
</property>
<item>
<widget class="QLabel" name="messagePageTitleLabel">
<property name="minimumSize">
<size>
<width>510</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
Expand Down Expand Up @@ -441,6 +450,12 @@ height: 24px;
</property>
<item>
<widget class="QLabel" name="selectCertificatePageTitleLabel">
<property name="minimumSize">
<size>
<width>510</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
Expand Down Expand Up @@ -523,6 +538,12 @@ height: 24px;
</property>
<item>
<widget class="QLabel" name="pinInputPageTitleLabel">
<property name="minimumSize">
<size>
<width>510</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
Expand Down Expand Up @@ -773,6 +794,12 @@ height: 24px;
</item>
<item>
<widget class="QWidget" name="aboutContent" native="true">
<property name="minimumSize">
<size>
<width>510</width>
<height>0</height>
</size>
</property>
<layout class="QGridLayout" name="aboutContentLayout">
<property name="horizontalSpacing">
<number>10</number>
Expand Down
20 changes: 4 additions & 16 deletions src/ui/webeiddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QAbstractButton*>(&QButtonGroup::buttonClicked), this,
[this] {
ui->okButton->setEnabled(true);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();
}

Expand Down Expand Up @@ -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"); };
Expand Down Expand Up @@ -485,7 +481,6 @@ void WebEidDialog::onVerifyPinFailed(const VerifyPinFailed::Status status, const
ui->pinTitleLabel->show();
ui->okButton->setDisabled(true);
ui->cancelButton->setEnabled(true);
resizeHeight();
}
}

Expand All @@ -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<QWidget*>(QStringLiteral("langMenu"))) {
Expand Down Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion src/ui/webeiddialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*, const char*, QLatin1String>
Expand Down

0 comments on commit b7db49a

Please sign in to comment.