From c0be53523cabe6b5b4caf4f0b12118aad992e8df Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 17 Apr 2020 09:43:51 +0200 Subject: [PATCH 1/4] [locale] Give TZWidget a fixed size --- src/modules/locale/timezonewidget/timezonewidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index 59367caf3..b81e0414c 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -52,6 +52,7 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) // Set size setMinimumSize( background.size() ); setMaximumSize( background.size() ); + setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); } From ade623f6b8351024fe658ac7007e17410bcc7215 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 17 Apr 2020 10:19:41 +0200 Subject: [PATCH 2/4] [locale] Shuffle code - Put the building-up-the-overall-page in one spot - Claim a little more vertical space for the TZ widget --- src/modules/locale/LocalePage.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 963fa3eab..53d97ea02 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -49,35 +49,32 @@ LocalePage::LocalePage( QWidget* parent ) QBoxLayout* mainLayout = new QVBoxLayout; QBoxLayout* tzwLayout = new QHBoxLayout; - mainLayout->addLayout( tzwLayout ); m_tzWidget = new TimeZoneWidget( this ); tzwLayout->addStretch(); tzwLayout->addWidget( m_tzWidget ); tzwLayout->addStretch(); - setMinimumWidth( m_tzWidget->width() ); - - QBoxLayout* bottomLayout = new QHBoxLayout; - mainLayout->addLayout( bottomLayout ); + // Adjust for margins and spacing in this page + m_tzWidget->setMinimumHeight( m_tzWidget->minimumHeight() + 12 ); // 2 * spacing + QBoxLayout* zoneAndRegionLayout = new QHBoxLayout; m_regionLabel = new QLabel( this ); - bottomLayout->addWidget( m_regionLabel ); + zoneAndRegionLayout->addWidget( m_regionLabel ); m_regionCombo = new QComboBox( this ); - bottomLayout->addWidget( m_regionCombo ); + zoneAndRegionLayout->addWidget( m_regionCombo ); m_regionCombo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_regionLabel->setBuddy( m_regionCombo ); - bottomLayout->addSpacing( 20 ); + zoneAndRegionLayout->addSpacing( 20 ); m_zoneLabel = new QLabel( this ); - bottomLayout->addWidget( m_zoneLabel ); + zoneAndRegionLayout->addWidget( m_zoneLabel ); m_zoneCombo = new QComboBox( this ); m_zoneCombo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - bottomLayout->addWidget( m_zoneCombo ); + zoneAndRegionLayout->addWidget( m_zoneCombo ); m_zoneLabel->setBuddy( m_zoneCombo ); - mainLayout->addStretch(); QBoxLayout* localeLayout = new QHBoxLayout; m_localeLabel = new QLabel( this ); @@ -88,7 +85,6 @@ LocalePage::LocalePage( QWidget* parent ) m_localeChangeButton = new QPushButton( this ); m_localeChangeButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); localeLayout->addWidget( m_localeChangeButton ); - mainLayout->addLayout( localeLayout ); QBoxLayout* formatsLayout = new QHBoxLayout; m_formatsLabel = new QLabel( this ); @@ -99,8 +95,14 @@ LocalePage::LocalePage( QWidget* parent ) m_formatsChangeButton = new QPushButton( this ); m_formatsChangeButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); formatsLayout->addWidget( m_formatsChangeButton ); - mainLayout->addLayout( formatsLayout ); + mainLayout->addLayout( tzwLayout ); + mainLayout->addStretch(); + mainLayout->addLayout( zoneAndRegionLayout ); + mainLayout->addStretch(); + mainLayout->addLayout( localeLayout ); + mainLayout->addLayout( formatsLayout ); + setMinimumWidth( m_tzWidget->width() ); setLayout( mainLayout ); connect( m_regionCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::regionChanged ); From 2a4c74c0999e878de412744ddcaaad667a42ae07 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 17 Apr 2020 11:38:07 +0200 Subject: [PATCH 3/4] [calamares] Layout-wranging - the navigation bar was set "too tall", leave it at the natural layout height for this widget - margins needed some massaging to give contents some more space (contents has a margin, so it doesn't need more space above the navigation bar) --- src/calamares/CalamaresWindow.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 0e8ac1421..ac8ab39ee 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -207,6 +207,7 @@ CalamaresWindow::getWidgetNavigation() bottomLayout->addWidget( quit ); } + bottomLayout->setContentsMargins( 0, 0, 6, 6 ); navigation->setLayout( bottomLayout ); return navigation; } @@ -220,6 +221,7 @@ CalamaresWindow::getQmlNavigation() w->setResizeMode( QQuickWidget::SizeRootObjectToView ); w->setSource( QUrl( CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-navigation" ) ) ) ); + w->setMinimumHeight( 30 ); // matchine the default widgets version return w; } @@ -259,14 +261,6 @@ insertIf( QBoxLayout* layout, { if ( first && side == firstSide ) { - if ( ( side == Calamares::Branding::PanelSide::Left ) || ( side == Calamares::Branding::PanelSide::Right ) ) - { - first->setMinimumWidth( qMax( first->minimumWidth(), 64 ) ); - } - else - { - first->setMinimumHeight( qMax( first->minimumHeight(), 64 ) ); - } layout->addWidget( first ); } } @@ -329,8 +323,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) QBoxLayout* mainLayout = new QHBoxLayout; QBoxLayout* contentsLayout = new QVBoxLayout; - - setLayout( mainLayout ); + contentsLayout->setSpacing( 0 ); QWidget* sideBox = flavoredWidget( branding->sidebarFlavor(), @@ -358,6 +351,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) CalamaresUtils::unmarginLayout( mainLayout ); CalamaresUtils::unmarginLayout( contentsLayout ); + setLayout( mainLayout ); setStyleSheet( Calamares::Branding::instance()->stylesheet() ); } From e804ad2488a142604628fab3dd830020e9747d65 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 17 Apr 2020 12:54:31 +0200 Subject: [PATCH 4/4] [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 } }