From 17d7a3b700732419e91bfad045a4a6a1984360c0 Mon Sep 17 00:00:00 2001 From: Mike Maslenkin Date: Mon, 3 Jan 2011 01:17:21 +0300 Subject: [PATCH] MAJOR add a slot for QApplication::commitData signal. Notes: Without handling of this signal KDE4 logout is prevented by running Last.fm app. This patch adds a handler to QApplication::commitData signal, that releases the session manager's interaction semaphore after an interaction phase. Thus Last.fm permits session logout. Signed-off-by: Mike Maslenkin --- src/lastfmapplication.cpp | 19 +++++++++++++++++++ src/lastfmapplication.h | 9 ++++++++- 2 files changed, 27 insertions(+), 1 deletions(-) diff --git a/src/lastfmapplication.cpp b/src/lastfmapplication.cpp index 2c5c30d..8f60de3 100644 --- a/src/lastfmapplication.cpp +++ b/src/lastfmapplication.cpp @@ -189,6 +189,8 @@ LastFmApplication::LastFmApplication( int& argc, char** argv ) // This is needed for the app to shut down properly when asked by Windows // to shut down. connect( this, SIGNAL( endSession() ), SLOT( quit() ) ); + + connect( this, SIGNAL( commitDataRequest(QSessionManager & manager) ), SLOT( commitData(QSessionManager& manager) ) ); } @@ -1175,6 +1177,24 @@ LastFmApplication::onNormanRequestDone( Request* r ) m_activeNorman = 0; } +#ifdef Q_WS_X11 +/** + * process KDE session logout event + **/ + void +LastFmApplication::commitData(QSessionManager& manager) +{ + if ( manager.allowsInteraction() ) + manager.release(); +} +#else +void +LastFmApplication::commitData(QSessionManager& manager) +{ + Q_UNUSED(manager); + return; +} +#endif namespace The { diff --git a/src/lastfmapplication.h b/src/lastfmapplication.h index bfe8f01..3d2b25a 100644 --- a/src/lastfmapplication.h +++ b/src/lastfmapplication.h @@ -32,6 +32,7 @@ #include #include #include +#include class CPlayerListener; class User; @@ -155,14 +156,20 @@ public slots: // Switch the app to a different language void setLanguage( QString langCode ); void onBootstrapReady( QString userName, QString pluginId ); + void commitData(QSessionManager& manager); -signals: + signals: void endSession(); // emitted when Windows shuts the app down /** see the Event::Type enum, data is corresponding data described in the enum * connect to this for all application level events, ie playback changes and * scrobble point notification */ void event( int event, const QVariant& data = QVariant() ); + + /** + * process session logout event + **/ + void commitDataRequest ( QSessionManager & manager ); protected: #ifdef WIN32 -- 1.6.6.1