Add a settings.conf option to disable "Cancel" button

In some cases, e.g. when calamares is used as an "initial setup" tool,
we may want to user to go through all the configuration steps in order
to end up with a usable system.
Therefore, disabling the "Cancel" button can be useful in this case.

This commit adds an option to settings.conf which disables this button
when set to "true". If the option is not present in the settings file,
the default behavior ("Cancel" button enabled & visible) is enforced.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
This commit is contained in:
Arnaud Ferraris 2019-01-23 15:56:07 +01:00
parent c9930788f7
commit db3d3a7d03
4 changed files with 28 additions and 0 deletions

View File

@ -146,3 +146,12 @@ prompt-install: false
# #
# YAML: boolean. # YAML: boolean.
dont-chroot: false dont-chroot: false
# If this is set to true, the "Cancel" button will be disabled.
# This can be useful if when e.g. calamares is used as a post-install configuration
# tool and you require the user to go through all the configuration steps.
#
# Default is false.
#
# YAML: boolean.
disable-cancel: false

View File

@ -81,6 +81,7 @@ Settings::Settings( const QString& settingsFilePath,
, m_debug( debugMode ) , m_debug( debugMode )
, m_doChroot( true ) , m_doChroot( true )
, m_promptInstall( false ) , m_promptInstall( false )
, m_disableCancel( false )
{ {
cDebug() << "Using Calamares settings file at" << settingsFilePath; cDebug() << "Using Calamares settings file at" << settingsFilePath;
QFile file( settingsFilePath ); QFile file( settingsFilePath );
@ -183,6 +184,7 @@ Settings::Settings( const QString& settingsFilePath,
m_brandingComponentName = requireString( config, "branding" ); m_brandingComponentName = requireString( config, "branding" );
m_promptInstall = requireBool( config, "prompt-install", false ); m_promptInstall = requireBool( config, "prompt-install", false );
m_doChroot = !requireBool( config, "dont-chroot", false ); m_doChroot = !requireBool( config, "dont-chroot", false );
m_disableCancel = requireBool( config, "disable-cancel", false );
} }
catch ( YAML::Exception& e ) catch ( YAML::Exception& e )
{ {
@ -245,5 +247,11 @@ Settings::doChroot() const
return m_doChroot; return m_doChroot;
} }
bool
Settings::disableCancel() const
{
return m_disableCancel;
}
} }

View File

@ -58,6 +58,8 @@ public:
bool doChroot() const; bool doChroot() const;
bool disableCancel() const;
private: private:
static Settings* s_instance; static Settings* s_instance;
@ -71,6 +73,7 @@ private:
bool m_debug; bool m_debug;
bool m_doChroot; bool m_doChroot;
bool m_promptInstall; bool m_promptInstall;
bool m_disableCancel;
}; };
} }

View File

@ -95,6 +95,10 @@ ViewManager::ViewManager( QObject* parent )
this, &ViewManager::onInstallationFailed ); this, &ViewManager::onInstallationFailed );
connect( JobQueue::instance(), &JobQueue::finished, connect( JobQueue::instance(), &JobQueue::finished,
this, &ViewManager::next ); this, &ViewManager::next );
if (Calamares::Settings::instance()->disableCancel())
m_quit->setVisible( false );
} }
@ -282,9 +286,13 @@ ViewManager::updateButtonLabels()
{ {
m_quit->setText( tr( "&Done" ) ); m_quit->setText( tr( "&Done" ) );
m_quit->setToolTip( tr( "The installation is complete. Close the installer." ) ); m_quit->setToolTip( tr( "The installation is complete. Close the installer." ) );
if (Calamares::Settings::instance()->disableCancel())
m_quit->setVisible( true );
} }
else else
{ {
if (Calamares::Settings::instance()->disableCancel())
m_quit->setVisible( false );
m_quit->setText( tr( "&Cancel" ) ); m_quit->setText( tr( "&Cancel" ) );
m_quit->setToolTip( tr( "Cancel installation without changing the system." ) ); m_quit->setToolTip( tr( "Cancel installation without changing the system." ) );
} }