mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 18:13:29 +02:00
commit
83d9d4d4be
5 changed files with 59 additions and 41 deletions
|
@ -3,8 +3,7 @@ import QtWebEngine 1.1
|
|||
|
||||
WebEngineView {
|
||||
id: root
|
||||
property var originalUrl
|
||||
property int lastFixupTime: 0
|
||||
property var newUrl;
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("Connecting JS messaging to Hifi Logging")
|
||||
|
@ -14,19 +13,26 @@ WebEngineView {
|
|||
});
|
||||
}
|
||||
|
||||
// FIXME hack to get the URL with the auth token included. Remove when we move to Qt 5.6
|
||||
Timer {
|
||||
id: urlReplacementTimer
|
||||
running: false
|
||||
repeat: false
|
||||
interval: 50
|
||||
onTriggered: url = newUrl;
|
||||
}
|
||||
|
||||
onUrlChanged: {
|
||||
var currentUrl = url.toString();
|
||||
var newUrl = urlHandler.fixupUrl(currentUrl).toString();
|
||||
if (newUrl != currentUrl) {
|
||||
var now = new Date().valueOf();
|
||||
if (url === originalUrl && (now - lastFixupTime < 100)) {
|
||||
console.warn("URL fixup loop detected")
|
||||
console.log("Url changed to " + url);
|
||||
var originalUrl = url.toString();
|
||||
newUrl = urlHandler.fixupUrl(originalUrl).toString();
|
||||
if (newUrl !== originalUrl) {
|
||||
root.stop();
|
||||
if (urlReplacementTimer.running) {
|
||||
console.warn("Replacement timer already running");
|
||||
return;
|
||||
}
|
||||
originalUrl = url
|
||||
lastFixupTime = now
|
||||
url = newUrl;
|
||||
urlReplacementTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,7 @@ import "../controls"
|
|||
|
||||
Frame {
|
||||
id: frame
|
||||
// The frame fills the parent, which should be the size of the content.
|
||||
// The frame decorations use negative anchor margins to extend beyond
|
||||
anchors.fill: parent
|
||||
|
||||
// FIXME needed?
|
||||
Rectangle {
|
||||
anchors { margins: -iconSize; topMargin: -iconSize * ((window && window.closable) ? 2 : 1); }
|
||||
anchors.fill: parent;
|
||||
|
@ -18,8 +14,6 @@ Frame {
|
|||
|
||||
// Allow dragging of the window
|
||||
MouseArea {
|
||||
id: dragMouseArea
|
||||
hoverEnabled: true
|
||||
anchors.fill: parent
|
||||
drag.target: window
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ import "../js/Utils.js" as Utils
|
|||
|
||||
Item {
|
||||
id: frame
|
||||
// Frames always fill their parents, but their decorations may extend
|
||||
// beyond the window via negative margin sizes
|
||||
anchors.fill: parent
|
||||
|
||||
// Convenience accessor for the window
|
||||
property alias window: frame.parent
|
||||
|
|
|
@ -5,10 +5,6 @@ import "../controls"
|
|||
|
||||
Frame {
|
||||
id: frame
|
||||
// The frame fills the parent, which should be the size of the content.
|
||||
// The frame decorations use negative anchor margins to extend beyond
|
||||
anchors.fill: parent
|
||||
property alias window: frame.parent
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
@ -16,15 +12,6 @@ Frame {
|
|||
visible: window.visible
|
||||
color: "#7f7f7f7f";
|
||||
radius: 3;
|
||||
MouseArea {
|
||||
enabled: window.visible
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.AllButtons
|
||||
onClicked: {}
|
||||
onDoubleClicked: {}
|
||||
onPressAndHold: {}
|
||||
onReleased: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,11 @@ Fadable {
|
|||
implicitHeight: content.height
|
||||
implicitWidth: content.width
|
||||
x: -1; y: -1
|
||||
enabled: visible
|
||||
|
||||
signal windowDestroyed();
|
||||
|
||||
property int modality: Qt.NonModal
|
||||
|
||||
readonly property bool topLevelWindow: true
|
||||
property string title
|
||||
// Should the window be closable control?
|
||||
|
@ -37,7 +39,6 @@ Fadable {
|
|||
property bool resizable: false
|
||||
property vector2d minSize: Qt.vector2d(100, 100)
|
||||
property vector2d maxSize: Qt.vector2d(1280, 720)
|
||||
enabled: visible
|
||||
|
||||
// The content to place inside the window, determined by the client
|
||||
default property var content
|
||||
|
@ -53,27 +54,39 @@ Fadable {
|
|||
propagateComposedEvents: true
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.AllButtons
|
||||
enabled: window.visible
|
||||
onPressed: {
|
||||
//console.log("Pressed on activator area");
|
||||
window.raise();
|
||||
mouse.accepted = false;
|
||||
}
|
||||
// Debugging
|
||||
// onEntered: console.log("activator entered")
|
||||
// onExited: console.log("activator exited")
|
||||
// onContainsMouseChanged: console.log("Activator contains mouse " + containsMouse)
|
||||
// onPositionChanged: console.log("Activator mouse position " + mouse.x + " x " + mouse.y)
|
||||
// Rectangle { anchors.fill:parent; color: "#7f00ff00" }
|
||||
}
|
||||
|
||||
signal windowDestroyed();
|
||||
// This mouse area serves to swallow mouse events while the mouse is over the window
|
||||
// to prevent things like mouse wheel events from reaching the application and changing
|
||||
// the camera if the user is scrolling through a list and gets to the end.
|
||||
property var swallower: MouseArea {
|
||||
width: frame.decoration.width
|
||||
height: frame.decoration.height
|
||||
x: frame.decoration.anchors.margins
|
||||
y: frame.decoration.anchors.topMargin
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.AllButtons
|
||||
enabled: window.visible
|
||||
onClicked: {}
|
||||
onDoubleClicked: {}
|
||||
onPressAndHold: {}
|
||||
onReleased: {}
|
||||
onWheel: {}
|
||||
}
|
||||
|
||||
|
||||
// Default to a standard frame. Can be overriden to provide custom
|
||||
// frame styles, like a full desktop frame to simulate a modal window
|
||||
property var frame: DefaultFrame { }
|
||||
|
||||
|
||||
children: [ frame, content, activator ]
|
||||
children: [ swallower, frame, content, activator ]
|
||||
|
||||
Component.onCompleted: raise();
|
||||
Component.onDestruction: windowDestroyed();
|
||||
|
@ -124,12 +137,27 @@ Fadable {
|
|||
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_Control:
|
||||
case Qt.Key_Shift:
|
||||
case Qt.Key_Meta:
|
||||
case Qt.Key_Alt:
|
||||
break;
|
||||
|
||||
|
||||
case Qt.Key_W:
|
||||
if (window.closable && (event.modifiers === Qt.ControlModifier)) {
|
||||
visible = false
|
||||
event.accepted = true
|
||||
}
|
||||
break
|
||||
// fall through
|
||||
|
||||
default:
|
||||
// Consume unmodified keyboard entries while the window is focused, to prevent them
|
||||
// from propagating to the application
|
||||
if (event.modifiers === Qt.NoModifier) {
|
||||
event.accepted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue