mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 18:06:57 +02:00
Merge pull request #8258 from AlexanderOtavka/edit-model-ui
Edit model dialog improvements
This commit is contained in:
commit
91714aaca6
15 changed files with 689 additions and 219 deletions
|
@ -28,6 +28,7 @@ module.exports = {
|
||||||
"ModelCache": false,
|
"ModelCache": false,
|
||||||
"MyAvatar": false,
|
"MyAvatar": false,
|
||||||
"Overlays": false,
|
"Overlays": false,
|
||||||
|
"OverlayWebWindow": false,
|
||||||
"Paths": false,
|
"Paths": false,
|
||||||
"Quat": false,
|
"Quat": false,
|
||||||
"Rates": false,
|
"Rates": false,
|
||||||
|
@ -43,6 +44,7 @@ module.exports = {
|
||||||
"Toolbars": false,
|
"Toolbars": false,
|
||||||
"Uuid": false,
|
"Uuid": false,
|
||||||
"UndoStack": false,
|
"UndoStack": false,
|
||||||
|
"UserActivityLogger": false,
|
||||||
"Vec3": false,
|
"Vec3": false,
|
||||||
"WebSocket": false,
|
"WebSocket": false,
|
||||||
"WebWindow": false,
|
"WebWindow": false,
|
||||||
|
@ -56,6 +58,7 @@ module.exports = {
|
||||||
"comma-dangle": ["error", "never"],
|
"comma-dangle": ["error", "never"],
|
||||||
"camelcase": ["error"],
|
"camelcase": ["error"],
|
||||||
"curly": ["error", "all"],
|
"curly": ["error", "all"],
|
||||||
|
"eqeqeq": ["error", "always"],
|
||||||
"indent": ["error", 4, { "SwitchCase": 1 }],
|
"indent": ["error", 4, { "SwitchCase": 1 }],
|
||||||
"keyword-spacing": ["error", { "before": true, "after": true }],
|
"keyword-spacing": ["error", { "before": true, "after": true }],
|
||||||
"max-len": ["error", 128, 4],
|
"max-len": ["error", 128, 4],
|
||||||
|
|
|
@ -65,6 +65,7 @@ Original.CheckBox {
|
||||||
colorScheme: checkBox.colorScheme
|
colorScheme: checkBox.colorScheme
|
||||||
x: checkBox.boxSize / 2
|
x: checkBox.boxSize / 2
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
|
enabled: checkBox.enabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,19 +117,22 @@ FocusScope {
|
||||||
|
|
||||||
function showList() {
|
function showList() {
|
||||||
var r = desktop.mapFromItem(root, 0, 0, root.width, root.height);
|
var r = desktop.mapFromItem(root, 0, 0, root.width, root.height);
|
||||||
listView.currentIndex = root.currentIndex
|
var y = r.y + r.height;
|
||||||
scrollView.x = r.x;
|
var bottom = y + scrollView.height;
|
||||||
scrollView.y = r.y + r.height;
|
|
||||||
var bottom = scrollView.y + scrollView.height;
|
|
||||||
if (bottom > desktop.height) {
|
if (bottom > desktop.height) {
|
||||||
scrollView.y -= bottom - desktop.height + 8;
|
y -= bottom - desktop.height + 8;
|
||||||
}
|
}
|
||||||
|
scrollView.x = r.x;
|
||||||
|
scrollView.y = y;
|
||||||
popup.visible = true;
|
popup.visible = true;
|
||||||
popup.forceActiveFocus();
|
popup.forceActiveFocus();
|
||||||
|
listView.currentIndex = root.currentIndex;
|
||||||
|
scrollView.hoverEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideList() {
|
function hideList() {
|
||||||
popup.visible = false;
|
popup.visible = false;
|
||||||
|
scrollView.hoverEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FocusScope {
|
FocusScope {
|
||||||
|
@ -161,6 +164,7 @@ FocusScope {
|
||||||
id: scrollView
|
id: scrollView
|
||||||
height: 480
|
height: 480
|
||||||
width: root.width + 4
|
width: root.width + 4
|
||||||
|
property bool hoverEnabled: false;
|
||||||
|
|
||||||
style: ScrollViewStyle {
|
style: ScrollViewStyle {
|
||||||
decrementControl: Item {
|
decrementControl: Item {
|
||||||
|
@ -193,7 +197,8 @@ FocusScope {
|
||||||
delegate: Rectangle {
|
delegate: Rectangle {
|
||||||
width: root.width + 4
|
width: root.width + 4
|
||||||
height: popupText.implicitHeight * 1.4
|
height: popupText.implicitHeight * 1.4
|
||||||
color: popupHover.containsMouse ? hifi.colors.primaryHighlight : (isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark)
|
color: (listView.currentIndex === index) ? hifi.colors.primaryHighlight :
|
||||||
|
(isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark)
|
||||||
FiraSansSemiBold {
|
FiraSansSemiBold {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: hifi.dimensions.textPadding
|
anchors.leftMargin: hifi.dimensions.textPadding
|
||||||
|
@ -206,9 +211,9 @@ FocusScope {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: popupHover
|
id: popupHover
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
hoverEnabled: true
|
hoverEnabled: scrollView.hoverEnabled;
|
||||||
onEntered: listView.currentIndex = index;
|
onEntered: listView.currentIndex = index;
|
||||||
onClicked: popup.selectSpecificItem(index)
|
onClicked: popup.selectSpecificItem(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,5 +16,6 @@ RalewaySemiBold {
|
||||||
property int colorScheme: hifi.colorSchemes.light
|
property int colorScheme: hifi.colorSchemes.light
|
||||||
|
|
||||||
size: hifi.fontSizes.inputLabel
|
size: hifi.fontSizes.inputLabel
|
||||||
color: colorScheme == hifi.colorSchemes.light ? hifi.colors.lightGray : hifi.colors.lightGrayText
|
color: enabled ? (colorScheme == hifi.colorSchemes.light ? hifi.colors.lightGray : hifi.colors.lightGrayText)
|
||||||
|
: (colorScheme == hifi.colorSchemes.light ? hifi.colors.lightGrayText : hifi.colors.baseGrayHighlight);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ FocusScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
onHeightChanged: d.handleSizeChanged();
|
onHeightChanged: d.handleSizeChanged();
|
||||||
|
|
||||||
onWidthChanged: d.handleSizeChanged();
|
onWidthChanged: d.handleSizeChanged();
|
||||||
|
|
||||||
// Controls and windows can trigger this signal to ensure the desktop becomes visible
|
// Controls and windows can trigger this signal to ensure the desktop becomes visible
|
||||||
|
@ -70,8 +70,8 @@ FocusScope {
|
||||||
}
|
}
|
||||||
var oldRecommendedRect = recommendedRect;
|
var oldRecommendedRect = recommendedRect;
|
||||||
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
|
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
|
||||||
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
|
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
|
||||||
newRecommendedRectJS.width,
|
newRecommendedRectJS.width,
|
||||||
newRecommendedRectJS.height);
|
newRecommendedRectJS.height);
|
||||||
|
|
||||||
var oldChildren = expectedChildren;
|
var oldChildren = expectedChildren;
|
||||||
|
@ -366,8 +366,8 @@ FocusScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
|
var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect();
|
||||||
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
|
var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y,
|
||||||
newRecommendedRectJS.width,
|
newRecommendedRectJS.width,
|
||||||
newRecommendedRectJS.height);
|
newRecommendedRectJS.height);
|
||||||
var newRecommendedDimmensions = { x: newRecommendedRect.width, y: newRecommendedRect.height };
|
var newRecommendedDimmensions = { x: newRecommendedRect.width, y: newRecommendedRect.height };
|
||||||
var newX = newRecommendedRect.x + ((newRecommendedRect.width - targetWindow.width) / 2);
|
var newX = newRecommendedRect.x + ((newRecommendedRect.width - targetWindow.width) / 2);
|
||||||
|
@ -402,7 +402,7 @@ FocusScope {
|
||||||
repositionWindow(targetWindow, false, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions);
|
repositionWindow(targetWindow, false, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function repositionWindow(targetWindow, forceReposition,
|
function repositionWindow(targetWindow, forceReposition,
|
||||||
oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions) {
|
oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions) {
|
||||||
|
|
||||||
if (desktop.width === 0 || desktop.height === 0) {
|
if (desktop.width === 0 || desktop.height === 0) {
|
||||||
|
@ -456,6 +456,11 @@ FocusScope {
|
||||||
return inputDialogBuilder.createObject(desktop, properties);
|
return inputDialogBuilder.createObject(desktop, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component { id: customInputDialogBuilder; CustomQueryDialog { } }
|
||||||
|
function customInputDialog(properties) {
|
||||||
|
return customInputDialogBuilder.createObject(desktop, properties);
|
||||||
|
}
|
||||||
|
|
||||||
Component { id: fileDialogBuilder; FileDialog { } }
|
Component { id: fileDialogBuilder; FileDialog { } }
|
||||||
function fileDialog(properties) {
|
function fileDialog(properties) {
|
||||||
return fileDialogBuilder.createObject(desktop, properties);
|
return fileDialogBuilder.createObject(desktop, properties);
|
||||||
|
@ -487,7 +492,7 @@ FocusScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unfocusWindows() {
|
function unfocusWindows() {
|
||||||
// First find the active focus item, and unfocus it, all the way
|
// First find the active focus item, and unfocus it, all the way
|
||||||
// up the parent chain to the window
|
// up the parent chain to the window
|
||||||
var currentFocus = offscreenWindow.activeFocusItem;
|
var currentFocus = offscreenWindow.activeFocusItem;
|
||||||
var targetWindow = d.getDesktopWindow(currentFocus);
|
var targetWindow = d.getDesktopWindow(currentFocus);
|
||||||
|
|
300
interface/resources/qml/dialogs/CustomQueryDialog.qml
Normal file
300
interface/resources/qml/dialogs/CustomQueryDialog.qml
Normal file
|
@ -0,0 +1,300 @@
|
||||||
|
//
|
||||||
|
// CustomQueryDialog.qml
|
||||||
|
//
|
||||||
|
// Created by Zander Otavka on 7/14/16
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
import QtQuick 2.5;
|
||||||
|
import QtQuick.Controls 1.4;
|
||||||
|
import QtQuick.Dialogs 1.2 as OriginalDialogs;
|
||||||
|
|
||||||
|
import "../controls-uit";
|
||||||
|
import "../styles-uit";
|
||||||
|
import "../windows";
|
||||||
|
|
||||||
|
ModalWindow {
|
||||||
|
id: root;
|
||||||
|
HifiConstants { id: hifi; }
|
||||||
|
implicitWidth: 640;
|
||||||
|
implicitHeight: 320;
|
||||||
|
visible: true;
|
||||||
|
|
||||||
|
signal selected(var result);
|
||||||
|
signal canceled();
|
||||||
|
|
||||||
|
property int icon: hifi.icons.none;
|
||||||
|
property string iconText: "";
|
||||||
|
property int iconSize: 35;
|
||||||
|
onIconChanged: updateIcon();
|
||||||
|
|
||||||
|
property var textInput;
|
||||||
|
property var comboBox;
|
||||||
|
property var checkBox;
|
||||||
|
onTextInputChanged: {
|
||||||
|
if (textInput && textInput.text !== undefined) {
|
||||||
|
textField.text = textInput.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onComboBoxChanged: {
|
||||||
|
if (comboBox && comboBox.index !== undefined) {
|
||||||
|
comboBoxField.currentIndex = comboBox.index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onCheckBoxChanged: {
|
||||||
|
if (checkBox && checkBox.checked !== undefined) {
|
||||||
|
checkBoxField.checked = checkBox.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property var warning: "";
|
||||||
|
property var result;
|
||||||
|
|
||||||
|
property var implicitCheckState: null;
|
||||||
|
|
||||||
|
property int titleWidth: 0;
|
||||||
|
onTitleWidthChanged: d.resize();
|
||||||
|
|
||||||
|
function updateIcon() {
|
||||||
|
if (!root) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
iconText = hifi.glyphForIcon(root.icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCheckbox() {
|
||||||
|
if (checkBox.disableForItems) {
|
||||||
|
var currentItemInDisableList = false;
|
||||||
|
for (var i in checkBox.disableForItems) {
|
||||||
|
if (comboBoxField.currentIndex === checkBox.disableForItems[i]) {
|
||||||
|
currentItemInDisableList = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentItemInDisableList) {
|
||||||
|
checkBoxField.enabled = false;
|
||||||
|
if (checkBox.checkStateOnDisable !== null && checkBox.checkStateOnDisable !== undefined) {
|
||||||
|
root.implicitCheckState = checkBoxField.checked;
|
||||||
|
checkBoxField.checked = checkBox.checkStateOnDisable;
|
||||||
|
}
|
||||||
|
root.warning = checkBox.warningOnDisable;
|
||||||
|
} else {
|
||||||
|
checkBoxField.enabled = true;
|
||||||
|
if (root.implicitCheckState !== null) {
|
||||||
|
checkBoxField.checked = root.implicitCheckState;
|
||||||
|
root.implicitCheckState = null;
|
||||||
|
}
|
||||||
|
root.warning = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
clip: true;
|
||||||
|
width: pane.width;
|
||||||
|
height: pane.height;
|
||||||
|
anchors.margins: 0;
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: d;
|
||||||
|
readonly property int minWidth: 480;
|
||||||
|
readonly property int maxWdith: 1280;
|
||||||
|
readonly property int minHeight: 120;
|
||||||
|
readonly property int maxHeight: 720;
|
||||||
|
|
||||||
|
function resize() {
|
||||||
|
var targetWidth = Math.max(titleWidth, pane.width);
|
||||||
|
var targetHeight = (textField.visible ? textField.controlHeight + hifi.dimensions.contentSpacing.y : 0) +
|
||||||
|
(extraInputs.visible ? extraInputs.height + hifi.dimensions.contentSpacing.y : 0) +
|
||||||
|
(buttons.height + 3 * hifi.dimensions.contentSpacing.y);
|
||||||
|
root.width = (targetWidth < d.minWidth) ? d.minWidth : ((targetWidth > d.maxWdith) ? d.maxWidth : targetWidth);
|
||||||
|
root.height = (targetHeight < d.minHeight) ? d.minHeight : ((targetHeight > d.maxHeight) ?
|
||||||
|
d.maxHeight : targetHeight);
|
||||||
|
if (checkBoxField.visible && comboBoxField.visible) {
|
||||||
|
checkBoxField.width = extraInputs.width / 2;
|
||||||
|
comboBoxField.width = extraInputs.width / 2;
|
||||||
|
} else if (!checkBoxField.visible && comboBoxField.visible) {
|
||||||
|
comboBoxField.width = extraInputs.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors {
|
||||||
|
top: parent.top;
|
||||||
|
bottom: extraInputs.visible ? extraInputs.top : buttons.top;
|
||||||
|
left: parent.left;
|
||||||
|
right: parent.right;
|
||||||
|
margins: 0;
|
||||||
|
bottomMargin: hifi.dimensions.contentSpacing.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME make a text field type that can be bound to a history for autocompletion
|
||||||
|
TextField {
|
||||||
|
id: textField;
|
||||||
|
label: root.textInput.label;
|
||||||
|
focus: root.textInput ? true : false;
|
||||||
|
visible: root.textInput ? true : false;
|
||||||
|
anchors {
|
||||||
|
left: parent.left;
|
||||||
|
right: parent.right;
|
||||||
|
bottom: parent.bottom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: extraInputs;
|
||||||
|
visible: Boolean(root.checkBox || root.comboBox);
|
||||||
|
anchors {
|
||||||
|
left: parent.left;
|
||||||
|
right: parent.right;
|
||||||
|
bottom: buttons.top;
|
||||||
|
bottomMargin: hifi.dimensions.contentSpacing.y;
|
||||||
|
}
|
||||||
|
height: comboBoxField.controlHeight;
|
||||||
|
onHeightChanged: d.resize();
|
||||||
|
onWidthChanged: d.resize();
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: checkBoxField;
|
||||||
|
text: root.checkBox.label;
|
||||||
|
focus: Boolean(root.checkBox);
|
||||||
|
visible: Boolean(root.checkBox);
|
||||||
|
anchors {
|
||||||
|
left: parent.left;
|
||||||
|
bottom: parent.bottom;
|
||||||
|
leftMargin: 6; // Magic number to align with warning icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: comboBoxField;
|
||||||
|
label: root.comboBox.label;
|
||||||
|
focus: Boolean(root.comboBox);
|
||||||
|
visible: Boolean(root.comboBox);
|
||||||
|
anchors {
|
||||||
|
right: parent.right;
|
||||||
|
bottom: parent.bottom;
|
||||||
|
}
|
||||||
|
model: root.comboBox ? root.comboBox.items : [];
|
||||||
|
onCurrentTextChanged: updateCheckbox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: buttons;
|
||||||
|
focus: true;
|
||||||
|
spacing: hifi.dimensions.contentSpacing.x;
|
||||||
|
layoutDirection: Qt.RightToLeft;
|
||||||
|
onHeightChanged: d.resize();
|
||||||
|
onWidthChanged: {
|
||||||
|
d.resize();
|
||||||
|
resizeWarningText();
|
||||||
|
}
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
bottom: parent.bottom;
|
||||||
|
left: parent.left;
|
||||||
|
right: parent.right;
|
||||||
|
bottomMargin: hifi.dimensions.contentSpacing.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resizeWarningText() {
|
||||||
|
var rowWidth = buttons.width;
|
||||||
|
var buttonsWidth = acceptButton.width + cancelButton.width + hifi.dimensions.contentSpacing.x * 2;
|
||||||
|
var warningIconWidth = warningIcon.width + hifi.dimensions.contentSpacing.x;
|
||||||
|
warningText.width = rowWidth - buttonsWidth - warningIconWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: cancelButton;
|
||||||
|
action: cancelAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: acceptButton;
|
||||||
|
action: acceptAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: warningText;
|
||||||
|
visible: Boolean(root.warning);
|
||||||
|
text: root.warning;
|
||||||
|
wrapMode: Text.WordWrap;
|
||||||
|
font.italic: true;
|
||||||
|
maximumLineCount: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
HiFiGlyphs {
|
||||||
|
id: warningIcon;
|
||||||
|
visible: Boolean(root.warning);
|
||||||
|
text: hifi.glyphs.alert;
|
||||||
|
size: hifi.dimensions.controlLineHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Action {
|
||||||
|
id: cancelAction;
|
||||||
|
text: qsTr("Cancel");
|
||||||
|
shortcut: Qt.Key_Escape;
|
||||||
|
onTriggered: {
|
||||||
|
root.result = null;
|
||||||
|
root.canceled();
|
||||||
|
root.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Action {
|
||||||
|
id: acceptAction;
|
||||||
|
text: qsTr("Add");
|
||||||
|
shortcut: Qt.Key_Return;
|
||||||
|
onTriggered: {
|
||||||
|
var result = {};
|
||||||
|
if (textInput) {
|
||||||
|
result.textInput = textField.text;
|
||||||
|
}
|
||||||
|
if (comboBox) {
|
||||||
|
result.comboBox = comboBoxField.currentIndex;
|
||||||
|
result.comboBoxText = comboBoxField.currentText;
|
||||||
|
}
|
||||||
|
if (checkBox) {
|
||||||
|
result.checkBox = checkBoxField.enabled ? checkBoxField.checked : null;
|
||||||
|
}
|
||||||
|
root.result = JSON.stringify(result);
|
||||||
|
root.selected(root.result);
|
||||||
|
root.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onPressed: {
|
||||||
|
if (!visible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (event.key) {
|
||||||
|
case Qt.Key_Escape:
|
||||||
|
case Qt.Key_Back:
|
||||||
|
cancelAction.trigger();
|
||||||
|
event.accepted = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt.Key_Return:
|
||||||
|
case Qt.Key_Enter:
|
||||||
|
acceptAction.trigger();
|
||||||
|
event.accepted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
updateIcon();
|
||||||
|
d.resize();
|
||||||
|
textField.forceActiveFocus();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4715,6 +4715,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Toolbars", DependencyManager::get<ToolbarScriptingInterface>().data());
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
||||||
|
qScriptRegisterMetaType(scriptEngine, CustomPromptResultToScriptValue, CustomPromptResultFromScriptValue);
|
||||||
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
||||||
LocationScriptingInterface::locationSetter, "Window");
|
LocationScriptingInterface::locationSetter, "Window");
|
||||||
// register `location` on the global object.
|
// register `location` on the global object.
|
||||||
|
|
|
@ -29,6 +29,20 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda
|
||||||
static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";
|
static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";
|
||||||
|
|
||||||
|
|
||||||
|
QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const CustomPromptResult& result) {
|
||||||
|
if (!result.value.isValid()) {
|
||||||
|
return QScriptValue::UndefinedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_ASSERT(result.value.userType() == qMetaTypeId<QVariantMap>());
|
||||||
|
return engine->toScriptValue(result.value.toMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result) {
|
||||||
|
result.value = object.toVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WindowScriptingInterface::WindowScriptingInterface() {
|
WindowScriptingInterface::WindowScriptingInterface() {
|
||||||
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
||||||
|
@ -95,6 +109,14 @@ QScriptValue WindowScriptingInterface::prompt(const QString& message, const QStr
|
||||||
return ok ? QScriptValue(result) : QScriptValue::NullValue;
|
return ok ? QScriptValue(result) : QScriptValue::NullValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) {
|
||||||
|
CustomPromptResult result;
|
||||||
|
bool ok = false;
|
||||||
|
auto configMap = config.toMap();
|
||||||
|
result.value = OffscreenUi::getCustomInfo(OffscreenUi::ICON_NONE, "", configMap, &ok);
|
||||||
|
return ok ? result : CustomPromptResult();
|
||||||
|
}
|
||||||
|
|
||||||
QString fixupPathForMac(const QString& directory) {
|
QString fixupPathForMac(const QString& directory) {
|
||||||
// On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
|
// On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
|
||||||
// filename if the directory is valid.
|
// filename if the directory is valid.
|
||||||
|
|
|
@ -18,6 +18,18 @@
|
||||||
|
|
||||||
class WebWindowClass;
|
class WebWindowClass;
|
||||||
|
|
||||||
|
|
||||||
|
class CustomPromptResult {
|
||||||
|
public:
|
||||||
|
QVariant value;
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CustomPromptResult);
|
||||||
|
|
||||||
|
QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const CustomPromptResult& result);
|
||||||
|
void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result);
|
||||||
|
|
||||||
|
|
||||||
class WindowScriptingInterface : public QObject, public Dependency {
|
class WindowScriptingInterface : public QObject, public Dependency {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int innerWidth READ getInnerWidth)
|
Q_PROPERTY(int innerWidth READ getInnerWidth)
|
||||||
|
@ -38,6 +50,7 @@ public slots:
|
||||||
void alert(const QString& message = "");
|
void alert(const QString& message = "");
|
||||||
QScriptValue confirm(const QString& message = "");
|
QScriptValue confirm(const QString& message = "");
|
||||||
QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
|
QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
|
||||||
|
CustomPromptResult customPrompt(const QVariant& config);
|
||||||
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
QScriptValue save(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
void copyToClipboard(const QString& text);
|
void copyToClipboard(const QString& text);
|
||||||
|
|
|
@ -700,11 +700,12 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
}
|
}
|
||||||
info.setParams(type, dimensions, _compoundShapeURL);
|
info.setParams(type, dimensions, _compoundShapeURL);
|
||||||
} else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) {
|
} else if (type >= SHAPE_TYPE_SIMPLE_HULL && type <= SHAPE_TYPE_STATIC_MESH) {
|
||||||
updateModelBounds();
|
|
||||||
|
|
||||||
// should never fall in here when model not fully loaded
|
// should never fall in here when model not fully loaded
|
||||||
assert(_model && _model->isLoaded());
|
assert(_model && _model->isLoaded());
|
||||||
|
|
||||||
|
updateModelBounds();
|
||||||
|
_model->updateGeometry();
|
||||||
|
|
||||||
// compute meshPart local transforms
|
// compute meshPart local transforms
|
||||||
QVector<glm::mat4> localTransforms;
|
QVector<glm::mat4> localTransforms;
|
||||||
const FBXGeometry& fbxGeometry = _model->getFBXGeometry();
|
const FBXGeometry& fbxGeometry = _model->getFBXGeometry();
|
||||||
|
|
|
@ -69,7 +69,6 @@ static const btVector3 _unitSphereDirections[NUM_UNIT_SPHERE_DIRECTIONS] = {
|
||||||
|
|
||||||
// util method
|
// util method
|
||||||
btConvexHullShape* createConvexHull(const ShapeInfo::PointList& points) {
|
btConvexHullShape* createConvexHull(const ShapeInfo::PointList& points) {
|
||||||
//std::cout << "adebug createConvexHull() points.size() = " << points.size() << std::endl; // adebug
|
|
||||||
assert(points.size() > 0);
|
assert(points.size() > 0);
|
||||||
|
|
||||||
btConvexHullShape* hull = new btConvexHullShape();
|
btConvexHullShape* hull = new btConvexHullShape();
|
||||||
|
@ -241,7 +240,6 @@ void deleteStaticMeshArray(btTriangleIndexVertexArray* dataArray) {
|
||||||
btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info) {
|
btCollisionShape* ShapeFactory::createShapeFromInfo(const ShapeInfo& info) {
|
||||||
btCollisionShape* shape = NULL;
|
btCollisionShape* shape = NULL;
|
||||||
int type = info.getType();
|
int type = info.getType();
|
||||||
//std::cout << "adebug createShapeFromInfo() type = " << type << std::endl; // adebug
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SHAPE_TYPE_BOX: {
|
case SHAPE_TYPE_BOX: {
|
||||||
shape = new btBoxShape(glmToBullet(info.getHalfExtents()));
|
shape = new btBoxShape(glmToBullet(info.getHalfExtents()));
|
||||||
|
|
|
@ -84,6 +84,7 @@ public:
|
||||||
bool readyToAddToScene(RenderArgs* renderArgs = nullptr) const {
|
bool readyToAddToScene(RenderArgs* renderArgs = nullptr) const {
|
||||||
return !_needsReload && isRenderable() && isActive();
|
return !_needsReload && isRenderable() && isActive();
|
||||||
}
|
}
|
||||||
|
bool needsReload() const { return _needsReload; }
|
||||||
bool initWhenReady(render::ScenePointer scene);
|
bool initWhenReady(render::ScenePointer scene);
|
||||||
bool addToScene(std::shared_ptr<render::Scene> scene,
|
bool addToScene(std::shared_ptr<render::Scene> scene,
|
||||||
render::PendingChanges& pendingChanges,
|
render::PendingChanges& pendingChanges,
|
||||||
|
@ -232,6 +233,9 @@ public:
|
||||||
|
|
||||||
const glm::vec3& getRegistrationPoint() const { return _registrationPoint; }
|
const glm::vec3& getRegistrationPoint() const { return _registrationPoint; }
|
||||||
|
|
||||||
|
// returns 'true' if needs fullUpdate after geometry change
|
||||||
|
bool updateGeometry();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void setPupilDilation(float dilation) { _pupilDilation = dilation; }
|
void setPupilDilation(float dilation) { _pupilDilation = dilation; }
|
||||||
|
@ -297,9 +301,6 @@ protected:
|
||||||
std::unordered_set<int> _cauterizeBoneSet;
|
std::unordered_set<int> _cauterizeBoneSet;
|
||||||
bool _cauterizeBones;
|
bool _cauterizeBones;
|
||||||
|
|
||||||
// returns 'true' if needs fullUpdate after geometry change
|
|
||||||
bool updateGeometry();
|
|
||||||
|
|
||||||
virtual void initJointStates();
|
virtual void initJointStates();
|
||||||
|
|
||||||
void setScaleInternal(const glm::vec3& scale);
|
void setScaleInternal(const glm::vec3& scale);
|
||||||
|
|
|
@ -343,6 +343,23 @@ QString OffscreenUi::getItem(const Icon icon, const QString& title, const QStrin
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant OffscreenUi::getCustomInfo(const Icon icon, const QString& title, const QVariantMap& config, bool* ok) {
|
||||||
|
if (ok) {
|
||||||
|
*ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant result = DependencyManager::get<OffscreenUi>()->customInputDialog(icon, title, config);
|
||||||
|
if (result.isValid()) {
|
||||||
|
// We get a JSON encoded result, so we unpack it into a QVariant wrapping a QVariantMap
|
||||||
|
result = QVariant(QJsonDocument::fromJson(result.toString().toUtf8()).object().toVariantMap());
|
||||||
|
if (ok) {
|
||||||
|
*ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant OffscreenUi::inputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current) {
|
QVariant OffscreenUi::inputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QVariant result;
|
QVariant result;
|
||||||
|
@ -358,6 +375,20 @@ QVariant OffscreenUi::inputDialog(const Icon icon, const QString& title, const Q
|
||||||
return waitForInputDialogResult(createInputDialog(icon, title, label, current));
|
return waitForInputDialogResult(createInputDialog(icon, title, label, current));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant OffscreenUi::customInputDialog(const Icon icon, const QString& title, const QVariantMap& config) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QVariant result;
|
||||||
|
QMetaObject::invokeMethod(this, "customInputDialog", Qt::BlockingQueuedConnection,
|
||||||
|
Q_RETURN_ARG(QVariant, result),
|
||||||
|
Q_ARG(Icon, icon),
|
||||||
|
Q_ARG(QString, title),
|
||||||
|
Q_ARG(QVariantMap, config));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return waitForInputDialogResult(createCustomInputDialog(icon, title, config));
|
||||||
|
}
|
||||||
|
|
||||||
void OffscreenUi::togglePinned() {
|
void OffscreenUi::togglePinned() {
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "togglePinned");
|
bool invokeResult = QMetaObject::invokeMethod(_desktop, "togglePinned");
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
|
@ -401,6 +432,23 @@ QQuickItem* OffscreenUi::createInputDialog(const Icon icon, const QString& title
|
||||||
return qvariant_cast<QQuickItem*>(result);
|
return qvariant_cast<QQuickItem*>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QQuickItem* OffscreenUi::createCustomInputDialog(const Icon icon, const QString& title, const QVariantMap& config) {
|
||||||
|
QVariantMap map = config;
|
||||||
|
map.insert("title", title);
|
||||||
|
map.insert("icon", icon);
|
||||||
|
QVariant result;
|
||||||
|
bool invokeResult = QMetaObject::invokeMethod(_desktop, "customInputDialog",
|
||||||
|
Q_RETURN_ARG(QVariant, result),
|
||||||
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
|
|
||||||
|
if (!invokeResult) {
|
||||||
|
qWarning() << "Failed to create custom message box";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return qvariant_cast<QQuickItem*>(result);
|
||||||
|
}
|
||||||
|
|
||||||
QVariant OffscreenUi::waitForInputDialogResult(QQuickItem* inputDialog) {
|
QVariant OffscreenUi::waitForInputDialogResult(QQuickItem* inputDialog) {
|
||||||
if (!inputDialog) {
|
if (!inputDialog) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
|
@ -122,7 +122,9 @@ public:
|
||||||
static QString getSaveFileName(void* ignored, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
static QString getSaveFileName(void* ignored, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString *selectedFilter = 0, QFileDialog::Options options = 0);
|
||||||
|
|
||||||
Q_INVOKABLE QVariant inputDialog(const Icon icon, const QString& title, const QString& label = QString(), const QVariant& current = QVariant());
|
Q_INVOKABLE QVariant inputDialog(const Icon icon, const QString& title, const QString& label = QString(), const QVariant& current = QVariant());
|
||||||
|
Q_INVOKABLE QVariant customInputDialog(const Icon icon, const QString& title, const QVariantMap& config);
|
||||||
QQuickItem* createInputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current);
|
QQuickItem* createInputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current);
|
||||||
|
QQuickItem* createCustomInputDialog(const Icon icon, const QString& title, const QVariantMap& config);
|
||||||
QVariant waitForInputDialogResult(QQuickItem* inputDialog);
|
QVariant waitForInputDialogResult(QQuickItem* inputDialog);
|
||||||
|
|
||||||
// Compatibility with QInputDialog::getText
|
// Compatibility with QInputDialog::getText
|
||||||
|
@ -140,6 +142,7 @@ public:
|
||||||
|
|
||||||
static QString getText(const Icon icon, const QString & title, const QString & label, const QString & text = QString(), bool * ok = 0);
|
static QString getText(const Icon icon, const QString & title, const QString & label, const QString & text = QString(), bool * ok = 0);
|
||||||
static QString getItem(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true, bool * ok = 0);
|
static QString getItem(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true, bool * ok = 0);
|
||||||
|
static QVariant getCustomInfo(const Icon icon, const QString& title, const QVariantMap& config, bool* ok = 0);
|
||||||
|
|
||||||
unsigned int getMenuUserDataId() const;
|
unsigned int getMenuUserDataId() const;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue