Merge pull request #8 from druiz17/tablet-edit-js

fixed combobox and pushOntoStack
This commit is contained in:
Seth Alves 2017-02-28 13:53:59 -08:00 committed by GitHub
commit 319c5f69e7
3 changed files with 45 additions and 20 deletions

View file

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

View file

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

View file

@ -344,8 +344,15 @@ void TabletProxy::pushOntoStack(const QVariant& path) {
} else {
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 {
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) {
QMetaObject::invokeMethod(stack, "popSource");
} 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 {
qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot is null";
qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot or _desktopWindow is null";
}
}