From 4ae3a7af617dfe6272558cc39c94a4c2dbde6bb8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Feb 2021 16:54:18 +0100 Subject: [PATCH 01/11] [finished] Start Config-ification - Introduce a Config class with suitable properties for use in QML, read configuration; this is unused right now. --- src/modules/finished/CMakeLists.txt | 1 + src/modules/finished/Config.cpp | 84 +++++++++++++++++++++++++++++ src/modules/finished/Config.h | 53 ++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 src/modules/finished/Config.cpp create mode 100644 src/modules/finished/Config.h diff --git a/src/modules/finished/CMakeLists.txt b/src/modules/finished/CMakeLists.txt index 21eb1ad18..b4d59db8f 100644 --- a/src/modules/finished/CMakeLists.txt +++ b/src/modules/finished/CMakeLists.txt @@ -11,6 +11,7 @@ calamares_add_plugin( finished TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES + Config.cpp FinishedViewStep.cpp FinishedPage.cpp UI diff --git a/src/modules/finished/Config.cpp b/src/modules/finished/Config.cpp new file mode 100644 index 000000000..7a84e8f22 --- /dev/null +++ b/src/modules/finished/Config.cpp @@ -0,0 +1,84 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#include "Config.h" + +#include "utils/Logger.h" +#include "utils/Variant.h" + +const NamedEnumTable< Config::RestartMode >& +restartModes() +{ + using M = Config::RestartMode; + static const NamedEnumTable< M > table { { "never", M::Never }, + { "user-unchecked", M::UserDefaultUnchecked }, + { "unchecked", M::UserDefaultUnchecked }, + { "user-checked", M::UserDefaultChecked }, + { "checked", M::UserDefaultChecked }, + { "always", M::Always } + + }; + return table; +} + + +Config::Config( QObject* parent ) + : QObject( parent ) +{ +} + +void +Config::setConfigurationMap( const QVariantMap& configurationMap ) +{ + RestartMode mode = RestartMode::Never; + + QString restartMode = CalamaresUtils::getString( configurationMap, "restartNowMode" ); + if ( restartMode.isEmpty() ) + { + if ( configurationMap.contains( "restartNowEnabled" ) ) + { + cWarning() << "Configuring the finished module with deprecated restartNowEnabled settings"; + } + + bool restartNowEnabled = CalamaresUtils::getBool( configurationMap, "restartNowEnabled", false ); + bool restartNowChecked = CalamaresUtils::getBool( configurationMap, "restartNowChecked", false ); + + if ( !restartNowEnabled ) + { + mode = RestartMode::Never; + } + else + { + mode = restartNowChecked ? RestartMode::UserDefaultChecked : RestartMode::UserDefaultUnchecked; + } + } + else + { + bool ok = false; + mode = restartModes().find( restartMode, ok ); + if ( !ok ) + { + cWarning() << "Configuring the finished module with bad restartNowMode" << restartMode; + } + } + + m_restartNowMode = mode; + + if ( mode != RestartMode::Never ) + { + QString restartNowCommand = CalamaresUtils::getString( configurationMap, "restartNowCommand" ); + if ( restartNowCommand.isEmpty() ) + { + restartNowCommand = QStringLiteral( "shutdown -r now" ); + } + m_restartNowCommand = restartNowCommand; + } + + m_notifyOnFinished = CalamaresUtils::getBool( configurationMap, "notifyOnFinished", false ); +} diff --git a/src/modules/finished/Config.h b/src/modules/finished/Config.h new file mode 100644 index 000000000..9b8c5d8d3 --- /dev/null +++ b/src/modules/finished/Config.h @@ -0,0 +1,53 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2021 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ + +#ifndef FINISHED_CONFIG_H +#define FINISHED_CONFIG_H + +#include "utils/NamedEnum.h" + +#include + +#include + +class Config : public QObject +{ + Q_OBJECT + + 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: + Config( QObject* parent = nullptr ); + + enum class RestartMode + { + Never, + UserDefaultUnchecked, + UserDefaultChecked, + Always + }; + Q_ENUM( RestartMode ) + + QString restartNowCommand() const { return m_restartNowCommand; } + RestartMode restartNowMode() const { return m_restartNowMode; } + bool notifyOnFinished() const { return m_notifyOnFinished; } + + void setConfigurationMap( const QVariantMap& configurationMap ); + +private: + QString m_restartNowCommand; + RestartMode m_restartNowMode = RestartMode::Never; + bool m_notifyOnFinished = false; +}; + +const NamedEnumTable< Config::RestartMode >& restartModes(); + +#endif From c82b802f4ed6f41d3da8a9febb9bf1eb68680412 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Feb 2021 17:12:33 +0100 Subject: [PATCH 02/11] [libcalamares] Typo in documentation --- src/libcalamares/utils/NamedEnum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamares/utils/NamedEnum.h b/src/libcalamares/utils/NamedEnum.h index cf56a26f2..1ac6c67b5 100644 --- a/src/libcalamares/utils/NamedEnum.h +++ b/src/libcalamares/utils/NamedEnum.h @@ -98,7 +98,7 @@ struct NamedEnumTable /** @brief Find a value @p s in the table and return its name. * - * Returns emptry string if the value is not found. + * Returns empty string if the value is not found. */ string_t find( enum_t s ) const { From cb4248e56d8f3b8a770c71ec511ebd29faf2d6c3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Feb 2021 17:14:49 +0100 Subject: [PATCH 03/11] [finished] Move config from viewstep to config object - the configuration is still duplicated in the widget, and functionality still needs to move to the Config object - the ViewStep is cut down to almost nothing --- src/modules/finished/FinishedPage.cpp | 18 +++--- src/modules/finished/FinishedPage.h | 9 +-- src/modules/finished/FinishedViewStep.cpp | 71 ++--------------------- src/modules/finished/FinishedViewStep.h | 18 ++---- 4 files changed, 25 insertions(+), 91 deletions(-) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index 23f09df99..618efa02e 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -10,10 +10,12 @@ */ #include "FinishedPage.h" +#include "ui_FinishedPage.h" +#include "Branding.h" +#include "Settings.h" #include "CalamaresVersion.h" #include "ViewManager.h" -#include "ui_FinishedPage.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" #include "utils/Retranslator.h" @@ -24,13 +26,11 @@ #include #include -#include "Branding.h" -#include "Settings.h" FinishedPage::FinishedPage( QWidget* parent ) : QWidget( parent ) , ui( new Ui::FinishedPage ) - , m_mode( FinishedViewStep::RestartMode::UserUnchecked ) + , m_mode( Config::RestartMode::UserDefaultUnchecked ) { ui->setupUi( this ); @@ -66,15 +66,15 @@ FinishedPage::FinishedPage( QWidget* parent ) void -FinishedPage::setRestart( FinishedViewStep::RestartMode mode ) +FinishedPage::setRestart( Config::RestartMode mode ) { - using Mode = FinishedViewStep::RestartMode; + 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::UserChecked ) ); + ui->restartCheckBox->setChecked( ( mode == Mode::Always ) || ( mode == Mode::UserDefaultChecked ) ); } @@ -89,7 +89,7 @@ void FinishedPage::setUpRestart() { cDebug() << "FinishedPage::setUpRestart(), Quit button" - << "setup=" << FinishedViewStep::modeName( m_mode ) << "command=" << m_restartNowCommand; + << "setup=" << restartModes().find( m_mode ) << "command=" << m_restartNowCommand; connect( qApp, &QApplication::aboutToQuit, [this]() { if ( ui->restartCheckBox->isVisible() && ui->restartCheckBox->isChecked() ) @@ -124,5 +124,5 @@ FinishedPage::onInstallationFailed( const QString& message, const QString& detai "The error message was: %2." ) .arg( branding->versionedName() ) .arg( message ) ); - setRestart( FinishedViewStep::RestartMode::Never ); + setRestart( Config::RestartMode::Never ); } diff --git a/src/modules/finished/FinishedPage.h b/src/modules/finished/FinishedPage.h index 1df022f58..30df5f8c3 100644 --- a/src/modules/finished/FinishedPage.h +++ b/src/modules/finished/FinishedPage.h @@ -11,9 +11,10 @@ #ifndef FINISHEDPAGE_H #define FINISHEDPAGE_H -#include -#include "FinishedViewStep.h" +#include "Config.h" + +#include namespace Ui { @@ -26,7 +27,7 @@ class FinishedPage : public QWidget public: explicit FinishedPage( QWidget* parent = nullptr ); - void setRestart( FinishedViewStep::RestartMode mode ); + void setRestart( Config::RestartMode mode ); void setRestartNowCommand( const QString& command ); void setUpRestart(); @@ -40,7 +41,7 @@ protected: private: Ui::FinishedPage* ui; - FinishedViewStep::RestartMode m_mode; + Config::RestartMode m_mode; QString m_restartNowCommand; }; diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 525108dc7..cd7fcc0d0 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -25,24 +25,11 @@ #include #include -static const NamedEnumTable< FinishedViewStep::RestartMode >& -modeNames() -{ - using Mode = FinishedViewStep::RestartMode; - - static const NamedEnumTable< Mode > names { { QStringLiteral( "never" ), Mode::Never }, - { QStringLiteral( "user-unchecked" ), Mode::UserUnchecked }, - { QStringLiteral( "user-checked" ), Mode::UserChecked }, - { QStringLiteral( "always" ), Mode::Always } }; - - return names; -} - FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) + , m_config( new Config( this )) , m_widget( new FinishedPage() ) , installFailed( false ) - , m_notifyOnFinished( false ) { auto jq = Calamares::JobQueue::instance(); connect( jq, &Calamares::JobQueue::failed, m_widget, &FinishedPage::onInstallationFailed ); @@ -146,7 +133,7 @@ FinishedViewStep::onActivate() { m_widget->setUpRestart(); - if ( m_notifyOnFinished ) + if ( m_config->notifyOnFinished() ) { sendNotification(); } @@ -170,59 +157,13 @@ FinishedViewStep::onInstallationFailed( const QString& message, const QString& d void FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { - RestartMode mode = RestartMode::Never; + m_config->setConfigurationMap(configurationMap); + m_widget->setRestart( m_config->restartNowMode() ); - QString restartMode = CalamaresUtils::getString( configurationMap, "restartNowMode" ); - if ( restartMode.isEmpty() ) + if ( m_config->restartNowMode() != Config::RestartMode::Never ) { - if ( configurationMap.contains( "restartNowEnabled" ) ) - { - cWarning() << "Configuring the finished module with deprecated restartNowEnabled settings"; - } - - bool restartNowEnabled = CalamaresUtils::getBool( configurationMap, "restartNowEnabled", false ); - bool restartNowChecked = CalamaresUtils::getBool( configurationMap, "restartNowChecked", false ); - - if ( !restartNowEnabled ) - { - mode = RestartMode::Never; - } - else - { - mode = restartNowChecked ? RestartMode::UserChecked : RestartMode::UserUnchecked; - } + m_widget->setRestartNowCommand( m_config->restartNowCommand() ); } - else - { - bool ok = false; - mode = modeNames().find( restartMode, ok ); - if ( !ok ) - { - cWarning() << "Configuring the finished module with bad restartNowMode" << restartMode; - } - } - - m_widget->setRestart( mode ); - - if ( mode != RestartMode::Never ) - { - QString restartNowCommand = CalamaresUtils::getString( configurationMap, "restartNowCommand" ); - if ( restartNowCommand.isEmpty() ) - { - restartNowCommand = QStringLiteral( "shutdown -r now" ); - } - m_widget->setRestartNowCommand( restartNowCommand ); - } - - 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< FinishedViewStep >(); ) diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index 729f9126d..aa71ab38a 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -11,12 +11,14 @@ #ifndef FINISHEDVIEWSTEP_H #define FINISHEDVIEWSTEP_H -#include +#include "Config.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" #include "viewpages/ViewStep.h" -#include "DllMacro.h" + +#include class FinishedPage; @@ -25,16 +27,6 @@ class PLUGINDLLEXPORT FinishedViewStep : public Calamares::ViewStep Q_OBJECT public: - enum class RestartMode - { - Never = 0, ///< @brief Don't show button, just exit - UserUnchecked, ///< @brief Show button, starts unchecked - 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 ); ~FinishedViewStep() override; @@ -58,6 +50,7 @@ public slots: void onInstallationFailed( const QString& message, const QString& details ); private: + Config* m_config; FinishedPage* m_widget; /** @@ -67,7 +60,6 @@ private: void sendNotification(); bool installFailed; - bool m_notifyOnFinished; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( FinishedViewStepFactory ) From 84240683f5591a9fe6b6ba7069851f105e89927d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Feb 2021 17:16:22 +0100 Subject: [PATCH 04/11] [finished] Apply coding style --- src/modules/finished/FinishedPage.cpp | 2 +- src/modules/finished/FinishedViewStep.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index 618efa02e..118ee96bf 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -13,8 +13,8 @@ #include "ui_FinishedPage.h" #include "Branding.h" -#include "Settings.h" #include "CalamaresVersion.h" +#include "Settings.h" #include "ViewManager.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index cd7fcc0d0..310dda25a 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -27,7 +27,7 @@ FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) - , m_config( new Config( this )) + , m_config( new Config( this ) ) , m_widget( new FinishedPage() ) , installFailed( false ) { @@ -157,7 +157,7 @@ FinishedViewStep::onInstallationFailed( const QString& message, const QString& d void FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { - m_config->setConfigurationMap(configurationMap); + m_config->setConfigurationMap( configurationMap ); m_widget->setRestart( m_config->restartNowMode() ); if ( m_config->restartNowMode() != Config::RestartMode::Never ) From 288fe5b274b59e3d3b29b364efc15a272fb204eb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Feb 2021 12:50:52 +0100 Subject: [PATCH 05/11] [finished] Rename and document following coding style --- src/modules/finished/FinishedViewStep.cpp | 6 +++--- src/modules/finished/FinishedViewStep.h | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 310dda25a..1469262a0 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -29,7 +29,7 @@ FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_config( new Config( this ) ) , m_widget( new FinishedPage() ) - , installFailed( false ) + , m_installFailed( false ) { auto jq = Calamares::JobQueue::instance(); connect( jq, &Calamares::JobQueue::failed, m_widget, &FinishedPage::onInstallationFailed ); @@ -94,7 +94,7 @@ FinishedViewStep::sendNotification() { // If the installation failed, don't send notification popup; // there's a (modal) dialog popped up with the failure notice. - if ( installFailed ) + if ( m_installFailed ) { return; } @@ -151,7 +151,7 @@ FinishedViewStep::onInstallationFailed( const QString& message, const QString& d { Q_UNUSED( message ) Q_UNUSED( details ) - installFailed = true; + m_installFailed = true; } void diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index aa71ab38a..ac54fdd35 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -50,16 +50,18 @@ public slots: void onInstallationFailed( const QString& message, const QString& details ); private: - Config* m_config; - FinishedPage* m_widget; - /** - * @brief At the end of installation (when this step is activated), - * send a desktop notification via DBus that the install is done. + * @brief Send notification at the end via DBus + * + * At the end of installation (when this step is activated), + * send a desktop notification via DBus that the install is done. + * If the installation failed, no notification is sent. */ void sendNotification(); - bool installFailed; + Config* m_config; + FinishedPage* m_widget; + bool m_installFailed; // Track if onInstallationFailed() was called }; CALAMARES_PLUGIN_FACTORY_DECLARATION( FinishedViewStepFactory ) From 9d6d8ecaea64d6476776b547ad737d545419ee3c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Feb 2021 15:03:16 +0100 Subject: [PATCH 06/11] [finished] Heavy refactor - move most of the business logic to Config - make retranslate of the page more robust (e.g. changing language after failure would restore the un-failed message) There's still some bits left. --- src/modules/finished/Config.cpp | 47 +++++++ src/modules/finished/Config.h | 17 ++- src/modules/finished/FinishedPage.cpp | 147 +++++++++++----------- src/modules/finished/FinishedPage.h | 13 +- src/modules/finished/FinishedViewStep.cpp | 29 +++-- 5 files changed, 159 insertions(+), 94 deletions(-) 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 -FinishedPage::FinishedPage( QWidget* parent ) +FinishedPage::FinishedPage( Config* config, QWidget* parent ) : QWidget( parent ) , ui( new Ui::FinishedPage ) - , m_mode( Config::RestartMode::UserDefaultUnchecked ) { ui->setupUi( this ); @@ -38,68 +37,19 @@ FinishedPage::FinishedPage( QWidget* parent ) ui->mainText->setWordWrap( true ); ui->mainText->setOpenExternalLinks( true ); - CALAMARES_RETRANSLATE( - const auto* branding = Calamares::Branding::instance(); ui->retranslateUi( this ); - if ( Calamares::Settings::instance()->isSetupMode() ) { - ui->mainText->setText( tr( "

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( "

All done.


" - "%1 has been installed on your computer.
" - "You may now restart into your new system, or continue " - "using the %2 Live environment." ) - .arg( branding->versionedName(), branding->productName() ) ); - ui->restartCheckBox->setToolTip( 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( "

Setup Failed


" - "%1 has not been set up on your computer.
" - "The error message was: %2." ) - .arg( branding->versionedName() ) - .arg( message ) ); - else - ui->mainText->setText( tr( "

Installation Failed


" - "%1 has not been installed on your computer.
" - "The error message was: %2." ) - .arg( branding->versionedName() ) - .arg( message ) ); - setRestart( Config::RestartMode::Never ); + m_failure = !message.isEmpty() ? message : details; + retranslate(); +} + +void +FinishedPage::retranslate() +{ + + const auto* branding = Calamares::Branding::instance(); + + ui->retranslateUi( this ); + if ( !m_failure.has_value() ) + { + if ( Calamares::Settings::instance()->isSetupMode() ) + { + ui->mainText->setText( tr( "

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( "

All done.


" + "%1 has been installed on your computer.
" + "You may now restart into your new system, or continue " + "using the %2 Live environment." ) + .arg( branding->versionedName(), branding->productName() ) ); + ui->restartCheckBox->setToolTip( 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( "

Setup Failed


" + "%1 has not been set up on your computer.
" + "The error message was: %2." ) + .arg( branding->versionedName() ) + .arg( message ) ); + } + else + { + ui->mainText->setText( tr( "

Installation Failed


" + "%1 has not been installed on your computer.
" + "The error message was: %2." ) + .arg( branding->versionedName() ) + .arg( message ) ); + } + } } diff --git a/src/modules/finished/FinishedPage.h b/src/modules/finished/FinishedPage.h index 30df5f8c3..4e312ab8b 100644 --- a/src/modules/finished/FinishedPage.h +++ b/src/modules/finished/FinishedPage.h @@ -16,6 +16,8 @@ #include +#include + namespace Ui { class FinishedPage; @@ -25,24 +27,19 @@ class FinishedPage : public QWidget { Q_OBJECT public: - explicit FinishedPage( QWidget* parent = nullptr ); + explicit FinishedPage( Config* config, QWidget* parent = nullptr ); - void setRestart( Config::RestartMode mode ); - void setRestartNowCommand( const QString& command ); - - void setUpRestart(); public slots: void onInstallationFailed( const QString& message, const QString& details ); + void retranslate(); protected: void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus private: Ui::FinishedPage* ui; - - Config::RestartMode m_mode; - QString m_restartNowCommand; + std::optional< QString > m_failure; }; #endif // FINISHEDPAGE_H diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 1469262a0..48e2c47d5 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -28,7 +28,7 @@ FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_config( new Config( this ) ) - , m_widget( new FinishedPage() ) + , m_widget( new FinishedPage( m_config ) ) , m_installFailed( false ) { auto jq = Calamares::JobQueue::instance(); @@ -128,10 +128,29 @@ FinishedViewStep::sendNotification() } +#if 0 +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 } ); + } + } ); +} +#endif + + void FinishedViewStep::onActivate() { - m_widget->setUpRestart(); + // m_widget->setUpRestart(); if ( m_config->notifyOnFinished() ) { @@ -158,12 +177,6 @@ void FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { m_config->setConfigurationMap( configurationMap ); - m_widget->setRestart( m_config->restartNowMode() ); - - if ( m_config->restartNowMode() != Config::RestartMode::Never ) - { - m_widget->setRestartNowCommand( m_config->restartNowCommand() ); - } } CALAMARES_PLUGIN_FACTORY_DEFINITION( FinishedViewStepFactory, registerPlugin< FinishedViewStep >(); ) From 7d024cf72be5a5a9d336376bcc24a1c33d550c12 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Feb 2021 15:36:44 +0100 Subject: [PATCH 07/11] [finished] Move restart handling to Config --- src/modules/finished/Config.cpp | 12 ++++++++++++ src/modules/finished/Config.h | 10 ++++++++-- src/modules/finished/FinishedViewStep.cpp | 24 ++--------------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/modules/finished/Config.cpp b/src/modules/finished/Config.cpp index a612661a8..b8f30be05 100644 --- a/src/modules/finished/Config.cpp +++ b/src/modules/finished/Config.cpp @@ -12,6 +12,8 @@ #include "utils/Logger.h" #include "utils/Variant.h" +#include + const NamedEnumTable< Config::RestartMode >& restartModes() { @@ -75,6 +77,16 @@ Config::setRestartNowWanted( bool w ) } } +void +Config::doRestart() +{ + if ( restartNowMode() != RestartMode::Never && restartNowWanted() ) + { + cDebug() << "Running restart command" << m_restartNowCommand; + QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } ); + } +} + void Config::setConfigurationMap( const QVariantMap& configurationMap ) diff --git a/src/modules/finished/Config.h b/src/modules/finished/Config.h index 32cc7bf22..718a3fae2 100644 --- a/src/modules/finished/Config.h +++ b/src/modules/finished/Config.h @@ -14,8 +14,6 @@ #include -#include - class Config : public QObject { Q_OBJECT @@ -50,6 +48,14 @@ public slots: void setRestartNowMode( RestartMode m ); void setRestartNowWanted( bool w ); + /** @brief Run the restart command, if desired. + * + * This should generally not be called somewhere during the + * application's execution, but only in response to QApplication::quit() + * or something like that when the user expects the system to restart. + */ + void doRestart(); + signals: void restartModeChanged( RestartMode m ); void restartNowWantedChanged( bool w ); diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 48e2c47d5..176b27cb4 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -20,7 +20,7 @@ #include "utils/NamedEnum.h" #include "utils/Variant.h" -#include +#include #include #include #include @@ -128,34 +128,14 @@ FinishedViewStep::sendNotification() } -#if 0 -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 } ); - } - } ); -} -#endif - - void FinishedViewStep::onActivate() { - // m_widget->setUpRestart(); - if ( m_config->notifyOnFinished() ) { sendNotification(); } + connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart ); } From 76a2791b1229977c9799ef60dba80344439e3266 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Feb 2021 15:42:14 +0100 Subject: [PATCH 08/11] [finished] Clean up includes --- src/modules/finished/FinishedPage.cpp | 10 ++-------- src/modules/finished/FinishedPage.h | 3 +-- src/modules/finished/FinishedViewStep.cpp | 3 ++- src/modules/finished/FinishedViewStep.h | 6 +----- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index 5f021dd3d..6c5f9ad16 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -10,21 +10,15 @@ */ #include "FinishedPage.h" + +#include "Config.h" #include "ui_FinishedPage.h" #include "Branding.h" -#include "CalamaresVersion.h" #include "Settings.h" -#include "ViewManager.h" -#include "utils/CalamaresUtilsGui.h" -#include "utils/Logger.h" #include "utils/Retranslator.h" -#include -#include #include -#include -#include FinishedPage::FinishedPage( Config* config, QWidget* parent ) diff --git a/src/modules/finished/FinishedPage.h b/src/modules/finished/FinishedPage.h index 4e312ab8b..068efbdb5 100644 --- a/src/modules/finished/FinishedPage.h +++ b/src/modules/finished/FinishedPage.h @@ -12,12 +12,11 @@ #define FINISHEDPAGE_H -#include "Config.h" - #include #include +class Config; namespace Ui { class FinishedPage; diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 176b27cb4..146a7c215 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -10,12 +10,13 @@ */ #include "FinishedViewStep.h" + +#include "Config.h" #include "FinishedPage.h" #include "Branding.h" #include "JobQueue.h" #include "Settings.h" - #include "utils/Logger.h" #include "utils/NamedEnum.h" #include "utils/Variant.h" diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index ac54fdd35..e2ce8ba55 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -11,15 +11,11 @@ #ifndef FINISHEDVIEWSTEP_H #define FINISHEDVIEWSTEP_H -#include "Config.h" - #include "DllMacro.h" #include "utils/PluginFactory.h" #include "viewpages/ViewStep.h" - -#include - +class Config; class FinishedPage; class PLUGINDLLEXPORT FinishedViewStep : public Calamares::ViewStep From ec4b6752d6fc01c8bf522e3e675f0a78a40a976d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Feb 2021 15:54:19 +0100 Subject: [PATCH 09/11] [finished] Move notification to Config --- src/modules/finished/Config.cpp | 37 ++++++++++++++++ src/modules/finished/Config.h | 11 +++++ src/modules/finished/FinishedViewStep.cpp | 52 ++--------------------- src/modules/finished/FinishedViewStep.h | 9 ---- 4 files changed, 51 insertions(+), 58 deletions(-) diff --git a/src/modules/finished/Config.cpp b/src/modules/finished/Config.cpp index b8f30be05..e382478a3 100644 --- a/src/modules/finished/Config.cpp +++ b/src/modules/finished/Config.cpp @@ -9,10 +9,15 @@ #include "Config.h" +#include "Branding.h" +#include "Settings.h" #include "utils/Logger.h" #include "utils/Variant.h" #include +#include +#include +#include const NamedEnumTable< Config::RestartMode >& restartModes() @@ -88,6 +93,38 @@ Config::doRestart() } +void +Config::doNotify() +{ + QDBusInterface notify( + "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" ); + if ( notify.isValid() ) + { + const auto* branding = Calamares::Branding::instance(); + QDBusReply< uint > r = notify.call( + "Notify", + QString( "Calamares" ), + QVariant( 0U ), + QString( "calamares" ), + Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Complete" ) : tr( "Installation Complete" ), + Calamares::Settings::instance()->isSetupMode() + ? tr( "The setup of %1 is complete." ).arg( branding->versionedName() ) + : tr( "The installation of %1 is complete." ).arg( branding->versionedName() ), + QStringList(), + QVariantMap(), + QVariant( 0 ) ); + if ( !r.isValid() ) + { + cWarning() << "Could not call org.freedesktop.Notifications.Notify at end of installation." << r.error(); + } + } + else + { + cWarning() << "Could not get dbus interface for notifications at end of installation." << notify.lastError(); + } +} + + void Config::setConfigurationMap( const QVariantMap& configurationMap ) { diff --git a/src/modules/finished/Config.h b/src/modules/finished/Config.h index 718a3fae2..d5335df83 100644 --- a/src/modules/finished/Config.h +++ b/src/modules/finished/Config.h @@ -56,6 +56,17 @@ public slots: */ void doRestart(); + /** @brief Send DBus notification, if desired. + * + * This takes notifyOnFinished() into account. + * + * At the end of installation (when the FinishedViewStep is activated), + * send a desktop notification via DBus that the install is done. + * If the installation failed, don't call this method because + * the notification is a positive one. + */ + void doNotify(); + signals: void restartModeChanged( RestartMode m ); void restartNowWantedChanged( bool w ); diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 146a7c215..70eb4127a 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -14,17 +14,9 @@ #include "Config.h" #include "FinishedPage.h" -#include "Branding.h" #include "JobQueue.h" -#include "Settings.h" -#include "utils/Logger.h" -#include "utils/NamedEnum.h" -#include "utils/Variant.h" #include -#include -#include -#include FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) @@ -90,53 +82,15 @@ FinishedViewStep::isAtEnd() const return true; } -void -FinishedViewStep::sendNotification() -{ - // If the installation failed, don't send notification popup; - // there's a (modal) dialog popped up with the failure notice. - if ( m_installFailed ) - { - return; - } - - QDBusInterface notify( - "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" ); - if ( notify.isValid() ) - { - const auto* branding = Calamares::Branding::instance(); - QDBusReply< uint > r = notify.call( - "Notify", - QString( "Calamares" ), - QVariant( 0U ), - QString( "calamares" ), - Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Complete" ) : tr( "Installation Complete" ), - Calamares::Settings::instance()->isSetupMode() - ? tr( "The setup of %1 is complete." ).arg( branding->versionedName() ) - : tr( "The installation of %1 is complete." ).arg( branding->versionedName() ), - QStringList(), - QVariantMap(), - QVariant( 0 ) ); - if ( !r.isValid() ) - { - cWarning() << "Could not call org.freedesktop.Notifications.Notify at end of installation." << r.error(); - } - } - else - { - cWarning() << "Could not get dbus interface for notifications at end of installation." << notify.lastError(); - } -} - void FinishedViewStep::onActivate() { - if ( m_config->notifyOnFinished() ) + if ( !m_installFailed ) { - sendNotification(); + m_config->doNotify(); + connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart ); } - connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart ); } diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index e2ce8ba55..a35d7fac8 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -46,15 +46,6 @@ public slots: void onInstallationFailed( const QString& message, const QString& details ); private: - /** - * @brief Send notification at the end via DBus - * - * At the end of installation (when this step is activated), - * send a desktop notification via DBus that the install is done. - * If the installation failed, no notification is sent. - */ - void sendNotification(); - Config* m_config; FinishedPage* m_widget; bool m_installFailed; // Track if onInstallationFailed() was called From 5af614daf7a9d06a0576cb0ff8b68a92039b67ba Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Feb 2021 15:59:40 +0100 Subject: [PATCH 10/11] [finished] Allow positive and negative notifications at end. --- src/modules/finished/Config.cpp | 42 +++++++++++++++++++++++---------- src/modules/finished/Config.h | 4 +--- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/modules/finished/Config.cpp b/src/modules/finished/Config.cpp index e382478a3..a749b0176 100644 --- a/src/modules/finished/Config.cpp +++ b/src/modules/finished/Config.cpp @@ -94,25 +94,41 @@ Config::doRestart() void -Config::doNotify() +Config::doNotify( bool hasFailed ) { QDBusInterface notify( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" ); if ( notify.isValid() ) { + cDebug() << "Sending notification of completion. Failed?" << hasFailed; + + QString title; + QString message; + if ( hasFailed ) + { + title = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" ); + message = Calamares::Settings::instance()->isSetupMode() + ? tr( "The setup of %1 did not complete successfully." ) + : tr( "The installation of %1 did not complete successfully." ); + } + else + { + title = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Complete" ) + : tr( "Installation Complete" ); + message = Calamares::Settings::instance()->isSetupMode() ? tr( "The setup of %1 is complete." ) + : tr( "The installation of %1 is complete." ); + } + const auto* branding = Calamares::Branding::instance(); - QDBusReply< uint > r = notify.call( - "Notify", - QString( "Calamares" ), - QVariant( 0U ), - QString( "calamares" ), - Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Complete" ) : tr( "Installation Complete" ), - Calamares::Settings::instance()->isSetupMode() - ? tr( "The setup of %1 is complete." ).arg( branding->versionedName() ) - : tr( "The installation of %1 is complete." ).arg( branding->versionedName() ), - QStringList(), - QVariantMap(), - QVariant( 0 ) ); + QDBusReply< uint > r = notify.call( "Notify", + QString( "Calamares" ), + QVariant( 0U ), + QString( "calamares" ), + title, + message.arg( branding->versionedName() ), + QStringList(), + QVariantMap(), + QVariant( 0 ) ); if ( !r.isValid() ) { cWarning() << "Could not call org.freedesktop.Notifications.Notify at end of installation." << r.error(); diff --git a/src/modules/finished/Config.h b/src/modules/finished/Config.h index d5335df83..78078b99b 100644 --- a/src/modules/finished/Config.h +++ b/src/modules/finished/Config.h @@ -62,10 +62,8 @@ public slots: * * At the end of installation (when the FinishedViewStep is activated), * send a desktop notification via DBus that the install is done. - * If the installation failed, don't call this method because - * the notification is a positive one. */ - void doNotify(); + void doNotify( bool hasFailed = false ); signals: void restartModeChanged( RestartMode m ); From a4682db9872e14c953c1de3a1084a7baea816890 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Feb 2021 16:05:48 +0100 Subject: [PATCH 11/11] [finished] Tidy up notification-at-end (and allow failed notifications) --- src/modules/finished/Config.cpp | 5 +++++ src/modules/finished/FinishedViewStep.cpp | 12 ++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/modules/finished/Config.cpp b/src/modules/finished/Config.cpp index a749b0176..5119da942 100644 --- a/src/modules/finished/Config.cpp +++ b/src/modules/finished/Config.cpp @@ -96,6 +96,11 @@ Config::doRestart() void Config::doNotify( bool hasFailed ) { + if ( !notifyOnFinished() ) + { + return; + } + QDBusInterface notify( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" ); if ( notify.isValid() ) diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 70eb4127a..3f9fd3aab 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -25,7 +25,6 @@ FinishedViewStep::FinishedViewStep( QObject* parent ) , m_installFailed( false ) { auto jq = Calamares::JobQueue::instance(); - connect( jq, &Calamares::JobQueue::failed, m_widget, &FinishedPage::onInstallationFailed ); connect( jq, &Calamares::JobQueue::failed, this, &FinishedViewStep::onInstallationFailed ); emit nextStatusChanged( true ); @@ -86,11 +85,8 @@ FinishedViewStep::isAtEnd() const void FinishedViewStep::onActivate() { - if ( !m_installFailed ) - { - m_config->doNotify(); - connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart ); - } + m_config->doNotify( m_installFailed ); + connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart ); } @@ -103,9 +99,9 @@ FinishedViewStep::jobs() const void FinishedViewStep::onInstallationFailed( const QString& message, const QString& details ) { - Q_UNUSED( message ) - Q_UNUSED( details ) m_installFailed = true; + m_config->setRestartNowMode( Config::RestartMode::Never ); + m_widget->onInstallationFailed( message, details ); } void