From 89c2c8a76e6f847b2f6c20c593116d864c1882af Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 23 Aug 2017 05:25:07 -0400 Subject: [PATCH] Suppress success-notification on failure --- src/modules/finished/FinishedViewStep.cpp | 18 +++++++++++++++++- src/modules/finished/FinishedViewStep.h | 5 +++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 2dfc1d0f6..8017a739c 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -33,11 +33,15 @@ FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_widget( new FinishedPage() ) + , installFailed( false ) { cDebug() << "FinishedViewStep()"; - connect( Calamares::JobQueue::instance(), &Calamares::JobQueue::failed, + 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 ); } @@ -107,6 +111,11 @@ FinishedViewStep::isAtEnd() const void FinishedViewStep::sendNotification() { + // If the installation failed, don't send notification popup; + // there's a (modal) dialog popped up with the failure notice. + if (installFailed) + return; + QDBusInterface notify( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" ); if ( notify.isValid() ) { @@ -145,6 +154,13 @@ FinishedViewStep::jobs() const return QList< Calamares::job_ptr >(); } +void +FinishedViewStep::onInstallationFailed( const QString& message, const QString& details ) +{ + Q_UNUSED(message); + Q_UNUSED(details); + installFailed = true; +} void FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index 075183f99..cb3656046 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -55,6 +55,9 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; +public slots: + void onInstallationFailed( const QString& message, const QString& details ); + private: FinishedPage* m_widget; @@ -63,6 +66,8 @@ private: * send a desktop notification via DBus that the install is done. */ void sendNotification(); + + bool installFailed; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( FinishedViewStepFactory )