Fixed some platform specific issues webkit
authorBartosz Szatkowski <bulislaw@linux.com>
Wed, 1 Sep 2010 07:08:51 +0000 (09:08 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Wed, 1 Sep 2010 07:08:51 +0000 (09:08 +0200)
trunk/src/base/base.pro
trunk/src/base/gui/TranslationTextEdit.cpp
trunk/src/base/gui/TranslationTextEdit.h
trunk/src/base/gui/TranslationWidget.cpp
trunk/src/base/xsl.xsl

index cc2e3cf..85b6409 100644 (file)
@@ -8,7 +8,6 @@ QT += core \
     xmlpatterns \
     webkit \
     dbus
-
 maemo5:QT += maemo5
 TARGET = mdictionary
 TEMPLATE = app
@@ -81,7 +80,6 @@ unix {
         icon64 \
         bookmarks \
         service
-
     target.path = $$BINDIR
     maemo5 { 
         desktop.path = $$DATADIR/applications/hildon
@@ -93,10 +91,8 @@ unix {
     }
     desktop.files += ../../../data/other/$${TARGET}.desktop
     icon64.files += ../../../data/icons/64x64/$${TARGET}.png
-
     bookmarks.path = $$LIBDIR
     bookmarks.files += ../../../data/icons/16x16/staron.png
-
     service.path = $$DATADIR/dbus-1/services
     service.files += ../../../data/other/com.comarch.mdictionary.service
 }
index 16160bc..4bf961c 100644 (file)
@@ -32,12 +32,43 @@ TranslationTextEdit::TranslationTextEdit(QWidget *parent) :
     searchSelectedAction = new QAction(tr("Search"), this);
     copySelectedAction = new QAction(tr("Copy"), this);
     selectAllAction = new QAction(tr("Select All"), this);
+    setAcceptDrops(false);
+
+    #ifdef Q_WS_MAEMO_5
+        installEventFilter(this);
+        property("kineticScroller").value<QAbstractKineticScroller*>()->
+                setEnabled(true);
+    #endif
+
 
     connect(searchSelectedAction, SIGNAL(triggered()),
             this, SIGNAL(search()));
     connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
 }
 
+
+bool TranslationTextEdit::eventFilter(QObject *, QEvent *e)
+{
+    switch (e->type()) {
+    case QEvent::MouseButtonPress:
+        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+            mousePressed = true;
+        break;
+    case QEvent::MouseButtonRelease:
+        if (static_cast<QMouseEvent *>(e)->button() == Qt::LeftButton)
+            mousePressed = false;
+        break;
+    case QEvent::MouseMove:
+        if (mousePressed)
+            return true;
+        break;
+    default:
+        break;
+    }
+    return false;
+}
+
+
 void TranslationTextEdit::contextMenuEvent(QContextMenuEvent *e) {
     QMenu *menu = new QMenu;
     if(selectedText().isEmpty())
index df47d30..7fdd2dc 100644 (file)
@@ -27,6 +27,8 @@
 #include <QTextEdit>
 #include <QAction>
 #include <QWebView>
+#include <QEvent>
+
 class TranslationWidget;
 
 class TranslationTextEdit : public QWebView
@@ -54,6 +56,8 @@ private:
     QAction* copySelectedAction;
     QAction* selectAllAction;
     TranslationWidget* realParent;
+    bool mousePressed;
+    bool eventFilter(QObject *, QEvent *);
 
 };
 
index b8f1bfd..689bef0 100644 (file)
@@ -81,12 +81,13 @@ void TranslationWidget::show(QStringList translations) {
             + trans + tr("\n </ar>");
     trans=XslConversion(trans);
 
-    QString head = "<html><head><link rel=\"stylesheet\" type=\"text/css\" " ;
+    QString head = "<html><head>";
+    head += "<link rel=\"stylesheet\" type=\"text/css\" " ;
     head += "href=\"" + QDir::homePath() + "/.mdictionary/style.css";
-    head += "\" /></head>";
+    head += "\" /></head><body ondragstart=\"return false\">";
     trans = head + trans;
 
-    trans+= "</html>";
+    trans+= "</body></html>";
     trans.replace("$STAR$", "/usr/lib/mdictionary/staron.png");
 
 
index c844b97..96770eb 100644 (file)
@@ -2,13 +2,11 @@
 <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
 <xsl:template match="/">
-             <body>
                 <table border="1" width="100%">
                    <xsl:for-each select="ar/dict"> 
                        <xsl:apply-templates/>
                    </xsl:for-each>
                 </table>
-             </body>
 </xsl:template> 
 
 <xsl:template match="info">