Make Save and Cancel buttons close preferences dialog

This commit is contained in:
David Rowe 2017-03-04 15:27:31 +13:00
parent 53cfad65cd
commit 0333122b23
2 changed files with 34 additions and 20 deletions

View file

@ -31,12 +31,18 @@ Item {
property bool keyboardEnabled: false
property bool keyboardRaised: false
property bool punctuationMode: false
property var tablet;
function saveAll() {
dialog.forceActiveFocus(); // Accept any text box edits in progress.
for (var i = 0; i < sections.length; ++i) {
var section = sections[i];
section.saveAll();
}
closeDialog();
}
function restoreAll() {
@ -44,6 +50,12 @@ Item {
var section = sections[i];
section.restoreAll();
}
closeDialog();
}
function closeDialog() {
Tablet.getTablet("com.highfidelity.interface.tablet.system").gotoHomeScreen();
}
Rectangle {
@ -164,6 +176,24 @@ Item {
}
}
MouseArea {
// Defocuses the current control so that the HMD keyboard gets hidden.
// Created under the footer so that the non-button part of the footer can defocus a control.
id: mouseArea
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: keyboard.top
}
propagateComposedEvents: true
acceptedButtons: Qt.AllButtons
onPressed: {
parent.forceActiveFocus();
mouse.accepted = false;
}
}
Rectangle {
id: footer
height: 40
@ -196,13 +226,13 @@ Item {
HifiControls.Button {
text: "Save changes"
color: hifi.buttons.blue
onClicked: root.saveAll()
onClicked: dialog.saveAll()
}
HifiControls.Button {
text: "Cancel"
color: hifi.buttons.white
onClicked: root.restoreAll()
onClicked: dialog.restoreAll()
}
}
}
@ -219,6 +249,7 @@ Item {
}
Component.onCompleted: {
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
keyboardEnabled = HMD.active;
}
@ -230,22 +261,4 @@ Item {
}
}
}
MouseArea {
// Defocuses the current control so that the HMD keyboard gets hidden.
id: mouseArea
anchors {
top: parent.top
left: parent.left
right: parent.right
bottom: keyboard.top
}
propagateComposedEvents: true
acceptedButtons: Qt.AllButtons
enabled: window.visible
onPressed: {
parent.forceActiveFocus();
mouse.accepted = false;
}
}
}

View file

@ -173,6 +173,7 @@ void Web3DOverlay::loadSourceURL() {
_webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
_webSurface->getRootContext()->setContextProperty("fileDialogHelper", new FileDialogHelper());
_webSurface->getRootContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get<ScriptEngines>().data());
_webSurface->getRootContext()->setContextProperty("Tablet", DependencyManager::get<TabletScriptingInterface>().data());
_webSurface->getRootContext()->setContextProperty("pathToFonts", "../../../");
tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data());