[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.
This commit is contained in:
parent
2a4c74c099
commit
e804ad2488
@ -310,7 +310,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
|||||||
m_viewManager = Calamares::ViewManager::instance( this );
|
m_viewManager = Calamares::ViewManager::instance( this );
|
||||||
if ( branding->windowExpands() )
|
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
|
// NOTE: Although the ViewManager has a signal cancelEnabled() that
|
||||||
// signals when the state of the cancel button changes (in
|
// signals when the state of the cancel button changes (in
|
||||||
@ -356,12 +356,19 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CalamaresWindow::enlarge( QSize enlarge )
|
CalamaresWindow::ensureSize( QSize size )
|
||||||
{
|
{
|
||||||
auto mainGeometry = this->geometry();
|
auto mainGeometry = this->geometry();
|
||||||
QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
|
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();
|
auto w = this->size().width();
|
||||||
|
|
||||||
resize( w, h );
|
resize( w, h );
|
||||||
|
@ -41,11 +41,11 @@ public:
|
|||||||
|
|
||||||
public slots:
|
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
|
* larger-than-expected window contents. The enlargement may be silently
|
||||||
* ignored.
|
* ignored.
|
||||||
*/
|
*/
|
||||||
void enlarge( QSize enlarge );
|
void ensureSize( QSize size );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent( QCloseEvent* e ) override;
|
virtual void closeEvent( QCloseEvent* e ) override;
|
||||||
|
@ -118,7 +118,7 @@ ViewManager::insertViewStep( int before, ViewStep* step )
|
|||||||
{
|
{
|
||||||
emit beginInsertRows( QModelIndex(), before, before );
|
emit beginInsertRows( QModelIndex(), before, before );
|
||||||
m_steps.insert( before, step );
|
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 );
|
connect( step, &ViewStep::nextStatusChanged, this, &ViewManager::updateNextStatus );
|
||||||
|
|
||||||
if ( !step->widget() )
|
if ( !step->widget() )
|
||||||
|
@ -195,7 +195,7 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentStepChanged();
|
void currentStepChanged();
|
||||||
void enlarge( QSize enlarge ) const; // See ViewStep::enlarge()
|
void ensureSize( QSize size ) const; // See ViewStep::ensureSize()
|
||||||
void cancelEnabled( bool enabled ) const;
|
void cancelEnabled( bool enabled ) const;
|
||||||
|
|
||||||
void nextEnabledChanged( bool ) const;
|
void nextEnabledChanged( bool ) const;
|
||||||
|
@ -149,10 +149,12 @@ signals:
|
|||||||
void nextStatusChanged( bool status );
|
void nextStatusChanged( bool status );
|
||||||
|
|
||||||
/* Emitted when the viewstep thinks it needs more space than is currently
|
/* Emitted when the viewstep thinks it needs more space than is currently
|
||||||
* available for display. @p enlarge is the requested additional space,
|
* available for display. @p size is the requested space, that is needed
|
||||||
* e.g. 24px vertical. This request may be silently ignored.
|
* to display the entire page.
|
||||||
|
*
|
||||||
|
* This request may be silently ignored.
|
||||||
*/
|
*/
|
||||||
void enlarge( QSize enlarge ) const;
|
void ensureSize( QSize enlarge ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Calamares::ModuleSystem::InstanceKey m_instanceKey;
|
Calamares::ModuleSystem::InstanceKey m_instanceKey;
|
||||||
|
@ -73,6 +73,8 @@ LocaleViewStep::setUpPage()
|
|||||||
m_actualWidget->init( m_startingTimezone.first, m_startingTimezone.second, m_localeGenPath );
|
m_actualWidget->init( m_startingTimezone.first, m_startingTimezone.second, m_localeGenPath );
|
||||||
m_widget->layout()->addWidget( m_actualWidget );
|
m_widget->layout()->addWidget( m_actualWidget );
|
||||||
|
|
||||||
|
ensureSize( m_actualWidget->sizeHint() );
|
||||||
|
|
||||||
m_nextEnabled = true;
|
m_nextEnabled = true;
|
||||||
emit nextStatusChanged( m_nextEnabled );
|
emit nextStatusChanged( m_nextEnabled );
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ SummaryPage::onActivate()
|
|||||||
|
|
||||||
cDebug() << "Summary widget is larger than viewport, enlarge by" << enlarge << "to" << widgetSize;
|
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…
Reference in New Issue
Block a user