mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
okular: drop text-to-speech support
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7fab52b62e
commit
5a08a23f45
7 changed files with 1 additions and 266 deletions
|
@ -215,7 +215,6 @@ set(okularpart_SRCS
|
|||
ui/toc.cpp
|
||||
ui/tocmodel.cpp
|
||||
ui/toolaction.cpp
|
||||
ui/tts.cpp
|
||||
ui/videowidget.cpp
|
||||
conf/dlgaccessibilitybase.ui
|
||||
conf/dlgeditorbase.ui
|
||||
|
@ -232,7 +231,6 @@ kde4_add_plugin(okularpart ${okularpart_SRCS})
|
|||
target_link_libraries(okularpart
|
||||
${KDE4_KPARTS_LIBS}
|
||||
${KDE4_KPASSWDSTORE_LIBS}
|
||||
${KDE4_KSPEECH_LIBS}
|
||||
${KDE4_KARCHIVE_LIBS}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
${QT_QTDBUS_LIBRARY}
|
||||
|
|
|
@ -95,7 +95,6 @@
|
|||
<choice name="Path" />
|
||||
</choices>
|
||||
</entry>
|
||||
<entry key="UseKTTSD" type="Bool" />
|
||||
<entry key="WatchFile" type="Bool" >
|
||||
<default>true</default>
|
||||
</entry>
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#include <kbookmarkmenu.h>
|
||||
#include <kpassworddialog.h>
|
||||
#include <kpasswdstore.h>
|
||||
#include <kspeech.h>
|
||||
|
||||
// local includes
|
||||
#include "aboutdata.h"
|
||||
|
@ -503,10 +502,6 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW
|
|||
// keep us informed when the user changes settings
|
||||
connect( Okular::Settings::self(), SIGNAL(configChanged()), this, SLOT(slotNewConfig()) );
|
||||
|
||||
// [SPEECH] check for KTTSD presence and usability
|
||||
Okular::Settings::setUseKTTSD( KSpeech::isSupported() );
|
||||
Okular::Settings::self()->writeConfig();
|
||||
|
||||
rebuildBookmarkMenu( false );
|
||||
|
||||
if ( m_embedMode == ViewerWidgetMode ) {
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
#include "pageviewannotator.h"
|
||||
#include "priorities.h"
|
||||
#include "toolaction.h"
|
||||
#include "tts.h"
|
||||
#include "videowidget.h"
|
||||
#include "core/action.h"
|
||||
#include "core/area.h"
|
||||
|
@ -115,7 +114,6 @@ public:
|
|||
PageViewPrivate( PageView *qq );
|
||||
|
||||
FormWidgetsController* formWidgetsController();
|
||||
OkularTTS* tts();
|
||||
QString selectedText() const;
|
||||
|
||||
// the document, pageviewItems and the 'visible cache'
|
||||
|
@ -171,7 +169,6 @@ public:
|
|||
PageViewMessage * messageWindow; // in pageviewutils.h
|
||||
bool m_formsVisible;
|
||||
FormWidgetsController *formsWidgetController;
|
||||
OkularTTS * m_tts;
|
||||
QTimer * refreshTimer;
|
||||
int refreshPage;
|
||||
|
||||
|
@ -208,9 +205,6 @@ public:
|
|||
KToggleAction * aViewContinuous;
|
||||
QAction * aPrevAction;
|
||||
KAction * aToggleForms;
|
||||
KAction * aSpeakDoc;
|
||||
KAction * aSpeakPage;
|
||||
KAction * aSpeakStop;
|
||||
KActionCollection * actionCollection;
|
||||
QActionGroup * mouseModeActionGroup;
|
||||
|
||||
|
@ -239,24 +233,6 @@ FormWidgetsController* PageViewPrivate::formWidgetsController()
|
|||
return formsWidgetController;
|
||||
}
|
||||
|
||||
OkularTTS* PageViewPrivate::tts()
|
||||
{
|
||||
if ( !m_tts )
|
||||
{
|
||||
m_tts = new OkularTTS( q );
|
||||
if ( aSpeakStop )
|
||||
{
|
||||
QObject::connect( m_tts, SIGNAL(hasSpeechs(bool)),
|
||||
aSpeakStop, SLOT(setEnabled(bool)) );
|
||||
QObject::connect( m_tts, SIGNAL(errorMessage(QString)),
|
||||
q, SLOT(errorMessage(QString)) );
|
||||
}
|
||||
}
|
||||
|
||||
return m_tts;
|
||||
}
|
||||
|
||||
|
||||
/* PageView. What's in this file? -> quick overview.
|
||||
* Code weight (in rows) and meaning:
|
||||
* 160 - constructor and creating actions plus their connected slots (empty stuff)
|
||||
|
@ -299,7 +275,6 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
|
|||
d->messageWindow = new PageViewMessage(this);
|
||||
d->m_formsVisible = false;
|
||||
d->formsWidgetController = 0;
|
||||
d->m_tts = 0;
|
||||
d->refreshTimer = 0;
|
||||
d->refreshPage = -1;
|
||||
d->aRotateClockwise = 0;
|
||||
|
@ -318,9 +293,6 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
|
|||
d->aViewContinuous = 0;
|
||||
d->aPrevAction = 0;
|
||||
d->aToggleForms = 0;
|
||||
d->aSpeakDoc = 0;
|
||||
d->aSpeakPage = 0;
|
||||
d->aSpeakStop = 0;
|
||||
d->actionCollection = 0;
|
||||
d->aPageSizes=0;
|
||||
d->setting_viewCols = Okular::Settings::viewColumns();
|
||||
|
@ -397,9 +369,6 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
|
|||
|
||||
PageView::~PageView()
|
||||
{
|
||||
if ( d->m_tts )
|
||||
d->m_tts->stopAllSpeechs();
|
||||
|
||||
// delete the local storage structure
|
||||
|
||||
// We need to assign it to a different list otherwise slotAnnotationWindowDestroyed
|
||||
|
@ -598,22 +567,6 @@ void PageView::setupActions( KActionCollection * ac )
|
|||
ta->addAction( d->aMouseTextSelect );
|
||||
ta->addAction( d->aMouseTableSelect );
|
||||
|
||||
// speak actions
|
||||
d->aSpeakDoc = new KAction( KIcon( "text-speak" ), i18n( "Speak Whole Document" ), this );
|
||||
ac->addAction( "speak_document", d->aSpeakDoc );
|
||||
d->aSpeakDoc->setEnabled( false );
|
||||
connect( d->aSpeakDoc, SIGNAL(triggered()), SLOT(slotSpeakDocument()) );
|
||||
|
||||
d->aSpeakPage = new KAction( KIcon( "text-speak" ), i18n( "Speak Current Page" ), this );
|
||||
ac->addAction( "speak_current_page", d->aSpeakPage );
|
||||
d->aSpeakPage->setEnabled( false );
|
||||
connect( d->aSpeakPage, SIGNAL(triggered()), SLOT(slotSpeakCurrentPage()) );
|
||||
|
||||
d->aSpeakStop = new KAction( KIcon( "media-playback-stop" ), i18n( "Stop Speaking" ), this );
|
||||
ac->addAction( "speak_stop_all", d->aSpeakStop );
|
||||
d->aSpeakStop->setEnabled( false );
|
||||
connect( d->aSpeakStop, SIGNAL(triggered()), SLOT(slotStopSpeaks()) );
|
||||
|
||||
// Other actions
|
||||
KAction * su = new KAction(i18n("Scroll Up"), this);
|
||||
ac->addAction("view_scroll_up", su );
|
||||
|
@ -1052,12 +1005,6 @@ void PageView::updateActionState( bool haspages, bool documentChanged, bool hasf
|
|||
}
|
||||
d->aToggleAnnotator->setEnabled( allowAnnotations );
|
||||
}
|
||||
if ( d->aSpeakDoc )
|
||||
{
|
||||
const bool enablettsactions = haspages ? Okular::Settings::useKTTSD() : false;
|
||||
d->aSpeakDoc->setEnabled( enablettsactions );
|
||||
d->aSpeakPage->setEnabled( enablettsactions );
|
||||
}
|
||||
if (d->aMouseMagnifier) {
|
||||
// FIXME: works only for some zoom-levels
|
||||
d->aMouseMagnifier->setVisible(false);
|
||||
|
@ -2505,7 +2452,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
|
|||
|
||||
// popup that ask to copy:text and copy/save:image
|
||||
KMenu menu( this );
|
||||
QAction *textToClipboard = 0, *speakText = 0, *imageToClipboard = 0, *imageToFile = 0;
|
||||
QAction *textToClipboard = 0, *imageToClipboard = 0, *imageToFile = 0;
|
||||
if ( d->document->supportsSearching() && !selectedText.isEmpty() )
|
||||
{
|
||||
menu.addTitle( i18np( "Text (1 character)", "Text (%1 characters)", selectedText.length() ) );
|
||||
|
@ -2516,8 +2463,6 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
|
|||
textToClipboard->setEnabled( false );
|
||||
textToClipboard->setText( i18n("Copy forbidden by DRM") );
|
||||
}
|
||||
if ( Okular::Settings::useKTTSD() )
|
||||
speakText = menu.addAction( KIcon("text-speak"), i18n( "Speak Text" ) );
|
||||
if ( copyAllowed )
|
||||
{
|
||||
addWebShortcutsMenu( &menu, selectedText );
|
||||
|
@ -2580,11 +2525,6 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
|
|||
if ( cb->supportsSelection() )
|
||||
cb->setText( selectedText, QClipboard::Selection );
|
||||
}
|
||||
else if ( choice == speakText )
|
||||
{
|
||||
// [2] speech selection using KTTSD
|
||||
d->tts()->say( selectedText );
|
||||
}
|
||||
}
|
||||
}
|
||||
// clear widget selection and invalidate rect
|
||||
|
@ -2765,10 +2705,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
|
|||
{
|
||||
KMenu menu( this );
|
||||
QAction *textToClipboard = menu.addAction( KIcon( "edit-copy" ), i18n( "Copy Text" ) );
|
||||
QAction *speakText = 0;
|
||||
QAction *httpLink = 0;
|
||||
if ( Okular::Settings::useKTTSD() )
|
||||
speakText = menu.addAction( KIcon( "text-speak" ), i18n( "Speak Text" ) );
|
||||
if ( !d->document->isAllowed( Okular::AllowCopy ) )
|
||||
{
|
||||
textToClipboard->setEnabled( false );
|
||||
|
@ -2790,11 +2727,6 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
|
|||
{
|
||||
if ( choice == textToClipboard )
|
||||
copyTextSelection();
|
||||
else if ( choice == speakText )
|
||||
{
|
||||
const QString text = d->selectedText();
|
||||
d->tts()->say( text );
|
||||
}
|
||||
else if ( choice == httpLink )
|
||||
new KRun( url, this );
|
||||
}
|
||||
|
@ -4798,41 +4730,6 @@ void PageView::slotRefreshPage()
|
|||
Q_ARG( int, req ) );
|
||||
}
|
||||
|
||||
void PageView::slotSpeakDocument()
|
||||
{
|
||||
QString text;
|
||||
QVector< PageViewItem * >::const_iterator it = d->items.constBegin(), itEnd = d->items.constEnd();
|
||||
for ( ; it < itEnd; ++it )
|
||||
{
|
||||
Okular::RegularAreaRect * area = textSelectionForItem( *it );
|
||||
text.append( (*it)->page()->text( area ) );
|
||||
text.append( '\n' );
|
||||
delete area;
|
||||
}
|
||||
|
||||
d->tts()->say( text );
|
||||
}
|
||||
|
||||
void PageView::slotSpeakCurrentPage()
|
||||
{
|
||||
const int currentPage = d->document->viewport().pageNumber;
|
||||
|
||||
PageViewItem *item = d->items.at( currentPage );
|
||||
Okular::RegularAreaRect * area = textSelectionForItem( item );
|
||||
const QString text = item->page()->text( area );
|
||||
delete area;
|
||||
|
||||
d->tts()->say( text );
|
||||
}
|
||||
|
||||
void PageView::slotStopSpeaks()
|
||||
{
|
||||
if ( !d->m_tts )
|
||||
return;
|
||||
|
||||
d->m_tts->stopAllSpeechs();
|
||||
}
|
||||
|
||||
void PageView::slotAction( Okular::Action *action )
|
||||
{
|
||||
d->document->processAction( action );
|
||||
|
|
|
@ -234,9 +234,6 @@ Q_OBJECT
|
|||
void slotToggleForms();
|
||||
void slotFormChanged( int pageNumber );
|
||||
void slotRefreshPage();
|
||||
void slotSpeakDocument();
|
||||
void slotSpeakCurrentPage();
|
||||
void slotStopSpeaks();
|
||||
void slotAction( Okular::Action *action );
|
||||
void externalKeyPressEvent( QKeyEvent *e );
|
||||
void slotAnnotationWindowDestroyed( QObject *window );
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
/***************************************************************************
|
||||
* 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 <qset.h>
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kspeech.h>
|
||||
|
||||
/* Private storage. */
|
||||
class OkularTTS::Private
|
||||
{
|
||||
public:
|
||||
Private( OkularTTS *qq )
|
||||
: q( qq ), kspeech( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
void setupIface();
|
||||
void teardownIface();
|
||||
|
||||
OkularTTS *q;
|
||||
KSpeech* kspeech;
|
||||
QSet< int > jobs;
|
||||
};
|
||||
|
||||
void OkularTTS::Private::setupIface()
|
||||
{
|
||||
if ( kspeech )
|
||||
return;
|
||||
|
||||
if ( !KSpeech::isSupported() )
|
||||
{
|
||||
emit q->errorMessage( i18n( "Text-to-Speech not supported" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
kspeech = new KSpeech(q);
|
||||
kspeech->setSpeechID(QString::fromLatin1("okular"));
|
||||
connect( kspeech, SIGNAL(jobStateChanged(int,int)),
|
||||
q, SLOT(slotJobStateChanged(int,int)) );
|
||||
}
|
||||
|
||||
void OkularTTS::Private::teardownIface()
|
||||
{
|
||||
delete kspeech;
|
||||
kspeech = 0;
|
||||
}
|
||||
|
||||
|
||||
OkularTTS::OkularTTS( QObject *parent )
|
||||
: QObject( parent ), d( new Private( this ) )
|
||||
{
|
||||
}
|
||||
|
||||
OkularTTS::~OkularTTS()
|
||||
{
|
||||
d->teardownIface();
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
void OkularTTS::say( const QString &text )
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
return;
|
||||
|
||||
d->setupIface();
|
||||
if ( d->kspeech )
|
||||
{
|
||||
const int jobId = d->kspeech->say( text );
|
||||
if ( jobId > 0 )
|
||||
{
|
||||
d->jobs.insert( jobId );
|
||||
emit hasSpeechs( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OkularTTS::stopAllSpeechs()
|
||||
{
|
||||
if ( !d->kspeech )
|
||||
return;
|
||||
|
||||
d->kspeech->removeAllJobs();
|
||||
}
|
||||
|
||||
void OkularTTS::slotJobStateChanged( int jobNum, int state )
|
||||
{
|
||||
if ( !d->kspeech )
|
||||
return;
|
||||
|
||||
switch ( state )
|
||||
{
|
||||
case KSpeech::JobCanceled: {
|
||||
d->jobs.remove( jobNum );
|
||||
emit hasSpeechs( !d->jobs.isEmpty() );
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_tts.cpp"
|
|
@ -1,38 +0,0 @@
|
|||
/***************************************************************************
|
||||
* 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 OkularTTS : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OkularTTS( QObject *parent = 0 );
|
||||
~OkularTTS();
|
||||
|
||||
void say( const QString &text );
|
||||
void stopAllSpeechs();
|
||||
|
||||
signals:
|
||||
void hasSpeechs( bool has );
|
||||
void errorMessage( const QString &message );
|
||||
|
||||
private slots:
|
||||
void slotJobStateChanged( int jobNum, int state );
|
||||
|
||||
private:
|
||||
// private storage
|
||||
class Private;
|
||||
Private *d;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue