From a9ff1f4ecd6356f77f794fc1d6cc9d49f36e2ae2 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Fri, 7 Sep 2018 17:53:45 +0300 Subject: [PATCH] add onscreen keyboard into 'Calibration' tab of Settings=>Controls dialog --- .../qml/hifi/tablet/ControllerSettings.qml | 31 +++++++++++++++++++ .../qml/hifi/tablet/OpenVrConfiguration.qml | 14 +++++++++ 2 files changed, 45 insertions(+) diff --git a/interface/resources/qml/hifi/tablet/ControllerSettings.qml b/interface/resources/qml/hifi/tablet/ControllerSettings.qml index b8bbd71f33..6727047eb0 100644 --- a/interface/resources/qml/hifi/tablet/ControllerSettings.qml +++ b/interface/resources/qml/hifi/tablet/ControllerSettings.qml @@ -9,6 +9,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 +import QtQuick.Window 2.2 import QtGraphicalEffects 1.0 import Qt.labs.settings 1.0 import stylesUit 1.0 @@ -72,6 +73,11 @@ Item { initialItem: inputConfiguration property alias messageVisible: imageMessageBox.visible property string selectedPlugin: "" + + property bool keyboardEnabled: false + property bool keyboardRaised: false + property bool punctuationMode: false + Rectangle { id: inputConfiguration anchors { @@ -227,6 +233,8 @@ Item { anchors.right: parent.right anchors.top: inputConfiguration.bottom anchors.bottom: parent.bottom + anchors.bottomMargin: keyboard.height + Loader { id: loader asynchronous: false @@ -248,6 +256,29 @@ Item { } } + 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; + } + } function inputPlugins() { if (checkBox.checked) { diff --git a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml index 2fc5cc4196..1c629349d8 100644 --- a/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml +++ b/interface/resources/qml/hifi/tablet/OpenVrConfiguration.qml @@ -32,6 +32,18 @@ Flickable { } } + function bringToView(item) { + var yTop = item.mapToItem(contentItem, 0, 0).y; + var yBottom = yTop + item.height; + + var surfaceTop = contentY; + var surfaceBottom = contentY + height; + + if(yTop < surfaceTop || yBottom > surfaceBottom) { + contentY = yTop - height / 2 + item.height + } + } + Component.onCompleted: { page = config.createObject(flick.contentItem); } @@ -39,6 +51,8 @@ Flickable { id: config Rectangle { id: openVrConfiguration + anchors.fill: parent + property int leftMargin: 75 property int countDown: 0 property string pluginName: ""