diff --git a/conf/dlgaccessibility.cpp b/conf/dlgaccessibility.cpp index bc9b5931d..7ebf6eb13 100644 --- a/conf/dlgaccessibility.cpp +++ b/conf/dlgaccessibility.cpp @@ -1,47 +1,58 @@ /*************************************************************************** * Copyright (C) 2006 by Pino Toscano * * * * 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 "dlgaccessibility.h" #include "ui_dlgaccessibilitybase.h" +#include "settings.h" + +#include + DlgAccessibility::DlgAccessibility( QWidget * parent ) : QWidget( parent ), m_selected( 0 ) { m_dlg = new Ui_DlgAccessibilityBase(); m_dlg->setupUi( this ); // ### not working yet, hide for now m_dlg->kcfg_HighlightImages->hide(); m_color_pages.append( m_dlg->page_invert ); m_color_pages.append( m_dlg->page_paperColor ); m_color_pages.append( m_dlg->page_darkLight ); m_color_pages.append( m_dlg->page_bw ); foreach ( QWidget * page, m_color_pages ) page->hide(); m_color_pages[ m_selected ]->show(); + // Populate tts engines + const QStringList engines = QTextToSpeech::availableEngines(); + for (const QString &engine: engines) { + m_dlg->kcfg_ttsEngine->addItem (engine); + } + m_dlg->kcfg_ttsEngine->setProperty("kcfg_property", QByteArray("currentText")); + connect(m_dlg->kcfg_RenderMode, static_cast(&KComboBox::currentIndexChanged), this, &DlgAccessibility::slotColorMode); } DlgAccessibility::~DlgAccessibility() { delete m_dlg; } void DlgAccessibility::slotColorMode( int mode ) { m_color_pages[ m_selected ]->hide(); m_color_pages[ mode ]->show(); m_selected = mode; } #include "moc_dlgaccessibility.cpp" diff --git a/conf/dlgaccessibilitybase.ui b/conf/dlgaccessibilitybase.ui index 9e76a754a..acc1f8225 100644 --- a/conf/dlgaccessibilitybase.ui +++ b/conf/dlgaccessibilitybase.ui @@ -1,386 +1,405 @@ DlgAccessibilityBase 0 0 374 - 327 + 479 0 0 0 0 Draw border around &Images Draw border around &Links true Change &colors true false 0 0 Warning: these options can badly affect drawing speed. Qt::PlainText true Color mode: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Invert Colors Change Paper Color Change Dark & Light Colors Convert to Black & White Qt::Vertical QSizePolicy::Fixed 20 8 0 0 0 0 6 0 0 0 0 Paper color: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter kcfg_PaperColor 0 0 0 0 6 0 0 0 0 Dark color: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 6 0 0 0 0 Light color: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 0 0 0 0 0 0 Threshold: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 0 0 16 Qt::Horizontal 0 0 Contrast: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 0 0 1 Qt::Horizontal + + + + Speech + + + + + + Engine + + + + + + + + + Qt::Vertical QSizePolicy::Expanding 20 20 KColorButton QPushButton
kcolorbutton.h
KComboBox QComboBox
kcombobox.h
diff --git a/conf/okular.kcfg b/conf/okular.kcfg index 8b2f356af..299f219d6 100644 --- a/conf/okular.kcfg +++ b/conf/okular.kcfg @@ -1,347 +1,350 @@ kuser.h true false false false false false false false false QStringList drawingTools; // load the default tool list from the 'xml tools definition' file QFile infoDrawingFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, "okular/drawingtools.xml") ); if ( infoDrawingFile.exists() && infoDrawingFile.open( QIODevice::ReadOnly ) ) { QDomDocument doc; if ( doc.setContent( &infoDrawingFile ) ) { const QDomElement toolsDefinition = doc.elementsByTagName("drawingTools").item( 0 ).toElement(); // create the annotationTools list from the XML dom tree QDomNode toolDescription = toolsDefinition.firstChild(); while ( toolDescription.isElement() ) { const QDomElement toolElement = toolDescription.toElement(); if ( toolElement.tagName() == "tool" ) { QDomDocument temp; temp.appendChild( temp.importNode( toolElement, true) ); // add each <tool>...</tool> as XML string drawingTools << temp.toString(-1); } toolDescription = toolDescription.nextSibling(); } } else { qWarning() << "DrawingTools XML file seems to be damaged"; } } else { qWarning() << "Unable to open DrawingTools XML definition"; } drawingTools QStringList annotationTools; // load the default tool list from the 'xml tools definition' file QFile infoFile( QStandardPaths::locate(QStandardPaths::GenericDataLocation, "okular/tools.xml") ); if ( infoFile.exists() && infoFile.open( QIODevice::ReadOnly ) ) { QDomDocument doc; if ( doc.setContent( &infoFile ) ) { QDomElement toolsDefinition = doc.elementsByTagName("annotatingTools").item( 0 ).toElement(); // create the annotationTools list from the XML dom tree QDomNode toolDescription = toolsDefinition.firstChild(); while ( toolDescription.isElement() ) { QDomElement toolElement = toolDescription.toElement(); if ( toolElement.tagName() == "tool" ) { QDomDocument temp; temp.appendChild( temp.importNode( toolElement, true) ); // add each <tool>...</tool> as XML string annotationTools << temp.toString(-1); } toolDescription = toolDescription.nextSibling(); } } else { qWarning() << "AnnotatingTools XML file seems to be damaged"; } } else { qWarning() << "Unable to open AnnotatingTools XML definition"; } annotationTools 1 3 false true true false Name + + speechd + true Qt::black Replace HiddenDelay true false true -2 -2 20 true true false true true false true true true 48 0 true 0 0 50 3 1 8 false true Single None Browse false false false true true false false 0x600000 0xF0F0F0 127 2 253 2 2 6 KUser currentUser; QString userString = currentUser.property( KUser::FullName ).toString(); if ( userString.isEmpty() ) { userString = currentUser.loginName(); } userString diff --git a/ui/tts.cpp b/ui/tts.cpp index 08ecf6bc5..eb3346c6c 100644 --- a/ui/tts.cpp +++ b/ui/tts.cpp @@ -1,83 +1,85 @@ /*************************************************************************** * Copyright (C) 2008 by Pino Toscano * * * * 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 #include #include +#include "settings.h" + /* Private storage. */ class OkularTTS::Private { public: Private( OkularTTS *qq ) - : q( qq ), speech( new QTextToSpeech ) + : q( qq ), speech( new QTextToSpeech( Okular::Settings::ttsEngine() ) ) { } ~Private() { delete speech; speech = nullptr; } OkularTTS *q; QTextToSpeech *speech; }; OkularTTS::OkularTTS( QObject *parent ) : QObject( parent ), d( new Private( this ) ) { connect( d->speech, &QTextToSpeech::stateChanged, this, &OkularTTS::slotSpeechStateChanged); } OkularTTS::~OkularTTS() { delete d; } void OkularTTS::say( const QString &text ) { if ( text.isEmpty() ) return; d->speech->say( text ); } void OkularTTS::stopAllSpeechs() { if ( !d->speech ) return; d->speech->stop(); } void OkularTTS::pauseResumeSpeech() { if ( !d->speech ) return; if ( d->speech->state() == QTextToSpeech::Speaking ) d->speech->pause(); else d->speech->resume(); } void OkularTTS::slotSpeechStateChanged(QTextToSpeech::State state) { if (state == QTextToSpeech::Speaking) emit isSpeaking(true); else emit isSpeaking(false); } #include "moc_tts.cpp"