plasma: notify about login, logout and cancel events

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-09 09:27:41 +03:00
parent c6b591023e
commit 095efa0323

View file

@ -45,6 +45,7 @@
#include <KConfigSkeleton> #include <KConfigSkeleton>
#include <KDesktopFile> #include <KDesktopFile>
#include <KShell> #include <KShell>
#include <KNotification>
#include <Plasma/AbstractToolBox> #include <Plasma/AbstractToolBox>
#include <Plasma/Containment> #include <Plasma/Containment>
@ -985,9 +986,9 @@ void PlasmaApp::saveClients()
kDebug() << "initiating session save" << m_clients.size(); kDebug() << "initiating session save" << m_clients.size();
m_waitingcount = 0; m_waitingcount = 0;
QMapIterator<QString,org::kde::KApplication*> iter(m_clients); QMapIterator<QString,org::kde::KApplication*> iter(m_clients);
iter.toBack();
// window manager should be last to save its state first to restore so iteration is done // window manager should be last to save its state first to restore so iteration is done
// backwards // backwards
iter.toBack();
while (iter.hasPrevious()) { while (iter.hasPrevious()) {
iter.previous(); iter.previous();
kDebug() << "calling saveSession() for" << iter.key(); kDebug() << "calling saveSession() for" << iter.key();
@ -1077,7 +1078,10 @@ void PlasmaApp::clientSaved()
void PlasmaApp::clientSaveCanceled() void PlasmaApp::clientSaveCanceled()
{ {
kDebug() << "client canceled session save"; kDebug() << "client canceled session save";
m_waitingcount++; KNotification::event(
"kde/cancellogout" , QString(),
i18n("Logout canceled by user")
);
} }
void PlasmaApp::suspendStartup(const QString &app) void PlasmaApp::suspendStartup(const QString &app)
@ -1089,7 +1093,9 @@ void PlasmaApp::suspendStartup(const QString &app)
void PlasmaApp::resumeStartup(const QString &app) void PlasmaApp::resumeStartup(const QString &app)
{ {
if (m_startupsuspend > 0) {
m_startupsuspend--; m_startupsuspend--;
}
kDebug() << "startup resumed by" << app; kDebug() << "startup resumed by" << app;
} }
@ -1158,6 +1164,7 @@ void PlasmaApp::cleanup()
void PlasmaApp::nextPhase() void PlasmaApp::nextPhase()
{ {
if (m_startupsuspend <= 0){ if (m_startupsuspend <= 0){
// TODO: phases should not be on timer
kDebug() << "next startup phase" << m_phase; kDebug() << "next startup phase" << m_phase;
switch (m_phase) { switch (m_phase) {
case 0: { case 0: {
@ -1183,6 +1190,7 @@ void PlasmaApp::nextPhase()
restoreClients(); restoreClients();
} }
kDebug() << "startup done"; kDebug() << "startup done";
KNotification::event("kde/startkde");
return; return;
} }
} }
@ -1215,6 +1223,7 @@ void PlasmaApp::rebootWithoutConfirmation()
void PlasmaApp::doLogout() void PlasmaApp::doLogout()
{ {
cleanup(); cleanup();
KNotification::event("kde/exitkde");
if (m_sdtype == KWorkSpace::ShutdownTypeDefault || m_sdtype == KWorkSpace::ShutdownTypeNone) { if (m_sdtype == KWorkSpace::ShutdownTypeDefault || m_sdtype == KWorkSpace::ShutdownTypeNone) {
quit(); quit();
} else { } else {