Browser work

This commit is contained in:
Brad Davis 2015-04-27 22:39:48 -07:00
parent 19ca543c2c
commit 4bb5e562ea
6 changed files with 122 additions and 20 deletions

View file

@ -2,29 +2,121 @@ import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtWebKit 3.0 import QtWebKit 3.0
import "controls" import "controls"
import "styles"
Dialog { Dialog {
title: "Browser Window" id: root
id: testDialog HifiConstants { id: hifi }
objectName: "Browser" title: "Browser"
width: 1280 resizable: true
height: 720 contentImplicitWidth: clientArea.implicitWidth
contentImplicitHeight: clientArea.implicitHeight
Component.onCompleted: {
enabled = true
addressBar.text = webview.url
}
onParentChanged: {
if (visible && enabled) {
forceActiveFocus();
}
}
Item { Item {
id: clientArea id: clientArea
// The client area implicitHeight: 400
anchors.fill: parent implicitWidth: 600
anchors.margins: parent.margins x: root.clientX
anchors.topMargin: parent.topMargin y: root.clientY
width: root.clientWidth
height: root.clientHeight
Row {
id: buttons
spacing: 4
anchors.top: parent.top
anchors.topMargin: 8
anchors.left: parent.left
anchors.leftMargin: 8
FontAwesome {
id: back; size: 48; enabled: webview.canGoBack; text: "\uf0a8"
MouseArea { anchors.fill: parent; onClicked: webview.goBack() }
}
FontAwesome {
id: forward; size: 48; enabled: webview.canGoForward; text: "\uf0a9"
MouseArea { anchors.fill: parent; onClicked: webview.goBack() }
}
FontAwesome {
id: reload; size: 48; text: webview.loading ? "\uf057" : "\uf021"
MouseArea { anchors.fill: parent; onClicked: webview.loading ? webview.stop() : webview.reload() }
}
}
Border {
id: border1
height: 48
radius: 8
color: "gray"
anchors.top: parent.top
anchors.topMargin: 8
anchors.right: parent.right
anchors.rightMargin: 8
anchors.left: buttons.right
anchors.leftMargin: 8
Item {
id: barIcon
width: parent.height
height: parent.height
Image {
source: webview.icon;
x: (parent.height - height) / 2
y: (parent.width - width) / 2
verticalAlignment: Image.AlignVCenter;
horizontalAlignment: Image.AlignHCenter
onSourceChanged: console.log("Icon url: " + source)
}
}
TextInput {
id: addressBar
anchors.right: parent.right
anchors.rightMargin: 8
anchors.left: barIcon.right
anchors.leftMargin: 0
anchors.verticalCenter: parent.verticalCenter
onAccepted: {
if (text.indexOf("http") != 0) {
text = "http://" + text;
}
webview.url = text
}
}
}
ScrollView { ScrollView {
anchors.fill: parent anchors.top: buttons.bottom
anchors.topMargin: 8
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
Rectangle { anchors.fill: parent; color: "#7500ff00" }
WebView { WebView {
id: webview id: webview
url: "http://slashdot.org" url: "http://highfidelity.com"
anchors.fill: parent anchors.fill: parent
onLoadingChanged: {
if (loadRequest.status == WebView.LoadSucceededStarted) {
addressBar.text = loadRequest.url
} }
} }
onIconChanged: {
barIcon.source = icon
} }
} }
}
} // item
} // dialog

View file

@ -92,6 +92,7 @@ DialogBase {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
width: 16 width: 16
height: 16 height: 16
z: 1000
hoverEnabled: true hoverEnabled: true
onPressed: { onPressed: {
startX = mouseX startX = mouseX

View file

@ -44,10 +44,18 @@ Item {
anchors.left: parent.left anchors.left: parent.left
border.color: root.frameColor border.color: root.frameColor
clip: true clip: true
radius: 10
color: root.active ? color: root.active ?
hifi.colors.activeWindow.headerBackground : hifi.colors.activeWindow.headerBackground :
hifi.colors.inactiveWindow.headerBackground hifi.colors.inactiveWindow.headerBackground
Rectangle {
y: titleBorder.height / 2
width: titleBorder.width
height: titleBorder.height /2
color: titleBorder.color
}
Text { Text {
id: titleText id: titleText
color: root.active ? color: root.active ?
@ -69,7 +77,6 @@ Item {
anchors.topMargin: -titleBorder.border.width anchors.topMargin: -titleBorder.border.width
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
clip: true
} // client border } // client border
} // window border } // window border

View file

@ -13,14 +13,14 @@ Original.TextInput {
font.family: hifi.fonts.fontFamily font.family: hifi.fonts.fontFamily
font.pointSize: hifi.fonts.fontSize font.pointSize: hifi.fonts.fontSize
/*
Original.Rectangle { Original.Rectangle {
// Render the rectangle as background // Render the rectangle as background
z: -1 z: -1
anchors.fill: parent anchors.fill: parent
color: hifi.colors.inputBackground color: hifi.colors.inputBackground
} }
*/
Text { Text {
anchors.fill: parent anchors.fill: parent
font.pointSize: parent.font.pointSize font.pointSize: parent.font.pointSize

View file

@ -50,7 +50,7 @@ Item {
QtObject { QtObject {
id: styles id: styles
readonly property int borderWidth: 5 readonly property int borderWidth: 0
readonly property int borderRadius: borderWidth * 2 readonly property int borderRadius: borderWidth * 2
} }

View file

@ -406,6 +406,8 @@ protected:
switch (event->key()) { switch (event->key()) {
case Qt::Key_L: case Qt::Key_L:
if (event->modifiers() & Qt::CTRL) { if (event->modifiers() & Qt::CTRL) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->load("Browser.qml");
} }
break; break;
case Qt::Key_K: case Qt::Key_K: