svn path=/trunk/KDE/kdegraphics/okular/; revision=782420remotes/origin/KDE/4.1
parent
822fd2488d
commit
f407f84d8a
4 changed files with 126 additions and 31 deletions
@ -0,0 +1,78 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* This program is free software; you can redistribute it and/or modify * |
||||
* it under the terms of the GNU General Public License as published by * |
||||
* the Free Software Foundation; either version 2 of the License, or * |
||||
* (at your option) any later version. * |
||||
***************************************************************************/ |
||||
|
||||
#include "tts.h" |
||||
|
||||
#include <QtDBus/QDBusConnection> |
||||
#include <QtDBus/QDBusConnectionInterface> |
||||
#include <QtDBus/QDBusInterface> |
||||
#include <QtDBus/QDBusReply> |
||||
|
||||
#include <klocale.h> |
||||
#include <ktoolinvocation.h> |
||||
|
||||
#include "pageviewutils.h" |
||||
|
||||
/* Private storage. */ |
||||
class OkularTTS::Private |
||||
{ |
||||
public: |
||||
Private() |
||||
{ |
||||
} |
||||
|
||||
PageViewMessage *messageWindow; |
||||
}; |
||||
|
||||
|
||||
OkularTTS::OkularTTS( PageViewMessage *messageWindow, QObject *parent ) |
||||
: QObject( parent ), d( new Private ) |
||||
{ |
||||
d->messageWindow = messageWindow; |
||||
} |
||||
|
||||
OkularTTS::~OkularTTS() |
||||
{ |
||||
delete d; |
||||
} |
||||
|
||||
void OkularTTS::say( const QString &text ) |
||||
{ |
||||
if ( text.isEmpty() ) |
||||
return; |
||||
|
||||
// Albert says is this ever necessary?
|
||||
// we already attached on Part constructor
|
||||
// If KTTSD not running, start it.
|
||||
QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered( "org.kde.kttsd" ); |
||||
bool kttsdactive = false; |
||||
if ( reply.isValid() ) |
||||
kttsdactive = reply.value(); |
||||
if ( !kttsdactive ) |
||||
{ |
||||
QString error; |
||||
if ( KToolInvocation::startServiceByDesktopName( "kttsd", QStringList(), &error ) ) |
||||
{ |
||||
d->messageWindow->display( i18n( "Starting KTTSD Failed: %1", error ) ); |
||||
} |
||||
else |
||||
{ |
||||
kttsdactive = true; |
||||
} |
||||
} |
||||
if ( kttsdactive ) |
||||
{ |
||||
// creating the connection to the kspeech interface
|
||||
QDBusInterface kspeech( "org.kde.kttsd", "/KSpeech", "org.kde.KSpeech" ); |
||||
kspeech.call( "setApplicationName", "Okular" ); |
||||
kspeech.call( "say", text, 0 ); |
||||
} |
||||
} |
||||
|
||||
#include "tts.moc" |
||||
@ -0,0 +1,32 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> * |
||||
* * |
||||
* This program is free software; you can redistribute it and/or modify * |
||||
* it under the terms of the GNU General Public License as published by * |
||||
* the Free Software Foundation; either version 2 of the License, or * |
||||
* (at your option) any later version. * |
||||
***************************************************************************/ |
||||
|
||||
#ifndef _TTS_H_ |
||||
#define _TTS_H_ |
||||
|
||||
#include <qobject.h> |
||||
|
||||
class PageViewMessage; |
||||
|
||||
class OkularTTS : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
OkularTTS( PageViewMessage *messageWindow, QObject *parent = 0 ); |
||||
~OkularTTS(); |
||||
|
||||
void say( const QString &text ); |
||||
|
||||
private: |
||||
// private storage
|
||||
class Private; |
||||
Private *d; |
||||
}; |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue