mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 10:00:18 +02:00
Adding a script and ui to check the values returned by the PlatformInfo ui
This commit is contained in:
parent
5001a04326
commit
546639fdfe
10 changed files with 195 additions and 11 deletions
|
@ -3322,6 +3322,7 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) {
|
||||||
surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance());
|
surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance());
|
||||||
|
surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance());
|
||||||
surfaceContext->setContextProperty("Workload", _gameWorkload._engine->getConfiguration().get());
|
surfaceContext->setContextProperty("Workload", _gameWorkload._engine->getConfiguration().get());
|
||||||
surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
|
surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
|
||||||
surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
||||||
|
@ -3445,6 +3446,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona
|
||||||
surfaceContext->setContextProperty("HiFiAbout", AboutUtil::getInstance());
|
surfaceContext->setContextProperty("HiFiAbout", AboutUtil::getInstance());
|
||||||
surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get<WalletScriptingInterface>().data());
|
surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get<WalletScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get<ResourceRequestObserver>().data());
|
surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get<ResourceRequestObserver>().data());
|
||||||
|
surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,15 @@ PropFolderPanel {
|
||||||
proItem['type'] = typeof(proItem.object[proItem.property])
|
proItem['type'] = typeof(proItem.object[proItem.property])
|
||||||
}
|
}
|
||||||
switch(proItem.type) {
|
switch(proItem.type) {
|
||||||
|
case 'string':
|
||||||
|
case 'PropString': {
|
||||||
|
var component = Qt.createComponent("PropString.qml");
|
||||||
|
component.createObject(propItemsContainer, {
|
||||||
|
"label": proItem.property,
|
||||||
|
"object": proItem.object,
|
||||||
|
"property": proItem.property
|
||||||
|
})
|
||||||
|
} break;
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
case 'PropBool': {
|
case 'PropBool': {
|
||||||
var component = Qt.createComponent("PropBool.qml");
|
var component = Qt.createComponent("PropBool.qml");
|
||||||
|
@ -57,6 +66,7 @@ PropFolderPanel {
|
||||||
"min": (proItem["min"] !== undefined ? proItem.min : 0.0),
|
"min": (proItem["min"] !== undefined ? proItem.min : 0.0),
|
||||||
"max": (proItem["max"] !== undefined ? proItem.max : 1.0),
|
"max": (proItem["max"] !== undefined ? proItem.max : 1.0),
|
||||||
"integer": (proItem["integral"] !== undefined ? proItem.integral : false),
|
"integer": (proItem["integral"] !== undefined ? proItem.integral : false),
|
||||||
|
"readOnly": (proItem["readOnly"] !== undefined ? proItem["readOnly"] : false),
|
||||||
})
|
})
|
||||||
} break;
|
} break;
|
||||||
case 'PropEnum': {
|
case 'PropEnum': {
|
||||||
|
@ -97,6 +107,22 @@ PropFolderPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function populateFromObjectProps(object) {
|
||||||
|
var propsModel = []
|
||||||
|
var props = Object.keys(object);
|
||||||
|
|
||||||
|
for (var p in props) {
|
||||||
|
var o = {};
|
||||||
|
o["object"] = object
|
||||||
|
o["property"] = props[p];
|
||||||
|
// o["readOnly"] = true;
|
||||||
|
o["type"] = "string";
|
||||||
|
propsModel.push(o)
|
||||||
|
}
|
||||||
|
root.updatePropItems(root.propItemsPanel, propsModel);
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,16 @@ Item {
|
||||||
// Prop item is designed to author an object[property]:
|
// Prop item is designed to author an object[property]:
|
||||||
property var object: {}
|
property var object: {}
|
||||||
property string property: ""
|
property string property: ""
|
||||||
|
property bool readOnly: false
|
||||||
|
|
||||||
// value is accessed through the "valueVarSetter" and "valueVarGetter"
|
// value is accessed through the "valueVarSetter" and "valueVarGetter"
|
||||||
// By default, these just go get or set the value from the object[property]
|
// By default, these just go get or set the value from the object[property]
|
||||||
//
|
//
|
||||||
function defaultGet() { return root.object[root.property]; }
|
function defaultGet() { return root.object[root.property]; }
|
||||||
function defaultSet(value) { root.object[root.property] = value; }
|
function defaultSet(value) { root.object[root.property] = value; }
|
||||||
|
// function defaultSetReadOnly(value) { log ( "read only " + property + ", NOT setting to " + value); }
|
||||||
|
// function defaultSetReadOnly(value) {}
|
||||||
|
// property var valueVarSetter: (root.readOnly ? defaultSetReadOnly : defaultSet)
|
||||||
property var valueVarSetter: defaultSet
|
property var valueVarSetter: defaultSet
|
||||||
property var valueVarGetter: defaultGet
|
property var valueVarGetter: defaultGet
|
||||||
|
|
||||||
|
|
|
@ -20,16 +20,12 @@ PropItem {
|
||||||
property bool integral: false
|
property bool integral: false
|
||||||
property var numDigits: 2
|
property var numDigits: 2
|
||||||
|
|
||||||
|
|
||||||
property alias valueVar : sliderControl.value
|
property alias valueVar : sliderControl.value
|
||||||
property alias min: sliderControl.minimumValue
|
property alias min: sliderControl.minimumValue
|
||||||
property alias max: sliderControl.maximumValue
|
property alias max: sliderControl.maximumValue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
property bool showValue: true
|
property bool showValue: true
|
||||||
|
|
||||||
|
|
||||||
signal valueChanged(real value)
|
signal valueChanged(real value)
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
@ -42,11 +38,11 @@ PropItem {
|
||||||
|
|
||||||
anchors.left: root.splitter.right
|
anchors.left: root.splitter.right
|
||||||
anchors.verticalCenter: root.verticalCenter
|
anchors.verticalCenter: root.verticalCenter
|
||||||
width: root.width * global.valueAreaWidthScale
|
width: root.width * (root.readOnly ? 1.0 : global.valueAreaWidthScale)
|
||||||
horizontalAlignment: global.valueTextAlign
|
horizontalAlignment: global.valueTextAlign
|
||||||
height: global.slimHeight
|
height: global.slimHeight
|
||||||
|
|
||||||
text: sliderControl.value.toFixed(root.integral ? 0 : root.numDigits)
|
text: root.valueVarGetter().toFixed(root.integral ? 0 : root.numDigits)
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: global.color
|
color: global.color
|
||||||
|
@ -58,12 +54,13 @@ PropItem {
|
||||||
|
|
||||||
HifiControls.Slider {
|
HifiControls.Slider {
|
||||||
id: sliderControl
|
id: sliderControl
|
||||||
|
visible: !root.readOnly
|
||||||
stepSize: root.integral ? 1.0 : 0.0
|
stepSize: root.integral ? 1.0 : 0.0
|
||||||
anchors.left: valueLabel.right
|
anchors.left: valueLabel.right
|
||||||
anchors.right: root.right
|
anchors.right: root.right
|
||||||
anchors.verticalCenter: root.verticalCenter
|
anchors.verticalCenter: root.verticalCenter
|
||||||
|
|
||||||
onValueChanged: { root.valueVarSetter(value) }
|
onValueChanged: { if (!root.readOnly) { root.valueVarSetter(value)} }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
41
scripts/developer/utilities/lib/prop/PropString.qml
Normal file
41
scripts/developer/utilities/lib/prop/PropString.qml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// PropItem.qml
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 3/2/2019
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
import QtQuick 2.7
|
||||||
|
|
||||||
|
import controlsUit 1.0 as HifiControls
|
||||||
|
|
||||||
|
PropItem {
|
||||||
|
Global { id: global }
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// Scalar Prop
|
||||||
|
property bool integral: false
|
||||||
|
property var numDigits: 2
|
||||||
|
|
||||||
|
PropLabel {
|
||||||
|
id: valueLabel
|
||||||
|
|
||||||
|
anchors.left: root.splitter.right
|
||||||
|
anchors.right: root.right
|
||||||
|
anchors.verticalCenter: root.verticalCenter
|
||||||
|
horizontalAlignment: global.valueTextAlign
|
||||||
|
height: global.slimHeight
|
||||||
|
|
||||||
|
text: root.valueVarGetter();
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: global.color
|
||||||
|
border.color: global.colorBorderLight
|
||||||
|
border.width: global.valueBorderWidth
|
||||||
|
radius: global.valueBorderRadius
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,5 +10,6 @@ PropFolderPanel 1.0 style/PiFolderPanel.qml
|
||||||
|
|
||||||
PropItem 1.0 PropItem.qml
|
PropItem 1.0 PropItem.qml
|
||||||
PropScalar 1.0 PropScalar.qml
|
PropScalar 1.0 PropScalar.qml
|
||||||
|
PropString 1.0 PropString.qml
|
||||||
PropEnum 1.0 PropEnum.qml
|
PropEnum 1.0 PropEnum.qml
|
||||||
PropColor 1.0 PropColor.qml
|
PropColor 1.0 PropColor.qml
|
||||||
|
|
|
@ -24,6 +24,7 @@ Item {
|
||||||
readonly property real horizontalMargin: 4
|
readonly property real horizontalMargin: 4
|
||||||
|
|
||||||
readonly property color color: hifi.colors.baseGray
|
readonly property color color: hifi.colors.baseGray
|
||||||
|
readonly property color colorBack: hifi.colors.baseGray
|
||||||
readonly property color colorBackShadow: hifi.colors.baseGrayShadow
|
readonly property color colorBackShadow: hifi.colors.baseGrayShadow
|
||||||
readonly property color colorBackHighlight: hifi.colors.baseGrayHighlight
|
readonly property color colorBackHighlight: hifi.colors.baseGrayHighlight
|
||||||
readonly property color colorBorderLight: hifi.colors.lightGray
|
readonly property color colorBorderLight: hifi.colors.lightGray
|
||||||
|
|
|
@ -31,7 +31,7 @@ Rectangle {
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
width: render.width
|
width: parent.width
|
||||||
Prop.PropFolderPanel {
|
Prop.PropFolderPanel {
|
||||||
label: "Shading Model"
|
label: "Shading Model"
|
||||||
panelFrameData: Component {
|
panelFrameData: Component {
|
||||||
|
@ -87,14 +87,14 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Jet.TaskPropView {
|
/* Jet.TaskPropView {
|
||||||
id: "le"
|
id: "le"
|
||||||
jobPath: ""
|
jobPath: ""
|
||||||
label: "Le Render Engine"
|
label: "Le Render Engine"
|
||||||
|
|
||||||
// anchors.left: parent.left
|
// anchors.left: parent.left
|
||||||
// anchors.right: parent.right
|
// anchors.right: parent.right
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
46
scripts/developer/utilities/render/platform.js
Normal file
46
scripts/developer/utilities/render/platform.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// Test key commands
|
||||||
|
PlatformInfo.getComputer()
|
||||||
|
// {"OS":"WINDOWS","keys":null,"model":"","profileTier":"HIGH","vendor":""}
|
||||||
|
PlatformInfo.getNumCPUs()
|
||||||
|
// 1
|
||||||
|
PlatformInfo.getCPU(0)
|
||||||
|
//{"clockSpeed":" 4.00GHz","model":") i7-6700K CPU @ 4.00GHz","numCores":8,"vendor":"Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz"}
|
||||||
|
PlatformInfo.getNumGPUs()
|
||||||
|
// 1
|
||||||
|
PlatformInfo.getGPU(0)
|
||||||
|
// {"driver":"25.21.14.1967","model":"NVIDIA GeForce GTX 1080","vendor":"NVIDIA GeForce GTX 1080","videoMemory":8079}
|
||||||
|
|
||||||
|
var Page = Script.require('./luci/Page.js');
|
||||||
|
|
||||||
|
|
||||||
|
function openView() {
|
||||||
|
var pages = new Pages();
|
||||||
|
function fromQml(message) {
|
||||||
|
if (pages.open(message.method)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var platformWindow
|
||||||
|
|
||||||
|
function closeLuciWindow() {
|
||||||
|
if (luciWindow !== undefined) {
|
||||||
|
activeWindow.fromQml.disconnect(fromQml);
|
||||||
|
}
|
||||||
|
luciWindow = {};
|
||||||
|
|
||||||
|
Controller.mousePressEvent.disconnect(onMousePressEvent);
|
||||||
|
Controller.mouseReleaseEvent.disconnect(onMouseReleaseEvent);
|
||||||
|
Controller.mouseMoveEvent.disconnect(onMouseMoveEvent);
|
||||||
|
pages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
pages.addPage('Platform', 'Platform', '../platform.qml', 350, 700);
|
||||||
|
pages.open('Platform');
|
||||||
|
|
||||||
|
|
||||||
|
return pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
openView();
|
66
scripts/developer/utilities/render/platform.qml
Normal file
66
scripts/developer/utilities/render/platform.qml
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
//
|
||||||
|
// platform.qml
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 5/25/2019
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
import QtQuick 2.7
|
||||||
|
import QtQuick.Controls 2.2
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
import controlsUit 1.0 as HifiControls
|
||||||
|
|
||||||
|
import "../lib/prop" as Prop
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
id: platform;
|
||||||
|
|
||||||
|
Prop.Global { id: global;}
|
||||||
|
color: global.colorBack
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
Prop.PropGroup {
|
||||||
|
id: computer
|
||||||
|
label: "Computer"
|
||||||
|
isUnfold: true
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
computer.populateFromObjectProps(JSON.parse(PlatformInfo.getComputer()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Prop.PropGroup {
|
||||||
|
id: cpu
|
||||||
|
label: "CPU"
|
||||||
|
isUnfold: true
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
cpu.populateFromObjectProps(JSON.parse(PlatformInfo.getCPU(0)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Prop.PropGroup {
|
||||||
|
id: gpu
|
||||||
|
label: "GPU"
|
||||||
|
isUnfold: true
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
gpu.populateFromObjectProps(JSON.parse(PlatformInfo.getGPU(0)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Prop.PropGroup {
|
||||||
|
id: display
|
||||||
|
label: "Display"
|
||||||
|
isUnfold: true
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
display.populateFromObjectProps(JSON.parse(PlatformInfo.getDisplay(0)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue