diff options
author | Alexis Menard <alexis.menard@openbossa.org> | 2012-06-12 17:55:20 -0300 |
---|---|---|
committer | Alexis Menard <alexis.menard@openbossa.org> | 2012-06-13 09:22:09 -0300 |
commit | 6c11185308eb60d30d7989fa8cb2e8550d573f45 (patch) | |
tree | 4c1cf2b3ce17cc4cd17e218074afc71b632f0313 | |
parent | 1b578f2e17a56000791f791518041e4e50fe1447 (diff) |
Add Inspector support inside Snowshoe.
Reviewed-by: Caio Oliveira
-rw-r--r-- | src/desktop/qml/PageWidget.qml | 91 | ||||
-rw-r--r-- | src/desktop/qml/main.qml | 5 | ||||
-rw-r--r-- | src/main.cpp | 1 |
3 files changed, 96 insertions, 1 deletions
diff --git a/src/desktop/qml/PageWidget.qml b/src/desktop/qml/PageWidget.qml index 756d9b4..df2e148 100644 --- a/src/desktop/qml/PageWidget.qml +++ b/src/desktop/qml/PageWidget.qml @@ -28,6 +28,7 @@ Item { property string title: "New Tab" property string currentUrl property bool active: false + state: "inspectorHidden" property variant tab; @@ -35,7 +36,12 @@ Item { WebView { id: webView - anchors.fill: parent + + // anchors.fill : root doesn't play nice with when using AnchorChanges we set them explicitely. + anchors.top: root.top + anchors.left: root.left + anchors.right: root.right + anchors.bottom: root.bottom visible: false @@ -74,6 +80,7 @@ Item { experimental.preferences.fullScreenEnabled: true + experimental.preferences.developerExtrasEnabled: true experimental.onDownloadRequested: { downloadItem.destinationPath = BrowserWindow.decideDownloadPath(downloadItem.suggestedFilename) @@ -99,6 +106,37 @@ Item { } } + Rectangle { + id: sizeGrip + color: "gray" + visible: false + height: 10 + anchors { + left: root.left + right: root.right + } + y: Math.round(root.height * 2 / 3) + + MouseArea { + anchors.fill: parent + drag.target: sizeGrip + drag.minimumY: 0 + drag.maximumY: root.height + drag.axis: Drag.YAxis + } + } + + WebView { + id: inspector + visible: false + anchors { + left: root.left + right: root.right + top: sizeGrip.bottom + bottom: root.bottom + } + } + function loadUrl(url) { webView.url = url @@ -110,6 +148,15 @@ Item { return "http://www.google.com/search?q=" + url; } + function toggleInspector() { + if (!UrlTools.isValid(webView.url)) + return; + if (state == "inspectorHidden") + state = "inspectorShown"; + else + state = "inspectorHidden"; + } + NewTab { id: newTab anchors.fill: parent @@ -120,4 +167,46 @@ Item { anchors.bottom: parent.bottom anchors.left: parent.left } + + states: [ + State { + name: "inspectorShown" + PropertyChanges { + target: inspector + visible: true + } + PropertyChanges { + target: sizeGrip + visible: true + } + PropertyChanges { + target: inspector + url: webView.experimental.remoteInspectorUrl + } + AnchorChanges { + target: webView + anchors.bottom: sizeGrip.top + } + }, + State { + name: "inspectorHidden" + PropertyChanges { + target: inspector + visible: false + } + PropertyChanges { + target: sizeGrip + visible: false + } + PropertyChanges { + target: inspector + url: "" + } + AnchorChanges { + target: webView + anchors.bottom: root.bottom + } + } + + ] } diff --git a/src/desktop/qml/main.qml b/src/desktop/qml/main.qml index 065048a..8c5670d 100644 --- a/src/desktop/qml/main.qml +++ b/src/desktop/qml/main.qml @@ -181,6 +181,11 @@ Item { } Shortcut { + key: "Ctrl+I" + onTriggered: tabWidget.activePage.toggleInspector() + } + + Shortcut { key: "F5" onTriggered: tabWidget.activePage.webView.reload() } diff --git a/src/main.cpp b/src/main.cpp index 033f803..69da3d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,6 +54,7 @@ int main(int argc, char** argv) if (pos != -1) arguments.removeAt(pos); arguments = arguments.mid(1); + qputenv("QTWEBKIT_INSPECTOR_SERVER", "127.0.0.1:9222"); QQuickWebViewExperimental::setFlickableViewportEnabled(false); window = new BrowserWindow(arguments); } |