mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Allow scripts to open SendAsset screen with pre-filled info
This commit is contained in:
parent
7e2f1ca64a
commit
8df5db4239
2 changed files with 48 additions and 16 deletions
|
@ -39,7 +39,7 @@ Item {
|
||||||
property string sendingPubliclyEffectImage;
|
property string sendingPubliclyEffectImage;
|
||||||
property var http;
|
property var http;
|
||||||
property var listModelName;
|
property var listModelName;
|
||||||
property var keyboardContainer: nil;
|
property var keyboardContainer;
|
||||||
|
|
||||||
// This object is always used in a popup or full-screen Wallet section.
|
// This object is always used in a popup or full-screen Wallet section.
|
||||||
// This MouseArea is used to prevent a user from being
|
// This MouseArea is used to prevent a user from being
|
||||||
|
@ -405,7 +405,7 @@ Item {
|
||||||
HifiModels.PSFListModel {
|
HifiModels.PSFListModel {
|
||||||
id: connectionsModel;
|
id: connectionsModel;
|
||||||
http: root.http;
|
http: root.http;
|
||||||
listModelName: root.listModelName;
|
listModelName: root.listModelName || "";
|
||||||
endpoint: "/api/v1/users?filter=connections";
|
endpoint: "/api/v1/users?filter=connections";
|
||||||
itemsPerPage: 9;
|
itemsPerPage: 9;
|
||||||
listView: connectionsList;
|
listView: connectionsList;
|
||||||
|
@ -853,7 +853,7 @@ Item {
|
||||||
id: sendAssetStep;
|
id: sendAssetStep;
|
||||||
z: 996;
|
z: 996;
|
||||||
|
|
||||||
property string referrer; // either "connections" or "nearby"
|
property string referrer; // either "connections", "nearby", or "payIn"
|
||||||
property string selectedRecipientNodeID;
|
property string selectedRecipientNodeID;
|
||||||
property string selectedRecipientDisplayName;
|
property string selectedRecipientDisplayName;
|
||||||
property string selectedRecipientUserName;
|
property string selectedRecipientUserName;
|
||||||
|
@ -931,6 +931,7 @@ Item {
|
||||||
height: 35;
|
height: 35;
|
||||||
width: 100;
|
width: 100;
|
||||||
text: "CHANGE";
|
text: "CHANGE";
|
||||||
|
visible: sendAssetStep.referrer !== "payIn";
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (sendAssetStep.referrer === "connections") {
|
if (sendAssetStep.referrer === "connections") {
|
||||||
root.nextActiveView = "chooseRecipientConnection";
|
root.nextActiveView = "chooseRecipientConnection";
|
||||||
|
@ -970,6 +971,7 @@ Item {
|
||||||
|
|
||||||
HifiControlsUit.TextField {
|
HifiControlsUit.TextField {
|
||||||
id: amountTextField;
|
id: amountTextField;
|
||||||
|
readOnly: sendAssetStep.referrer === "payIn";
|
||||||
text: root.assetName === "" ? "" : "1";
|
text: root.assetName === "" ? "" : "1";
|
||||||
colorScheme: root.assetName === "" ? hifi.colorSchemes.dark : hifi.colorSchemes.light;
|
colorScheme: root.assetName === "" ? hifi.colorSchemes.dark : hifi.colorSchemes.light;
|
||||||
inputMethodHints: Qt.ImhDigitsOnly;
|
inputMethodHints: Qt.ImhDigitsOnly;
|
||||||
|
@ -980,8 +982,8 @@ Item {
|
||||||
height: 50;
|
height: 50;
|
||||||
// Style
|
// Style
|
||||||
leftPermanentGlyph: hifi.glyphs.hfc;
|
leftPermanentGlyph: hifi.glyphs.hfc;
|
||||||
activeFocusOnPress: true;
|
activeFocusOnPress: !amountTextField.readOnly;
|
||||||
activeFocusOnTab: true;
|
activeFocusOnTab: !amountTextField.readOnly;
|
||||||
|
|
||||||
validator: IntValidator { bottom: 0; }
|
validator: IntValidator { bottom: 0; }
|
||||||
|
|
||||||
|
@ -1071,6 +1073,7 @@ Item {
|
||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
id: optionalMessage;
|
id: optionalMessage;
|
||||||
|
readOnly: sendAssetStep.referrer === "payIn";
|
||||||
property int maximumLength: 72;
|
property int maximumLength: 72;
|
||||||
property string previousText: text;
|
property string previousText: text;
|
||||||
placeholderText: "<i>Optional Public Message (" + maximumLength + " character limit)</i>";
|
placeholderText: "<i>Optional Public Message (" + maximumLength + " character limit)</i>";
|
||||||
|
@ -1081,10 +1084,10 @@ Item {
|
||||||
// Style
|
// Style
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
color: root.assetName === "" ? (optionalMessage.activeFocus ? hifi.colors.black : hifi.colors.baseGrayShadow) :
|
color: root.assetName === "" ? (optionalMessage.activeFocus && !optionalMessage.readOnly ? hifi.colors.black : hifi.colors.baseGrayShadow) :
|
||||||
(optionalMessage.activeFocus ? "#EFEFEF" : "#EEEEEE");
|
(optionalMessage.activeFocus && !optionalMessage.readOnly ? "#EFEFEF" : "#EEEEEE");
|
||||||
border.width: optionalMessage.activeFocus ? 1 : 0;
|
border.width: optionalMessage.activeFocus && !optionalMessage.readOnly ? 1 : 0;
|
||||||
border.color: optionalMessage.activeFocus ? hifi.colors.primaryHighlight : hifi.colors.textFieldLightBackground;
|
border.color: optionalMessage.activeFocus && !optionalMessage.readOnly ? hifi.colors.primaryHighlight : hifi.colors.textFieldLightBackground;
|
||||||
}
|
}
|
||||||
color: root.assetName === "" ? hifi.colors.white : hifi.colors.black;
|
color: root.assetName === "" ? hifi.colors.white : hifi.colors.black;
|
||||||
textFormat: TextEdit.PlainText;
|
textFormat: TextEdit.PlainText;
|
||||||
|
@ -1205,8 +1208,12 @@ Item {
|
||||||
width: 100;
|
width: 100;
|
||||||
text: "CANCEL";
|
text: "CANCEL";
|
||||||
onClicked: {
|
onClicked: {
|
||||||
resetSendAssetData();
|
if (sendAssetStep.referrer === "payIn") {
|
||||||
root.nextActiveView = "sendAssetHome";
|
sendToScript({method: "closeSendAsset"});
|
||||||
|
} else {
|
||||||
|
resetSendAssetData();
|
||||||
|
root.nextActiveView = "sendAssetHome";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1236,7 +1243,7 @@ Item {
|
||||||
root.isCurrentlySendingAsset = true;
|
root.isCurrentlySendingAsset = true;
|
||||||
amountTextField.focus = false;
|
amountTextField.focus = false;
|
||||||
optionalMessage.focus = false;
|
optionalMessage.focus = false;
|
||||||
if (sendAssetStep.referrer === "connections") {
|
if (sendAssetStep.referrer === "connections" || sendAssetStep.referrer === "payIn") {
|
||||||
Commerce.transferAssetToUsername(sendAssetStep.selectedRecipientUserName,
|
Commerce.transferAssetToUsername(sendAssetStep.selectedRecipientUserName,
|
||||||
root.assetCertID,
|
root.assetCertID,
|
||||||
parseInt(amountTextField.text),
|
parseInt(amountTextField.text),
|
||||||
|
@ -1364,10 +1371,14 @@ Item {
|
||||||
parent.text = hifi.glyphs.close;
|
parent.text = hifi.glyphs.close;
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.nextActiveView = "sendAssetHome";
|
if (sendAssetStep.referrer === "payIn") {
|
||||||
resetSendAssetData();
|
sendToScript({method: "closeSendAsset"});
|
||||||
if (root.assetName !== "") {
|
} else {
|
||||||
sendSignalToParent({method: "closeSendAsset"});
|
root.nextActiveView = "sendAssetHome";
|
||||||
|
resetSendAssetData();
|
||||||
|
if (root.assetName !== "") {
|
||||||
|
sendSignalToParent({method: "closeSendAsset"});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1866,11 +1877,27 @@ Item {
|
||||||
case 'updateSelectedRecipientUsername':
|
case 'updateSelectedRecipientUsername':
|
||||||
sendAssetStep.selectedRecipientUserName = message.userName;
|
sendAssetStep.selectedRecipientUserName = message.userName;
|
||||||
break;
|
break;
|
||||||
|
case 'updateSendAssetQML':
|
||||||
|
root.assetName = message.assetName || "";
|
||||||
|
root.assetCertID = message.assetCertID || "";
|
||||||
|
amountTextField.text = message.amount || 1;
|
||||||
|
sendAssetStep.referrer = "payIn";
|
||||||
|
sendAssetStep.selectedRecipientNodeID = "";
|
||||||
|
sendAssetStep.selectedRecipientDisplayName = 'Secure Payment';
|
||||||
|
sendAssetStep.selectedRecipientUserName = message.username;
|
||||||
|
optionalMessage.text = message.message || "No Message Provided";
|
||||||
|
|
||||||
|
root.nextActiveView = "sendAssetStep";
|
||||||
|
break;
|
||||||
|
case 'inspectionCertificate_resetCert':
|
||||||
|
// NOP
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('SendAsset: Unrecognized message from wallet.js');
|
console.log('SendAsset: Unrecognized message from wallet.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
signal sendSignalToParent(var msg);
|
signal sendSignalToParent(var msg);
|
||||||
|
signal sendToScript(var message);
|
||||||
//
|
//
|
||||||
// FUNCTION DEFINITIONS END
|
// FUNCTION DEFINITIONS END
|
||||||
//
|
//
|
||||||
|
|
|
@ -539,6 +539,9 @@ function fromQml(message) {
|
||||||
case 'http.request':
|
case 'http.request':
|
||||||
// Handled elsewhere, don't log.
|
// Handled elsewhere, don't log.
|
||||||
break;
|
break;
|
||||||
|
case 'closeSendAsset':
|
||||||
|
ui.close();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print('wallet.js: Unrecognized message from QML');
|
print('wallet.js: Unrecognized message from QML');
|
||||||
}
|
}
|
||||||
|
@ -663,6 +666,7 @@ function uninstallMarketplaceItemTester() {
|
||||||
|
|
||||||
var BUTTON_NAME = "INVENTORY";
|
var BUTTON_NAME = "INVENTORY";
|
||||||
var WALLET_QML_SOURCE = "hifi/commerce/wallet/Wallet.qml";
|
var WALLET_QML_SOURCE = "hifi/commerce/wallet/Wallet.qml";
|
||||||
|
var SENDASSET_QML_SOURCE = "hifi/commerce/common/sendAsset/SendAsset.qml";
|
||||||
var NOTIFICATION_POLL_TIMEOUT = 300000;
|
var NOTIFICATION_POLL_TIMEOUT = 300000;
|
||||||
var ui;
|
var ui;
|
||||||
function startup() {
|
function startup() {
|
||||||
|
@ -686,6 +690,7 @@ function startup() {
|
||||||
buttonName: BUTTON_NAME,
|
buttonName: BUTTON_NAME,
|
||||||
sortOrder: 10,
|
sortOrder: 10,
|
||||||
home: WALLET_QML_SOURCE,
|
home: WALLET_QML_SOURCE,
|
||||||
|
additionalAppScreens: SENDASSET_QML_SOURCE,
|
||||||
onOpened: walletOpened,
|
onOpened: walletOpened,
|
||||||
onClosed: walletClosed,
|
onClosed: walletClosed,
|
||||||
onMessage: fromQml,
|
onMessage: fromQml,
|
||||||
|
|
Loading…
Reference in a new issue