mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 23:39:23 +02:00
Merge pull request #14568 from zfox23/MS20187_itemTrash
Implement MS20187: Add trash can feature to Inventory
This commit is contained in:
commit
22c2954423
2 changed files with 85 additions and 3 deletions
|
@ -176,6 +176,7 @@ Item {
|
|||
Item {
|
||||
property alias buttonGlyphText: buttonGlyph.text;
|
||||
property alias buttonText: buttonText.text;
|
||||
property alias glyphSize: buttonGlyph.size;
|
||||
property string buttonColor: hifi.colors.black;
|
||||
property string buttonColor_hover: hifi.colors.blueHighlight;
|
||||
property alias enabled: buttonMouseArea.enabled;
|
||||
|
@ -186,7 +187,8 @@ Item {
|
|||
anchors.top: parent.top;
|
||||
anchors.topMargin: 4;
|
||||
anchors.horizontalCenter: parent.horizontalCenter;
|
||||
anchors.bottom: parent.verticalCenter;
|
||||
anchors.bottom: buttonText.visible ? parent.verticalCenter : parent.bottom;
|
||||
anchors.bottomMargin: buttonText.visible ? 0 : 4;
|
||||
width: parent.width;
|
||||
size: 40;
|
||||
horizontalAlignment: Text.AlignHCenter;
|
||||
|
@ -196,6 +198,7 @@ Item {
|
|||
|
||||
RalewayRegular {
|
||||
id: buttonText;
|
||||
visible: text !== "";
|
||||
anchors.top: parent.verticalCenter;
|
||||
anchors.topMargin: 4;
|
||||
anchors.bottom: parent.bottom;
|
||||
|
@ -300,7 +303,7 @@ Item {
|
|||
anchors.right: certificateButton.left;
|
||||
anchors.top: parent.top;
|
||||
anchors.bottom: parent.bottom;
|
||||
width: 78;
|
||||
width: 72;
|
||||
|
||||
onLoaded: {
|
||||
item.buttonGlyphText = hifi.glyphs.uninstall;
|
||||
|
@ -310,6 +313,10 @@ Item {
|
|||
Commerce.uninstallApp(root.itemHref);
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
trashButton.updateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
|
@ -319,7 +326,7 @@ Item {
|
|||
anchors.right: uninstallButton.visible ? uninstallButton.left : certificateButton.left;
|
||||
anchors.top: parent.top;
|
||||
anchors.bottom: parent.bottom;
|
||||
width: 84;
|
||||
width: 78;
|
||||
|
||||
onLoaded: {
|
||||
item.buttonGlyphText = hifi.glyphs.update;
|
||||
|
@ -339,6 +346,45 @@ Item {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
trashButton.updateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: trashButton;
|
||||
visible: root.itemEdition > 0;
|
||||
sourceComponent: contextCardButton;
|
||||
anchors.right: updateButton.visible ? updateButton.left : (uninstallButton.visible ? uninstallButton.left : certificateButton.left);
|
||||
anchors.top: parent.top;
|
||||
anchors.bottom: parent.bottom;
|
||||
width: (updateButton.visible && uninstallButton.visible) ? 15 : 78;
|
||||
|
||||
onLoaded: {
|
||||
item.buttonGlyphText = hifi.glyphs.trash;
|
||||
updateProperties();
|
||||
item.buttonClicked = function() {
|
||||
sendToPurchases({method: 'showTrashLightbox',
|
||||
isInstalled: root.isInstalled,
|
||||
itemHref: root.itemHref,
|
||||
itemName: root.itemName,
|
||||
certID: root.certificateId,
|
||||
itemType: root.itemType,
|
||||
wornEntityID: root.wornEntityID
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateProperties() {
|
||||
if (updateButton.visible && uninstallButton.visible) {
|
||||
item.buttonText = "";
|
||||
item.glyphSize = 20;
|
||||
} else {
|
||||
item.buttonText = "Send to Trash";
|
||||
item.glyphSize = 30;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -651,6 +651,42 @@ Rectangle {
|
|||
lightboxPopup.visible = false;
|
||||
};
|
||||
lightboxPopup.visible = true;
|
||||
} else if (msg.method === "showTrashLightbox") {
|
||||
lightboxPopup.titleText = "Send \"" + msg.itemName + "\" to Trash";
|
||||
lightboxPopup.bodyText = "Sending this item to the Trash means you will no longer own this item " +
|
||||
"and it will be inaccessible to you from Purchases.\n\nThis action cannot be undone.";
|
||||
lightboxPopup.button1text = "CANCEL";
|
||||
lightboxPopup.button1method = function() {
|
||||
lightboxPopup.visible = false;
|
||||
}
|
||||
lightboxPopup.button2text = "CONFIRM";
|
||||
lightboxPopup.button2method = function() {
|
||||
if (msg.isInstalled) {
|
||||
Commerce.uninstallApp(msg.itemHref);
|
||||
}
|
||||
|
||||
if (MyAvatar.skeletonModelURL === msg.itemHref) {
|
||||
MyAvatar.useFullAvatarURL('');
|
||||
}
|
||||
|
||||
if (msg.itemType === "wearable" && msg.wornEntityID !== '') {
|
||||
Entities.deleteEntity(msg.wornEntityID);
|
||||
purchasesModel.setProperty(index, 'wornEntityID', '');
|
||||
}
|
||||
|
||||
Commerce.transferAssetToUsername("trashbot", msg.certID, 1, "Sent " + msg.itemName + " to trash.");
|
||||
|
||||
lightboxPopup.titleText = '"' + msg.itemName + '" Sent to Trash';
|
||||
lightboxPopup.button1text = "OK";
|
||||
lightboxPopup.button1method = function() {
|
||||
root.purchasesReceived = false;
|
||||
lightboxPopup.visible = false;
|
||||
getPurchases();
|
||||
}
|
||||
lightboxPopup.button2text = "";
|
||||
lightboxPopup.bodyText = "";
|
||||
};
|
||||
lightboxPopup.visible = true;
|
||||
} else if (msg.method === "showChangeAvatarLightbox") {
|
||||
lightboxPopup.titleText = "Change Avatar";
|
||||
lightboxPopup.bodyText = "This will change your current avatar to " + msg.itemName + " while retaining your wearables.";
|
||||
|
|
Loading…
Reference in a new issue