[libcalamaresui] Refactor quit-enabling
- Add signal for change-of-quit-enabledness - Minor tidying
This commit is contained in:
parent
088fa5004c
commit
d4f4a40fa5
@ -288,12 +288,7 @@ ViewManager::next()
|
||||
m_steps.at( m_currentStep )->onActivate();
|
||||
executing = qobject_cast< ExecutionViewStep* >( m_steps.at( m_currentStep ) ) != nullptr;
|
||||
emit currentStepChanged();
|
||||
if ( executing )
|
||||
// Enabled if there's nothing blocking it during exec
|
||||
m_quit->setEnabled( !( settings->dontCancel() || settings->disableCancel() ) );
|
||||
else
|
||||
// Enabled unless it's also hidden
|
||||
m_quit->setEnabled( !settings->disableCancel() );
|
||||
updateCancelEnabled( !settings->disableCancel() && !(executing && settings->dontCancel() ) );
|
||||
}
|
||||
else
|
||||
step->next();
|
||||
@ -307,13 +302,15 @@ ViewManager::next()
|
||||
void
|
||||
ViewManager::updateButtonLabels()
|
||||
{
|
||||
QString next = Calamares::Settings::instance()->isSetupMode()
|
||||
const auto* const settings = Calamares::Settings::instance();
|
||||
|
||||
QString next = settings->isSetupMode()
|
||||
? tr( "&Set up" )
|
||||
: tr( "&Install" );
|
||||
QString complete = Calamares::Settings::instance()->isSetupMode()
|
||||
QString complete = settings->isSetupMode()
|
||||
? tr( "Setup is complete. Close the setup program." )
|
||||
: tr( "The installation is complete. Close the installer." );
|
||||
QString quit = Calamares::Settings::instance()->isSetupMode()
|
||||
QString quit = settings->isSetupMode()
|
||||
? tr( "Cancel setup without changing the system." )
|
||||
: tr( "Cancel installation without changing the system." );
|
||||
|
||||
@ -328,15 +325,14 @@ ViewManager::updateButtonLabels()
|
||||
m_quit->setText( tr( "&Done" ) );
|
||||
m_quit->setToolTip( complete );
|
||||
m_quit->setVisible( true ); // At end, always visible and enabled.
|
||||
m_quit->setEnabled( true );
|
||||
updateCancelEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Calamares::Settings::instance()->disableCancel() )
|
||||
{
|
||||
m_quit->setVisible( false );
|
||||
m_quit->setEnabled( false ); // Can't be triggered through DBUS
|
||||
}
|
||||
if ( settings->disableCancel() )
|
||||
m_quit->setVisible( false ); // In case we went back from final
|
||||
updateCancelEnabled( !settings->disableCancel() && !( stepIsExecute( m_steps, m_currentStep ) && settings->dontCancel() ) );
|
||||
|
||||
m_quit->setText( tr( "&Cancel" ) );
|
||||
m_quit->setToolTip( quit );
|
||||
}
|
||||
@ -403,4 +399,11 @@ bool ViewManager::confirmCancelInstallation()
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ViewManager::updateCancelEnabled( bool enabled )
|
||||
{
|
||||
m_quit->setEnabled( enabled );
|
||||
emit cancelEnabled( enabled );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -121,6 +121,7 @@ public slots:
|
||||
signals:
|
||||
void currentStepChanged();
|
||||
void enlarge( QSize enlarge ) const; // See ViewStep::enlarge()
|
||||
void cancelEnabled( bool enabled ) const;
|
||||
|
||||
private:
|
||||
explicit ViewManager( QObject* parent = nullptr );
|
||||
@ -128,6 +129,7 @@ private:
|
||||
|
||||
void insertViewStep( int before, ViewStep* step );
|
||||
void updateButtonLabels();
|
||||
void updateCancelEnabled( bool enabled );
|
||||
|
||||
static ViewManager* s_instance;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user