Show username when admin (this probably isn't the way to get username

This commit is contained in:
Zach Fox 2018-01-11 14:45:43 -08:00
parent df58065e75
commit 1e608b13b2
8 changed files with 169 additions and 42 deletions
interface/resources/qml/hifi/commerce/wallet
libraries/avatars/src
scripts/system

View file

@ -736,6 +736,7 @@ Rectangle {
sendMoney.updateConnections(message.connections);
break;
case 'selectRecipient':
case 'updateSelectedRecipientUsername':
sendMoney.fromScript(message);
break;
default:

View file

@ -114,7 +114,7 @@ Item {
width: 110;
text: "CHOOSE";
onClicked: {
var msg = { method: 'chooseConnection', userName: root.userName };
var msg = { method: 'chooseConnection', userName: root.userName, profilePicUrl: root.profilePicUrl };
sendToSendMoney(msg);
}
}

View file

@ -14,6 +14,7 @@
import Hifi 1.0 as Hifi
import QtQuick 2.6
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0
import "../../../../styles-uit"
import "../../../../controls-uit" as HifiControlsUit
import "../../../../controls" as HifiControls
@ -440,6 +441,7 @@ Item {
sendMoneyStep.selectedRecipientNodeID = '';
sendMoneyStep.selectedRecipientDisplayName = msg.userName;
sendMoneyStep.selectedRecipientUserName = 'connection';
sendMoneyStep.selectedRecipientProfilePic = msg.profilePicUrl;
root.nextActiveView = "sendMoneyStep";
}
@ -561,8 +563,8 @@ Item {
}
RalewaySemiBold {
id: avatarNodeID;
text: chooseRecipientNearby.selectedRecipient;
id: avatarDisplayName;
text: '"' + AvatarList.getAvatar(chooseRecipientNearby.selectedRecipient).sessionDisplayName + '"';
// Anchors
anchors.top: sendToText.bottom;
anchors.topMargin: 60;
@ -572,7 +574,43 @@ Item {
anchors.rightMargin: 30;
height: paintedHeight;
// Text size
size: 18;
size: 22;
// Style
horizontalAlignment: Text.AlignHCenter;
color: hifi.colors.baseGray;
}
RalewaySemiBold {
id: avatarNodeID;
text: chooseRecipientNearby.selectedRecipient;
// Anchors
anchors.top: avatarDisplayName.bottom;
anchors.topMargin: 6;
anchors.left: parent.left;
anchors.leftMargin: 30;
anchors.right: parent.right;
anchors.rightMargin: 30;
height: paintedHeight;
// Text size
size: 14;
// Style
horizontalAlignment: Text.AlignHCenter;
color: hifi.colors.lightGrayText;
}
RalewaySemiBold {
id: avatarUserName;
text: sendMoneyStep.selectedRecipientUserName;
// Anchors
anchors.top: avatarNodeID.bottom;
anchors.topMargin: 12;
anchors.left: parent.left;
anchors.leftMargin: 30;
anchors.right: parent.right;
anchors.rightMargin: 30;
height: paintedHeight;
// Text size
size: 22;
// Style
horizontalAlignment: Text.AlignHCenter;
color: hifi.colors.baseGray;
@ -632,8 +670,6 @@ Item {
onClicked: {
sendMoneyStep.referrer = "nearby";
sendMoneyStep.selectedRecipientNodeID = chooseRecipientNearby.selectedRecipient;
sendMoneyStep.selectedRecipientDisplayName = '"ZRF Changeme"';
sendMoneyStep.selectedRecipientUserName = 'unknown username';
chooseRecipientNearby.selectedRecipient = "";
root.nextActiveView = "sendMoneyStep";
@ -652,6 +688,7 @@ Item {
property string selectedRecipientNodeID;
property string selectedRecipientDisplayName;
property string selectedRecipientUserName;
property string selectedRecipientProfilePic;
visible: root.currentActiveView === "sendMoneyStep";
anchors.fill: parent;
@ -703,37 +740,94 @@ Item {
verticalAlignment: Text.AlignVCenter;
}
RalewaySemiBold {
id: recipientDisplayName;
text: sendMoneyStep.selectedRecipientDisplayName;
// Anchors
Item {
id: recipientIsNearby;
visible: sendMoneyStep.referrer === "nearby";
anchors.top: parent.top;
anchors.left: sendToText_sendMoneyStep.right;
anchors.right: changeButton.left;
anchors.rightMargin: 12;
height: parent.height/2;
// Text size
size: 18;
// Style
color: hifi.colors.baseGray;
verticalAlignment: Text.AlignBottom;
height: parent.height;
RalewaySemiBold {
id: recipientDisplayName;
text: sendMoneyStep.selectedRecipientDisplayName;
// Anchors
anchors.top: parent.top;
anchors.left: parent.left;
anchors.right: parent.right;
anchors.rightMargin: 12;
height: parent.height/2;
// Text size
size: 18;
// Style
color: hifi.colors.baseGray;
verticalAlignment: Text.AlignBottom;
}
RalewaySemiBold {
text: sendMoneyStep.selectedRecipientUserName;
// Anchors
anchors.bottom: parent.bottom;
anchors.left: recipientDisplayName.anchors.left;
anchors.leftMargin: recipientDisplayName.anchors.leftMargin;
anchors.right: recipientDisplayName.anchors.right;
anchors.rightMargin: recipientDisplayName.anchors.rightMargin;
height: parent.height/2;
// Text size
size: 16;
// Style
color: hifi.colors.baseGray;
verticalAlignment: Text.AlignTop;
}
}
RalewaySemiBold {
id: recipientUsername;
text: sendMoneyStep.selectedRecipientUserName;
// Anchors
anchors.bottom: parent.bottom;
anchors.left: recipientDisplayName.anchors.left;
anchors.leftMargin: recipientDisplayName.anchors.leftMargin;
anchors.right: recipientDisplayName.anchors.right;
anchors.rightMargin: recipientDisplayName.anchors.rightMargin;
height: parent.height/2;
// Text size
size: 16;
// Style
color: hifi.colors.baseGray;
verticalAlignment: Text.AlignTop;
Item {
id: recipientIsConnection;
visible: sendMoneyStep.referrer === "connections";
anchors.top: parent.top;
anchors.left: sendToText_sendMoneyStep.right;
anchors.right: changeButton.left;
anchors.rightMargin: 12;
height: parent.height;
Image {
id: userImage;
source: sendMoneyStep.selectedRecipientProfilePic !== "" ? ((0 === sendMoneyStep.selectedRecipientProfilePic.indexOf("http")) ?
sendMoneyStep.selectedRecipientProfilePic : (Account.metaverseServerURL + sendMoneyStep.selectedRecipientProfilePic)) : "";
mipmap: true;
// Anchors
anchors.left: parent.left;
anchors.verticalCenter: parent.verticalCenter;
height: parent.height - 4;
layer.enabled: true;
layer.effect: OpacityMask {
maskSource: Item {
width: userImage.width;
height: userImage.height;
Rectangle {
anchors.centerIn: parent;
width: userImage.width; // This works because userImage is square
height: width;
radius: width;
}
}
}
}
RalewaySemiBold {
text: sendMoneyStep.selectedRecipientUserName;
// Anchors
anchors.left: userImage.right;
anchors.leftMargin: 8;
anchors.verticalCenter: parent.verticalCenter;
height: parent.height - 4;
// Text size
size: 16;
// Style
color: hifi.colors.baseGray;
verticalAlignment: Text.AlignVCenter;
}
}
// "CHANGE" button
@ -1472,6 +1566,7 @@ Item {
sendMoneyStep.selectedRecipientNodeID = "";
sendMoneyStep.selectedRecipientDisplayName = "";
sendMoneyStep.selectedRecipientUserName = "";
sendMoneyStep.selectedRecipientProfilePic = "";
amountTextField.text = "";
optionalMessage.text = "";
}
@ -1494,10 +1589,17 @@ Item {
case 'selectRecipient':
if (message.isSelected) {
chooseRecipientNearby.selectedRecipient = message.id[0];
sendMoneyStep.selectedRecipientDisplayName = message.displayName;
sendMoneyStep.selectedRecipientUserName = message.userName;
} else {
chooseRecipientNearby.selectedRecipient = "";
sendMoneyStep.selectedRecipientDisplayName = '';
sendMoneyStep.selectedRecipientUserName = '';
}
break;
case 'updateSelectedRecipientUsername':
sendMoneyStep.selectedRecipientUserName = message.userName;
break;
default:
console.log('SendMoney: Unrecognized message from wallet.js:', JSON.stringify(message));
}

View file

@ -358,7 +358,7 @@ class AvatarData : public QObject, public SpatiallyNestable {
Q_PROPERTY(QString displayName READ getDisplayName WRITE setDisplayName NOTIFY displayNameChanged)
// sessionDisplayName is sanitized, defaulted version displayName that is defined by the AvatarMixer rather than by Interface clients.
// The result is unique among all avatars present at the time.
Q_PROPERTY(QString sessionDisplayName READ getSessionDisplayName WRITE setSessionDisplayName)
Q_PROPERTY(QString sessionDisplayName READ getSessionDisplayName WRITE setSessionDisplayName NOTIFY sessionDisplayNameChanged)
Q_PROPERTY(bool lookAtSnappingEnabled MEMBER _lookAtSnappingEnabled NOTIFY lookAtSnappingChanged)
Q_PROPERTY(QString skeletonModelURL READ getSkeletonModelURLFromScript WRITE setSkeletonModelURLFromScript)
Q_PROPERTY(QVector<AttachmentData> attachmentData READ getAttachmentData WRITE setAttachmentData)
@ -685,6 +685,7 @@ public:
signals:
void displayNameChanged();
void sessionDisplayNameChanged();
void lookAtSnappingChanged(bool enabled);
void sessionUUIDChanged();

View file

@ -15,6 +15,7 @@ ScriptAvatarData::ScriptAvatarData(AvatarSharedPointer avatarData) :
_avatarData(avatarData)
{
QObject::connect(avatarData.get(), &AvatarData::displayNameChanged, this, &ScriptAvatarData::displayNameChanged);
QObject::connect(avatarData.get(), &AvatarData::sessionDisplayNameChanged, this, &ScriptAvatarData::sessionDisplayNameChanged);
QObject::connect(avatarData.get(), &AvatarData::lookAtSnappingChanged, this, &ScriptAvatarData::lookAtSnappingChanged);
}

View file

@ -44,7 +44,7 @@ class ScriptAvatarData : public QObject {
//
Q_PROPERTY(QUuid sessionUUID READ getSessionUUID)
Q_PROPERTY(QString displayName READ getDisplayName NOTIFY displayNameChanged)
Q_PROPERTY(QString sessionDisplayName READ getSessionDisplayName)
Q_PROPERTY(QString sessionDisplayName READ getSessionDisplayName NOTIFY sessionDisplayNameChanged)
Q_PROPERTY(bool isReplicated READ getIsReplicated)
Q_PROPERTY(bool lookAtSnappingEnabled READ getLookAtSnappingEnabled NOTIFY lookAtSnappingChanged)
@ -131,6 +131,7 @@ public:
signals:
void displayNameChanged();
void sessionDisplayNameChanged();
void lookAtSnappingChanged(bool enabled);
public slots:

View file

@ -390,13 +390,32 @@
//
// Clicks.
//
function usernameFromIDReply(id, username, machineFingerprint, isAdmin) {
if (selectedIds[0] === id) {
var message = {
method: 'updateSelectedRecipientUsername',
userName: username === "" ? "unknown username" : username
};
sendToQml(message);
}
}
function handleClick(pickRay) {
ExtendedOverlay.applyPickRay(pickRay, function (overlay) {
var nextSelectedStatus = !overlay.selected;
var message = { method: 'selectRecipient', id: [overlay.key], isSelected: nextSelectedStatus };
var avatarId = overlay.key;
selectedIds = nextSelectedStatus ? [avatarId] : [];
if (nextSelectedStatus) {
Users.requestUsernameFromID(avatarId);
}
var message = {
method: 'selectRecipient',
id: [avatarId],
isSelected: nextSelectedStatus,
displayName: '"' + AvatarList.getAvatar(avatarId).sessionDisplayName + '"',
userName: ''
};
sendToQml(message);
selectedIds = nextSelectedStatus ? [overlay.key] : [];
ExtendedOverlay.some(function (overlay) {
var id = overlay.key;
var selected = ExtendedOverlay.isSelected(id);
@ -625,6 +644,11 @@
if (onWalletScreen) {
isWired = true;
Users.usernameFromIDReply.connect(usernameFromIDReply);
Controller.mousePressEvent.connect(handleMouseEvent);
Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
triggerMapping.enable();
triggerPressMapping.enable();
} else {
off();
}
@ -648,15 +672,12 @@
});
button.clicked.connect(onButtonClicked);
tablet.screenChanged.connect(onTabletScreenChanged);
Controller.mousePressEvent.connect(handleMouseEvent);
Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
triggerMapping.enable();
triggerPressMapping.enable();
}
}
var isWired = false;
function off() {
if (isWired) { // It is not ok to disconnect these twice, hence guard.
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
Script.update.disconnect(updateOverlays);
Controller.mousePressEvent.disconnect(handleMouseEvent);
Controller.mouseMoveEvent.disconnect(handleMouseMoveEvent);

View file

@ -685,7 +685,6 @@ function startup() {
});
button.clicked.connect(onTabletButtonClicked);
tablet.screenChanged.connect(onTabletScreenChanged);
Users.usernameFromIDReply.connect(usernameFromIDReply);
Window.domainChanged.connect(clearLocalQMLDataAndClosePAL);
Window.domainConnectionRefused.connect(clearLocalQMLDataAndClosePAL);
Messages.subscribe(CHANNEL);
@ -708,6 +707,7 @@ function off() {
Controller.mousePressEvent.disconnect(handleMouseEvent);
Controller.mouseMoveEvent.disconnect(handleMouseMoveEvent);
tablet.tabletShownChanged.disconnect(tabletVisibilityChanged);
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
isWired = false;
ContextOverlay.enabled = true
}
@ -744,6 +744,7 @@ function onTabletButtonClicked() {
Script.update.connect(updateOverlays);
Controller.mousePressEvent.connect(handleMouseEvent);
Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
Users.usernameFromIDReply.connect(usernameFromIDReply);
triggerMapping.enable();
triggerPressMapping.enable();
audioTimer = createAudioInterval(conserveResources ? AUDIO_LEVEL_CONSERVED_UPDATE_INTERVAL_MS : AUDIO_LEVEL_UPDATE_INTERVAL_MS);
@ -890,7 +891,6 @@ function shutdown() {
button.clicked.disconnect(onTabletButtonClicked);
tablet.removeButton(button);
tablet.screenChanged.disconnect(onTabletScreenChanged);
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
Window.domainChanged.disconnect(clearLocalQMLDataAndClosePAL);
Window.domainConnectionRefused.disconnect(clearLocalQMLDataAndClosePAL);
Messages.subscribe(CHANNEL);