aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/m_ver_check/UpdateTab.cpp17
-rw-r--r--src/m_ver_check/UpdateTab.h1
-rw-r--r--src/m_ver_check/VersionCheckingModule.cpp2
3 files changed, 19 insertions, 1 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) {
diff --git a/src/m_ver_check/UpdateTab.h b/src/m_ver_check/UpdateTab.h
index edcf9b1..fc66305 100644
--- a/src/m_ver_check/UpdateTab.h
+++ b/src/m_ver_check/UpdateTab.h
@@ -52,6 +52,7 @@ class UpdateTab : public QWidget {
private:
void render();
void apply(const UpdateView& view);
+ void fit_window();
QPointer<UpdateChecker> checker_;
diff --git a/src/m_ver_check/VersionCheckingModule.cpp b/src/m_ver_check/VersionCheckingModule.cpp
index 4fe5bd7..71dde75 100644
--- a/src/m_ver_check/VersionCheckingModule.cpp
+++ b/src/m_ver_check/VersionCheckingModule.cpp
@@ -214,7 +214,7 @@ auto OnActivate() -> GFResult {
"update_checking_api");
const bool dialog = gf::ui::RegisterNativeWidget<UpdateWidget>(
- "update", {GC_TR("Check for Updates"), "", "", "", "", 500, 600},
+ "update", {GC_TR("Check for Updates"), "", "", "", "", 0, 0},
[](const QCborMap& /*args*/) { return new UpdateWidget(); });
const bool settings = gf::ui::RegisterNativeWidget<UpdateSettingsWidget>(
"settings",