[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegraphics/okular/ui
From:       Pino Toscano <pino () kde ! org>
Date:       2010-08-14 13:18:55
Message-ID: 20100814131855.C816BAC84E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1163584 by pino:

port TTS to QDBusServiceWatcher


 M  +7 -14     tts.cpp  
 M  +0 -1      tts.h  


--- trunk/KDE/kdegraphics/okular/ui/tts.cpp #1163583:1163584
@@ -9,6 +9,7 @@
 
 #include "tts.h"
 
+#include <qdbusservicewatcher.h>
 #include <qset.h>
 
 #include <klocale.h>
@@ -23,6 +24,7 @@
 public:
     Private( OkularTTS *qq )
         : q( qq ), kspeech( 0 )
+        , watcher( "org.kde.kttsd", QDBusConnection::sessionBus(), \
QDBusServiceWatcher::WatchForUnregistration )  {
     }
 
@@ -32,6 +34,7 @@
     OkularTTS *q;
     org::kde::KSpeech* kspeech;
     QSet< int > jobs;
+    QDBusServiceWatcher watcher;
 };
 
 void OkularTTS::Private::setupIface()
@@ -64,17 +67,11 @@
         kspeech->setApplicationName( "Okular" );
         connect( kspeech, SIGNAL( jobStateChanged( const QString &, int, int ) ),
                  q, SLOT( slotJobStateChanged( const QString &, int, int ) ) );
-        connect( QDBusConnection::sessionBus().interface(), SIGNAL( \
                serviceUnregistered( const QString & ) ),
-                 q, SLOT( slotServiceUnregistered( const QString & ) ) );
-        connect( QDBusConnection::sessionBus().interface(), SIGNAL( \
                serviceOwnerChanged( const QString &, const QString &, const QString \
                & ) ),
-                 q, SLOT( slotServiceOwnerChanged( const QString &, const QString &, \
const QString & ) ) );  }
 }
 
 void OkularTTS::Private::teardownIface()
 {
-    disconnect( QDBusConnection::sessionBus().interface(), 0, q, 0 );
-
     delete kspeech;
     kspeech = 0;
 }
@@ -83,10 +80,14 @@
 OkularTTS::OkularTTS( QObject *parent )
     : QObject( parent ), d( new Private( this ) )
 {
+    connect( &d->watcher, SIGNAL( serviceUnregistered( const QString & ) ),
+             this, SLOT( slotServiceUnregistered( const QString & ) ) );
 }
 
 OkularTTS::~OkularTTS()
 {
+    disconnect( &d->watcher, 0, this, 0 );
+
     delete d;
 }
 
@@ -123,14 +124,6 @@
     }
 }
 
-void OkularTTS::slotServiceOwnerChanged( const QString &service, const QString &, \
                const QString &newOwner )
-{
-    if ( service == QLatin1String( "org.kde.kttsd" ) && newOwner.isEmpty() )
-    {
-        d->teardownIface();
-    }
-}
-
 void OkularTTS::slotJobStateChanged( const QString &appId, int jobNum, int state )
 {
     // discard non ours job
--- trunk/KDE/kdegraphics/okular/ui/tts.h #1163583:1163584
@@ -28,7 +28,6 @@
 
     private slots:
         void slotServiceUnregistered( const QString& );
-        void slotServiceOwnerChanged( const QString&, const QString&, const QString& \
                );
         void slotJobStateChanged( const QString &appId, int jobNum, int state );
 
     private:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic