Fix security images; actually do the right thing when wallet not set up

This commit is contained in:
Zach Fox 2017-08-28 12:18:53 -07:00
parent ceb38e261d
commit 1c1b841a86
3 changed files with 108 additions and 13 deletions

View file

@ -34,15 +34,18 @@ Rectangle {
property bool alreadyOwned: false;
property int itemPriceFull: 0;
property bool itemIsJson: true;
property bool securityImageResultReceived: false;
property bool keyFilePathIfExistsResultReceived: false;
// Style
color: hifi.colors.baseGray;
Hifi.QmlCommerce {
id: commerce;
onSecurityImageResult: {
securityImageResultReceived = true;
if (!exists && root.activeView !== "notSetUp") { // "If security image is not set up"
root.activeView = "notSetUp";
} else if (exists && root.activeView !== "checkoutMain") {
} else if (root.securityImageResultReceived && exists && root.keyFilePathIfExistsResultReceived && root.activeView === "initialize") {
root.activeView = "checkoutMain";
} else if (exists) {
// just set the source again (to be sure the change was noticed)
@ -52,9 +55,10 @@ Rectangle {
}
onKeyFilePathIfExistsResult: {
keyFilePathIfExistsResultReceived = true;
if (path === "" && root.activeView !== "notSetUp") {
root.activeView = "notSetUp";
} else if (path !== "" && root.activeView !== "checkoutMain") {
} else if (root.securityImageResultReceived && root.keyFilePathIfExistsResultReceived && path !== "" && root.activeView === "initialize") {
root.activeView = "checkoutMain";
}
}
@ -276,14 +280,13 @@ Rectangle {
//
Item {
id: itemDescriptionContainer;
// Size
height: childrenRect.height + 20;
// Anchors
anchors.left: parent.left;
anchors.leftMargin: 32;
anchors.right: parent.right;
anchors.rightMargin: 32;
anchors.top: titleBarContainer.bottom;
anchors.top: parent.top;
anchors.bottom: checkoutActionButtonsContainer.top;
// HFC Balance text
Item {
@ -349,8 +352,7 @@ Rectangle {
id: itemNameTextLabel;
text: "Item:";
// Anchors
anchors.top: hfcBalanceContainer.bottom;
anchors.topMargin: 20;
anchors.top: parent.top;
anchors.left: parent.left;
width: paintedWidth;
height: paintedHeight;

View file

@ -27,6 +27,8 @@ Rectangle {
id: root;
property string activeView: "initialize";
property string referrerURL: "";
property bool securityImageResultReceived: false;
property bool keyFilePathIfExistsResultReceived: false;
property bool punctuationMode: false;
// Style
color: hifi.colors.baseGray;
@ -34,9 +36,10 @@ Rectangle {
id: commerce;
onSecurityImageResult: {
securityImageResultReceived = true;
if (!exists && root.activeView !== "notSetUp") { // "If security image is not set up"
root.activeView = "notSetUp";
} else if (exists && root.activeView !== "purchasesMain") {
} else if (root.securityImageResultReceived && exists && root.keyFilePathIfExistsResultReceived && root.activeView === "initialize") {
root.activeView = "purchasesMain";
} else if (exists) {
// just set the source again (to be sure the change was noticed)
@ -46,9 +49,10 @@ Rectangle {
}
onKeyFilePathIfExistsResult: {
keyFilePathIfExistsResultReceived = true;
if (path === "" && root.activeView !== "notSetUp") {
root.activeView = "notSetUp";
} else if (path !== "" && root.activeView !== "purchasesMain") {
} else if (root.securityImageResultReceived && root.keyFilePathIfExistsResultReceived && path !== "" && root.activeView === "initialize") {
root.activeView = "purchasesMain";
}
}
@ -138,6 +142,89 @@ Rectangle {
commerce.getKeyFilePathIfExists();
}
}
//
// "WALLET NOT SET UP" START
//
Item {
id: notSetUp;
visible: root.activeView === "notSetUp";
anchors.top: titleBarContainer.bottom;
anchors.bottom: parent.bottom;
anchors.left: parent.left;
anchors.right: parent.right;
RalewayRegular {
id: notSetUpText;
text: "<b>Your wallet isn't set up.</b><br><br>Set up your Wallet (no credit card necessary) to claim your <b>free HFC</b> " +
"and get items from the Marketplace.";
// Text size
size: 24;
// Anchors
anchors.top: parent.top;
anchors.bottom: notSetUpActionButtonsContainer.top;
anchors.left: parent.left;
anchors.leftMargin: 16;
anchors.right: parent.right;
anchors.rightMargin: 16;
// Style
color: hifi.colors.faintGray;
wrapMode: Text.WordWrap;
// Alignment
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
}
Item {
id: notSetUpActionButtonsContainer;
// Size
width: root.width;
height: 70;
// Anchors
anchors.left: parent.left;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 24;
// "Cancel" button
HifiControlsUit.Button {
id: cancelButton;
color: hifi.buttons.black;
colorScheme: hifi.colorSchemes.dark;
anchors.top: parent.top;
anchors.topMargin: 3;
anchors.bottom: parent.bottom;
anchors.bottomMargin: 3;
anchors.left: parent.left;
anchors.leftMargin: 20;
width: parent.width/2 - anchors.leftMargin*2;
text: "Cancel"
onClicked: {
sendToScript({method: 'purchases_backClicked', referrerURL: referrerURL});
}
}
// "Set Up" button
HifiControlsUit.Button {
id: setUpButton;
color: hifi.buttons.blue;
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: parent.width/2 - anchors.rightMargin*2;
text: "Set Up Wallet"
onClicked: {
sendToScript({method: 'checkout_setUpClicked'});
}
}
}
}
//
// "WALLET NOT SET UP" END
//
//
// PURCHASES CONTENTS START
@ -153,7 +240,14 @@ Rectangle {
anchors.top: titleBarContainer.bottom;
anchors.topMargin: 8;
anchors.bottom: actionButtonsContainer.top;
anchors.bottomMargin: 8;
anchors.bottomMargin: 8;
onVisibleChanged: {
if (visible) {
commerce.balance();
commerce.inventory();
}
}
//
// FILTER BAR START
@ -244,6 +338,7 @@ Rectangle {
//
Item {
id: actionButtonsContainer;
visible: purchasesContentsContainer.visible;
// Size
width: parent.width;
height: 40;
@ -305,8 +400,6 @@ Rectangle {
switch (message.method) {
case 'updatePurchases':
referrerURL = message.referrerURL;
commerce.balance();
commerce.inventory();
break;
default:
console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message));

View file

@ -420,7 +420,7 @@ void Wallet::chooseSecurityImage(const QString& filename) {
}
// temporary...
QString path = qApp->applicationDirPath();
path.append("/resources/qml/hifi/commerce/");
path.append("/resources/qml/hifi/commerce/wallet/");
path.append(filename);
// now create a new security image pixmap
_securityImage = new QPixmap();