diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a0cb790958..a962e7602a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3322,6 +3322,7 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) { surfaceContext->setContextProperty("HMD", DependencyManager::get().data()); surfaceContext->setContextProperty("Scene", DependencyManager::get().data()); surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance()); + surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance()); surfaceContext->setContextProperty("Workload", _gameWorkload._engine->getConfiguration().get()); surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface()); surfaceContext->setContextProperty("Snapshot", DependencyManager::get().data()); @@ -3445,6 +3446,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona surfaceContext->setContextProperty("HiFiAbout", AboutUtil::getInstance()); surfaceContext->setContextProperty("WalletScriptingInterface", DependencyManager::get().data()); surfaceContext->setContextProperty("ResourceRequestObserver", DependencyManager::get().data()); + surfaceContext->setContextProperty("PlatformInfo", PlatformInfoScriptingInterface::getInstance()); } } diff --git a/scripts/developer/utilities/lib/prop/PropGroup.qml b/scripts/developer/utilities/lib/prop/PropGroup.qml index 384b50ecad..22facb71c6 100644 --- a/scripts/developer/utilities/lib/prop/PropGroup.qml +++ b/scripts/developer/utilities/lib/prop/PropGroup.qml @@ -38,6 +38,15 @@ PropFolderPanel { proItem['type'] = typeof(proItem.object[proItem.property]) } 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 'PropBool': { var component = Qt.createComponent("PropBool.qml"); @@ -57,6 +66,7 @@ PropFolderPanel { "min": (proItem["min"] !== undefined ? proItem.min : 0.0), "max": (proItem["max"] !== undefined ? proItem.max : 1.0), "integer": (proItem["integral"] !== undefined ? proItem.integral : false), + "readOnly": (proItem["readOnly"] !== undefined ? proItem["readOnly"] : false), }) } break; 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: { } } diff --git a/scripts/developer/utilities/lib/prop/PropItem.qml b/scripts/developer/utilities/lib/prop/PropItem.qml index 339ff10422..03eabae39b 100644 --- a/scripts/developer/utilities/lib/prop/PropItem.qml +++ b/scripts/developer/utilities/lib/prop/PropItem.qml @@ -18,12 +18,16 @@ Item { // Prop item is designed to author an object[property]: property var object: {} property string property: "" + property bool readOnly: false // value is accessed through the "valueVarSetter" and "valueVarGetter" // By default, these just go get or set the value from the object[property] // function defaultGet() { return root.object[root.property]; } 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 valueVarGetter: defaultGet diff --git a/scripts/developer/utilities/lib/prop/PropScalar.qml b/scripts/developer/utilities/lib/prop/PropScalar.qml index 684dd4fed4..4c569eb57e 100644 --- a/scripts/developer/utilities/lib/prop/PropScalar.qml +++ b/scripts/developer/utilities/lib/prop/PropScalar.qml @@ -20,16 +20,12 @@ PropItem { property bool integral: false property var numDigits: 2 - property alias valueVar : sliderControl.value property alias min: sliderControl.minimumValue property alias max: sliderControl.maximumValue - - property bool showValue: true - - + signal valueChanged(real value) Component.onCompleted: { @@ -42,11 +38,11 @@ PropItem { anchors.left: root.splitter.right anchors.verticalCenter: root.verticalCenter - width: root.width * global.valueAreaWidthScale + width: root.width * (root.readOnly ? 1.0 : global.valueAreaWidthScale) horizontalAlignment: global.valueTextAlign height: global.slimHeight - text: sliderControl.value.toFixed(root.integral ? 0 : root.numDigits) + text: root.valueVarGetter().toFixed(root.integral ? 0 : root.numDigits) background: Rectangle { color: global.color @@ -58,12 +54,13 @@ PropItem { HifiControls.Slider { id: sliderControl + visible: !root.readOnly stepSize: root.integral ? 1.0 : 0.0 anchors.left: valueLabel.right anchors.right: root.right anchors.verticalCenter: root.verticalCenter - onValueChanged: { root.valueVarSetter(value) } + onValueChanged: { if (!root.readOnly) { root.valueVarSetter(value)} } } diff --git a/scripts/developer/utilities/lib/prop/PropString.qml b/scripts/developer/utilities/lib/prop/PropString.qml new file mode 100644 index 0000000000..7b7cbc4c91 --- /dev/null +++ b/scripts/developer/utilities/lib/prop/PropString.qml @@ -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 + } + } +} diff --git a/scripts/developer/utilities/lib/prop/qmldir b/scripts/developer/utilities/lib/prop/qmldir index c67ab6a41a..e09785846d 100644 --- a/scripts/developer/utilities/lib/prop/qmldir +++ b/scripts/developer/utilities/lib/prop/qmldir @@ -10,5 +10,6 @@ PropFolderPanel 1.0 style/PiFolderPanel.qml PropItem 1.0 PropItem.qml PropScalar 1.0 PropScalar.qml +PropString 1.0 PropString.qml PropEnum 1.0 PropEnum.qml PropColor 1.0 PropColor.qml diff --git a/scripts/developer/utilities/lib/prop/style/Global.qml b/scripts/developer/utilities/lib/prop/style/Global.qml index 4cdee70244..bbc8acfa0b 100644 --- a/scripts/developer/utilities/lib/prop/style/Global.qml +++ b/scripts/developer/utilities/lib/prop/style/Global.qml @@ -24,6 +24,7 @@ Item { readonly property real horizontalMargin: 4 readonly property color color: hifi.colors.baseGray + readonly property color colorBack: hifi.colors.baseGray readonly property color colorBackShadow: hifi.colors.baseGrayShadow readonly property color colorBackHighlight: hifi.colors.baseGrayHighlight readonly property color colorBorderLight: hifi.colors.lightGray diff --git a/scripts/developer/utilities/render/luci.qml b/scripts/developer/utilities/render/luci.qml index a904ec52fc..2dc8fda081 100644 --- a/scripts/developer/utilities/render/luci.qml +++ b/scripts/developer/utilities/render/luci.qml @@ -31,7 +31,7 @@ Rectangle { clip: true Column { - width: render.width + width: parent.width Prop.PropFolderPanel { label: "Shading Model" panelFrameData: Component { @@ -87,14 +87,14 @@ Rectangle { } } } - Jet.TaskPropView { + /* Jet.TaskPropView { id: "le" jobPath: "" label: "Le Render Engine" // anchors.left: parent.left // anchors.right: parent.right - } + }*/ } } } \ No newline at end of file diff --git a/scripts/developer/utilities/render/platform.js b/scripts/developer/utilities/render/platform.js new file mode 100644 index 0000000000..b51c9614ba --- /dev/null +++ b/scripts/developer/utilities/render/platform.js @@ -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(); diff --git a/scripts/developer/utilities/render/platform.qml b/scripts/developer/utilities/render/platform.qml new file mode 100644 index 0000000000..1f7000bc57 --- /dev/null +++ b/scripts/developer/utilities/render/platform.qml @@ -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))) + } + } + } +} +