mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 05:03:31 +02:00
Oooooh it's so pretty
This commit is contained in:
parent
7879fb293f
commit
ab3a91a1da
3 changed files with 190 additions and 91 deletions
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
@ -23,16 +23,27 @@ Rectangle {
|
|||
HifiConstants { id: hifi; }
|
||||
|
||||
id: root;
|
||||
property string marketplaceUrl;
|
||||
property string certificateId;
|
||||
property string marketplaceUrl: "";
|
||||
property string certificateId: "";
|
||||
property string itemName: "--";
|
||||
property string itemOwner: "--";
|
||||
property string itemEdition: "--";
|
||||
property string dateOfPurchase: "--";
|
||||
property string itemCost: "--";
|
||||
property string certTitleTextColor: hifi.colors.darkGray;
|
||||
property string certTextColor: hifi.colors.white;
|
||||
property string infoTextColor: hifi.colors.blueAccent;
|
||||
// 0 means replace none
|
||||
// 1 means replace "Item Name" only
|
||||
// 2 means replace "Item Name" and "Edition" only
|
||||
// 5 means replace all 5 replaceable fields
|
||||
property int certInfoReplaceMode: 0;
|
||||
property bool isLightbox: false;
|
||||
property bool isMyCert: false;
|
||||
property bool isCertificateInvalid: false;
|
||||
property bool useGoldCert: true;
|
||||
property bool certificateInfoPending: true;
|
||||
property int certificateStatus: 0;
|
||||
property bool certificateStatusPending: true;
|
||||
// Style
|
||||
color: hifi.colors.faintGray;
|
||||
Connections {
|
||||
|
@ -44,84 +55,131 @@ Rectangle {
|
|||
} else {
|
||||
root.marketplaceUrl = result.data.marketplace_item_url;
|
||||
root.isMyCert = result.isMyCert ? result.isMyCert : false;
|
||||
root.itemOwner = root.isCertificateInvalid ? "--" : (root.isMyCert ? Account.username :
|
||||
"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022");
|
||||
root.itemEdition = root.isCertificateInvalid ? "Uncertified Copy" :
|
||||
(result.data.edition_number + "/" + (result.data.limited_run === -1 ? "\u221e" : result.data.limited_run));
|
||||
root.dateOfPurchase = root.isCertificateInvalid ? "--" : (!root.isMyCert ? "Undisclosed" : getFormattedDate(result.data.transfer_created_at * 1000));
|
||||
root.itemName = result.data.marketplace_item_name;
|
||||
root.itemCost = root.isCertificateInvalid ? "--" : (root.isMyCert ? result.data.cost : "Undisclosed");
|
||||
|
||||
if (root.certInfoReplaceMode > 0) {
|
||||
root.itemName = result.data.marketplace_item_name;
|
||||
if (root.certInfoReplaceMode > 1) {
|
||||
root.itemEdition = result.data.edition_number + "/" + (result.data.limited_run === -1 ? "\u221e" : result.data.limited_run);
|
||||
if (root.certInfoReplaceMode > 2) {
|
||||
root.itemOwner = root.isMyCert ? Account.username :
|
||||
"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
|
||||
root.dateOfPurchase = root.isMyCert ? getFormattedDate(result.data.transfer_created_at * 1000) : "Undisclosed";
|
||||
root.itemCost = (root.isMyCert && result.data.cost !== undefined) ? result.data.cost : "Undisclosed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (root.certificateStatus === 4) { // CERTIFICATE_STATUS_OWNER_VERIFICATION_FAILED
|
||||
if (root.isMyCert) {
|
||||
errorText.text = "This item is an uncertified copy of an item you purchased.";
|
||||
} else {
|
||||
errorText.text = "The person who placed this item doesn't own it.";
|
||||
}
|
||||
}
|
||||
|
||||
if (result.data.invalid_reason || result.data.transfer_status[0] === "failed") {
|
||||
root.isCertificateInvalid = true;
|
||||
titleBarText.text = "Invalid Certificate";
|
||||
titleBarText.color = hifi.colors.redHighlight;
|
||||
root.useGoldCert = false;
|
||||
root.certTitleTextColor = hifi.colors.redHighlight;
|
||||
root.certTextColor = hifi.colors.redHighlight;
|
||||
root.infoTextColor = hifi.colors.redHighlight;
|
||||
titleBarText.text = "Certificate\nNo Longer Valid";
|
||||
popText.text = "";
|
||||
root.itemOwner = "--";
|
||||
root.dateOfPurchase = "--";
|
||||
root.itemCost = "--";
|
||||
root.itemEdition = "Uncertified Copy";
|
||||
showInMarketplaceButton.visible = false;
|
||||
// "Edition" text previously set above in this function
|
||||
// "Owner" text previously set above in this function
|
||||
// "Purchase Date" text previously set above in this function
|
||||
// "Purchase Price" text previously set above in this function
|
||||
if (result.data.invalid_reason) {
|
||||
errorText.text = result.data.invalid_reason;
|
||||
}
|
||||
} else if (result.data.transfer_status[0] === "pending") {
|
||||
root.isCertificateInvalid = true;
|
||||
titleBarText.text = "Certificate Pending";
|
||||
titleBarText.color = hifi.colors.redHighlight;
|
||||
root.useGoldCert = false;
|
||||
root.certTitleTextColor = hifi.colors.redHighlight;
|
||||
root.certTextColor = hifi.colors.redHighlight;
|
||||
root.infoTextColor = hifi.colors.redHighlight;
|
||||
titleBarText.text = "Certificate\nNo Longer Valid";
|
||||
popText.text = "";
|
||||
showInMarketplaceButton.visible = true;
|
||||
// "Edition" text previously set above in this function
|
||||
// "Owner" text previously set above in this function
|
||||
// "Purchase Date" text previously set above in this function
|
||||
// "Purchase Price" text previously set above in this function
|
||||
errorText.text = "The status of this item is still pending confirmation. If the purchase is not confirmed, " +
|
||||
"this entity will be cleaned up by the domain.";
|
||||
}
|
||||
}
|
||||
root.certificateInfoPending = false;
|
||||
}
|
||||
|
||||
onUpdateCertificateStatus: {
|
||||
if (certStatus === 1) { // CERTIFICATE_STATUS_VERIFICATION_SUCCESS
|
||||
// NOP
|
||||
} else if (certStatus === 2) { // CERTIFICATE_STATUS_VERIFICATION_TIMEOUT
|
||||
root.isCertificateInvalid = true;
|
||||
titleBarText.text = "Invalid Certificate";
|
||||
titleBarText.color = hifi.colors.redHighlight;
|
||||
root.certificateStatus = certStatus;
|
||||
if (root.certificateStatus === 1) { // CERTIFICATE_STATUS_VERIFICATION_SUCCESS
|
||||
root.useGoldCert = true;
|
||||
root.certTitleTextColor = hifi.colors.darkGray;
|
||||
root.certTextColor = hifi.colors.white;
|
||||
root.infoTextColor = hifi.colors.blueAccent;
|
||||
titleBarText.text = "Certificate";
|
||||
popText.text = "PROOF OF PROVENANCE";
|
||||
showInMarketplaceButton.visible = true;
|
||||
root.certInfoReplaceMode = 5;
|
||||
// "Item Name" text will be set in "onCertificateInfoResult()"
|
||||
// "Edition" text will be set in "onCertificateInfoResult()"
|
||||
// "Owner" text will be set in "onCertificateInfoResult()"
|
||||
// "Purchase Date" text will be set in "onCertificateInfoResult()"
|
||||
// "Purchase Price" text will be set in "onCertificateInfoResult()"
|
||||
errorText.text = "";
|
||||
} else if (root.certificateStatus === 2) { // CERTIFICATE_STATUS_VERIFICATION_TIMEOUT
|
||||
root.useGoldCert = false;
|
||||
root.certTitleTextColor = hifi.colors.redHighlight;
|
||||
root.certTextColor = hifi.colors.redHighlight;
|
||||
root.infoTextColor = hifi.colors.redHighlight;
|
||||
titleBarText.text = "Request Timed Out";
|
||||
popText.text = "";
|
||||
root.itemOwner = "--";
|
||||
root.dateOfPurchase = "--";
|
||||
root.itemCost = "--";
|
||||
root.itemEdition = "Uncertified Copy";
|
||||
|
||||
errorText.text = "Verification of this certificate timed out.";
|
||||
} else if (certStatus === 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
|
||||
root.isCertificateInvalid = true;
|
||||
titleBarText.text = "Invalid Certificate";
|
||||
titleBarText.color = hifi.colors.redHighlight;
|
||||
popText.text = "";
|
||||
root.itemOwner = "--";
|
||||
root.dateOfPurchase = "--";
|
||||
root.itemCost = "--";
|
||||
root.itemEdition = "Uncertified Copy";
|
||||
showInMarketplaceButton.visible = false;
|
||||
|
||||
errorText.text = "The information associated with this item has been modified and it no longer matches the original certified item.";
|
||||
} else if (certStatus === 4) { // CERTIFICATE_STATUS_OWNER_VERIFICATION_FAILED
|
||||
root.isCertificateInvalid = true;
|
||||
titleBarText.text = "Invalid Certificate";
|
||||
titleBarText.color = hifi.colors.redHighlight;
|
||||
root.certInfoReplaceMode = 0;
|
||||
root.itemName = "";
|
||||
root.itemEdition = "";
|
||||
root.itemOwner = "";
|
||||
root.dateOfPurchase = "";
|
||||
root.itemCost = "";
|
||||
errorText.text = "Your request to inspect this item timed out. Please try again later.";
|
||||
} else if (root.certificateStatus === 3) { // CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED
|
||||
root.useGoldCert = false;
|
||||
root.certTitleTextColor = hifi.colors.redHighlight;
|
||||
root.certTextColor = hifi.colors.redHighlight;
|
||||
root.infoTextColor = hifi.colors.redHighlight;
|
||||
titleBarText.text = "Certificate\nNo Longer Valid";
|
||||
popText.text = "";
|
||||
root.itemOwner = "--";
|
||||
root.dateOfPurchase = "--";
|
||||
root.itemCost = "--";
|
||||
root.itemEdition = "Uncertified Copy";
|
||||
root.isMyCert = false;
|
||||
|
||||
errorText.text = "The avatar who rezzed this item doesn't own it.";
|
||||
showInMarketplaceButton.visible = true;
|
||||
root.certInfoReplaceMode = 5;
|
||||
// "Item Name" text will be set in "onCertificateInfoResult()"
|
||||
// "Edition" text will be set in "onCertificateInfoResult()"
|
||||
// "Owner" text will be set in "onCertificateInfoResult()"
|
||||
// "Purchase Date" text will be set in "onCertificateInfoResult()"
|
||||
// "Purchase Price" text will be set in "onCertificateInfoResult()"
|
||||
errorText.text = "The information associated with this item has been modified and it no longer matches the original certified item.";
|
||||
} else if (root.certificateStatus === 4) { // CERTIFICATE_STATUS_OWNER_VERIFICATION_FAILED
|
||||
root.useGoldCert = false;
|
||||
root.certTitleTextColor = hifi.colors.redHighlight;
|
||||
root.certTextColor = hifi.colors.redHighlight;
|
||||
root.infoTextColor = hifi.colors.redHighlight;
|
||||
titleBarText.text = "Invalid Certificate";
|
||||
popText.text = "";
|
||||
showInMarketplaceButton.visible = true;
|
||||
root.certInfoReplaceMode = 1;
|
||||
// "Item Name" text will be set in "onCertificateInfoResult()"
|
||||
root.itemEdition = "Uncertified Copy"
|
||||
// "Owner" text will be set in "onCertificateInfoResult()"
|
||||
// "Purchase Date" text will be set in "onCertificateInfoResult()"
|
||||
// "Purchase Price" text will be set in "onCertificateInfoResult()"
|
||||
// "Error Text" text will be set in "onCertificateInfoResult()"
|
||||
} else {
|
||||
console.log("Unknown certificate status received from ledger signal!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onCertificateIdChanged: {
|
||||
if (certificateId !== "") {
|
||||
Commerce.certificateInfo(certificateId);
|
||||
|
||||
root.certificateStatusPending = false;
|
||||
// We've gotten cert status - we are GO on getting the cert info
|
||||
Commerce.certificateInfo(root.certificateId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,9 +191,35 @@ Rectangle {
|
|||
propagateComposedEvents: false;
|
||||
}
|
||||
|
||||
Image {
|
||||
Rectangle {
|
||||
id: loadingOverlay;
|
||||
z: 998;
|
||||
|
||||
visible: root.certificateInfoPending || root.certificateStatusPending;
|
||||
anchors.fill: parent;
|
||||
source: root.isCertificateInvalid ? "images/nocert-bg-split.png" : "images/cert-bg-gold-split.png";
|
||||
color: Qt.rgba(0.0, 0.0, 0.0, 0.7);
|
||||
|
||||
// This object is always used in a popup or full-screen Wallet section.
|
||||
// This MouseArea is used to prevent a user from being
|
||||
// able to click on a button/mouseArea underneath the popup/section.
|
||||
MouseArea {
|
||||
anchors.fill: parent;
|
||||
propagateComposedEvents: false;
|
||||
}
|
||||
|
||||
AnimatedImage {
|
||||
source: "../common/images/loader.gif"
|
||||
width: 96;
|
||||
height: width;
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
anchors.horizontalCenter: parent.horizontalCenter;
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: backgroundImage;
|
||||
anchors.fill: parent;
|
||||
source: root.useGoldCert ? "images/cert-bg-gold-split.png" : "images/nocert-bg-split.png";
|
||||
}
|
||||
|
||||
// Title text
|
||||
|
@ -150,14 +234,15 @@ Rectangle {
|
|||
anchors.left: parent.left;
|
||||
anchors.leftMargin: 36;
|
||||
anchors.right: parent.right;
|
||||
anchors.rightMargin: 8;
|
||||
height: paintedHeight;
|
||||
// Style
|
||||
color: hifi.colors.darkGray;
|
||||
color: root.certTitleTextColor;
|
||||
wrapMode: Text.WordWrap;
|
||||
}
|
||||
// Title text
|
||||
RalewayRegular {
|
||||
id: popText;
|
||||
text: "PROOF OF PROVENANCE";
|
||||
// Text size
|
||||
size: 16;
|
||||
// Anchors
|
||||
|
@ -165,9 +250,9 @@ Rectangle {
|
|||
anchors.topMargin: 4;
|
||||
anchors.left: titleBarText.left;
|
||||
anchors.right: titleBarText.right;
|
||||
height: paintedHeight;
|
||||
height: text === "" ? 0 : paintedHeight;
|
||||
// Style
|
||||
color: hifi.colors.darkGray;
|
||||
color: root.certTitleTextColor;
|
||||
}
|
||||
|
||||
// "Close" button
|
||||
|
@ -204,8 +289,8 @@ Rectangle {
|
|||
//
|
||||
Item {
|
||||
id: certificateContainer;
|
||||
anchors.top: popText.bottom;
|
||||
anchors.topMargin: 30;
|
||||
anchors.top: titleBarText.top;
|
||||
anchors.topMargin: 110;
|
||||
anchors.bottom: infoContainer.top;
|
||||
anchors.left: parent.left;
|
||||
anchors.leftMargin: titleBarText.anchors.leftMargin;
|
||||
|
@ -237,7 +322,7 @@ Rectangle {
|
|||
anchors.right: itemNameHeader.right;
|
||||
height: paintedHeight;
|
||||
// Style
|
||||
color: root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.white;
|
||||
color: root.certTextColor;
|
||||
elide: Text.ElideRight;
|
||||
MouseArea {
|
||||
enabled: showInMarketplaceButton.visible;
|
||||
|
@ -247,7 +332,7 @@ Rectangle {
|
|||
sendToScript({method: 'inspectionCertificate_showInMarketplaceClicked', marketplaceUrl: root.marketplaceUrl});
|
||||
}
|
||||
onEntered: itemName.color = hifi.colors.blueHighlight;
|
||||
onExited: itemName.color = root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.white;
|
||||
onExited: itemName.color = root.certTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +362,7 @@ Rectangle {
|
|||
anchors.right: editionHeader.right;
|
||||
height: paintedHeight;
|
||||
// Style
|
||||
color: root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.white;
|
||||
color: root.certTextColor;
|
||||
}
|
||||
|
||||
// "Show In Marketplace" button
|
||||
|
@ -311,7 +396,7 @@ Rectangle {
|
|||
anchors.leftMargin: titleBarText.anchors.leftMargin;
|
||||
anchors.right: parent.right;
|
||||
anchors.rightMargin: 24;
|
||||
height: root.isCertificateInvalid ? 372 : 220;
|
||||
height: root.useGoldCert ? 220 : 372;
|
||||
|
||||
RalewayRegular {
|
||||
id: errorText;
|
||||
|
@ -356,12 +441,12 @@ Rectangle {
|
|||
anchors.left: ownedByHeader.left;
|
||||
height: paintedHeight;
|
||||
// Style
|
||||
color: root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.blueAccent;
|
||||
color: root.infoTextColor;
|
||||
elide: Text.ElideRight;
|
||||
}
|
||||
AnonymousProRegular {
|
||||
id: isMyCertText;
|
||||
visible: root.isMyCert && !root.isCertificateInvalid;
|
||||
visible: root.isMyCert && ownedBy.text !== "--" && ownedBy.text !== "";
|
||||
text: "(Private)";
|
||||
size: 18;
|
||||
// Anchors
|
||||
|
@ -372,7 +457,7 @@ Rectangle {
|
|||
anchors.leftMargin: 6;
|
||||
anchors.right: ownedByHeader.right;
|
||||
// Style
|
||||
color: root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.blueAccent;
|
||||
color: root.infoTextColor;
|
||||
elide: Text.ElideRight;
|
||||
verticalAlignment: Text.AlignVCenter;
|
||||
}
|
||||
|
@ -404,7 +489,7 @@ Rectangle {
|
|||
anchors.right: dateOfPurchaseHeader.right;
|
||||
height: paintedHeight;
|
||||
// Style
|
||||
color: root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.blueAccent;
|
||||
color: root.infoTextColor;
|
||||
}
|
||||
|
||||
RalewayRegular {
|
||||
|
@ -423,7 +508,7 @@ Rectangle {
|
|||
}
|
||||
HiFiGlyphs {
|
||||
id: hfcGlyph;
|
||||
visible: priceText.text !== "Undisclosed";
|
||||
visible: priceText.text !== "Undisclosed" && priceText.text !== "";
|
||||
text: hifi.glyphs.hfc;
|
||||
// Size
|
||||
size: 24;
|
||||
|
@ -434,7 +519,7 @@ Rectangle {
|
|||
width: visible ? paintedWidth + 6 : 0;
|
||||
height: 40;
|
||||
// Style
|
||||
color: root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.blueAccent;
|
||||
color: root.infoTextColor;
|
||||
verticalAlignment: Text.AlignTop;
|
||||
horizontalAlignment: Text.AlignLeft;
|
||||
}
|
||||
|
@ -450,7 +535,7 @@ Rectangle {
|
|||
anchors.right: priceHeader.right;
|
||||
height: paintedHeight;
|
||||
// Style
|
||||
color: root.isCertificateInvalid ? hifi.colors.redHighlight : hifi.colors.blueAccent;
|
||||
color: root.infoTextColor;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -476,20 +561,11 @@ Rectangle {
|
|||
function fromScript(message) {
|
||||
switch (message.method) {
|
||||
case 'inspectionCertificate_setCertificateId':
|
||||
resetCert(false);
|
||||
root.certificateId = message.certificateId;
|
||||
break;
|
||||
case 'inspectionCertificate_resetCert':
|
||||
titleBarText.text = "Certificate";
|
||||
popText.text = "PROOF OF PURCHASE";
|
||||
root.certificateId = "";
|
||||
root.itemName = "--";
|
||||
root.itemOwner = "--";
|
||||
root.itemEdition = "--";
|
||||
root.dateOfPurchase = "--";
|
||||
root.marketplaceUrl = "";
|
||||
root.itemCost = "--";
|
||||
root.isMyCert = false;
|
||||
errorText.text = "";
|
||||
resetCert(true);
|
||||
break;
|
||||
default:
|
||||
console.log('Unrecognized message from marketplaces.js:', JSON.stringify(message));
|
||||
|
@ -497,6 +573,29 @@ Rectangle {
|
|||
}
|
||||
signal sendToScript(var message);
|
||||
|
||||
function resetCert(alsoResetCertID) {
|
||||
if (alsoResetCertID) {
|
||||
root.certificateId = "";
|
||||
}
|
||||
root.certInfoReplaceMode = 0;
|
||||
root.certificateInfoPending = true;
|
||||
root.certificateStatusPending = true;
|
||||
root.useGoldCert = true;
|
||||
root.certTitleTextColor = hifi.colors.darkGray;
|
||||
root.certTextColor = hifi.colors.white;
|
||||
root.infoTextColor = hifi.colors.blueAccent;
|
||||
titleBarText.text = "Certificate";
|
||||
popText.text = "";
|
||||
root.itemName = "--";
|
||||
root.itemOwner = "--";
|
||||
root.itemEdition = "--";
|
||||
root.dateOfPurchase = "--";
|
||||
root.marketplaceUrl = "";
|
||||
root.itemCost = "--";
|
||||
root.isMyCert = false;
|
||||
errorText.text = "";
|
||||
}
|
||||
|
||||
function getFormattedDate(timestamp) {
|
||||
if (timestamp === "--") {
|
||||
return "--";
|
||||
|
|
|
@ -1063,7 +1063,7 @@ Item {
|
|||
|
||||
AnimatedImage {
|
||||
id: sendingMoneyImage;
|
||||
source: "./images/loader.gif"
|
||||
source: "../../common/images/loader.gif"
|
||||
width: 96;
|
||||
height: width;
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
|
|
Loading…
Reference in a new issue