From 3d0fd76997642be8d019b450582d59d8fedac0c2 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 24 Aug 2017 10:24:06 -0700 Subject: [PATCH] Temp fix for inventory and buy --- .../resources/qml/hifi/commerce/Checkout.qml | 52 ++++++------------- .../resources/qml/hifi/commerce/Inventory.qml | 47 ++--------------- 2 files changed, 19 insertions(+), 80 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/Checkout.qml b/interface/resources/qml/hifi/commerce/Checkout.qml index 55bd6cb4c6..d33d46fab2 100644 --- a/interface/resources/qml/hifi/commerce/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/Checkout.qml @@ -17,6 +17,7 @@ import QtQuick.Controls 1.4 import "../../styles-uit" import "../../controls-uit" as HifiControlsUit import "../../controls" as HifiControls +import "./wallet" as HifiWallet // references XXX from root context @@ -30,28 +31,29 @@ Rectangle { property string itemHref: ""; property int balanceAfterPurchase: 0; property bool alreadyOwned: false; + property int itemPriceFull: 0; // Style color: hifi.colors.baseGray; Hifi.QmlCommerce { id: commerce; onBuyResult: { - if (result.status !== 'success') { - buyButton.text = result.message; - buyButton.enabled = false; - } else { - if (urlHandler.canHandleUrl(itemHref)) { - urlHandler.handleUrl(itemHref); - } - sendToScript({method: 'checkout_buySuccess', itemId: itemId}); + if (result.status !== 'success') { + buyButton.text = result.message; + buyButton.enabled = false; + } else { + if (urlHandler.canHandleUrl(itemHref)) { + urlHandler.handleUrl(itemHref); } + sendToScript({method: 'checkout_buySuccess', itemId: itemId}); + } } onBalanceResult: { if (result.status !== 'success') { console.log("Failed to get balance", result.message); } else { balanceReceived = true; - hfcBalanceText.text = result.data.balance; - balanceAfterPurchase = result.data.balance - parseInt(itemPriceText.text, 10); + hfcBalanceText.text = parseFloat(result.data.balance/100).toFixed(2); + balanceAfterPurchase = parseFloat(result.data.balance/100) - parseFloat(checkoutRoot.itemPriceFull/100).toFixed(2); } } onInventoryResult: { @@ -67,14 +69,6 @@ Rectangle { } } } - onSecurityImageResult: { - securityImage.source = securityImageSelection.getImagePathFromImageID(imageID); - } - } - - SecurityImageSelection { - id: securityImageSelection; - referrerURL: checkoutRoot.itemHref; } // @@ -89,20 +83,6 @@ Rectangle { anchors.left: parent.left; anchors.top: parent.top; - // Security Image - Image { - id: securityImage; - // Anchors - anchors.top: parent.top; - anchors.left: parent.left; - anchors.leftMargin: 16; - height: parent.height - 5; - width: height; - anchors.verticalCenter: parent.verticalCenter; - fillMode: Image.PreserveAspectFit; - mipmap: true; - } - // Title Bar text RalewaySemiBold { id: titleBarText; @@ -111,7 +91,7 @@ Rectangle { size: hifi.fontSizes.overlayTitle; // Anchors anchors.top: parent.top; - anchors.left: securityImage.right; + anchors.left: parent.left; anchors.leftMargin: 16; anchors.bottom: parent.bottom; width: paintedWidth; @@ -420,7 +400,7 @@ Rectangle { text: (inventoryReceived && balanceReceived) ? (alreadyOwned ? "Already Owned: Get Item" : "Buy") : "--"; onClicked: { if (!alreadyOwned) { - commerce.buy(itemId, parseInt(itemPriceText.text)); + commerce.buy(itemId, parseFloat(itemPriceText.text*100)); } else { if (urlHandler.canHandleUrl(itemHref)) { urlHandler.handleUrl(itemHref); @@ -456,11 +436,11 @@ Rectangle { itemId = message.params.itemId; itemNameText.text = message.params.itemName; itemAuthorText.text = message.params.itemAuthor; - itemPriceText.text = message.params.itemPrice; + checkoutRoot.itemPriceFull = message.params.itemPrice; + itemPriceText.text = parseFloat(checkoutRoot.itemPriceFull/100).toFixed(2); itemHref = message.params.itemHref; commerce.balance(); commerce.inventory(); - commerce.getSecurityImage(); break; default: console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message)); diff --git a/interface/resources/qml/hifi/commerce/Inventory.qml b/interface/resources/qml/hifi/commerce/Inventory.qml index 8f22e7de0f..b422d308ba 100644 --- a/interface/resources/qml/hifi/commerce/Inventory.qml +++ b/interface/resources/qml/hifi/commerce/Inventory.qml @@ -17,6 +17,7 @@ import QtQuick.Controls 1.4 import "../../styles-uit" import "../../controls-uit" as HifiControlsUit import "../../controls" as HifiControls +import "./wallet" as HifiWallet // references XXX from root context @@ -33,7 +34,7 @@ Rectangle { if (result.status !== 'success') { console.log("Failed to get balance", result.message); } else { - hfcBalanceText.text = result.data.balance; + hfcBalanceText.text = parseFloat(result.data.balance/100).toFixed(2); } } onInventoryResult: { @@ -43,14 +44,6 @@ Rectangle { inventoryContentsList.model = result.data.assets; } } - onSecurityImageResult: { - securityImage.source = securityImageSelection.getImagePathFromImageID(imageID); - } - } - - SecurityImageSelection { - id: securityImageSelection; - referrerURL: inventoryRoot.referrerURL; } // @@ -65,20 +58,6 @@ Rectangle { anchors.left: parent.left; anchors.top: parent.top; - // Security Image - Image { - id: securityImage; - // Anchors - anchors.top: parent.top; - anchors.left: parent.left; - anchors.leftMargin: 16; - height: parent.height - 5; - width: height; - anchors.verticalCenter: parent.verticalCenter; - fillMode: Image.PreserveAspectFit; - mipmap: true; - } - // Title Bar text RalewaySemiBold { id: titleBarText; @@ -87,7 +66,7 @@ Rectangle { size: hifi.fontSizes.overlayTitle; // Anchors anchors.top: parent.top; - anchors.left: securityImage.right; + anchors.left: parent.left; anchors.leftMargin: 16; anchors.bottom: parent.bottom; width: paintedWidth; @@ -98,25 +77,6 @@ Rectangle { verticalAlignment: Text.AlignVCenter; } - // "Change Security Image" button - HifiControlsUit.Button { - id: changeSecurityImageButton; - color: hifi.buttons.black; - colorScheme: hifi.colorSchemes.dark; - anchors.top: parent.top; - anchors.topMargin: 3; - anchors.bottom: parent.bottom; - anchors.bottomMargin: 3; - anchors.right: parent.right; - anchors.rightMargin: 20; - width: 200; - text: "Change Security Image" - onClicked: { - securityImageSelection.isManuallyChangingSecurityImage = true; - securityImageSelection.visible = true; - } - } - // Separator HifiControlsUit.Separator { anchors.left: parent.left; @@ -307,7 +267,6 @@ Rectangle { referrerURL = message.referrerURL; commerce.balance(); commerce.inventory(); - commerce.getSecurityImage(); break; default: console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message));