From db3d3a7d033476ef13d29f02e9ad80947759aae2 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Wed, 23 Jan 2019 15:56:07 +0100 Subject: [PATCH] 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 --- settings.conf | 9 +++++++++ src/libcalamares/Settings.cpp | 8 ++++++++ src/libcalamares/Settings.h | 3 +++ src/libcalamaresui/ViewManager.cpp | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/settings.conf b/settings.conf index 1c95721b7..2be482d44 100644 --- a/settings.conf +++ b/settings.conf @@ -146,3 +146,12 @@ prompt-install: false # # YAML: boolean. 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 diff --git a/src/libcalamares/Settings.cpp b/src/libcalamares/Settings.cpp index 8fd4eeac3..3a00399f4 100644 --- a/src/libcalamares/Settings.cpp +++ b/src/libcalamares/Settings.cpp @@ -81,6 +81,7 @@ Settings::Settings( const QString& settingsFilePath, , m_debug( debugMode ) , m_doChroot( true ) , m_promptInstall( false ) + , m_disableCancel( false ) { cDebug() << "Using Calamares settings file at" << settingsFilePath; QFile file( settingsFilePath ); @@ -183,6 +184,7 @@ Settings::Settings( const QString& settingsFilePath, m_brandingComponentName = requireString( config, "branding" ); m_promptInstall = requireBool( config, "prompt-install", false ); m_doChroot = !requireBool( config, "dont-chroot", false ); + m_disableCancel = requireBool( config, "disable-cancel", false ); } catch ( YAML::Exception& e ) { @@ -245,5 +247,11 @@ Settings::doChroot() const return m_doChroot; } +bool +Settings::disableCancel() const +{ + return m_disableCancel; +} + } diff --git a/src/libcalamares/Settings.h b/src/libcalamares/Settings.h index 4da65f710..4d7568c7d 100644 --- a/src/libcalamares/Settings.h +++ b/src/libcalamares/Settings.h @@ -58,6 +58,8 @@ public: bool doChroot() const; + bool disableCancel() const; + private: static Settings* s_instance; @@ -71,6 +73,7 @@ private: bool m_debug; bool m_doChroot; bool m_promptInstall; + bool m_disableCancel; }; } diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 4d1f3591e..e222707ac 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -95,6 +95,10 @@ ViewManager::ViewManager( QObject* parent ) this, &ViewManager::onInstallationFailed ); connect( JobQueue::instance(), &JobQueue::finished, 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->setToolTip( tr( "The installation is complete. Close the installer." ) ); + if (Calamares::Settings::instance()->disableCancel()) + m_quit->setVisible( true ); } else { + if (Calamares::Settings::instance()->disableCancel()) + m_quit->setVisible( false ); m_quit->setText( tr( "&Cancel" ) ); m_quit->setToolTip( tr( "Cancel installation without changing the system." ) ); }