From fd2535ecaf2978d4815e86fd3cf85f18e018b2ea Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 6 Sep 2020 20:40:07 +1200 Subject: [PATCH 1/6] Fix browser window buttons and Web page favicon display --- interface/resources/qml/Browser.qml | 34 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 496209a2a8..d2b93f45c9 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -63,29 +63,38 @@ ScrollingWindow { anchors.leftMargin: 8 HiFiGlyphs { id: back; - enabled: webview.canGoBack; + enabled: webview.canGoBack text: hifi.glyphs.backward - color: enabled ? hifi.colors.text : hifi.colors.disabledText + color: enabled ? hifi.colors.faintGray : hifi.colors.lightGray size: 48 - MouseArea { anchors.fill: parent; onClicked: webview.goBack() } + MouseArea { + anchors.fill: parent + onClicked: webview.goBack(); + } } HiFiGlyphs { id: forward; - enabled: webview.canGoForward; + enabled: webview.canGoForward text: hifi.glyphs.forward - color: enabled ? hifi.colors.text : hifi.colors.disabledText + color: enabled ? hifi.colors.faintGray : hifi.colors.lightGray size: 48 - MouseArea { anchors.fill: parent; onClicked: webview.goForward() } + MouseArea { + anchors.fill: parent + onClicked: webview.goForward(); + } } HiFiGlyphs { id: reload; - enabled: webview.canGoForward; + enabled: url !== "" text: webview.loading ? hifi.glyphs.close : hifi.glyphs.reload - color: enabled ? hifi.colors.text : hifi.colors.disabledText + color: enabled ? hifi.colors.faintGray : hifi.colors.lightGray size: 48 - MouseArea { anchors.fill: parent; onClicked: webview.goForward() } + MouseArea { + anchors.fill: parent + onClicked: webview.loading ? webview.stop() : webview.reload(); + } } } @@ -105,11 +114,12 @@ ScrollingWindow { width: parent.height height: parent.height Image { - source: webview.icon; + source: webview.icon x: (parent.height - height) / 2 y: (parent.width - width) / 2 - sourceSize: Qt.size(width, height); - verticalAlignment: Image.AlignVCenter; + width: 28 + height: 28 + verticalAlignment: Image.AlignVCenter horizontalAlignment: Image.AlignHCenter } } From 9d3b763256847dc833538c4f8dfc74fd07134b90 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 6 Sep 2020 20:49:29 +1200 Subject: [PATCH 2/6] Add hover state to browser window buttons --- interface/resources/qml/Browser.qml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index d2b93f45c9..b477ac0cbb 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -62,37 +62,43 @@ ScrollingWindow { anchors.left: parent.left anchors.leftMargin: 8 HiFiGlyphs { - id: back; + id: back enabled: webview.canGoBack text: hifi.glyphs.backward - color: enabled ? hifi.colors.faintGray : hifi.colors.lightGray + color: enabled ? (backMouseArea.containsMouse ? hifi.colors.blueHighlight : hifi.colors.faintGray) : hifi.colors.lightGray size: 48 MouseArea { + id: backMouseArea anchors.fill: parent + hoverEnabled: true onClicked: webview.goBack(); } } HiFiGlyphs { - id: forward; + id: forward enabled: webview.canGoForward text: hifi.glyphs.forward - color: enabled ? hifi.colors.faintGray : hifi.colors.lightGray + color: enabled ? (forwardMouseArea.containsMouse ? hifi.colors.blueHighlight : hifi.colors.faintGray) : hifi.colors.lightGray size: 48 MouseArea { + id: forwardMouseArea anchors.fill: parent + hoverEnabled: true onClicked: webview.goForward(); } } HiFiGlyphs { - id: reload; + id: reload enabled: url !== "" text: webview.loading ? hifi.glyphs.close : hifi.glyphs.reload - color: enabled ? hifi.colors.faintGray : hifi.colors.lightGray + color: enabled ? (reloadMouseArea.containsMouse ? hifi.colors.blueHighlight : hifi.colors.faintGray) : hifi.colors.lightGray size: 48 MouseArea { + id: reloadMouseArea anchors.fill: parent + hoverEnabled: true onClicked: webview.loading ? webview.stop() : webview.reload(); } } From 7da2fa1315e68213e871e30c398bea3bdd6133b9 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 6 Sep 2020 20:56:44 +1200 Subject: [PATCH 3/6] Add open-in-externa-window button --- interface/resources/qml/Browser.qml | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index b477ac0cbb..018f333ff3 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -49,6 +49,12 @@ ScrollingWindow { desktop.setAutoAdd(auto); } + function openExternalBrowser() { + Qt.openUrlExternally(addressBar.text); + root.shown = false; + root.windowClosed(); + } + Item { id:item width: pane.contentWidth @@ -115,6 +121,25 @@ ScrollingWindow { anchors.left: buttons.right anchors.leftMargin: 8 + HiFiGlyphs { + id: externalBrowser + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: 4 + enabled: !HMD.active && url !== "" + font.family: "FontAwesome" + text: "\uf24d" + rotation: -90 + color: enabled ? (externalBrowserMouseArea.containsMouse ? hifi.colors.blueHighlight : hifi.colors.faintGray) : hifi.colors.lightGray + size: 32 + MouseArea { + id: externalBrowserMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: openExternalBrowser(); + } + } + Item { id: barIcon width: parent.height @@ -132,7 +157,7 @@ ScrollingWindow { TextField { id: addressBar - anchors.right: parent.right + anchors.right: externalBrowser.left anchors.rightMargin: 8 anchors.left: barIcon.right anchors.leftMargin: 0 From 1d27c0138c41818ce9122568a4ad99c39dfed697 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 6 Sep 2020 21:00:45 +1200 Subject: [PATCH 4/6] Fix browsing history --- interface/resources/qml/Browser.qml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 018f333ff3..44c544de97 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -165,22 +165,32 @@ ScrollingWindow { focus: true colorScheme: hifi.colorSchemes.dark placeholderText: "Enter URL" + inputMethodHints: Qt.ImhUrlCharactersOnly Component.onCompleted: ScriptDiscoveryService.scriptsModelFilter.filterRegExp = new RegExp("^.*$", "i") Keys.onPressed: { switch(event.key) { case Qt.Key_Enter: case Qt.Key_Return: event.accepted = true - if (text.indexOf("http") != 0) { + if (text.indexOf("http") !== 0) { text = "http://" + text; } + + // Setting webiew.url directly doesn't add the URL to the navigation history. + //webview.url = text; + // The following works around this bug. + text = encodeURI(text); + text = text.replace(/;/g, "%3b"); // Prevent script injection. + text = text.replace(/'/g, "%25"); // "" + webview.runJavaScript("window.location='" + text + "'"); + root.hidePermissionsBar(); root.keyboardRaised = false; - webview.url = text; break; } } } + } Rectangle { @@ -257,7 +267,7 @@ ScrollingWindow { Keys.onPressed: { switch(event.key) { case Qt.Key_L: - if (event.modifiers == Qt.ControlModifier) { + if (event.modifiers === Qt.ControlModifier) { event.accepted = true addressBar.selectAll() addressBar.forceActiveFocus() @@ -265,4 +275,5 @@ ScrollingWindow { break; } } + } // dialog From 29b96432bc533b3ad7bbf1634e5596a3521a9e03 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 6 Sep 2020 21:04:13 +1200 Subject: [PATCH 5/6] Clear favicon image when page is changed --- interface/resources/qml/Browser.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 44c544de97..6d5b9b7ae1 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -145,7 +145,7 @@ ScrollingWindow { width: parent.height height: parent.height Image { - source: webview.icon + source: webview.loading ? "" : webview.icon x: (parent.height - height) / 2 y: (parent.width - width) / 2 width: 28 From 2985ac2262383f3cf638e6bd139cc4456675a943 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 10 Sep 2020 13:15:56 +1200 Subject: [PATCH 6/6] Twek browser bar layout --- interface/resources/qml/Browser.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 6d5b9b7ae1..2fefb6bff4 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -64,7 +64,7 @@ ScrollingWindow { id: buttons spacing: 4 anchors.top: parent.top - anchors.topMargin: 8 + anchors.topMargin: 4 anchors.left: parent.left anchors.leftMargin: 8 HiFiGlyphs { @@ -115,7 +115,7 @@ ScrollingWindow { id: border height: 48 anchors.top: parent.top - anchors.topMargin: 8 + anchors.topMargin: 4 anchors.right: parent.right anchors.rightMargin: 8 anchors.left: buttons.right @@ -158,7 +158,7 @@ ScrollingWindow { TextField { id: addressBar anchors.right: externalBrowser.left - anchors.rightMargin: 8 + anchors.rightMargin: 32 anchors.left: barIcon.right anchors.leftMargin: 0 anchors.verticalCenter: parent.verticalCenter @@ -255,7 +255,7 @@ ScrollingWindow { parentRoot: root anchors.top: buttons.bottom - anchors.topMargin: 8 + anchors.topMargin: 4 anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right