mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 11:04:02 +02:00
Fix popups misbehavior, wrong links with double http etc
This commit is contained in:
parent
92fc6daecc
commit
83c14bba5c
1 changed files with 25 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
//
|
//
|
||||||
// WebBrowser.qml
|
// WebBrowser.qml
|
||||||
//
|
//
|
||||||
|
@ -45,7 +46,7 @@ Rectangle {
|
||||||
onSuggestions: {
|
onSuggestions: {
|
||||||
if (suggestions.length > 0) {
|
if (suggestions.length > 0) {
|
||||||
suggestionsList = []
|
suggestionsList = []
|
||||||
suggestionsList.push(addressBar.editText) //do not overwrite edit text
|
suggestionsList.push(addressBarInput.text) //do not overwrite edit text
|
||||||
for(var i = 0; i < suggestions.length; i++) {
|
for(var i = 0; i < suggestions.length; i++) {
|
||||||
suggestionsList.push(suggestions[i])
|
suggestionsList.push(suggestions[i])
|
||||||
}
|
}
|
||||||
|
@ -63,7 +64,7 @@ Rectangle {
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (addressBar.editText !== "") {
|
if (addressBar.editText !== "") {
|
||||||
searchEngine.requestSuggestions(addressBar.editText)
|
searchEngine.requestSuggestions(addressBarInput.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,12 +73,16 @@ Rectangle {
|
||||||
|
|
||||||
function goTo(url) {
|
function goTo(url) {
|
||||||
//must be valid attempt to open an site with dot
|
//must be valid attempt to open an site with dot
|
||||||
if (url.indexOf("http") <= 0 && url.indexOf(".") > 0) {
|
|
||||||
url = "http://" + url;
|
if (url.indexOf(".") > 0) {
|
||||||
|
if (url.indexOf("http") < 0) {
|
||||||
|
url = "http://" + url;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
url = searchEngine.searchUrl(url)
|
url = searchEngine.searchUrl(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addressBar.model = []
|
||||||
webEngineView.url = url
|
webEngineView.url = url
|
||||||
suggestionRequestTimer.stop()
|
suggestionRequestTimer.stop()
|
||||||
addressBar.popup.close()
|
addressBar.popup.close()
|
||||||
|
@ -151,12 +156,12 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onDeletePressed: {
|
Keys.onDeletePressed: {
|
||||||
editText = ""
|
addressBarInput.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if (event.key === Qt.Key_Return) {
|
if (event.key === Qt.Key_Return) {
|
||||||
goTo(editText)
|
goTo(addressBarInput.text)
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,19 +197,24 @@ Rectangle {
|
||||||
|
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if (event.key === Qt.Key_Return) {
|
if (event.key === Qt.Key_Return) {
|
||||||
goTo(editText)
|
goTo(addressBarInput.text)
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditTextChanged: {
|
onEditTextChanged: {
|
||||||
console.log("edit text", addressBar.editText)
|
if (addressBar.editText !== "" && addressBar.editText !== webEngineView.url.toString()) {
|
||||||
suggestionRequestTimer.restart()
|
suggestionRequestTimer.restart();
|
||||||
|
} else {
|
||||||
|
addressBar.model = []
|
||||||
|
addressBar.popup.close()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
editText: webEngineView.url
|
editText: webEngineView.url
|
||||||
onAccepted: goTo(editText)
|
onAccepted: goTo(addressBarInput.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
HifiControls.WebGlyphButton {
|
HifiControls.WebGlyphButton {
|
||||||
|
@ -265,6 +275,11 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLinkHovered: {
|
||||||
|
//TODO: change cursor shape?
|
||||||
|
console.error("hoveredUrl:", hoveredUrl)
|
||||||
|
}
|
||||||
|
|
||||||
// creates a global EventBridge object.
|
// creates a global EventBridge object.
|
||||||
WebEngineScript {
|
WebEngineScript {
|
||||||
id: createGlobalEventBridge
|
id: createGlobalEventBridge
|
||||||
|
|
Loading…
Reference in a new issue