mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:03:41 +02:00
Merge branch 'browser' into infoview
Conflicts: tests/ui/src/main.cpp
This commit is contained in:
commit
0fb8884f9c
3 changed files with 169 additions and 44 deletions
|
@ -2,29 +2,149 @@ 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
|
||||||
|
backgroundColor: "#7f000000"
|
||||||
|
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
enabled = true
|
||||||
|
addressBar.text = webview.url
|
||||||
|
}
|
||||||
|
|
||||||
|
onParentChanged: {
|
||||||
|
if (visible && enabled) {
|
||||||
|
addressBar.forceActiveFocus();
|
||||||
|
addressBar.selectAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: clientArea
|
id: clientArea
|
||||||
// The client area
|
implicitHeight: 600
|
||||||
anchors.fill: parent
|
implicitWidth: 800
|
||||||
anchors.margins: parent.margins
|
x: root.clientX
|
||||||
anchors.topMargin: parent.topMargin
|
y: root.clientY
|
||||||
|
width: root.clientWidth
|
||||||
|
height: root.clientHeight
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: scrollView.top
|
||||||
|
color: "white"
|
||||||
|
}
|
||||||
|
Row {
|
||||||
|
id: buttons
|
||||||
|
spacing: 4
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 8
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 8
|
||||||
|
FontAwesome {
|
||||||
|
id: back; text: "\uf0a8"; size: 48; enabled: webview.canGoBack;
|
||||||
|
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||||
|
MouseArea { anchors.fill: parent; onClicked: webview.goBack() }
|
||||||
|
}
|
||||||
|
FontAwesome {
|
||||||
|
id: forward; text: "\uf0a9"; size: 48; enabled: webview.canGoForward;
|
||||||
|
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||||
|
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 {
|
||||||
|
height: 48
|
||||||
|
radius: 8
|
||||||
|
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
|
||||||
|
|
||||||
|
Keys.onPressed: {
|
||||||
|
switch(event.key) {
|
||||||
|
case Qt.Key_Enter:
|
||||||
|
case Qt.Key_Return:
|
||||||
|
event.accepted = true
|
||||||
|
if (text.indexOf("http") != 0) {
|
||||||
|
text = "http://" + text
|
||||||
|
}
|
||||||
|
webview.url = text
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ScrollView {
|
ScrollView {
|
||||||
anchors.fill: parent
|
id: scrollView
|
||||||
|
anchors.top: buttons.bottom
|
||||||
|
anchors.topMargin: 8
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
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
|
||||||
|
|
||||||
|
Keys.onPressed: {
|
||||||
|
switch(event.key) {
|
||||||
|
case Qt.Key_L:
|
||||||
|
if (event.modifiers == Qt.ControlModifier) {
|
||||||
|
event.accepted = true
|
||||||
|
addressBar.selectAll()
|
||||||
|
addressBar.forceActiveFocus()
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // dialog
|
||||||
}
|
|
||||||
|
|
|
@ -1095,6 +1095,13 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::AddressBar);
|
Menu::getInstance()->triggerOption(MenuOption::AddressBar);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Qt::Key_B:
|
||||||
|
if (isMeta) {
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
offscreenUi->load("Browser.qml");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case Qt::Key_L:
|
case Qt::Key_L:
|
||||||
if (isShifted && isMeta) {
|
if (isShifted && isMeta) {
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Log);
|
Menu::getInstance()->triggerOption(MenuOption::Log);
|
||||||
|
|
|
@ -414,6 +414,12 @@ protected:
|
||||||
void keyPressEvent(QKeyEvent* event) {
|
void keyPressEvent(QKeyEvent* event) {
|
||||||
_altPressed = Qt::Key_Alt == event->key();
|
_altPressed = Qt::Key_Alt == event->key();
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
|
case Qt::Key_B:
|
||||||
|
if (event->modifiers() & Qt::CTRL) {
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
offscreenUi->load("Browser.qml");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Qt::Key_L:
|
case Qt::Key_L:
|
||||||
if (event->modifiers() & Qt::CTRL) {
|
if (event->modifiers() & Qt::CTRL) {
|
||||||
InfoView::show(getResourcesDir() + "html/interface-welcome.html", true);
|
InfoView::show(getResourcesDir() + "html/interface-welcome.html", true);
|
||||||
|
@ -485,14 +491,6 @@ hifi.offscreen.focus.debug=false
|
||||||
qt.quick.mouse.debug=false
|
qt.quick.mouse.debug=false
|
||||||
)V0G0N";
|
)V0G0N";
|
||||||
|
|
||||||
//int main(int argc, char *argv[]) {
|
|
||||||
// QGuiApplication app(argc, argv);
|
|
||||||
// QQmlApplicationEngine engine;
|
|
||||||
// engine.setBaseUrl(QUrl::fromLocalFile(getQmlDir()));
|
|
||||||
// engine.load(QUrl("Main.qml"));
|
|
||||||
// return app.exec();
|
|
||||||
//}
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
|
||||||
|
|
Loading…
Reference in a new issue