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 );