diff --git a/src/modules/finished/Config.cpp b/src/modules/finished/Config.cpp
index 7a84e8f22..a612661a8 100644
--- a/src/modules/finished/Config.cpp
+++ b/src/modules/finished/Config.cpp
@@ -33,11 +33,55 @@ Config::Config( QObject* parent )
{
}
+void
+Config::setRestartNowMode( Config::RestartMode m )
+{
+ // Can only go "down" in state (Always > UserDefaultChecked > .. > Never)
+ if ( m > m_restartNowMode )
+ {
+ return;
+ }
+
+ // If changing to an unconditional mode, also set other flag
+ if ( m == RestartMode::Always || m == RestartMode::Never )
+ {
+ setRestartNowWanted( m == RestartMode::Always );
+ }
+
+ if ( m != m_restartNowMode )
+ {
+ m_restartNowMode = m;
+ emit restartModeChanged( m );
+ }
+}
+
+void
+Config::setRestartNowWanted( bool w )
+{
+ // Follow the mode which may affect @p w
+ if ( m_restartNowMode == RestartMode::Always )
+ {
+ w = true;
+ }
+ if ( m_restartNowMode == RestartMode::Never )
+ {
+ w = false;
+ }
+
+ if ( w != m_userWantsRestart )
+ {
+ m_userWantsRestart = w;
+ emit restartNowWantedChanged( w );
+ }
+}
+
+
void
Config::setConfigurationMap( const QVariantMap& configurationMap )
{
RestartMode mode = RestartMode::Never;
+ //TODO:3.3 remove deprecated restart settings
QString restartMode = CalamaresUtils::getString( configurationMap, "restartNowMode" );
if ( restartMode.isEmpty() )
{
@@ -69,6 +113,9 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
}
m_restartNowMode = mode;
+ m_userWantsRestart = ( mode == RestartMode::Always || mode == RestartMode::UserDefaultChecked );
+ emit restartModeChanged( m_restartNowMode );
+ emit restartNowWantedChanged( m_userWantsRestart );
if ( mode != RestartMode::Never )
{
diff --git a/src/modules/finished/Config.h b/src/modules/finished/Config.h
index 9b8c5d8d3..32cc7bf22 100644
--- a/src/modules/finished/Config.h
+++ b/src/modules/finished/Config.h
@@ -20,8 +20,10 @@ class Config : public QObject
{
Q_OBJECT
+ Q_PROPERTY( RestartMode restartNowMode READ restartNowMode WRITE setRestartNowMode NOTIFY restartModeChanged )
+ Q_PROPERTY( bool restartNowWanted READ restartNowWanted WRITE setRestartNowWanted NOTIFY restartNowWantedChanged )
+
Q_PROPERTY( QString restartNowCommand READ restartNowCommand CONSTANT FINAL )
- Q_PROPERTY( RestartMode restartNowMode READ restartNowMode CONSTANT FINAL )
Q_PROPERTY( bool notifyOnFinished READ notifyOnFinished CONSTANT FINAL )
public:
@@ -36,15 +38,26 @@ public:
};
Q_ENUM( RestartMode )
- QString restartNowCommand() const { return m_restartNowCommand; }
RestartMode restartNowMode() const { return m_restartNowMode; }
+ bool restartNowWanted() const { return m_userWantsRestart; }
+
+ QString restartNowCommand() const { return m_restartNowCommand; }
bool notifyOnFinished() const { return m_notifyOnFinished; }
void setConfigurationMap( const QVariantMap& configurationMap );
+public slots:
+ void setRestartNowMode( RestartMode m );
+ void setRestartNowWanted( bool w );
+
+signals:
+ void restartModeChanged( RestartMode m );
+ void restartNowWantedChanged( bool w );
+
private:
QString m_restartNowCommand;
RestartMode m_restartNowMode = RestartMode::Never;
+ bool m_userWantsRestart = false;
bool m_notifyOnFinished = false;
};
diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp
index 118ee96bf..5f021dd3d 100644
--- a/src/modules/finished/FinishedPage.cpp
+++ b/src/modules/finished/FinishedPage.cpp
@@ -27,10 +27,9 @@
#include All done.
"
- "%1 has been set up on your computer.
"
- "You may now start using your new system." )
- .arg( branding->versionedName() ) );
- ui->restartCheckBox->setToolTip( tr( "
When this box is checked, your system will " - "restart immediately when you click on " - "Done " - "or close the setup program.
" ) ); - } else { - ui->mainText->setText( tr( "When this box is checked, your system will " - "restart immediately when you click on " - "Done " - "or close the installer.
" ) ); - } ) -} + connect( config, &Config::restartModeChanged, [this]( Config::RestartMode mode ) { + using Mode = Config::RestartMode; - -void -FinishedPage::setRestart( Config::RestartMode mode ) -{ - using Mode = Config::RestartMode; - - m_mode = mode; - - ui->restartCheckBox->setVisible( mode != Mode::Never ); - ui->restartCheckBox->setEnabled( mode != Mode::Always ); - ui->restartCheckBox->setChecked( ( mode == Mode::Always ) || ( mode == Mode::UserDefaultChecked ) ); -} - - -void -FinishedPage::setRestartNowCommand( const QString& command ) -{ - m_restartNowCommand = command; -} - - -void -FinishedPage::setUpRestart() -{ - cDebug() << "FinishedPage::setUpRestart(), Quit button" - << "setup=" << restartModes().find( m_mode ) << "command=" << 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 } ); - } + ui->restartCheckBox->setVisible( mode != Mode::Never ); + ui->restartCheckBox->setEnabled( mode != Mode::Always ); + } ); + connect( config, &Config::restartNowWantedChanged, ui->restartCheckBox, &QCheckBox::setChecked ); + connect( ui->restartCheckBox, &QCheckBox::stateChanged, [config]( int state ) { + config->setRestartNowWanted( state != 0 ); } ); -} + CALAMARES_RETRANSLATE_SLOT( &FinishedPage::retranslate ); +} void FinishedPage::focusInEvent( QFocusEvent* e ) @@ -110,19 +60,64 @@ FinishedPage::focusInEvent( QFocusEvent* e ) void FinishedPage::onInstallationFailed( const QString& message, const QString& details ) { - const auto* branding = Calamares::Branding::instance(); - Q_UNUSED( details ) - if ( Calamares::Settings::instance()->isSetupMode() ) - ui->mainText->setText( tr( "When this box is checked, your system will " + "restart immediately when you click on " + "Done " + "or close the setup program.
" ) ); + } + else + { + ui->mainText->setText( tr( "When this box is checked, your system will " + "restart immediately when you click on " + "Done " + "or close the installer.
" ) ); + } + } + else + { + const QString message = m_failure.value(); + + if ( Calamares::Settings::instance()->isSetupMode() ) + { + ui->mainText->setText( tr( "