[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/apps/konqueror/kttsplugin
From: Laurent Montel <montel () kde ! org>
Date: 2008-04-10 6:56:22
Message-ID: 1207810582.615405.30473.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 795393 by mlaurent:
Start to add webkitpart support
M +27 -1 CMakeLists.txt
A config-kttsplugin.h.cmake
M +65 -23 khtmlkttsd.cpp
--- trunk/KDE/kdebase/apps/konqueror/kttsplugin/CMakeLists.txt #795392:795393
@@ -3,18 +3,44 @@
########### next target ###############
+include(MacroOptionalDependPackage)
+
+MACRO_OPTIONAL_DEPEND_PACKAGE(WebKitKde "webkitkde")
+if(DEPEND_PACKAGE_WebKitKde)
+ macro_optional_find_package(WebKitKde QUIET)
+else(DEPEND_PACKAGE_WebKitKde)
+ set(WEBKITKDE_FOUND FALSE)
+endif(DEPEND_PACKAGE_WebKitKde)
+
+macro_bool_to_01(WEBKITKDE_FOUND HAVE_WEBKITKDE)
+
+configure_file(config-kttsplugin.h.cmake \
${CMAKE_CURRENT_BINARY_DIR}/config-kttsplugin.h ) +
+
+if( WEBKITKDE_FOUND )
+ include_directories(${WEBKITKDE_INCLUDE_DIR})
+endif(WEBKITKDE_FOUND)
+
+
set(khtmlkttsdplugin_PART_SRCS khtmlkttsd.cpp )
qt4_add_dbus_interfaces(khtmlkttsdplugin_PART_SRCS \
${KDE4_DBUS_INTERFACES_DIR}/org.kde.KSpeech.xml)
kde4_add_plugin(khtmlkttsdplugin ${khtmlkttsdplugin_PART_SRCS})
-
target_link_libraries(khtmlkttsdplugin ${KDE4_KHTML_LIBS} )
+if( WEBKITKDE_FOUND)
+ target_link_libraries(khtmlkttsdplugin ${WEBKITKDE_LIBRARIES} \
${QT_QTWEBKIT_LIBRARY} ) +endif(WEBKITKDE_FOUND)
+
+
install(TARGETS khtmlkttsdplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES khtmlkttsd.rc khtmlkttsd.desktop DESTINATION \
${DATA_INSTALL_DIR}/khtml/kpartplugins ) +if( WEBKITKDE_FOUND)
+ install( FILES khtmlkttsd.rc khtmlkttsd.desktop DESTINATION \
${DATA_INSTALL_DIR}/webkitpart/kpartplugins ) +endif( WEBKITKDE_FOUND)
--- trunk/KDE/kdebase/apps/konqueror/kttsplugin/khtmlkttsd.cpp #795392:795393
@@ -23,6 +23,9 @@
#include <kactioncollection.h>
#include <kdebug.h>
#include <khtml_part.h> // this plugin applies to a khtml part
+#ifdef HAVE_WEBKIT
+#include <webkitpart.h>
+#endif
#include <kicon.h>
#include <klocale.h>
#include <kmessagebox.h>
@@ -31,6 +34,7 @@
#include <kspeech.h>
#include <ktoolinvocation.h>
+
#include "kspeechinterface.h"
KHTMLPluginKTTSD::KHTMLPluginKTTSD( QObject* parent, const QVariantList& )
@@ -55,12 +59,11 @@
void KHTMLPluginKTTSD::slotReadOut()
{
- KHTMLPart *part = qobject_cast<KHTMLPart *>(parent());
-
+ KParts::ReadOnlyPart* part = static_cast<KParts::ReadOnlyPart *>(parent());
// The parent is assumed to be a KHTMLPart
if (!part)
- KMessageBox::sorry( 0, i18n( "You cannot read anything except web pages with \
this plugin, sorry." ),
- i18n( "Cannot Read source" ) );
+ KMessageBox::sorry( 0, i18n( "You cannot read anything except web pages with \
this plugin, sorry." ), + i18n( "Cannot Read source" ) );
else
{
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kttsd"))
@@ -82,34 +85,73 @@
}
QString query;
- if (supportsXhtml)
+ bool hasSelection = false;
+ KHTMLPart *compPart = dynamic_cast<KHTMLPart *>(part);
+ if ( compPart )
{
- kDebug() << "KTTS claims to support rich speak (XHTML to SSML).";
- if (part->hasSelection())
- query = part->selectedTextAsHTML();
- else
+ if (supportsXhtml)
{
- // TODO: Fooling around with the selection probably has unwanted
- // side effects, but until a method is supplied to get valid xhtml
- // from entire document..
- // query = part->document().toString().string();
- part->selectAll();
- query = part->selectedTextAsHTML();
- // Restore no selection.
- part->setSelection(part->document().createRange());
+ kDebug() << "KTTS claims to support rich speak (XHTML to SSML).";
+ if (hasSelection)
+ query = compPart->selectedTextAsHTML();
+ else
+ {
+ // TODO: Fooling around with the selection probably has unwanted
+ // side effects, but until a method is supplied to get valid \
xhtml + // from entire document..
+ // query = part->document().toString().string();
+ compPart->selectAll();
+ query = compPart->selectedTextAsHTML();
+ // Restore no selection.
+ compPart->setSelection(compPart->document().createRange());
+ }
+ } else {
+ if (hasSelection)
+ query = compPart->selectedText();
+ else
+ query = compPart->htmlDocument().body().innerText().string();
}
- } else {
- if (part->hasSelection())
- query = part->selectedText();
- else
- query = part->htmlDocument().body().innerText().string();
}
+#ifdef HAVE_WEBKITKDE
+ else
+ {
+ WebKitPart *webkitPart = dynamic_cast<WebKitPart *>(part);
+ if ( webkitPart )
+ {
+#if 0
+ if (supportsXhtml)
+ {
+ kDebug() << "KTTS claims to support rich speak (XHTML to \
SSML)."; + if (hasSelection)
+ query = part->selectedTextAsHTML();
+ else
+ {
+ // TODO: Fooling around with the selection probably has \
unwanted + // side effects, but until a method is supplied to \
get valid xhtml + // from entire document..
+ // query = part->document().toString().string();
+ part->selectAll();
+ query = part->selectedTextAsHTML();
+ // Restore no selection.
+ part->setSelection(part->document().createRange());
+ }
+ } else {
+ if (hasSelection)
+ query = part->selectedText();
+ else
+ query = part->htmlDocument().body().innerText().string();
+ }
+#endif
+ }
+
+ }
+#endif
// kDebug() << "query =" << query;
reply = kttsd.say(query, KSpeech::soNone);
if ( !reply.isValid())
KMessageBox::sorry( 0, i18n( "The D-Bus call say() failed." ),
- i18n( "D-Bus Call Failed" ));
+ i18n( "D-Bus Call Failed" ));
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic