return tabView.get(tabView.currentIndex) ? tabView.get(tabView.currentIndex).item.webView : null
}
+ property string googleSearchQuery: "https://www.google.com/search?sourceid=qtbrowser&ie=UTF-8&q="
+
property int toolBarSize: 80
property string uiColor: settingsView.privateBrowsingEnabled ? "#26282a" : "#46a2da"
property string uiSeparatorColor: settingsView.privateBrowsingEnabled ? "#717273" : "#7ebee5"
if (!tab)
return
- navigation.addressBar.forceActiveFocus();
navigation.addressBar.selectAll();
tabView.makeCurrent(tabView.count - 1)
navigation.addressBar.forceActiveFocus()
onDoneClicked: {
settingsView.state = "disabled"
- tabView.interactive = true
}
}
PageView {
id: tabView
- interactive: !sslDialog.visible && homeScreen.state == "disabled"
-
+ interactive: {
+ if (sslDialog.visible || homeScreen.state != "disabled" || urlDropDown.state == "enabled" || settingsView.state == "enabled")
+ return false
+ return true
+ }
height: parent.height
anchors {
}
}
+ Rectangle {
+ id: urlDropDown
+ color: "white"
+ visible: navigation.visible
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: navigation.bottom
+ }
+
+ state: "disabled"
+
+ states: [
+ State {
+ name: "enabled"
+ PropertyChanges {
+ target: homeScreen
+ state: "disabled"
+ }
+ PropertyChanges {
+ target: urlDropDown
+ height: Math.min(3 * toolBarSize, historyList.childrenRect.height)
+ }
+ },
+ State {
+ name: "disabled"
+ PropertyChanges {
+ target: urlDropDown
+ height: 0
+ }
+ }
+ ]
+
+ ListView {
+ id: historyList
+ model: navigation.webView.navigationHistory.items
+ clip: true
+ visible: urlDropDown.state == "enabled"
+ footerPositioning: ListView.OverlayFooter
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ }
+ height: Math.min(childrenRect.height, parent.height)
+ delegate: Rectangle {
+ id: wrapper
+ width: historyList.width
+ height: toolBarSize
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (!url)
+ return
+ navigation.addressBar.text = url
+ navigation.addressBar.accepted()
+ }
+ }
+
+ Column {
+ width: parent.width - 60
+ height: parent.height
+ anchors {
+ verticalCenter: parent.verticalCenter
+ horizontalCenter: parent.horizontalCenter
+ }
+ Text {
+ height: wrapper.height / 2
+ width: parent.width
+ elide: Text.ElideRight
+ verticalAlignment: Text.AlignBottom
+ anchors{
+ leftMargin: 30
+ rightMargin: 30
+ }
+ id: titleLabel
+ font.family: defaultFontFamily
+ font.pixelSize: 23
+ color: "black"
+ text: title ? title : ""
+ }
+ Text {
+ height: wrapper.height / 2 - 1
+ width: parent.width
+ elide: Text.ElideRight
+ verticalAlignment: Text.AlignTop
+ font.family: defaultFontFamily
+ font.pixelSize: 23
+ color: uiColor
+ text: url ? url : ""
+ }
+ Rectangle {
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: historyList.width
+ height: 1
+ color: iconStrokeColor
+ }
+ }
+ }
+ footer: Rectangle {
+ z: 5
+ width: historyList.width
+ height: toolBarSize
+ border.color: iconStrokeColor
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ var string = searchText.text
+ var constructedUrl = ""
+ if (engine.isUrl(string)) {
+ constructedUrl = engine.fromUserInput(string)
+ } else {
+ constructedUrl = engine.fromUserInput(googleSearchQuery + string)
+ }
+ navigation.addressBar.text = constructedUrl
+ navigation.addressBar.accepted()
+ }
+ }
+ Row {
+ height: parent.height
+ Rectangle {
+ id: searchIcon
+ height: parent.height
+ width: height
+ color: "transparent"
+ Image {
+ anchors.centerIn: parent
+ source: "qrc:///search"
+ }
+ }
+ Text {
+ id: searchText
+ height: parent.height
+ width: historyList.width - searchIcon.width - 30
+ elide: Text.ElideRight
+ text: navigation.addressBar.text
+ verticalAlignment: Text.AlignVCenter
+ font.family: defaultFontFamily
+ font.pixelSize: 23
+ color: "black"
+ }
+ }
+ }
+ }
+
+
+ transitions: Transition {
+ PropertyAnimation { property: "height"; duration: animationDuration; easing.type : Easing.InSine }
+ }
+ }
+
HomeScreen {
id: homeScreen
height: parent.height - toolBarSize
placeholderText: qsTr("Search or type a URL")
onActiveFocusChanged: {
- if (activeFocus)
+ if (activeFocus) {
+ urlBar.selectAll()
root.state = "enabled"
- else
+ urlDropDown.state = "enabled"
+ } else {
+ urlDropDown.state = "disabled"
root.state = "tracking"
+ }
}
UIButton {
id: reloadButton
- source: webView && webView.loading ? "qrc:///stop" : "qrc:///refresh"
+ state: cancelButton.visible ? "edit" : "load"
+ states: [
+ State {
+ name: "load"
+ PropertyChanges {
+ target: reloadButton
+ source: webView && webView.loading ? "qrc:///stop" : "qrc:///refresh"
+ height: 54
+ }
+ },
+ State {
+ name: "edit"
+ PropertyChanges {
+ target: reloadButton
+ source: "qrc:///stop"
+ height: 45
+ visible: urlBar.text != ""
+ }
+ }
+ ]
height: 54
width: height
color: "transparent"
right: parent.right
verticalCenter: addressBar.verticalCenter;
}
- onClicked: { webView.loading ? webView.stop() : webView.reload() }
+ onClicked: {
+ if (state == "load") {
+ webView.loading ? webView.stop() : webView.reload()
+ return
+ }
+ urlBar.selectAll()
+ urlBar.remove(urlBar.selectionStart, urlBar.selectionEnd)
+ }
}
style: TextFieldStyle {
textColor: "black"
}
onTextChanged: refresh()
- onEditingFinished: selectAll()
- onFocusChanged: {
- if (focus) {
- forceActiveFocus()
- selectAll()
- } else {
- urlBar.cursorPosition = 0
- deselect()
- }
+ onEditingFinished: {
+ selectAll()
+ webView.forceActiveFocus()
}
}
Rectangle {
+ visible: !cancelButton.visible
Layout.fillWidth: true
implicitWidth: 10
anchors {
}
color: uiColor
}
+
+ UIButton {
+ id: cancelButton
+ color: uiColor
+ visible: urlDropDown.state === "enabled"
+ highlightColor: buttonPressedColor
+ Text {
+ color: "white"
+ anchors.centerIn: parent
+ text: "Cancel"
+ font.family: defaultFontFamily
+ font.pixelSize: 28
+ }
+ implicitWidth: 120
+ onClicked: {
+ urlDropDown.state = "disabled"
+ webView.forceActiveFocus()
+ }
+ }
Rectangle {
width: 1
anchors {
color: uiColor
highlightColor: buttonPressedColor
onClicked: {
- tabView.interactive = false
settingsView.state = "enabled"
}
}