From e804ad2488a142604628fab3dd830020e9747d65 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 17 Apr 2020 12:54:31 +0200 Subject: [PATCH] [libcalamaresui] Rename enlarge() - rename enlarge to ensureSize() and change the meaning from "make this much bigger" to "make sure this is displayed", which is easier on the caller to calculate. --- src/calamares/CalamaresWindow.cpp | 13 ++++++++++--- src/calamares/CalamaresWindow.h | 4 ++-- src/libcalamaresui/ViewManager.cpp | 2 +- src/libcalamaresui/ViewManager.h | 2 +- src/libcalamaresui/viewpages/ViewStep.h | 8 +++++--- src/modules/locale/LocaleViewStep.cpp | 2 ++ src/modules/summary/SummaryPage.cpp | 2 +- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index ac8ab39ee..57fffd1bb 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -310,7 +310,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) m_viewManager = Calamares::ViewManager::instance( this ); if ( branding->windowExpands() ) { - connect( m_viewManager, &Calamares::ViewManager::enlarge, this, &CalamaresWindow::enlarge ); + connect( m_viewManager, &Calamares::ViewManager::ensureSize, this, &CalamaresWindow::ensureSize ); } // NOTE: Although the ViewManager has a signal cancelEnabled() that // signals when the state of the cancel button changes (in @@ -356,12 +356,19 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) } void -CalamaresWindow::enlarge( QSize enlarge ) +CalamaresWindow::ensureSize( QSize size ) { auto mainGeometry = this->geometry(); QSize availableSize = qApp->desktop()->availableGeometry( this ).size(); - auto h = qBound( 0, mainGeometry.height() + enlarge.height(), availableSize.height() ); + // We only care about vertical sizes that are big enough + int embiggenment = qMax( 0, size.height() - m_viewManager->centralWidget()->size().height() ); + if ( embiggenment < 6 ) + { + return; + } + + auto h = qBound( 0, mainGeometry.height() + embiggenment, availableSize.height() ); auto w = this->size().width(); resize( w, h ); diff --git a/src/calamares/CalamaresWindow.h b/src/calamares/CalamaresWindow.h index d6592c99a..1d3162b86 100644 --- a/src/calamares/CalamaresWindow.h +++ b/src/calamares/CalamaresWindow.h @@ -41,11 +41,11 @@ public: public slots: /** - * This asks the main window to grow by @p enlarge pixels, to accomodate + * This asks the main window to grow to accomodate @p size pixels, to accomodate * larger-than-expected window contents. The enlargement may be silently * ignored. */ - void enlarge( QSize enlarge ); + void ensureSize( QSize size ); protected: virtual void closeEvent( QCloseEvent* e ) override; diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 43308d3d6..137a7d99e 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -118,7 +118,7 @@ ViewManager::insertViewStep( int before, ViewStep* step ) { emit beginInsertRows( QModelIndex(), before, before ); m_steps.insert( before, step ); - connect( step, &ViewStep::enlarge, this, &ViewManager::enlarge ); + connect( step, &ViewStep::ensureSize, this, &ViewManager::ensureSize ); connect( step, &ViewStep::nextStatusChanged, this, &ViewManager::updateNextStatus ); if ( !step->widget() ) diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 6c283cfbe..cfff5abd9 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -195,7 +195,7 @@ public Q_SLOTS: signals: void currentStepChanged(); - void enlarge( QSize enlarge ) const; // See ViewStep::enlarge() + void ensureSize( QSize size ) const; // See ViewStep::ensureSize() void cancelEnabled( bool enabled ) const; void nextEnabledChanged( bool ) const; diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index bdc235476..88adb83f5 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -149,10 +149,12 @@ signals: void nextStatusChanged( bool status ); /* Emitted when the viewstep thinks it needs more space than is currently - * available for display. @p enlarge is the requested additional space, - * e.g. 24px vertical. This request may be silently ignored. + * available for display. @p size is the requested space, that is needed + * to display the entire page. + * + * This request may be silently ignored. */ - void enlarge( QSize enlarge ) const; + void ensureSize( QSize enlarge ) const; protected: Calamares::ModuleSystem::InstanceKey m_instanceKey; diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index 6a2c17816..3a8c37673 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -73,6 +73,8 @@ LocaleViewStep::setUpPage() m_actualWidget->init( m_startingTimezone.first, m_startingTimezone.second, m_localeGenPath ); m_widget->layout()->addWidget( m_actualWidget ); + ensureSize( m_actualWidget->sizeHint() ); + m_nextEnabled = true; emit nextStatusChanged( m_nextEnabled ); } diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index 7114f27ee..2885b1d61 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -124,7 +124,7 @@ SummaryPage::onActivate() cDebug() << "Summary widget is larger than viewport, enlarge by" << enlarge << "to" << widgetSize; - emit m_thisViewStep->enlarge( QSize( 0, enlarge ) ); // Only expand height + emit m_thisViewStep->ensureSize( widgetSize ); // Only expand height } }