mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:56:43 +02:00
Merge pull request #6812 from jherico/running_scripts
Running scripts in QML
This commit is contained in:
commit
cd167e43fb
16 changed files with 587 additions and 858 deletions
|
@ -1,18 +1,17 @@
|
||||||
import QtQuick 2.3
|
import QtQuick 2.3
|
||||||
import QtQuick.Controls 1.2
|
import QtQuick.Controls 1.2
|
||||||
import QtWebEngine 1.1
|
import QtWebEngine 1.1
|
||||||
|
|
||||||
import "controls"
|
import "controls"
|
||||||
import "styles"
|
import "styles"
|
||||||
|
import "windows"
|
||||||
|
|
||||||
VrDialog {
|
Window {
|
||||||
id: root
|
id: root
|
||||||
HifiConstants { id: hifi }
|
HifiConstants { id: hifi }
|
||||||
title: "Browser"
|
title: "Browser"
|
||||||
resizable: true
|
resizable: true
|
||||||
contentImplicitWidth: clientArea.implicitWidth
|
destroyOnInvisible: true
|
||||||
contentImplicitHeight: clientArea.implicitHeight
|
|
||||||
backgroundColor: "#7f000000"
|
|
||||||
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
enabled = true
|
enabled = true
|
||||||
|
@ -27,13 +26,8 @@ VrDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: clientArea
|
width: 800
|
||||||
implicitHeight: 600
|
height: 600
|
||||||
implicitWidth: 800
|
|
||||||
x: root.clientX
|
|
||||||
y: root.clientY
|
|
||||||
width: root.clientWidth
|
|
||||||
height: root.clientHeight
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
|
|
@ -40,7 +40,8 @@ function getTopLevelWindows(item) {
|
||||||
|
|
||||||
for (var i = 0; i < desktop.children.length; ++i) {
|
for (var i = 0; i < desktop.children.length; ++i) {
|
||||||
var child = desktop.children[i];
|
var child = desktop.children[i];
|
||||||
if (Global.OFFSCREEN_WINDOW_OBJECT_NAME === child.objectName) {
|
if ((Global.OFFSCREEN_WINDOW_OBJECT_NAME === child.objectName) ||
|
||||||
|
child[Global.OFFSCREEN_WINDOW_OBJECT_NAME]) {
|
||||||
var windowId = child.toString();
|
var windowId = child.toString();
|
||||||
currentWindows.push(child)
|
currentWindows.push(child)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import Hifi 1.0
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
|
|
||||||
import "Global.js" as Global
|
import "Global.js" as Global
|
||||||
|
|
||||||
// This is our primary 'window' object to which all dialogs and controls will
|
// This is our primary 'desktop' object to which all VR dialogs and
|
||||||
// be childed.
|
// windows will be childed.
|
||||||
Root {
|
Item {
|
||||||
id: root
|
id: desktop
|
||||||
objectName: Global.OFFSCREEN_ROOT_OBJECT_NAME
|
objectName: Global.OFFSCREEN_ROOT_OBJECT_NAME
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
property var windows: [];
|
property var windows: [];
|
||||||
|
@ -16,11 +15,14 @@ Root {
|
||||||
}
|
}
|
||||||
|
|
||||||
onChildrenChanged: {
|
onChildrenChanged: {
|
||||||
windows = Global.getTopLevelWindows(root);
|
windows = Global.getTopLevelWindows(desktop);
|
||||||
}
|
}
|
||||||
|
|
||||||
onParentChanged: {
|
onParentChanged: {
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
function raise(item) {
|
||||||
|
Global.raiseWindow(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
237
interface/resources/qml/dialogs/RunningScripts.qml
Normal file
237
interface/resources/qml/dialogs/RunningScripts.qml
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Dialogs 1.2 as OriginalDialogs
|
||||||
|
import Qt.labs.settings 1.0
|
||||||
|
|
||||||
|
import "../styles" as Hifi
|
||||||
|
import "../controls" as HifiControls
|
||||||
|
import "../windows"
|
||||||
|
|
||||||
|
Window {
|
||||||
|
id: root
|
||||||
|
objectName: "RunningScripts"
|
||||||
|
title: "Running Scripts"
|
||||||
|
resizable: true
|
||||||
|
destroyOnInvisible: true
|
||||||
|
enabled: false
|
||||||
|
x: 40; y: 40
|
||||||
|
|
||||||
|
property var scripts: ScriptDiscoveryService;
|
||||||
|
property var scriptsModel: scripts.scriptsModelFilter
|
||||||
|
property var runningScriptsModel: ListModel { }
|
||||||
|
|
||||||
|
Settings {
|
||||||
|
category: "Overlay.RunningScripts"
|
||||||
|
property alias x: root.x
|
||||||
|
property alias y: root.y
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: ScriptDiscoveryService
|
||||||
|
onScriptCountChanged: updateRunningScripts();
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: updateRunningScripts()
|
||||||
|
|
||||||
|
function updateRunningScripts() {
|
||||||
|
var runningScripts = ScriptDiscoveryService.getRunning();
|
||||||
|
runningScriptsModel.clear()
|
||||||
|
for (var i = 0; i < runningScripts.length; ++i) {
|
||||||
|
runningScriptsModel.append(runningScripts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadScript(script) {
|
||||||
|
console.log("Load script " + script);
|
||||||
|
scripts.loadOneScript(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadScript(script) {
|
||||||
|
console.log("Reload script " + script);
|
||||||
|
scripts.stopScript(script, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopScript(script) {
|
||||||
|
console.log("Stop script " + script);
|
||||||
|
scripts.stopScript(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reloadAll() {
|
||||||
|
console.log("Reload all scripts");
|
||||||
|
scripts.reloadAllScripts();
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopAll() {
|
||||||
|
console.log("Stop all scripts");
|
||||||
|
scripts.stopAllScripts();
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: "white"
|
||||||
|
implicitWidth: 384; implicitHeight: 640
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors { fill: parent; margins: 8 }
|
||||||
|
Text {
|
||||||
|
id: title
|
||||||
|
font.bold: true
|
||||||
|
font.pointSize: 16
|
||||||
|
color: "#0e7077"
|
||||||
|
text: "Currently Running"
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: allButtons
|
||||||
|
anchors.top: title.bottom
|
||||||
|
anchors.topMargin: 8
|
||||||
|
spacing: 8
|
||||||
|
Button { text: "Reload all"; onClicked: reloadAll() }
|
||||||
|
Button { text: "Stop all"; onClicked: stopAll() }
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
clip: true
|
||||||
|
anchors {
|
||||||
|
top: allButtons.bottom;
|
||||||
|
left: parent.left;
|
||||||
|
right: parent.right;
|
||||||
|
topMargin: 8
|
||||||
|
bottom: row1.top
|
||||||
|
bottomMargin: 8
|
||||||
|
}
|
||||||
|
|
||||||
|
model: runningScriptsModel
|
||||||
|
|
||||||
|
delegate: Rectangle {
|
||||||
|
radius: 3
|
||||||
|
anchors { left: parent.left; right: parent.right }
|
||||||
|
|
||||||
|
height: scriptName.height + 12
|
||||||
|
color: index % 2 ? "#ddd" : "#eee"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors { left: parent.left; leftMargin: 4; verticalCenter: parent.verticalCenter }
|
||||||
|
id: scriptName
|
||||||
|
text: name
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: 4
|
||||||
|
spacing: 4
|
||||||
|
HifiControls.FontAwesome {
|
||||||
|
text: "\uf021"; size: scriptName.height;
|
||||||
|
MouseArea {
|
||||||
|
anchors { fill: parent; margins: -2; }
|
||||||
|
onClicked: reloadScript(model.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HifiControls.FontAwesome {
|
||||||
|
size: scriptName.height; text: "\uf00d"
|
||||||
|
MouseArea {
|
||||||
|
anchors { fill: parent; margins: -2; }
|
||||||
|
onClicked: stopScript(model.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: loadLabel
|
||||||
|
text: "Load Scripts"
|
||||||
|
font.bold: true
|
||||||
|
font.pointSize: 16
|
||||||
|
color: "#0e7077"
|
||||||
|
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 0
|
||||||
|
anchors.bottom: filterEdit.top
|
||||||
|
anchors.bottomMargin: 8
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: row1
|
||||||
|
spacing: 8
|
||||||
|
anchors.bottom: filterEdit.top
|
||||||
|
anchors.bottomMargin: 8
|
||||||
|
anchors.right: parent.right
|
||||||
|
Button {
|
||||||
|
text: "from URL";
|
||||||
|
onClicked: ApplicationInterface.loadScriptURLDialog();
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
text: "from Disk"
|
||||||
|
onClicked: ApplicationInterface.loadDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: filterEdit
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: treeView.top
|
||||||
|
anchors.bottomMargin: 8
|
||||||
|
placeholderText: "filter"
|
||||||
|
onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$")
|
||||||
|
}
|
||||||
|
|
||||||
|
TreeView {
|
||||||
|
id: treeView
|
||||||
|
height: 128
|
||||||
|
anchors.bottom: loadButton.top
|
||||||
|
anchors.bottomMargin: 8
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
headerVisible: false
|
||||||
|
focus: true
|
||||||
|
// FIXME doesn't work?
|
||||||
|
onDoubleClicked: isExpanded(index) ? collapse(index) : expand(index)
|
||||||
|
// FIXME not triggered by double click?
|
||||||
|
onActivated: {
|
||||||
|
var path = scriptsModel.data(index, 0x100)
|
||||||
|
if (path) {
|
||||||
|
loadScript(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model: scriptsModel
|
||||||
|
TableViewColumn { title: "Name"; role: "display"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: selectedScript
|
||||||
|
enabled: true
|
||||||
|
readOnly: true
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: loadButton.left
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
anchors.bottom: loadButton.bottom
|
||||||
|
anchors.top: loadButton.top
|
||||||
|
Connections {
|
||||||
|
target: treeView
|
||||||
|
onCurrentIndexChanged: {
|
||||||
|
var path = scriptsModel.data(treeView.currentIndex, 0x100)
|
||||||
|
if (path) {
|
||||||
|
selectedScript.text = path
|
||||||
|
} else {
|
||||||
|
selectedScript.text = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: loadButton
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
|
text: "Load"
|
||||||
|
enabled: selectedScript.text != ""
|
||||||
|
onClicked: root.loadScript(selectedScript.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
93
interface/resources/qml/windows/DefaultFrame.qml
Normal file
93
interface/resources/qml/windows/DefaultFrame.qml
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
|
||||||
|
import "."
|
||||||
|
import "../controls"
|
||||||
|
|
||||||
|
Frame {
|
||||||
|
id: root
|
||||||
|
anchors { margins: -16; topMargin: parent.closable ? -32 : -16; }
|
||||||
|
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: controlsArea
|
||||||
|
anchors.fill: desktopControls
|
||||||
|
hoverEnabled: true
|
||||||
|
drag.target: root.parent
|
||||||
|
propagateComposedEvents: true
|
||||||
|
onClicked: {
|
||||||
|
root.raise()
|
||||||
|
mouse.accepted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: sizeDrag
|
||||||
|
enabled: root.parent.resizable
|
||||||
|
property int startX
|
||||||
|
property int startY
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
width: 16
|
||||||
|
height: 16
|
||||||
|
z: 1000
|
||||||
|
hoverEnabled: true
|
||||||
|
onPressed: {
|
||||||
|
startX = mouseX
|
||||||
|
startY = mouseY
|
||||||
|
}
|
||||||
|
onPositionChanged: {
|
||||||
|
if (pressed) {
|
||||||
|
root.deltaSize((mouseX - startX), (mouseY - startY))
|
||||||
|
startX = mouseX
|
||||||
|
startY = mouseY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: desktopControls
|
||||||
|
// FIXME this doesn't work as expected
|
||||||
|
visible: root.parent.showFrame
|
||||||
|
anchors.fill: parent;
|
||||||
|
color: "#7f7f7f7f";
|
||||||
|
radius: 3;
|
||||||
|
|
||||||
|
|
||||||
|
Row {
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.rightMargin: 4
|
||||||
|
anchors.topMargin: 4
|
||||||
|
spacing: 4
|
||||||
|
FontAwesome {
|
||||||
|
visible: false
|
||||||
|
text: "\uf08d"
|
||||||
|
style: Text.Outline; styleColor: "white"
|
||||||
|
size: 16
|
||||||
|
rotation: !root.parent ? 90 : root.parent.pinned ? 0 : 90
|
||||||
|
color: root.pinned ? "red" : "black"
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
propagateComposedEvents: true
|
||||||
|
onClicked: { root.pin(); mouse.accepted = false; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FontAwesome {
|
||||||
|
visible: root.parent.closable
|
||||||
|
text: closeClickArea.containsMouse ? "\uf057" : "\uf05c"
|
||||||
|
style: Text.Outline;
|
||||||
|
styleColor: "white"
|
||||||
|
color: closeClickArea.containsMouse ? "red" : "black"
|
||||||
|
size: 16
|
||||||
|
MouseArea {
|
||||||
|
id: closeClickArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onClicked: root.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
8
interface/resources/qml/windows/Frame.qml
Normal file
8
interface/resources/qml/windows/Frame.qml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
|
||||||
|
Item {
|
||||||
|
signal close()
|
||||||
|
signal pin()
|
||||||
|
signal raise()
|
||||||
|
signal deltaSize(real dx, real dy)
|
||||||
|
}
|
181
interface/resources/qml/windows/Window.qml
Normal file
181
interface/resources/qml/windows/Window.qml
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
import "."
|
||||||
|
import "../styles"
|
||||||
|
|
||||||
|
FocusScope {
|
||||||
|
id: window
|
||||||
|
objectName: "topLevelWindow"
|
||||||
|
HifiConstants { id: hifi }
|
||||||
|
implicitHeight: frame.height
|
||||||
|
implicitWidth: frame.width
|
||||||
|
|
||||||
|
property bool topLevelWindow: true
|
||||||
|
property string title
|
||||||
|
property bool showFrame: true
|
||||||
|
property bool closable: true
|
||||||
|
property bool destroyOnInvisible: false
|
||||||
|
property bool destroyOnCloseButton: true
|
||||||
|
property bool pinned: false
|
||||||
|
property bool resizable: false
|
||||||
|
property real minX: 320
|
||||||
|
property real minY: 240;
|
||||||
|
default property var content
|
||||||
|
property var frame: DefaultFrame { anchors.fill: content }
|
||||||
|
property var blur: FastBlur { anchors.fill: content; source: content; visible: false; radius: 0}
|
||||||
|
//property var hoverDetector: MouseArea { anchors.fill: frame; hoverEnabled: true; propagateComposedEvents: true; }
|
||||||
|
//property bool mouseInWindow: hoverDetector.containsMouse
|
||||||
|
children: [ frame, content, blur ]
|
||||||
|
signal windowDestroyed();
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
property vector2d minPosition: Qt.vector2d(0, 0);
|
||||||
|
property vector2d maxPosition: Qt.vector2d(100, 100);
|
||||||
|
|
||||||
|
function clamp(value, min, max) {
|
||||||
|
return Math.min(Math.max(value, min), max);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateParentRect() {
|
||||||
|
// if (!frame) { return; }
|
||||||
|
// console.log(window.parent.width);
|
||||||
|
// console.log(frame.width);
|
||||||
|
// minPosition = Qt.vector2d(-frame.anchors.leftMargin, -frame.anchors.topMargin);
|
||||||
|
// maxPosition = Qt.vector2d(
|
||||||
|
// Math.max(minPosition.x, Desktop.width - frame.width + minPosition.x),
|
||||||
|
// Math.max(minPosition.y, Desktop.height - frame.height + minPosition.y))
|
||||||
|
// console.log(maxPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
function keepOnScreen() {
|
||||||
|
//window.x = clamp(x, minPosition.x, maxPosition.x);
|
||||||
|
//window.y = clamp(y, minPosition.y, maxPosition.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMinPositionChanged: keepOnScreen();
|
||||||
|
onMaxPositionChanged: keepOnScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
d.updateParentRect();
|
||||||
|
raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
console.log("Destroyed " + window);
|
||||||
|
windowDestroyed();
|
||||||
|
}
|
||||||
|
|
||||||
|
onParentChanged: {
|
||||||
|
d.updateParentRect();
|
||||||
|
raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
onFrameChanged: d.updateParentRect();
|
||||||
|
onWidthChanged: d.updateParentRect();
|
||||||
|
onHeightChanged: d.updateParentRect();
|
||||||
|
onXChanged: d.keepOnScreen();
|
||||||
|
onYChanged: d.keepOnScreen();
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: frame
|
||||||
|
onRaise: window.raise();
|
||||||
|
onClose: window.close();
|
||||||
|
onPin: window.pin();
|
||||||
|
onDeltaSize: {
|
||||||
|
console.log("deltaSize")
|
||||||
|
content.width = Math.max(content.width + dx, minX)
|
||||||
|
content.height = Math.max(content.height + dy, minY)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function raise() {
|
||||||
|
if (enabled && parent) {
|
||||||
|
Desktop.raise(window)
|
||||||
|
if (!focus) {
|
||||||
|
focus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pin() {
|
||||||
|
pinned = ! pinned
|
||||||
|
}
|
||||||
|
|
||||||
|
// our close function performs the same way as the OffscreenUI class:
|
||||||
|
// don't do anything but manipulate the enabled flag and let the other
|
||||||
|
// mechanisms decide if the window should be destroyed after the close
|
||||||
|
// animation completes
|
||||||
|
function close() {
|
||||||
|
if (destroyOnCloseButton) {
|
||||||
|
destroyOnInvisible = true
|
||||||
|
}
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onEnabledChanged: {
|
||||||
|
if (!enabled) {
|
||||||
|
if (blur) {
|
||||||
|
blur.visible = true;
|
||||||
|
}
|
||||||
|
if (content) {
|
||||||
|
content.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
opacity = enabled ? 1.0 : 0.0
|
||||||
|
// If the dialog is initially invisible, setting opacity doesn't
|
||||||
|
// trigger making it visible.
|
||||||
|
if (enabled) {
|
||||||
|
visible = true;
|
||||||
|
raise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The offscreen UI will enable an object, rather than manipulating it's
|
||||||
|
// visibility, so that we can do animations in both directions. Because
|
||||||
|
// visibility and enabled are boolean flags, they cannot be animated. So when
|
||||||
|
// enabled is change, we modify a property that can be animated, like scale or
|
||||||
|
// opacity, and then when the target animation value is reached, we can
|
||||||
|
// modify the visibility
|
||||||
|
|
||||||
|
// The actual animator
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: hifi.effects.fadeInDuration
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once we're transparent, disable the dialog's visibility
|
||||||
|
onOpacityChanged: {
|
||||||
|
visible = (opacity != 0.0);
|
||||||
|
if (opacity == 1.0) {
|
||||||
|
content.visible = true;
|
||||||
|
blur.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some dialogs should be destroyed when they become
|
||||||
|
// invisible, so handle that
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (!visible && destroyOnInvisible) {
|
||||||
|
console.log("Destroying " + window);
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onPressed: {
|
||||||
|
switch(event.key) {
|
||||||
|
case Qt.Key_W:
|
||||||
|
if (event.modifiers == Qt.ControlModifier) {
|
||||||
|
event.accepted = true
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -982,12 +982,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
|
connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
|
||||||
|
|
||||||
// FIXME -- NOTE: This will call ProcessEvents() which can cause authentication signals to fire, which
|
|
||||||
// if not logged in can cause the login dialog to appear. As currently implemented, the login requires
|
|
||||||
// the offscreen UI to render, so this needs to be well after OffscreenUi is available
|
|
||||||
_runningScriptsWidget = new RunningScriptsWidget(_window);
|
|
||||||
|
|
||||||
qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
|
qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1199,7 +1193,10 @@ void Application::initializeUi() {
|
||||||
offscreenUi->create(_offscreenContext->getContext());
|
offscreenUi->create(_offscreenContext->getContext());
|
||||||
offscreenUi->setProxyWindow(_window->windowHandle());
|
offscreenUi->setProxyWindow(_window->windowHandle());
|
||||||
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
||||||
offscreenUi->load("Root.qml");
|
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
||||||
|
// support the window management and scripting proxies for VR use
|
||||||
|
offscreenUi->createDesktop();
|
||||||
|
|
||||||
// FIXME either expose so that dialogs can set this themselves or
|
// FIXME either expose so that dialogs can set this themselves or
|
||||||
// do better detection in the offscreen UI of what has focus
|
// do better detection in the offscreen UI of what has focus
|
||||||
offscreenUi->setNavigationFocused(false);
|
offscreenUi->setNavigationFocused(false);
|
||||||
|
@ -1210,6 +1207,9 @@ void Application::initializeUi() {
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// For some reason there is already an "Application" object in the QML context,
|
||||||
|
// though I can't find it. Hence, "ApplicationInterface"
|
||||||
|
rootContext->setContextProperty("ApplicationInterface", this);
|
||||||
rootContext->setContextProperty("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
rootContext->setContextProperty("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||||
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
||||||
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
||||||
|
@ -1232,8 +1232,6 @@ void Application::initializeUi() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rootContext->setContextProperty("Overlays", &_overlays);
|
rootContext->setContextProperty("Overlays", &_overlays);
|
||||||
rootContext->setContextProperty("Desktop", DependencyManager::get<DesktopScriptingInterface>().data());
|
|
||||||
|
|
||||||
rootContext->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
rootContext->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
||||||
rootContext->setContextProperty("Menu", MenuScriptingInterface::getInstance());
|
rootContext->setContextProperty("Menu", MenuScriptingInterface::getInstance());
|
||||||
rootContext->setContextProperty("Stats", Stats::getInstance());
|
rootContext->setContextProperty("Stats", Stats::getInstance());
|
||||||
|
@ -4535,18 +4533,20 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::toggleRunningScriptsWidget() {
|
void Application::toggleRunningScriptsWidget() {
|
||||||
if (_runningScriptsWidget->isVisible()) {
|
static const QUrl url("dialogs/RunningScripts.qml");
|
||||||
if (_runningScriptsWidget->hasFocus()) {
|
DependencyManager::get<OffscreenUi>()->toggle(url, "RunningScripts");
|
||||||
_runningScriptsWidget->hide();
|
//if (_runningScriptsWidget->isVisible()) {
|
||||||
} else {
|
// if (_runningScriptsWidget->hasFocus()) {
|
||||||
_runningScriptsWidget->raise();
|
// _runningScriptsWidget->hide();
|
||||||
setActiveWindow(_runningScriptsWidget);
|
// } else {
|
||||||
_runningScriptsWidget->setFocus();
|
// _runningScriptsWidget->raise();
|
||||||
}
|
// setActiveWindow(_runningScriptsWidget);
|
||||||
} else {
|
// _runningScriptsWidget->setFocus();
|
||||||
_runningScriptsWidget->show();
|
// }
|
||||||
_runningScriptsWidget->setFocus();
|
//} else {
|
||||||
}
|
// _runningScriptsWidget->show();
|
||||||
|
// _runningScriptsWidget->setFocus();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::packageModel() {
|
void Application::packageModel() {
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
#include "ui/OctreeStatsDialog.h"
|
#include "ui/OctreeStatsDialog.h"
|
||||||
#include "ui/OverlayConductor.h"
|
#include "ui/OverlayConductor.h"
|
||||||
#include "ui/overlays/Overlays.h"
|
#include "ui/overlays/Overlays.h"
|
||||||
#include "ui/RunningScriptsWidget.h"
|
|
||||||
#include "ui/SnapshotShareDialog.h"
|
#include "ui/SnapshotShareDialog.h"
|
||||||
#include "ui/ToolWindow.h"
|
#include "ui/ToolWindow.h"
|
||||||
#include "UndoStackScriptingInterface.h"
|
#include "UndoStackScriptingInterface.h"
|
||||||
|
@ -246,8 +245,8 @@ public slots:
|
||||||
bool importEntities(const QString& url);
|
bool importEntities(const QString& url);
|
||||||
|
|
||||||
void setLowVelocityFilter(bool lowVelocityFilter);
|
void setLowVelocityFilter(bool lowVelocityFilter);
|
||||||
void loadDialog();
|
Q_INVOKABLE void loadDialog();
|
||||||
void loadScriptURLDialog();
|
Q_INVOKABLE void loadScriptURLDialog();
|
||||||
void toggleLogDialog();
|
void toggleLogDialog();
|
||||||
void toggleRunningScriptsWidget();
|
void toggleRunningScriptsWidget();
|
||||||
|
|
||||||
|
@ -467,7 +466,6 @@ private:
|
||||||
|
|
||||||
TouchEvent _lastTouchEvent;
|
TouchEvent _lastTouchEvent;
|
||||||
|
|
||||||
RunningScriptsWidget* _runningScriptsWidget { nullptr };
|
|
||||||
quint64 _lastNackTime;
|
quint64 _lastNackTime;
|
||||||
quint64 _lastSendDownstreamAudioStats;
|
quint64 _lastSendDownstreamAudioStats;
|
||||||
|
|
||||||
|
|
|
@ -1,222 +0,0 @@
|
||||||
//
|
|
||||||
// RunningScriptsWidget.cpp
|
|
||||||
// interface/src/ui
|
|
||||||
//
|
|
||||||
// Created by Mohammed Nafees on 03/28/2014.
|
|
||||||
// Updated by Ryan Huffman on 05/13/2014.
|
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "ui_runningScriptsWidget.h"
|
|
||||||
#include "RunningScriptsWidget.h"
|
|
||||||
|
|
||||||
#include <QAbstractProxyModel>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QScreen>
|
|
||||||
#include <QTableWidgetItem>
|
|
||||||
#include <QWindow>
|
|
||||||
|
|
||||||
#include <PathUtils.h>
|
|
||||||
#include <ScriptEngines.h>
|
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "MainWindow.h"
|
|
||||||
#include "Menu.h"
|
|
||||||
#include "ScriptsModel.h"
|
|
||||||
#include "UIUtil.h"
|
|
||||||
|
|
||||||
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
|
||||||
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
|
||||||
Qt::WindowCloseButtonHint),
|
|
||||||
ui(new Ui::RunningScriptsWidget),
|
|
||||||
_reloadSignalMapper(this),
|
|
||||||
_stopSignalMapper(this) {
|
|
||||||
ui->setupUi(this);
|
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
|
||||||
|
|
||||||
ui->filterLineEdit->installEventFilter(this);
|
|
||||||
|
|
||||||
auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
|
|
||||||
connect(scriptEngines->scriptsModelFilter(), &QSortFilterProxyModel::modelReset,
|
|
||||||
this, &RunningScriptsWidget::selectFirstInList);
|
|
||||||
|
|
||||||
// FIXME: menu isn't prepared at this point.
|
|
||||||
//QString shortcutText = Menu::getInstance()->getActionForOption(MenuOption::ReloadAllScripts)->shortcut().toString(QKeySequence::NativeText);
|
|
||||||
//ui->tipLabel->setText("Tip: Use " + shortcutText + " to reload all scripts.");
|
|
||||||
ui->scriptTreeView->setModel(scriptEngines->scriptsModelFilter());
|
|
||||||
|
|
||||||
connect(ui->filterLineEdit, &QLineEdit::textChanged, this, &RunningScriptsWidget::updateFileFilter);
|
|
||||||
connect(ui->scriptTreeView, &QTreeView::doubleClicked, this, &RunningScriptsWidget::loadScriptFromList);
|
|
||||||
|
|
||||||
connect(ui->reloadAllButton, &QPushButton::clicked, scriptEngines, &ScriptEngines::reloadAllScripts);
|
|
||||||
connect(ui->stopAllButton, &QPushButton::clicked, scriptEngines, &ScriptEngines::stopAllScripts);
|
|
||||||
connect(ui->loadScriptFromDiskButton, &QPushButton::clicked, qApp, &Application::loadDialog);
|
|
||||||
connect(ui->loadScriptFromURLButton, &QPushButton::clicked, qApp, &Application::loadScriptURLDialog);
|
|
||||||
connect(&_reloadSignalMapper, static_cast<void(QSignalMapper::*)(const QString&)>(&QSignalMapper::mapped),
|
|
||||||
[scriptEngines](const QString& scriptName) { scriptEngines->stopScript(scriptName, true); });
|
|
||||||
connect(&_stopSignalMapper, static_cast<void(QSignalMapper::*)(const QString&)>(&QSignalMapper::mapped),
|
|
||||||
[scriptEngines](const QString& scriptName) { scriptEngines->stopScript(scriptName); });
|
|
||||||
|
|
||||||
setRunningScripts(scriptEngines->getRunningScripts());
|
|
||||||
connect(scriptEngines, &ScriptEngines::scriptCountChanged, scriptEngines, [this, scriptEngines] {
|
|
||||||
setRunningScripts(scriptEngines->getRunningScripts());
|
|
||||||
}, Qt::QueuedConnection);
|
|
||||||
UIUtil::scaleWidgetFontSizes(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
RunningScriptsWidget::~RunningScriptsWidget() {
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::updateFileFilter(const QString& filter) {
|
|
||||||
QRegExp regex("^.*" + QRegExp::escape(filter) + ".*$", Qt::CaseInsensitive);
|
|
||||||
DependencyManager::get<ScriptEngines>()->scriptsModelFilter()->setFilterRegExp(regex);
|
|
||||||
selectFirstInList();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::loadScriptFromList(const QModelIndex& index) {
|
|
||||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
|
||||||
QVariant scriptFile = scriptEngines->scriptsModelFilter()->data(index, ScriptsModel::ScriptPath);
|
|
||||||
scriptEngines->loadScript(scriptFile.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::loadSelectedScript() {
|
|
||||||
QModelIndex selectedIndex = ui->scriptTreeView->currentIndex();
|
|
||||||
if (selectedIndex.isValid()) {
|
|
||||||
loadScriptFromList(selectedIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
|
|
||||||
setUpdatesEnabled(false);
|
|
||||||
QLayoutItem* widget;
|
|
||||||
while ((widget = ui->scriptListWidget->layout()->takeAt(0)) != NULL) {
|
|
||||||
delete widget->widget();
|
|
||||||
delete widget;
|
|
||||||
}
|
|
||||||
QHash<QString, int> hash;
|
|
||||||
const int CLOSE_ICON_HEIGHT = 12;
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
if (!hash.contains(list.at(i))) {
|
|
||||||
hash.insert(list.at(i), 1);
|
|
||||||
}
|
|
||||||
QWidget* row = new QWidget(ui->scriptListWidget);
|
|
||||||
row->setFont(ui->scriptListWidget->font());
|
|
||||||
row->setLayout(new QHBoxLayout(row));
|
|
||||||
|
|
||||||
QUrl url = QUrl(list.at(i));
|
|
||||||
QLabel* name = new QLabel(url.fileName(), row);
|
|
||||||
if (hash.find(list.at(i)).value() != 1) {
|
|
||||||
name->setText(name->text() + "(" + QString::number(hash.find(list.at(i)).value()) + ")");
|
|
||||||
}
|
|
||||||
++hash[list.at(i)];
|
|
||||||
|
|
||||||
QPushButton* reloadButton = new QPushButton(row);
|
|
||||||
reloadButton->setFlat(true);
|
|
||||||
reloadButton->setIcon(
|
|
||||||
QIcon(QPixmap(PathUtils::resourcesPath() + "images/reload-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT)));
|
|
||||||
reloadButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
|
|
||||||
reloadButton->setStyleSheet("border: 0;");
|
|
||||||
reloadButton->setCursor(Qt::PointingHandCursor);
|
|
||||||
connect(reloadButton, SIGNAL(clicked()), &_reloadSignalMapper, SLOT(map()));
|
|
||||||
_reloadSignalMapper.setMapping(reloadButton, url.toString());
|
|
||||||
|
|
||||||
QPushButton* closeButton = new QPushButton(row);
|
|
||||||
closeButton->setFlat(true);
|
|
||||||
closeButton->setIcon(
|
|
||||||
QIcon(QPixmap(PathUtils::resourcesPath() + "images/kill-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT)));
|
|
||||||
closeButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
|
|
||||||
closeButton->setStyleSheet("border: 0;");
|
|
||||||
closeButton->setCursor(Qt::PointingHandCursor);
|
|
||||||
connect(closeButton, SIGNAL(clicked()), &_stopSignalMapper, SLOT(map()));
|
|
||||||
_stopSignalMapper.setMapping(closeButton, url.toString());
|
|
||||||
|
|
||||||
row->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
|
||||||
|
|
||||||
row->layout()->setContentsMargins(4, 4, 4, 4);
|
|
||||||
row->layout()->setSpacing(0);
|
|
||||||
|
|
||||||
row->layout()->addWidget(name);
|
|
||||||
row->layout()->addWidget(reloadButton);
|
|
||||||
row->layout()->addWidget(closeButton);
|
|
||||||
|
|
||||||
row->setToolTip(url.toString());
|
|
||||||
|
|
||||||
QFrame* line = new QFrame(row);
|
|
||||||
line->setFrameShape(QFrame::HLine);
|
|
||||||
line->setStyleSheet("color: #E1E1E1; margin-left: 6px; margin-right: 6px;");
|
|
||||||
|
|
||||||
ui->scriptListWidget->layout()->addWidget(row);
|
|
||||||
ui->scriptListWidget->layout()->addWidget(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ui->noRunningScriptsLabel->setVisible(list.isEmpty());
|
|
||||||
ui->reloadAllButton->setVisible(!list.isEmpty());
|
|
||||||
ui->stopAllButton->setVisible(!list.isEmpty());
|
|
||||||
|
|
||||||
ui->scriptListWidget->updateGeometry();
|
|
||||||
setUpdatesEnabled(true);
|
|
||||||
Application::processEvents();
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::showEvent(QShowEvent* event) {
|
|
||||||
if (!event->spontaneous()) {
|
|
||||||
ui->filterLineEdit->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect parentGeometry = qApp->getDesirableApplicationGeometry();
|
|
||||||
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
|
|
||||||
int topMargin = titleBarHeight;
|
|
||||||
|
|
||||||
setGeometry(parentGeometry.topLeft().x(), parentGeometry.topLeft().y() + topMargin,
|
|
||||||
size().width(), parentWidget()->height() - topMargin);
|
|
||||||
|
|
||||||
QWidget::showEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::selectFirstInList() {
|
|
||||||
auto model = DependencyManager::get<ScriptEngines>()->scriptsModelFilter();
|
|
||||||
if (model->rowCount() > 0) {
|
|
||||||
ui->scriptTreeView->setCurrentIndex(model->index(0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RunningScriptsWidget::eventFilter(QObject* sender, QEvent* event) {
|
|
||||||
if (sender == ui->filterLineEdit) {
|
|
||||||
if (event->type() != QEvent::KeyPress) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
|
||||||
if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
|
|
||||||
QModelIndex selectedIndex = ui->scriptTreeView->currentIndex();
|
|
||||||
if (selectedIndex.isValid()) {
|
|
||||||
loadScriptFromList(selectedIndex);
|
|
||||||
}
|
|
||||||
event->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QWidget::eventFilter(sender, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::keyPressEvent(QKeyEvent *keyEvent) {
|
|
||||||
if (keyEvent->key() == Qt::Key_Escape) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
QWidget::keyPressEvent(keyEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunningScriptsWidget::allScriptsStopped() {
|
|
||||||
DependencyManager::get<ScriptEngines>()->stopAllScripts();
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
//
|
|
||||||
// RunningScriptsWidget.h
|
|
||||||
// interface/src/ui
|
|
||||||
//
|
|
||||||
// Created by Mohammed Nafees on 03/28/2014.
|
|
||||||
// Updated by Ryan Huffman on 05/13/2014.
|
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef hifi_RunningScriptsWidget_h
|
|
||||||
#define hifi_RunningScriptsWidget_h
|
|
||||||
|
|
||||||
#include <QFileSystemModel>
|
|
||||||
#include <QSignalMapper>
|
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
|
|
||||||
#include "ScriptsModel.h"
|
|
||||||
#include "ScriptsModelFilter.h"
|
|
||||||
#include "ScriptsTableWidget.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class RunningScriptsWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
class RunningScriptsWidget : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
explicit RunningScriptsWidget(QWidget* parent = NULL);
|
|
||||||
~RunningScriptsWidget();
|
|
||||||
|
|
||||||
void setRunningScripts(const QStringList& list);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual bool eventFilter(QObject* sender, QEvent* event);
|
|
||||||
|
|
||||||
virtual void keyPressEvent(QKeyEvent* event);
|
|
||||||
virtual void showEvent(QShowEvent* event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void allScriptsStopped();
|
|
||||||
void updateFileFilter(const QString& filter);
|
|
||||||
void loadScriptFromList(const QModelIndex& index);
|
|
||||||
void loadSelectedScript();
|
|
||||||
void selectFirstInList();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::RunningScriptsWidget* ui;
|
|
||||||
QSignalMapper _reloadSignalMapper;
|
|
||||||
QSignalMapper _stopSignalMapper;
|
|
||||||
QVariantList getPublicChildNodes(TreeNodeFolder* parent);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // hifi_RunningScriptsWidget_h
|
|
|
@ -1,511 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>RunningScriptsWidget</class>
|
|
||||||
<widget class="QWidget" name="RunningScriptsWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>364</width>
|
|
||||||
<height>728</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Running Scripts</string>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">* { font-family: Helvetica, Arial, sans-serif; }</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="3,2">
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="runningScriptsArea" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>141</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget_3" native="true">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="currentlyRunningLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>16</pointsize>
|
|
||||||
<weight>75</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #0e7077;
|
|
||||||
font: bold 16pt;
|
|
||||||
</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Currently Running</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Minimum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>4</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="reloadStopButtonArea" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">reloadStopButtonArea { padding: 0 }</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="reloadAllButton">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Reload all</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="stopAllButton">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Stop all</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget_4" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>13</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="noRunningScriptsLabel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>14</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #5f5f5f; margin: 2px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>There are no scripts running.</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QScrollArea" name="runningScriptsList">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>14</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="layoutDirection">
|
|
||||||
<enum>Qt::LeftToRight</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::NoFrame</enum>
|
|
||||||
</property>
|
|
||||||
<property name="lineWidth">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalScrollBarPolicy">
|
|
||||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalScrollBarPolicy">
|
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
|
||||||
</property>
|
|
||||||
<property name="widgetResizable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>328</width>
|
|
||||||
<height>18</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>14</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="layoutDirection">
|
|
||||||
<enum>Qt::LeftToRight</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="scriptListWidget" native="true">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Helvetica,Arial,sans-serif</family>
|
|
||||||
<pointsize>14</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="quickLoadArea" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #0e7077;
|
|
||||||
font: bold 16pt;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Load Scripts</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="loadScriptFromURLButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>from URL</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="loadScriptFromDiskButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>from Disk</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="widget_2" native="true">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="filterLineEdit">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
|
||||||
<string>filter</string>
|
|
||||||
</property>
|
|
||||||
<property name="clearButtonEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="scriptTreeView">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="verticalScrollBarPolicy">
|
|
||||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalScrollBarPolicy">
|
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
|
||||||
</property>
|
|
||||||
<property name="rootIsDecorated">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<attribute name="headerVisible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -61,7 +61,6 @@ ScriptsModel::ScriptsModel(QObject* parent) :
|
||||||
_localDirectory.setFilter(QDir::Files | QDir::Readable);
|
_localDirectory.setFilter(QDir::Files | QDir::Readable);
|
||||||
_localDirectory.setNameFilters(QStringList("*.js"));
|
_localDirectory.setNameFilters(QStringList("*.js"));
|
||||||
|
|
||||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
|
||||||
connect(&_fsWatcher, &QFileSystemWatcher::directoryChanged, this, &ScriptsModel::reloadLocalFiles);
|
connect(&_fsWatcher, &QFileSystemWatcher::directoryChanged, this, &ScriptsModel::reloadLocalFiles);
|
||||||
reloadLocalFiles();
|
reloadLocalFiles();
|
||||||
reloadRemoteFiles();
|
reloadRemoteFiles();
|
||||||
|
|
|
@ -16,19 +16,14 @@
|
||||||
#include <AbstractUriHandler.h>
|
#include <AbstractUriHandler.h>
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
|
|
||||||
|
|
||||||
#include "ErrorDialog.h"
|
#include "ErrorDialog.h"
|
||||||
#include "MessageDialog.h"
|
#include "MessageDialog.h"
|
||||||
|
|
||||||
class OffscreenUiRoot : public QQuickItem {
|
// Needs to match the constants in resources/qml/Global.js
|
||||||
Q_OBJECT
|
static const QString OFFSCREEN_ROOT_OBJECT_NAME = "desktopRoot";
|
||||||
public:
|
static const QString OFFSCREEN_WINDOW_OBJECT_NAME = "topLevelWindow";
|
||||||
|
static QQuickItem* _desktop { nullptr };
|
||||||
OffscreenUiRoot(QQuickItem* parent = 0);
|
|
||||||
Q_INVOKABLE void information(const QString& title, const QString& text);
|
|
||||||
Q_INVOKABLE void loadChild(const QUrl& url) {
|
|
||||||
DependencyManager::get<OffscreenUi>()->load(url);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OffscreenFlags : public QObject {
|
class OffscreenFlags : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -105,15 +100,7 @@ bool OffscreenUi::shouldSwallowShortcut(QEvent* event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OffscreenUiRoot::OffscreenUiRoot(QQuickItem* parent) : QQuickItem(parent) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void OffscreenUiRoot::information(const QString& title, const QString& text) {
|
|
||||||
OffscreenUi::information(title, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
OffscreenUi::OffscreenUi() {
|
OffscreenUi::OffscreenUi() {
|
||||||
::qmlRegisterType<OffscreenUiRoot>("Hifi", 1, 0, "Root");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::create(QOpenGLContext* context) {
|
void OffscreenUi::create(QOpenGLContext* context) {
|
||||||
|
@ -258,4 +245,13 @@ void OffscreenUi::setNavigationFocused(bool focused) {
|
||||||
offscreenFlags->setNavigationFocused(focused);
|
offscreenFlags->setNavigationFocused(focused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OffscreenUi::createDesktop() {
|
||||||
|
if (_desktop) {
|
||||||
|
qDebug() << "Desktop already created";
|
||||||
|
}
|
||||||
|
_desktop = dynamic_cast<QQuickItem*>(load("Root.qml"));
|
||||||
|
Q_ASSERT(_desktop);
|
||||||
|
getRootContext()->setContextProperty("Desktop", _desktop);
|
||||||
|
}
|
||||||
|
|
||||||
#include "OffscreenUi.moc"
|
#include "OffscreenUi.moc"
|
||||||
|
|
|
@ -26,6 +26,7 @@ class OffscreenUi : public OffscreenQmlSurface, public Dependency {
|
||||||
public:
|
public:
|
||||||
OffscreenUi();
|
OffscreenUi();
|
||||||
virtual void create(QOpenGLContext* context) override;
|
virtual void create(QOpenGLContext* context) override;
|
||||||
|
void createDesktop();
|
||||||
void show(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
void show(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
||||||
void toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
void toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {});
|
||||||
bool shouldSwallowShortcut(QEvent* event);
|
bool shouldSwallowShortcut(QEvent* event);
|
||||||
|
|
|
@ -91,7 +91,7 @@ QScriptValue QmlWindowClass::internalConstructor(const QString& qmlSource,
|
||||||
const auto argumentCount = context->argumentCount();
|
const auto argumentCount = context->argumentCount();
|
||||||
QString url;
|
QString url;
|
||||||
QString title;
|
QString title;
|
||||||
int width = 100, height = 100;
|
int width = -1, height = -1;
|
||||||
bool visible = true;
|
bool visible = true;
|
||||||
if (argumentCount > 1) {
|
if (argumentCount > 1) {
|
||||||
|
|
||||||
|
@ -131,13 +131,19 @@ QScriptValue QmlWindowClass::internalConstructor(const QString& qmlSource,
|
||||||
url = QUrl::fromLocalFile(url).toString();
|
url = QUrl::fromLocalFile(url).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
width = std::max(100, std::min(1280, width));
|
if (width != -1 || height != -1) {
|
||||||
height = std::max(100, std::min(720, height));
|
width = std::max(100, std::min(1280, width));
|
||||||
|
height = std::max(100, std::min(720, height));
|
||||||
|
}
|
||||||
|
|
||||||
QmlWindowClass* retVal{ nullptr };
|
QmlWindowClass* retVal{ nullptr };
|
||||||
|
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
qDebug() << "Clearing component cache";
|
||||||
|
offscreenUi->getRootContext()->engine()->clearComponentCache();
|
||||||
|
|
||||||
// Build the event bridge and wrapper on the main thread
|
// Build the event bridge and wrapper on the main thread
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<OffscreenUi>().data(), "load", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(offscreenUi.data(), "load", Qt::BlockingQueuedConnection,
|
||||||
Q_ARG(const QString&, qmlSource),
|
Q_ARG(const QString&, qmlSource),
|
||||||
Q_ARG(std::function<void(QQmlContext*, QObject*)>, [&](QQmlContext* context, QObject* object) {
|
Q_ARG(std::function<void(QQmlContext*, QObject*)>, [&](QQmlContext* context, QObject* object) {
|
||||||
setupServer();
|
setupServer();
|
||||||
|
@ -147,7 +153,9 @@ QScriptValue QmlWindowClass::internalConstructor(const QString& qmlSource,
|
||||||
if (!title.isEmpty()) {
|
if (!title.isEmpty()) {
|
||||||
retVal->setTitle(title);
|
retVal->setTitle(title);
|
||||||
}
|
}
|
||||||
retVal->setSize(width, height);
|
if (width != -1 && height != -1) {
|
||||||
|
retVal->setSize(width, height);
|
||||||
|
}
|
||||||
object->setProperty(SOURCE_PROPERTY, url);
|
object->setProperty(SOURCE_PROPERTY, url);
|
||||||
if (visible) {
|
if (visible) {
|
||||||
object->setProperty("enabled", true);
|
object->setProperty("enabled", true);
|
||||||
|
|
Loading…
Reference in a new issue