mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Beginning of stack stuff
This commit is contained in:
parent
45424f0cfe
commit
1493a310af
2 changed files with 56 additions and 4 deletions
|
@ -240,7 +240,9 @@ Rectangle {
|
|||
anchors.leftMargin: 20;
|
||||
width: parent.width/2 - anchors.leftMargin*2;
|
||||
text: "Cancel"
|
||||
//onClicked: deleteAttachment(root.attachment);
|
||||
onClicked: {
|
||||
sendToScript({method: 'checkout_cancelClicked'});
|
||||
}
|
||||
}
|
||||
|
||||
// "Buy" button
|
||||
|
@ -255,7 +257,9 @@ Rectangle {
|
|||
anchors.rightMargin: 20;
|
||||
width: parent.width/2 - anchors.rightMargin*2;
|
||||
text: "Buy"
|
||||
//onClicked: deleteAttachment(root.attachment);
|
||||
onClicked: {
|
||||
sendToScript({method: 'checkout_buyClicked'});
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -281,7 +285,6 @@ Rectangle {
|
|||
function fromScript(message) {
|
||||
switch (message.method) {
|
||||
case 'updateCheckoutQML':
|
||||
console.log("ZRF:", JSON.stringify(message));
|
||||
itemNameText.text = message.params.itemName;
|
||||
itemAuthorText.text = message.params.itemAuthor;
|
||||
itemPriceText.text = message.params.itemPrice;
|
||||
|
|
|
@ -131,7 +131,8 @@
|
|||
}
|
||||
|
||||
function onScreenChanged(type, url) {
|
||||
onMarketplaceScreen = type === "Web" && url === MARKETPLACE_URL_INITIAL
|
||||
onMarketplaceScreen = type === "Web" && url === MARKETPLACE_URL_INITIAL;
|
||||
wireEventBridge(type === "QML" && url === MARKETPLACE_CHECKOUT_QML_PATH);
|
||||
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
||||
marketplaceButton.editProperties({ isActive: onMarketplaceScreen });
|
||||
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
||||
|
@ -154,4 +155,52 @@
|
|||
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Function Name: wireEventBridge()
|
||||
//
|
||||
// Description:
|
||||
// -Used to connect/disconnect the script's response to the tablet's "fromQml" signal. Set the "on" argument to enable or
|
||||
// disable to event bridge.
|
||||
//
|
||||
// Relevant Variables:
|
||||
// -hasEventBridge: true/false depending on whether we've already connected the event bridge.
|
||||
var hasEventBridge = false;
|
||||
function wireEventBridge(on) {
|
||||
if (!tablet) {
|
||||
print("Warning in wireEventBridge(): 'tablet' undefined!");
|
||||
return;
|
||||
}
|
||||
if (on) {
|
||||
if (!hasEventBridge) {
|
||||
tablet.fromQml.connect(fromQml);
|
||||
hasEventBridge = true;
|
||||
}
|
||||
} else {
|
||||
if (hasEventBridge) {
|
||||
tablet.fromQml.disconnect(fromQml);
|
||||
hasEventBridge = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function Name: fromQml()
|
||||
//
|
||||
// Description:
|
||||
// -Called when a message is received from Checkout.qml. The "message" argument is what is sent from the Checkout QML
|
||||
// in the format "{method, params}", like json-rpc.
|
||||
function fromQml(message) {
|
||||
switch (message.method) {
|
||||
case 'checkout_cancelClicked':
|
||||
print('fromQml: ' + JSON.stringify(message));
|
||||
tablet.popFromStack();
|
||||
break;
|
||||
case 'checkout_buyClicked':
|
||||
tablet.popFromStack();
|
||||
break;
|
||||
default:
|
||||
print('Unrecognized message from Checkout.qml: ' + JSON.stringify(message));
|
||||
}
|
||||
}
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
Loading…
Reference in a new issue