mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-27 09:25:36 -04:00
Popup notification when the installation is done.
- Use DBus and FreeDesktop interface to popup message - Code style / formatting FIXES #599
This commit is contained in:
parent
40c3b3dd04
commit
93115b7385
3 changed files with 45 additions and 11 deletions
|
@ -23,8 +23,13 @@
|
|||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QVariantMap>
|
||||
|
||||
#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<uint> 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" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue