diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index ade0b486b..4bffa8221 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -39,7 +39,7 @@ FinishedPage::FinishedPage( QWidget* parent ) : QWidget( parent ) , ui( new Ui::FinishedPage ) - , m_restartSetUp( false ) + , m_mode( FinishedViewStep::RestartMode::UserUnchecked ) { ui->setupUi( this ); @@ -83,6 +83,8 @@ FinishedPage::setRestart( FinishedViewStep::RestartMode mode ) { using Mode = FinishedViewStep::RestartMode; + m_mode = mode; + ui->restartCheckBox->setVisible( mode != Mode::Never ); ui->restartCheckBox->setEnabled( mode != Mode::Always ); ui->restartCheckBox->setChecked( ( mode == Mode::Always ) || ( mode == Mode::UserChecked ) ); @@ -100,18 +102,20 @@ void FinishedPage::setUpRestart() { cDebug() << "FinishedPage::setUpRestart(), Quit button" - << "setup=" << m_restartSetUp + << "setup=" << FinishedViewStep::modeName( m_mode ) << "command=" << m_restartNowCommand; - if ( !m_restartSetUp ) - { - connect( qApp, &QApplication::aboutToQuit, - this, [this] - { - if ( ui->restartCheckBox->isVisible() && - ui->restartCheckBox->isChecked() ) - QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } ); - } ); - } + + connect( qApp, &QApplication::aboutToQuit, + [this]() + { + if ( ui->restartCheckBox->isVisible() && + ui->restartCheckBox->isChecked() ) + { + cDebug() << "Running restart command" << m_restartNowCommand; + QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } ); + } + } + ); } diff --git a/src/modules/finished/FinishedPage.h b/src/modules/finished/FinishedPage.h index 9954e6fa0..25b776ead 100644 --- a/src/modules/finished/FinishedPage.h +++ b/src/modules/finished/FinishedPage.h @@ -49,9 +49,8 @@ protected: private: Ui::FinishedPage* ui; + FinishedViewStep::RestartMode m_mode; QString m_restartNowCommand; - - bool m_restartSetUp; }; #endif // FINISHEDPAGE_H diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 16b1de7eb..f5c0935c3 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -210,4 +210,11 @@ FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) m_notifyOnFinished = CalamaresUtils::getBool( configurationMap, "notifyOnFinished", false ); } +QString FinishedViewStep::modeName(FinishedViewStep::RestartMode m) +{ + bool ok = false; + return modeNames().find( m, ok ); // May be QString() +} + + CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin(); ) diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index 02ba6ef83..7b3881099 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -41,6 +41,8 @@ public: UserChecked, ///< @brief Show button, starts checked Always ///< @brief Show button, can't change, checked }; + /// @brief Returns the config-name of the given restart-mode @p m + static QString modeName( RestartMode m ); explicit FinishedViewStep( QObject* parent = nullptr ); virtual ~FinishedViewStep() override;