Title: [104546] trunk/Tools
Revision
104546
Author
[email protected]
Date
2012-01-10 03:06:52 -0800 (Tue, 10 Jan 2012)

Log Message

[Qt][WK2] Fix keyboard shortcuts in MiniBrowser.
https://bugs.webkit.org/show_bug.cgi?id=75885

In QML events are propagated through parents. But since the
WebView may consume key events, a shortcut might never reach
the top QtQuickItem.
Therefore an application wide event handling function in C++
needs to take care of shortcuts for MiniBrowser.

Reviewed by Kenneth Rohde Christiansen.

* MiniBrowser/qt/BrowserWindow.cpp:
(BrowserWindow::reload):
(BrowserWindow::focusAddressBar):
* MiniBrowser/qt/BrowserWindow.h:
* MiniBrowser/qt/MiniBrowserApplication.cpp:
(MiniBrowserApplication::notify):
* MiniBrowser/qt/qml/BrowserWindow.qml:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (104545 => 104546)


--- trunk/Tools/ChangeLog	2012-01-10 10:46:31 UTC (rev 104545)
+++ trunk/Tools/ChangeLog	2012-01-10 11:06:52 UTC (rev 104546)
@@ -1,3 +1,24 @@
+2012-01-10  Zeno Albisser  <[email protected]>
+
+        [Qt][WK2] Fix keyboard shortcuts in MiniBrowser.
+        https://bugs.webkit.org/show_bug.cgi?id=75885
+
+        In QML events are propagated through parents. But since the
+        WebView may consume key events, a shortcut might never reach
+        the top QtQuickItem.
+        Therefore an application wide event handling function in C++
+        needs to take care of shortcuts for MiniBrowser.
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        * MiniBrowser/qt/BrowserWindow.cpp:
+        (BrowserWindow::reload):
+        (BrowserWindow::focusAddressBar):
+        * MiniBrowser/qt/BrowserWindow.h:
+        * MiniBrowser/qt/MiniBrowserApplication.cpp:
+        (MiniBrowserApplication::notify):
+        * MiniBrowser/qt/qml/BrowserWindow.qml:
+
 2012-01-10  Gyuyoung Kim  <[email protected]>
 
         Add --efl alias for --platform=efl to run-webkit-test

Modified: trunk/Tools/MiniBrowser/qt/BrowserWindow.cpp (104545 => 104546)


--- trunk/Tools/MiniBrowser/qt/BrowserWindow.cpp	2012-01-10 10:46:31 UTC (rev 104545)
+++ trunk/Tools/MiniBrowser/qt/BrowserWindow.cpp	2012-01-10 11:06:52 UTC (rev 104546)
@@ -76,6 +76,16 @@
     QMetaObject::invokeMethod(rootObject(), "load", Qt::DirectConnection, Q_ARG(QVariant, completedUrl));
 }
 
+void BrowserWindow::reload()
+{
+    QMetaObject::invokeMethod(rootObject(), "reload", Qt::DirectConnection);
+}
+
+void BrowserWindow::focusAddressBar()
+{
+    QMetaObject::invokeMethod(rootObject(), "focusAddressBar", Qt::DirectConnection);
+}
+
 BrowserWindow* BrowserWindow::newWindow(const QString& url)
 {
     BrowserWindow* window = new BrowserWindow();

Modified: trunk/Tools/MiniBrowser/qt/BrowserWindow.h (104545 => 104546)


--- trunk/Tools/MiniBrowser/qt/BrowserWindow.h	2012-01-10 10:46:31 UTC (rev 104545)
+++ trunk/Tools/MiniBrowser/qt/BrowserWindow.h	2012-01-10 11:06:52 UTC (rev 104546)
@@ -42,6 +42,8 @@
     BrowserWindow(WindowOptions* = 0);
     ~BrowserWindow();
     void load(const QString& url);
+    void reload();
+    void focusAddressBar();
     QQuickWebView* webView() const;
 
     void updateVisualMockTouchPoints(const QList<QWindowSystemInterface::TouchPoint>& touchPoints);

Modified: trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp (104545 => 104546)


--- trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp	2012-01-10 10:46:31 UTC (rev 104545)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp	2012-01-10 11:06:52 UTC (rev 104546)
@@ -97,6 +97,21 @@
     if (!browserWindow)
         return QApplication::notify(target, event);
 
+    // In QML events are propagated through parents. But since the WebView
+    // may consume key events, a shortcut might never reach the top QQuickItem.
+    // Therefore we are checking here for shortcuts.
+    if (event->type() == QEvent::KeyPress) {
+        QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
+        if ((keyEvent->key() == Qt::Key_R && keyEvent->modifiers() == Qt::ControlModifier) || keyEvent->key() == Qt::Key_F5) {
+            browserWindow->reload();
+            return true;
+        }
+        if ((keyEvent->key() == Qt::Key_L && keyEvent->modifiers() == Qt::ControlModifier) || keyEvent->key() == Qt::Key_F6) {
+            browserWindow->focusAddressBar();
+            return true;
+        }
+    }
+
     if (event->type() == QEvent::KeyRelease && static_cast<QKeyEvent*>(event)->key() == Qt::Key_Control) {
         foreach (int id, m_heldTouchPoints)
             if (m_touchPoints.contains(id))

Modified: trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml (104545 => 104546)


--- trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml	2012-01-10 10:46:31 UTC (rev 104545)
+++ trunk/Tools/MiniBrowser/qt/qml/BrowserWindow.qml	2012-01-10 11:06:52 UTC (rev 104546)
@@ -41,6 +41,10 @@
         webView.load(address)
     }
 
+    function reload() {
+        webView.reload()
+    }
+
     function focusAddressBar() {
         addressLine.forceActiveFocus()
         addressLine.selectAll()
@@ -151,11 +155,9 @@
                     onReleased: { parent.color = "#efefef" }
                     onClicked: {
                         if (webView.loading) {
-                            console.log("stop loading")
                             webView.stop()
                         } else {
-                            console.log("reloading")
-                            webView.reload()
+                            reload()
                         }
                     }
                 }
@@ -261,13 +263,6 @@
                     console.log("going to: ", addressLine.text)
                     webView.load(utils.urlFromUserInput(addressLine.text))
                 }
-
-                Keys.onPressed: {
-                    if (((event.modifiers & Qt.ControlModifier) && event.key == Qt.Key_L) || event.key == Qt.key_F6) {
-                        focusAddressBar()
-                        event.accepted = true
-                    }
-                }
             }
         }
     }
@@ -306,11 +301,4 @@
         visible: false
         viewportInfo : webView.experimental.viewportInfo
     }
-
-    Keys.onPressed: {
-        if (((event.modifiers & Qt.ControlModifier) && event.key == Qt.Key_L) || event.key == Qt.key_F6) {
-            focusAddressBar()
-            event.accepted = true
-        }
-    }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to