fix comboBox and PushOntoStack

This commit is contained in:
Dante Ruiz 2017-02-28 21:30:25 +00:00
parent 50471db376
commit f0f2b8c4da
3 changed files with 46 additions and 20 deletions

View file

@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4
import "../styles-uit" import "../styles-uit"
import "../controls-uit" as HifiControls import "../controls-uit" as HifiControls
import "." as VrControls //import "." as VrControls
FocusScope { FocusScope {
id: root id: root
@ -119,14 +119,14 @@ FocusScope {
} }
function showList() { function showList() {
var r = 20//desktop.mapFromItem(root, 0, 0, root.width, root.height); var r = mapFromItem(root, 0, 0, root.width, root.height);
var y = 200; var y = r.y + r.height;
var bottom = 0 + scrollView.height; var bottom = y + scrollView.height;
if (bottom > 720) { if (bottom > 720) {
y -= bottom - 720 + 8; y -= bottom - tabletRoot.height + 8;
} }
scrollView.x = 0; scrollView.x = r.x;
scrollView.y = 0; scrollView.y = y;
popup.visible = true; popup.visible = true;
popup.forceActiveFocus(); popup.forceActiveFocus();
listView.currentIndex = root.currentIndex; listView.currentIndex = root.currentIndex;
@ -141,6 +141,7 @@ FocusScope {
FocusScope { FocusScope {
id: popup id: popup
z: 12
parent: parent parent: parent
anchors.fill: parent anchors.fill: parent
visible: false visible: false

View file

@ -11,12 +11,15 @@
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import "../../styles-uit"
import "../../controls-uit"
Rectangle { Rectangle {
id: newModelDialog id: newModelDialog
// width: parent.width // width: parent.width
// height: parent.height // height: parent.height
HifiConstants { id: hifi }
color: hifi.colors.baseGray;
property var eventBridge; property var eventBridge;
signal sendToScript(var message); signal sendToScript(var message);
@ -32,6 +35,7 @@ Rectangle {
Text { Text {
id: text1 id: text1
text: qsTr("Model URL") text: qsTr("Model URL")
color: "#ffffff"
font.pixelSize: 12 font.pixelSize: 12
} }
@ -64,6 +68,7 @@ Rectangle {
CheckBox { CheckBox {
id: dynamic id: dynamic
text: qsTr("Dynamic") text: qsTr("Dynamic")
} }
Row { Row {
@ -82,6 +87,7 @@ Rectangle {
Text { Text {
id: text2 id: text2
width: 160 width: 160
color: "#ffffff"
text: qsTr("Models with automatic collisions set to 'Exact' cannot be dynamic") text: qsTr("Models with automatic collisions set to 'Exact' cannot be dynamic")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
font.pixelSize: 12 font.pixelSize: 12
@ -97,30 +103,34 @@ Rectangle {
Text { Text {
id: text3 id: text3
text: qsTr("Automatic Collisions") text: qsTr("Automatic Collisions")
color: "#ffffff"
font.pixelSize: 12 font.pixelSize: 12
} }
ComboBox { TabletComboBox {
id: collisionType id: collisionType
width: 200 width: 200
z: 100
transformOrigin: Item.Center transformOrigin: Item.Center
model: ListModel { model: ["No Collision",
id: collisionDropdown "Basic - Whole model",
ListElement { text: "No Collision" } "Good - Sub-meshes",
ListElement { text: "Basic - Whole model" } "Exact - All polygons"]
ListElement { text: "Good - Sub-meshes" }
ListElement { text: "Exact - All polygons" }
}
} }
Row { Row {
id: row3 id: row3
width: 200 width: 200
height: 400 height: 400
spacing: 5
anchors {
rightMargin: 15
}
Button { Button {
id: button1 id: button1
text: qsTr("Add") text: qsTr("Add")
z: -1
onClicked: { onClicked: {
newModelDialog.sendToScript({ newModelDialog.sendToScript({
method: "newModelDialogAdd", method: "newModelDialogAdd",
@ -135,6 +145,7 @@ Rectangle {
Button { Button {
id: button2 id: button2
z: -1
text: qsTr("Cancel") text: qsTr("Cancel")
onClicked: { onClicked: {
newModelDialog.sendToScript({method: "newModelDialogCancel"}) newModelDialog.sendToScript({method: "newModelDialogCancel"})

View file

@ -344,8 +344,15 @@ void TabletProxy::pushOntoStack(const QVariant& path) {
} else { } else {
qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack"; qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack";
} }
} else if (_desktopWindow) {
auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack");
if (stack) {
QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path));
} else {
qCDebug(scriptengine) << "tablet cannot push QML because _desktopWindow doesn't have child stack";
}
} else { } else {
qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot is null"; qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null";
} }
} }
@ -355,10 +362,17 @@ void TabletProxy::popFromStack() {
if (stack) { if (stack) {
QMetaObject::invokeMethod(stack, "popSource"); QMetaObject::invokeMethod(stack, "popSource");
} else { } else {
qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot doesn't have child stack"; qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack";
}
} else if (_desktopWindow) {
auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack");
if (stack) {
QMetaObject::invokeMethod(stack, "popSource");
} else {
qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack";
} }
} else { } else {
qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot is null"; qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot or _desktopWindow is null";
} }
} }