From 768eb7f91ced1b1e9081b1606ec48e54770c18f8 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 15 Aug 2017 15:02:28 -0700 Subject: [PATCH] Getting closer --- .../resources/qml/hifi/commerce/Inventory.qml | 28 +++++++++++++++++-- .../qml/hifi/commerce/SecurityImageModel.qml | 12 ++++---- .../hifi/commerce/SecurityImageSelection.qml | 8 ++++-- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/Inventory.qml b/interface/resources/qml/hifi/commerce/Inventory.qml index a3e11e6426..17024be0a3 100644 --- a/interface/resources/qml/hifi/commerce/Inventory.qml +++ b/interface/resources/qml/hifi/commerce/Inventory.qml @@ -43,12 +43,18 @@ Rectangle { inventoryContentsList.model = inventory.assets; } } + onSecurityImageResult: { + securityImage.source = imageID ? gridModel.get(imageID - 1).sourcePath : ""; + } } SecurityImageSelection { id: securityImageSelection; referrerURL: inventoryRoot.referrerURL; } + SecurityImageModel { + id: gridModel; + } // // TITLE BAR START @@ -56,7 +62,7 @@ Rectangle { Item { id: titleBarContainer; // Size - width: inventoryRoot.width; + width: parent.width; height: 50; // Anchors anchors.left: parent.left; @@ -69,8 +75,11 @@ Rectangle { // Text size size: hifi.fontSizes.overlayTitle; // Anchors - anchors.fill: parent; + anchors.top: parent.top; + anchors.left: parent.left; anchors.leftMargin: 16; + anchors.bottom: parent.bottom; + width: paintedWidth; // Style color: hifi.colors.lightGrayText; // Alignment @@ -78,6 +87,20 @@ Rectangle { verticalAlignment: Text.AlignVCenter; } + // Security Image + Image { + id: securityImage; + // Anchors + anchors.top: parent.top; + anchors.left: titleBarText.right; + anchors.leftMargin: 16; + height: parent.height - 5; + width: height; + anchors.horizontalCenter: parent.horizontalCenter; + anchors.verticalCenter: parent.verticalCenter; + fillMode: Image.PreserveAspectFit; + } + // "Change Security Image" button HifiControlsUit.Button { id: changeSecurityImageButton; @@ -286,6 +309,7 @@ Rectangle { referrerURL = message.referrerURL; 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/SecurityImageModel.qml b/interface/resources/qml/hifi/commerce/SecurityImageModel.qml index df4490a5b1..2fbf28683f 100644 --- a/interface/resources/qml/hifi/commerce/SecurityImageModel.qml +++ b/interface/resources/qml/hifi/commerce/SecurityImageModel.qml @@ -17,26 +17,26 @@ ListModel { id: root; ListElement{ sourcePath: "images/01cat.jpg" - securityImageEnumIndex: 1; + securityImageEnumValue: 1; } ListElement{ sourcePath: "images/02car.jpg" - securityImageEnumIndex: 2; + securityImageEnumValue: 2; } ListElement{ sourcePath: "images/03dog.jpg" - securityImageEnumIndex: 3; + securityImageEnumValue: 3; } ListElement{ sourcePath: "images/04stars.jpg" - securityImageEnumIndex: 4; + securityImageEnumValue: 4; } ListElement{ sourcePath: "images/05plane.jpg" - securityImageEnumIndex: 5; + securityImageEnumValue: 5; } ListElement{ sourcePath: "images/06gingerbread.jpg" - securityImageEnumIndex: 6; + securityImageEnumValue: 6; } } diff --git a/interface/resources/qml/hifi/commerce/SecurityImageSelection.qml b/interface/resources/qml/hifi/commerce/SecurityImageSelection.qml index 744234c95a..70e9baaf40 100644 --- a/interface/resources/qml/hifi/commerce/SecurityImageSelection.qml +++ b/interface/resources/qml/hifi/commerce/SecurityImageSelection.qml @@ -26,6 +26,7 @@ Rectangle { id: securityImageSelectionRoot; property string referrerURL: ""; property bool isManuallyChangingSecurityImage: false; + property int imageEnumValue: 0; anchors.fill: parent; // Style color: hifi.colors.baseGray; @@ -40,8 +41,11 @@ Rectangle { } if (imageID !== 0) { for (var itr = 0; itr < gridModel.count; itr++) { - if (gridModel.get(itr).securityImageEnumIndex === imageID) { + var thisValue = gridModel.get(itr).securityImageEnumValue; + if (thisValue === imageID) { + securityImageSelectionRoot.imageEnumValue = thisValue; securityImageGrid.currentIndex = itr; + return; } } } @@ -252,7 +256,7 @@ Rectangle { text: "Confirm"; onClicked: { securityImageSelectionRoot.isManuallyChangingSecurityImage = false; - commerce.chooseSecurityImage(gridModel.get(securityImageGrid.currentIndex).securityImageEnumIndex); + commerce.chooseSecurityImage(gridModel.get(securityImageGrid.currentIndex).securityImageEnumValue); } } }