From fb4b0f60fa0dbedde33938e67f8e8331e158c0ac Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 30 Aug 2017 11:55:29 -0700 Subject: [PATCH] Remove most dependencies on 'onVisibleChanged' --- .../qml/hifi/commerce/checkout/Checkout.qml | 17 +++++++------- .../qml/hifi/commerce/purchases/Purchases.qml | 19 +++++++--------- .../commerce/wallet/PassphraseSelection.qml | 22 +++++++++---------- .../wallet/PassphraseSelectionLightbox.qml | 10 ++++----- .../wallet/SecurityImageSelection.qml | 11 +++++----- .../wallet/SecurityImageSelectionLightbox.qml | 6 ----- .../qml/hifi/commerce/wallet/Wallet.qml | 1 + .../commerce/wallet/WalletSetupLightbox.qml | 1 + 8 files changed, 37 insertions(+), 50 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 4f4aab70af..109e357206 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -28,14 +28,14 @@ Rectangle { property string activeView: "initialize"; property bool purchasesReceived: false; property bool balanceReceived: false; + property bool securityImageResultReceived: false; + property bool keyFilePathIfExistsResultReceived: false; property string itemId: ""; property string itemHref: ""; property double balanceAfterPurchase: 0; 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 { @@ -48,6 +48,8 @@ Rectangle { root.activeView = "initialize"; commerce.getSecurityImage(); commerce.getKeyFilePathIfExists(); + commerce.balance(); + commerce.inventory(); } } @@ -190,6 +192,10 @@ Rectangle { color: hifi.colors.baseGray; Component.onCompleted: { + securityImageResultReceived = false; + purchasesReceived = false; + balanceReceived = false; + keyFilePathIfExistsResultReceived = false; commerce.getLoginStatus(); } } @@ -311,13 +317,6 @@ Rectangle { anchors.left: parent.left; anchors.right: parent.right; - onVisibleChanged: { - if (visible) { - commerce.balance(); - commerce.inventory(); - } - } - // // ITEM DESCRIPTION START // diff --git a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml index 8e58b5190f..3cf8eb9b29 100644 --- a/interface/resources/qml/hifi/commerce/purchases/Purchases.qml +++ b/interface/resources/qml/hifi/commerce/purchases/Purchases.qml @@ -29,7 +29,7 @@ Rectangle { property string referrerURL: ""; property bool securityImageResultReceived: false; property bool keyFilePathIfExistsResultReceived: false; - property bool inventoryReceived: false; + property bool purchasesReceived: false; property bool punctuationMode: false; // Style color: hifi.colors.baseGray; @@ -43,6 +43,7 @@ Rectangle { root.activeView = "initialize"; commerce.getSecurityImage(); commerce.getKeyFilePathIfExists(); + commerce.inventory(); } } @@ -69,7 +70,7 @@ Rectangle { } onInventoryResult: { - inventoryReceived = true; + purchasesReceived = true; if (result.status !== 'success') { console.log("Failed to get purchases", result.message); } else { @@ -161,6 +162,9 @@ Rectangle { color: hifi.colors.baseGray; Component.onCompleted: { + securityImageResultReceived = false; + purchasesReceived = false; + keyFilePathIfExistsResultReceived = false; commerce.getLoginStatus(); } } @@ -283,14 +287,7 @@ Rectangle { anchors.top: titleBarContainer.bottom; anchors.topMargin: 8; anchors.bottom: actionButtonsContainer.top; - anchors.bottomMargin: 8; - - onVisibleChanged: { - if (visible) { - commerce.balance(); - commerce.inventory(); - } - } + anchors.bottomMargin: 8; // // FILTER BAR START @@ -378,7 +375,7 @@ Rectangle { Item { id: noPurchasesAlertContainer; - visible: !purchasesContentsList.visible && root.inventoryReceived; + visible: !purchasesContentsList.visible && root.purchasesReceived; anchors.top: filterBarContainer.bottom; anchors.topMargin: 12; anchors.left: parent.left; diff --git a/interface/resources/qml/hifi/commerce/wallet/PassphraseSelection.qml b/interface/resources/qml/hifi/commerce/wallet/PassphraseSelection.qml index 84c9393b06..39d07315d5 100644 --- a/interface/resources/qml/hifi/commerce/wallet/PassphraseSelection.qml +++ b/interface/resources/qml/hifi/commerce/wallet/PassphraseSelection.qml @@ -45,6 +45,10 @@ Item { } } + // This will cause a bug -- if you bring up passphrase selection in HUD mode while + // in HMD while having HMD preview enabled, then move, then finish passphrase selection, + // HMD preview will stay off. + // TODO: Fix this unlikely bug onVisibleChanged: { if (visible) { passphraseField.focus = true; @@ -69,12 +73,6 @@ Item { echoMode: TextInput.Password; placeholderText: "passphrase"; - onVisibleChanged: { - if (visible) { - text = ""; - } - } - onFocusChanged: { if (focus) { sendMessageToLightbox({method: 'walletSetup_raiseKeyboard'}); @@ -105,12 +103,6 @@ Item { echoMode: TextInput.Password; placeholderText: "re-enter passphrase"; - onVisibleChanged: { - if (visible) { - text = ""; - } - } - onFocusChanged: { if (focus) { sendMessageToLightbox({method: 'walletSetup_raiseKeyboard'}); @@ -281,5 +273,11 @@ Item { errorText.text = text; } + function clearPassphraseFields() { + passphraseField.text = ""; + passphraseFieldAgain.text = ""; + setErrorText(""); + } + signal sendMessageToLightbox(var msg); } diff --git a/interface/resources/qml/hifi/commerce/wallet/PassphraseSelectionLightbox.qml b/interface/resources/qml/hifi/commerce/wallet/PassphraseSelectionLightbox.qml index a26bc01533..608cb229b0 100644 --- a/interface/resources/qml/hifi/commerce/wallet/PassphraseSelectionLightbox.qml +++ b/interface/resources/qml/hifi/commerce/wallet/PassphraseSelectionLightbox.qml @@ -27,12 +27,6 @@ Rectangle { // Style color: hifi.colors.baseGray; - onVisibleChanged: { - if (visible) { - root.resetSubmitButton(); - } - } - // // SECURE PASSPHRASE SELECTION START // @@ -175,4 +169,8 @@ Rectangle { passphraseSubmitButton.enabled = true; passphraseSubmitButton.text = "Submit"; } + + function clearPassphraseFields() { + passphraseSelection.clearPassphraseFields(); + } } diff --git a/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelection.qml b/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelection.qml index 2bf99ba615..5f5a3e8247 100644 --- a/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelection.qml +++ b/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelection.qml @@ -24,14 +24,13 @@ Item { HifiConstants { id: hifi; } id: root; - - Hifi.QmlCommerce { - id: commerce; - } - + + // This will cause a bug -- if you bring up security image selection in HUD mode while + // in HMD while having HMD preview enabled, then move, then finish passphrase selection, + // HMD preview will stay off. + // TODO: Fix this unlikely bug onVisibleChanged: { if (visible) { - commerce.getSecurityImage(); sendSignalToWallet({method: 'disableHmdPreview'}); } else { sendSignalToWallet({method: 'maybeEnableHmdPreview'}); diff --git a/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelectionLightbox.qml b/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelectionLightbox.qml index 397c5c7788..ff7156dd6c 100644 --- a/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelectionLightbox.qml +++ b/interface/resources/qml/hifi/commerce/wallet/SecurityImageSelectionLightbox.qml @@ -28,12 +28,6 @@ Rectangle { // Style color: hifi.colors.baseGray; - onVisibleChanged: { - if (visible) { - root.resetSubmitButton(); - } - } - Hifi.QmlCommerce { id: commerce; diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index 1cb6b45d5e..0d46077f2a 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -277,6 +277,7 @@ Rectangle { onSendSignalToWallet: { if (msg.method === 'walletSecurity_changePassphrase') { passphraseSelectionLightbox.visible = true; + passphraseSelectionLightbox.clearPassphraseFields(); } else if (msg.method === 'walletSecurity_changeSecurityImage') { securityImageSelectionLightbox.visible = true; } diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml b/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml index adc1d67975..f36529e6c1 100644 --- a/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml +++ b/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml @@ -197,6 +197,7 @@ Rectangle { commerce.chooseSecurityImage(securityImagePath); securityImageContainer.visible = false; choosePassphraseContainer.visible = true; + passphraseSelection.clearPassphraseFields(); } } }