[finished] Allow positive and negative notifications at end.

main
Adriaan de Groot 4 years ago
parent ec4b6752d6
commit 5af614daf7

@ -94,25 +94,41 @@ Config::doRestart()
void void
Config::doNotify() Config::doNotify( bool hasFailed )
{ {
QDBusInterface notify( QDBusInterface notify(
"org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" ); "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" );
if ( notify.isValid() ) 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(); const auto* branding = Calamares::Branding::instance();
QDBusReply< uint > r = notify.call( QDBusReply< uint > r = notify.call( "Notify",
"Notify", QString( "Calamares" ),
QString( "Calamares" ), QVariant( 0U ),
QVariant( 0U ), QString( "calamares" ),
QString( "calamares" ), title,
Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Complete" ) : tr( "Installation Complete" ), message.arg( branding->versionedName() ),
Calamares::Settings::instance()->isSetupMode() QStringList(),
? tr( "The setup of %1 is complete." ).arg( branding->versionedName() ) QVariantMap(),
: tr( "The installation of %1 is complete." ).arg( branding->versionedName() ), QVariant( 0 ) );
QStringList(),
QVariantMap(),
QVariant( 0 ) );
if ( !r.isValid() ) if ( !r.isValid() )
{ {
cWarning() << "Could not call org.freedesktop.Notifications.Notify at end of installation." << r.error(); cWarning() << "Could not call org.freedesktop.Notifications.Notify at end of installation." << r.error();

@ -62,10 +62,8 @@ public slots:
* *
* At the end of installation (when the FinishedViewStep is activated), * At the end of installation (when the FinishedViewStep is activated),
* send a desktop notification via DBus that the install is done. * 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: signals:
void restartModeChanged( RestartMode m ); void restartModeChanged( RestartMode m );

Loading…
Cancel
Save