diff --git a/src/modules/finished/CMakeLists.txt b/src/modules/finished/CMakeLists.txt index 6549c364e..6482fb2cd 100644 --- a/src/modules/finished/CMakeLists.txt +++ b/src/modules/finished/CMakeLists.txt @@ -1,4 +1,7 @@ +find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED DBus Network ) + include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) + calamares_add_plugin( finished TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO @@ -9,5 +12,6 @@ calamares_add_plugin( finished FinishedPage.ui LINK_PRIVATE_LIBRARIES calamaresui + Qt5::DBus SHARED_LIB ) diff --git a/src/modules/finished/FinishedViewStep.cpp b/src/modules/finished/FinishedViewStep.cpp index 3c9bc042c..2dfc1d0f6 100644 --- a/src/modules/finished/FinishedViewStep.cpp +++ b/src/modules/finished/FinishedViewStep.cpp @@ -23,8 +23,13 @@ #include "utils/Logger.h" +#include +#include +#include #include +#include "Branding.h" + FinishedViewStep::FinishedViewStep( QObject* parent ) : Calamares::ViewStep( parent ) , m_widget( new FinishedPage() ) @@ -32,7 +37,7 @@ FinishedViewStep::FinishedViewStep( QObject* parent ) cDebug() << "FinishedViewStep()"; connect( Calamares::JobQueue::instance(), &Calamares::JobQueue::failed, - m_widget, &FinishedPage::onInstallationFailed ); + m_widget, &FinishedPage::onInstallationFailed ); emit nextStatusChanged( true ); } @@ -99,12 +104,37 @@ FinishedViewStep::isAtEnd() const return true; } +void +FinishedViewStep::sendNotification() +{ + QDBusInterface notify( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications" ); + if ( notify.isValid() ) + { + QDBusReply r = notify.call( "Notify", + QString( "Calamares" ), + QVariant( 0U ), + QString( "calamares" ), + tr( "Installation Complete" ), + tr( "The installation of %1 is complete." ).arg( *Calamares::Branding::VersionedName ), + QStringList(), + QVariantMap(), + QVariant( 0 ) + ); + if ( !r.isValid() ) + cDebug() << "Could not call notify for end of installation." << r.error(); + } + else + cDebug() << "Could not get dbus interface for notifications." << notify.lastError(); +} + void FinishedViewStep::onActivate() { cDebug() << "FinishedViewStep::onActivate()"; m_widget->setUpRestart(); + + sendNotification(); } @@ -120,7 +150,7 @@ void FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { if ( configurationMap.contains( "restartNowEnabled" ) && - configurationMap.value( "restartNowEnabled" ).type() == QVariant::Bool ) + configurationMap.value( "restartNowEnabled" ).type() == QVariant::Bool ) { bool restartNowEnabled = configurationMap.value( "restartNowEnabled" ).toBool(); @@ -128,20 +158,14 @@ FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap ) if ( restartNowEnabled ) { if ( configurationMap.contains( "restartNowChecked" ) && - configurationMap.value( "restartNowChecked" ).type() == QVariant::Bool ) - { + configurationMap.value( "restartNowChecked" ).type() == QVariant::Bool ) m_widget->setRestartNowChecked( configurationMap.value( "restartNowChecked" ).toBool() ); - } if ( configurationMap.contains( "restartNowCommand" ) && - configurationMap.value( "restartNowCommand" ).type() == QVariant::String ) - { + configurationMap.value( "restartNowCommand" ).type() == QVariant::String ) m_widget->setRestartNowCommand( configurationMap.value( "restartNowCommand" ).toString() ); - } else - { - m_widget->setRestartNowCommand( "systemctl -i reboot"); - } + m_widget->setRestartNowCommand( "systemctl -i reboot" ); } } } diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index 30151dffb..075183f99 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -57,6 +57,12 @@ public: private: 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. + */ + void sendNotification(); }; CALAMARES_PLUGIN_FACTORY_DECLARATION( FinishedViewStepFactory )