overte/interface/resources/qml/hifi/tablet/ControllerSettings.qml

348 lines
11 KiB
QML
Raw Normal View History

2017-06-20 01:19:10 +01:00
//
// Created by Dante Ruiz on 6/1/17.
// Copyright 2017 High Fidelity, Inc.
2020-07-10 07:18:29 +12:00
// Copyright 2020 Vircadia contributors.
2017-06-20 01:19:10 +01:00
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
2017-11-18 20:44:52 +01:00
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
2017-06-20 01:19:10 +01:00
import QtGraphicalEffects 1.0
import Qt.labs.settings 1.0
import stylesUit 1.0
2017-06-20 01:19:10 +01:00
import "../../controls"
import controlsUit 1.0 as HifiControls
import "../../dialogs"
import "../../dialogs/preferences"
import "tabletWindows"
import "../audio"
Item {
id: controllerSettings
height: parent.height
width: parent.width
2018-09-06 11:15:14 +12:00
property string title: "Controls"
property var openVRDevices: ["HTC Vive", "Valve Index", "Valve HMD", "Valve", "WindowsMR", "Oculus"]
2018-09-06 11:15:14 +12:00
HifiConstants { id: hifi }
TabBar {
id: bar
spacing: 0
2018-05-18 16:41:39 -07:00
anchors.top: controllerSettings.top
width: parent.width
2018-05-18 16:41:39 -07:00
height: 40
z: 10
TabButton {
height: parent.height
text: qsTr("Settings")
onClicked: {
stackView.clear();
stackView.push(controllerPreferencesComponent);
}
}
TabButton {
height: parent.height
text: qsTr("Calibration")
onClicked: {
stackView.clear();
stackView.push(inputConfigurationComponent);
}
}
}
2017-06-20 01:19:10 +01:00
StackView {
id: stackView
anchors.top: bar.bottom
anchors.bottom: controllerSettings.bottom
anchors.left: controllerSettings.left
anchors.right: controllerSettings.right
2017-06-20 01:19:10 +01:00
initialItem: controllerPreferencesComponent
}
2017-06-20 01:19:10 +01:00
Component {
id: inputConfigurationComponent
StackView {
id: stack
initialItem: inputConfiguration
property alias messageVisible: imageMessageBox.visible
2018-07-02 14:38:16 -07:00
property string selectedPlugin: ""
property bool keyboardEnabled: false
property bool keyboardRaised: false
property bool punctuationMode: false
Rectangle {
id: inputConfiguration
2018-06-04 15:16:11 -07:00
anchors {
top: parent.top
left: parent.left
right: parent.right
}
height: 230
2017-06-20 01:19:10 +01:00
HifiConstants { id: hifi }
2017-07-06 17:32:40 +01:00
color: hifi.colors.baseGray
2017-06-20 01:19:10 +01:00
property var pluginSettings: null
HifiControls.ImageMessageBox {
id: imageMessageBox
anchors.top: parent.top
anchors.topMargin: 444
z: 2000
imageWidth: 442
imageHeight: 670
source: "../../../images/calibration-help.png"
}
2017-06-20 01:19:10 +01:00
Rectangle {
width: inputConfiguration.width
height: 1
color: hifi.colors.baseGrayShadow
x: -hifi.dimensions.contentMargin.x
}
2017-06-20 01:19:10 +01:00
RalewayRegular {
id: header
text: "Control Settings"
size: 22
color: "white"
2017-06-20 01:19:10 +01:00
anchors.top: inputConfiguration.top
anchors.left: inputConfiguration.left
anchors.leftMargin: 20
anchors.topMargin: 20
}
Separator {
id: headerSeparator
width: inputConfiguration.width
anchors.top: header.bottom
anchors.topMargin: 10
}
2017-06-20 01:19:10 +01:00
HiFiGlyphs {
id: sourceGlyph
text: hifi.glyphs.source
size: 36
color: hifi.colors.blueHighlight
2017-06-20 01:19:10 +01:00
anchors.top: headerSeparator.bottom
anchors.left: inputConfiguration.left
anchors.leftMargin: 40
anchors.topMargin: 20
}
2017-06-20 01:19:10 +01:00
RalewayRegular {
id: configuration
text: "SELECT DEVICE"
size: 15
color: hifi.colors.lightGrayText
2017-06-20 01:19:10 +01:00
anchors.top: headerSeparator.bottom
anchors.left: sourceGlyph.right
anchors.leftMargin: 10
anchors.topMargin: 30
}
2017-06-20 01:19:10 +01:00
Row {
id: configRow
z: 999
anchors.top: sourceGlyph.bottom
anchors.topMargin: 20
anchors.left: sourceGlyph.left
anchors.leftMargin: 40
spacing: 10
HifiControls.ComboBox {
id: box
width: 160
z: 999
editable: true
colorScheme: hifi.colorSchemes.dark
model: inputPlugins()
label: ""
onCurrentIndexChanged: {
changeSource();
}
}
HifiControls.CheckBox {
id: checkBox
colorScheme: hifi.colorSchemes.dark
text: "Show all input devices"
onClicked: {
2018-06-04 16:09:31 -07:00
box.model = inputPlugins();
changeSource();
}
}
}
2017-06-20 01:19:10 +01:00
Separator {
id: configurationSeparator
z: 0
width: inputConfiguration.width
anchors.top: configRow.bottom
anchors.topMargin: 10
}
2017-06-20 01:19:10 +01:00
HiFiGlyphs {
id: sliderGlyph
text: hifi.glyphs.sliders
size: 36
color: hifi.colors.blueHighlight
2017-06-20 01:19:10 +01:00
anchors.top: configurationSeparator.bottom
anchors.left: inputConfiguration.left
anchors.leftMargin: 40
anchors.topMargin: 20
}
2017-06-20 01:19:10 +01:00
RalewayRegular {
id: configurationHeader
text: "CONFIGURATION"
size: 15
color: hifi.colors.lightGrayText
2017-06-20 01:19:10 +01:00
anchors.top: configurationSeparator.bottom
anchors.left: sliderGlyph.right
anchors.leftMargin: 10
anchors.topMargin: 30
}
2018-06-04 15:16:11 -07:00
}
2017-06-20 01:19:10 +01:00
2018-06-04 15:16:11 -07:00
Rectangle {
id: loaderRectangle
z: -1
color: hifi.colors.baseGray
width: parent.width
anchors.left: parent.left
anchors.right: parent.right
anchors.top: inputConfiguration.bottom
anchors.bottom: parent.bottom
anchors.bottomMargin: keyboard.height
Loader {
id: loader
asynchronous: false
2018-06-04 15:16:11 -07:00
anchors.fill: parent
2018-06-13 17:58:10 -07:00
source: InputConfiguration.configurationLayout(box.textAt(box.currentIndex));
onLoaded: {
if (loader.item.hasOwnProperty("pluginName")) {
2020-10-13 18:33:15 +02:00
if (openVRDevices.indexOf(box.textAt(box.currentIndex)) !== -1) {
loader.item.pluginName = "OpenVR";
} else {
2018-06-08 11:18:52 -07:00
loader.item.pluginName = box.textAt(box.currentIndex);
}
}
if (loader.item.hasOwnProperty("displayInformation")) {
loader.item.displayConfiguration();
}
}
}
}
2017-06-20 01:19:10 +01:00
HifiControls.Keyboard {
id: keyboard
raised: parent.keyboardEnabled && parent.keyboardRaised
onRaisedChanged: {
if (raised) {
// delayed execution to allow loader and its content to adjust size
Qt.callLater(function() {
loader.item.bringToView(Window.activeFocusItem);
})
}
}
numeric: parent.punctuationMode
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
Component.onCompleted: {
parent.keyboardEnabled = HMD.active;
}
}
2017-06-20 01:19:10 +01:00
function inputPlugins() {
if (checkBox.checked) {
return InputConfiguration.inputPlugins();
} else {
return InputConfiguration.activeInputPlugins();
2017-06-21 01:07:12 +01:00
}
}
2017-06-20 01:19:10 +01:00
function initialize() {
changeSource();
}
2017-07-06 17:32:40 +01:00
function changeSource() {
loader.source = "";
2018-06-04 16:09:31 -07:00
var selectedDevice = box.textAt(box.currentIndex);
var source = "";
2020-10-13 18:33:15 +02:00
if (openVRDevices.indexOf(selectedDevice) !== -1) {
source = InputConfiguration.configurationLayout("OpenVR");
} else {
2018-06-04 16:09:31 -07:00
source = InputConfiguration.configurationLayout(selectedDevice);
}
2017-07-06 17:32:40 +01:00
loader.source = source;
if (source === "") {
box.label = "(not configurable)";
} else {
box.label = "";
}
2018-07-02 14:38:16 -07:00
stack.selectedPlugin = selectedDevice;
}
2017-07-06 17:32:40 +01:00
Timer {
id: timer
repeat: false
interval: 300
onTriggered: initialize()
}
Component.onCompleted: {
timer.start();
}
}
}
Component {
id: controllerPreferencesComponent
TabletPreferencesDialog {
anchors.fill: stackView
id: controllerPrefereneces
objectName: "TabletControllerPreferences"
2023-06-20 21:18:33 +02:00
showCategories: ["Desktop Movement", "VR Movement", "Game Controller", "Sixense Controllers", "Perception Neuron", "Leap Motion", "Open Sound Control (OSC)"]
categoryProperties: {
"VR Movement" : {
"User real-world height (meters)" : { "anchors.right" : "undefined" },
"RESET SENSORS" : { "width" : "180", "anchors.left" : "undefined" }
}
}
2017-06-20 01:19:10 +01:00
}
}
}