Make QueryDioalogs buttons works

This commit is contained in:
vladest 2017-11-15 20:32:28 +01:00
parent 6b732804eb
commit 2852375285
2 changed files with 22 additions and 13 deletions

View file

@ -8,7 +8,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.5
import QtQuick 2.7
import QtQuick.Controls 2.2 as Original
import TabletScriptingInterface 1.0
@ -22,7 +22,7 @@ Original.Button {
property string buttonGlyph: "";
//TODO: add real Action item. Backport from Qt 5.10
property QtObject action: null
property Shortcut action: null
width: 120
height: hifi.dimensions.controlLineHeight
@ -37,6 +37,9 @@ Original.Button {
onClicked: {
tabletInterface.playSound(TabletEnums.ButtonClick);
if (action !== null) {
action.activated()
}
}
background: Rectangle {

View file

@ -9,7 +9,7 @@
//
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2 as OriginalDialogs
import "../controls-uit"
@ -145,24 +145,30 @@ ModalWindow {
margins: 0
bottomMargin: hifi.dimensions.contentSpacing.y
}
Button { action: cancelAction }
Button { action: acceptAction }
Button {
action: cancelAction;
text: qsTr("Cancel");
}
Action {
Button {
action: acceptAction
text: qsTr("OK");
}
}
Shortcut {
id: cancelAction
text: qsTr("Cancel")
shortcut: Qt.Key_Escape
onTriggered: {
sequence: Qt.Key_Escape
onActivated: {
root.canceled();
root.destroy();
}
}
Action {
Shortcut {
id: acceptAction
text: qsTr("OK")
shortcut: Qt.Key_Return
onTriggered: {
sequence: Qt.Key_Return
onActivated: {
root.result = items ? comboBox.currentText : textResult.text
root.selected(root.result);
root.destroy();