From d74f7eb0982d65e7b371a923268fbef75f5222b3 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 11 Dec 2018 15:41:07 -0800 Subject: [PATCH 1/5] Implement MS20187: Add trash can feature to Inventory --- .../hifi/commerce/purchases/PurchasedItem.qml | 38 +++++++++++++++++-- .../qml/hifi/commerce/purchases/Purchases.qml | 25 ++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index c8ec7238d6..12a9912e8e 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -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; @@ -319,7 +322,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; @@ -340,6 +343,35 @@ Item { } } } + + 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; + if (updateButton.visible && uninstallButton.visible) { + item.buttonText = ""; + item.glyphSize = 20; + } else { + item.buttonText = "Send to Trash"; + item.glyphSize = 30; + } + item.buttonClicked = function() { + sendToPurchases({method: 'showTrashLightbox', + isInstalled: root.isInstalled, + itemHref: root.itemHref, + itemName: root.itemName, + certID: root.certificateId + }); + } + } + } } Rectangle { diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 18d6bc9f78..dae93b3315 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -651,6 +651,31 @@ 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); + } + Commerce.transferAssetToUsername("TrashCan", msg.certID, 1, "Sent " + msg.itemName + " to trash."); + + lightboxPopup.titleText = '"' + msg.itemName + '" Sent to Trash'; + lightboxPopup.button1text = "OK"; + lightboxPopup.button1method = function() { + 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."; From dff7804cdc4f3834ad83bdc92c3e61ad3452cb62 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 11 Dec 2018 16:26:49 -0800 Subject: [PATCH 2/5] Change username to trashbot --- interface/resources/qml/hifi/commerce/purchases/Purchases.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index dae93b3315..f50ce0bda3 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -664,7 +664,7 @@ Rectangle { if (msg.isInstalled) { Commerce.uninstallApp(msg.itemHref); } - Commerce.transferAssetToUsername("TrashCan", msg.certID, 1, "Sent " + msg.itemName + " to trash."); + Commerce.transferAssetToUsername("trashbot", msg.certID, 1, "Sent " + msg.itemName + " to trash."); lightboxPopup.titleText = '"' + msg.itemName + '" Sent to Trash'; lightboxPopup.button1text = "OK"; From f407042f3e983670771f2d5fcbd0a2ae815cefc0 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 18 Dec 2018 17:11:10 -0800 Subject: [PATCH 3/5] Quick polish fix to prevent UI flashing --- interface/resources/qml/hifi/commerce/purchases/Purchases.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index f50ce0bda3..af61cfa410 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -39,7 +39,8 @@ Rectangle { property int numUpdatesAvailable: 0; // Style color: hifi.colors.white; - function getPurchases() { + function + () { root.activeView = "purchasesMain"; root.installedApps = Commerce.getInstalledApps(); purchasesModel.getFirstPage(); @@ -669,6 +670,7 @@ Rectangle { lightboxPopup.titleText = '"' + msg.itemName + '" Sent to Trash'; lightboxPopup.button1text = "OK"; lightboxPopup.button1method = function() { + root.purchasesReceived = false; lightboxPopup.visible = false; getPurchases(); } From 116edcc224c45edc023699b024a479173b514dcd Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 19 Dec 2018 09:36:05 -0800 Subject: [PATCH 4/5] I have no idea how this happened --- interface/resources/qml/hifi/commerce/purchases/Purchases.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index af61cfa410..67a61a2835 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -39,8 +39,7 @@ Rectangle { property int numUpdatesAvailable: 0; // Style color: hifi.colors.white; - function - () { + function getPurchases() { root.activeView = "purchasesMain"; root.installedApps = Commerce.getInstalledApps(); purchasesModel.getFirstPage(); From d0998174ffc7ca028cc33274a1bcc9759713589d Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 19 Dec 2018 15:16:48 -0800 Subject: [PATCH 5/5] Un-wear things when trashing them if worn --- .../hifi/commerce/purchases/PurchasedItem.qml | 30 ++++++++++++++----- .../qml/hifi/commerce/purchases/Purchases.qml | 10 +++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index 12a9912e8e..f7dc26df5f 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -313,6 +313,10 @@ Item { Commerce.uninstallApp(root.itemHref); } } + + onVisibleChanged: { + trashButton.updateProperties(); + } } Loader { @@ -342,6 +346,10 @@ Item { }); } } + + onVisibleChanged: { + trashButton.updateProperties(); + } } Loader { @@ -355,6 +363,20 @@ Item { 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; @@ -362,14 +384,6 @@ Item { item.buttonText = "Send to Trash"; item.glyphSize = 30; } - item.buttonClicked = function() { - sendToPurchases({method: 'showTrashLightbox', - isInstalled: root.isInstalled, - itemHref: root.itemHref, - itemName: root.itemName, - certID: root.certificateId - }); - } } } } diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index f50ce0bda3..873e8bef1d 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -664,6 +664,16 @@ Rectangle { 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';