Merge branch 'tzwidget-layout'

The introduction of navigation panels made them taller, leaving less
space for the locale page's timezonewidget -- which then got
comboboxes overlapping it. That's weird from a QVBoxLayout point of
view, but the issue remains that the locale page is actually a
*smidgen* (2px) too tall.

- Massage a bunch of layout code to make the default navigation panel
  30 pixels again, like it was. This is obviously fragile in the face
  of HiDPI, but Calamares is weak there anyway.
- Rework the enlarge signals to make it possible to claim space, so
  that if a page needs more space it's easy to get; because the locale
  page is just a smidgen too tall, it won't trigger resizes right now.
main
Adriaan de Groot 5 years ago
commit 06f96dc16f

@ -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 );
}
}
@ -316,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
@ -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,16 +351,24 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
CalamaresUtils::unmarginLayout( mainLayout );
CalamaresUtils::unmarginLayout( contentsLayout );
setLayout( mainLayout );
setStyleSheet( Calamares::Branding::instance()->stylesheet() );
}
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 );

@ -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;

@ -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() )

@ -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;

@ -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;

@ -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 );

@ -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 );
}

@ -52,6 +52,7 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent )
// Set size
setMinimumSize( background.size() );
setMaximumSize( background.size() );
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
}

@ -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
}
}

Loading…
Cancel
Save