aboutsummaryrefslogtreecommitdiffstats
path: root/src/m_ver_check/UpdateTab.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2026-09-26 20:22:12 +0200
committersaturneric <[email protected]>2026-09-26 20:22:12 +0200
commit68c44fe780bb501d13d3f4c82c1ef2baa78988a1 (patch)
treea946bff71409839c1da9367ef010f170485825e3 /src/m_ver_check/UpdateTab.cpp
parentrefactor(email): simplify crypto SDK test stubs (diff)
downloadmodules-68c44fe780bb501d13d3f4c82c1ef2baa78988a1.tar.gz
modules-68c44fe780bb501d13d3f4c82c1ef2baa78988a1.zip
fix(update): fit update window to content
- set a minimum width to limit headline wrapping - resize the window after content and notes visibility changes - remove fixed dimensions from the update widget registration
Diffstat (limited to 'src/m_ver_check/UpdateTab.cpp')
-rw-r--r--src/m_ver_check/UpdateTab.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/m_ver_check/UpdateTab.cpp b/src/m_ver_check/UpdateTab.cpp
index e123f6e..5328085 100644
--- a/src/m_ver_check/UpdateTab.cpp
+++ b/src/m_ver_check/UpdateTab.cpp
@@ -127,9 +127,14 @@ UpdateTab::UpdateTab(QWidget* parent)
layout->addWidget(notes_, 1);
layout->addStretch();
+ // Wide enough that a headline wraps at most once; the height follows the
+ // content (see fit_window()).
+ setMinimumWidth(fontMetrics().averageCharWidth() * 64);
+
connect(notes_toggle_, &QToolButton::toggled, this, [this](bool open) {
notes_toggle_->setArrowType(open ? Qt::DownArrow : Qt::RightArrow);
notes_->setVisible(open);
+ fit_window();
});
connect(check_btn_, &QPushButton::clicked, this, [this] {
@@ -165,6 +170,16 @@ void UpdateTab::render() {
apply(PresentUpdate(checker_->State(), QDateTime::currentDateTime()));
}
+void UpdateTab::fit_window() {
+ // Deferred: the layout settles the new content first. The frame is the
+ // window; this page fills it, so fitting the window fits the page. It
+ // keeps its place on screen, and overrides a size remembered from a page
+ // that showed something else.
+ QTimer::singleShot(0, this, [this] {
+ if (isVisible()) window()->adjustSize();
+ });
+}
+
void UpdateTab::apply(const UpdateView& view) {
const auto icon_size = style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
icon_->setPixmap(ToneIcon(style(), view.tone).pixmap(icon_size, icon_size));
@@ -192,6 +207,8 @@ void UpdateTab::apply(const UpdateView& view) {
notes_->clear();
notes_->hide();
}
+
+ fit_window();
}
void UpdateTab::showEvent(QShowEvent* event) {