From 117e302b2af7400b5694bb3fd7898ad2d08d1ab6 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 12 Jan 2017 15:40:37 -0800 Subject: [PATCH 01/10] First pass --- interface/resources/qml/hifi/NameCard.qml | 72 ++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index c6daf53b9a..c1b93b92ca 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -55,12 +55,82 @@ Item { width: parent.width - /*avatarImage.width - parent.spacing - */parent.anchors.leftMargin - parent.anchors.rightMargin height: childrenRect.height anchors.verticalCenter: parent.verticalCenter - // DisplayName Text + + // DisplayName field for my card + Rectangle { + id: myDisplayName + visible: isMyCard + color: "#C5C5C5" + anchors.left: parent.left + anchors.leftMargin: -10 + width: parent.width + 70 + height: 35 + TextInput { + id: myDisplayNameText + // Properties + text: thisNameCard.displayName + autoScroll: false + maximumLength: 64 + width: parent.width + height: parent.height + wrapMode: TextInput.Wrap + // Anchors + anchors.fill: parent + anchors.leftMargin: 10 + // Text Positioning + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + // Style + color: hifi.colors.darkGray + FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } + font.family: firaSansSemiBold.name + font.pointSize: thisNameCard.displayTextHeight + // Signals + onEditingFinished: { + console.log("New displayName: ", text) + } + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton + hoverEnabled: true + propagateComposedEvents: true + onClicked: { + myDisplayNameText.selectAll(); + myDisplayNameText.focus = true; + } + onEntered: myDisplayName.color = hifi.colors.lightGrayText + onExited: myDisplayName.color = "#C5C5C5" + } + // Edit pencil glyph + HiFiGlyphs { + text: hifi.glyphs.edit + // Size + size: thisNameCard.displayTextHeight + // Anchors + anchors.right: parent.right + anchors.rightMargin: size/2 + anchors.verticalCenter: parent.verticalCenter + // Style + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: hifi.colors.baseGray + } + } + // Spacer for DisplayName for my card + Rectangle { + width: myDisplayName.width + height: 5 + visible: isMyCard + opacity: 0 + } + // DisplayName Text for others' cards FiraSansSemiBold { id: displayNameText // Properties text: thisNameCard.displayName elide: Text.ElideRight + visible: !isMyCard // Size width: parent.width // Anchors From 6e4a4da92ab2ec2920ac135493d935b73d62f5f3 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 12 Jan 2017 16:40:47 -0800 Subject: [PATCH 02/10] Checkpoint --- interface/resources/qml/hifi/NameCard.qml | 18 ++++++++++-------- scripts/system/pal.js | 6 ++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index c1b93b92ca..906e81a08d 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -69,17 +69,15 @@ Item { id: myDisplayNameText // Properties text: thisNameCard.displayName - autoScroll: false maximumLength: 64 - width: parent.width - height: parent.height - wrapMode: TextInput.Wrap + clip: true // Anchors anchors.fill: parent anchors.leftMargin: 10 + anchors.rightMargin: editGlyph.implicitWidth + editGlyph.anchors.rightMargin // Text Positioning - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignLeft + verticalAlignment: TextInput.AlignVCenter + horizontalAlignment: TextInput.AlignLeft // Style color: hifi.colors.darkGray FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } @@ -87,15 +85,18 @@ Item { font.pointSize: thisNameCard.displayTextHeight // Signals onEditingFinished: { - console.log("New displayName: ", text) + pal.sendToScript({method: 'displayNameUpdate', params: text}) } } MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton hoverEnabled: true - propagateComposedEvents: true onClicked: { + myDisplayNameText.focus ? myDisplayNameText.cursorPosition = myDisplayNameText.positionAt(mouseX, mouseY, TextInput.CursorOnCharacter) : myDisplayNameText.selectAll(); + myDisplayNameText.focus = true; + } + onDoubleClicked: { myDisplayNameText.selectAll(); myDisplayNameText.focus = true; } @@ -104,6 +105,7 @@ Item { } // Edit pencil glyph HiFiGlyphs { + id: editGlyph text: hifi.glyphs.edit // Size size: thisNameCard.displayTextHeight diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 6b3fd00c3b..c6ac1056de 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -237,6 +237,12 @@ pal.fromQml.connect(function (message) { // messages are {method, params}, like data = message.params; Users.setAvatarGain(data['sessionId'], data['gain']); break; + case 'displayNameUpdate': + if (MyAvatar.displayName != message.params) { + MyAvatar.displayName = message.params; + } + break; + default: default: print('Unrecognized message from Pal.qml:', JSON.stringify(message)); } From 2f176f50fae4ff06d9ab2e92b92acdf81b63e38c Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 13 Jan 2017 12:56:59 -0800 Subject: [PATCH 03/10] Another checkpoint --- interface/resources/fonts/hifi-glyphs.ttf | Bin 24580 -> 24772 bytes interface/resources/qml/hifi/NameCard.qml | 13 +++++++++---- interface/resources/qml/hifi/Pal.qml | 13 +++++++++++-- .../qml/styles-uit/HifiConstants.qml | 3 ++- libraries/avatars/src/AvatarData.cpp | 1 + 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/interface/resources/fonts/hifi-glyphs.ttf b/interface/resources/fonts/hifi-glyphs.ttf index 09aefffdfef007aa94f3cbdfd02a61612c0ee9e7..c139a196d0f70536b980d7cbbad81c416d237e0b 100644 GIT binary patch delta 684 zcmX|;O-Phs5Xb-XywCf*>%Q(6$S&oZx@9eHv}!B62_*z(6xCL4;;xpy=;jLh1+Jh( z>Y;-|hw`~Z*sVi>V9P>>2uv~|=n@!tkdO}2rArZH1jc^Qz|8y(GsFC6?!BS)HJSwh zuwf1guJ-gqFHcTK2Z7;d0F3k9=X$UN0SwOrXo~cQqI-(GC(KMSZ&foL?DFh{Mi9}57s0fdst#H`8NXa}G=0L{sC ze(Jz(-5NkI0PLo+Bj%l^hur{Q2e6Yir*il}w*Wd-S}0?t6W_wG`heJPfQq^7MBZ}$ z>nbp?4DgR-aRiK-7nX+{r+-0bDB0$dt&K`%TN{gXhO)AYZjwzd(Oz({T%rJFH_9_W z%}~l@fRm*p4i;2~&Ft9ZI{QhP;!DLr@-6?&{QlySTIiisFo+nf&y? zVy4k%5F@MqxvQY7cFh^-AZZBA>D4M7hyAs@)MEA3Qw?Wa+-3QK`kR zDeVZ#SUkYmgK|DTDgVa3l$8ww+l*4hKLhU+yPg;w&!5O8G9%+DK&}ooP)2?ks@MPj HXlvsiT0xGP delta 494 zcmX|+Pe>GT6vsbrW_Gp4>>>-+5?hq(sSUw@UQl~C_V^eb z5-UJuYW%_I)Aqmn;9G#$Qab63obA}G1$Kd^bUK-Hj2p5CQUhE~yVJ9^&udmemVlq* z6T{BKQ0f90%fNTnna%Q520>c9hcb?v91A~s5B*Uulbx8F{?oob3GpK^J{IK!=6Zj0 zCeF7VU}|`^t*m@$YF7S*+?0&EB?D5W7UVF3Cs6EQF^^n9FH#Ug{GJ$D=U6E9HrGeVw}Msz}qtW z2(VRVKLP%$+x9h8i1$dNs<5w1qiVKi)Ehe_8MSHe7GB@~tgGD6C2`f_&_(mq(#oFz Dg()->killNodeWithUUID(getSessionUUID()); qCDebug(avatars) << "Changing display name for avatar to" << displayName; } From 32e330320e0e50d84d8d7bb1a03d0831732fcb17 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 16 Jan 2017 11:26:57 -0800 Subject: [PATCH 04/10] Cleanup after rebase --- interface/resources/qml/hifi/NameCard.qml | 17 ++++++++++++----- interface/resources/qml/hifi/Pal.qml | 8 -------- libraries/avatars/src/AvatarData.cpp | 2 +- scripts/system/pal.js | 1 - 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index 250dad7f7f..b389891255 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -60,11 +60,15 @@ Item { Rectangle { id: myDisplayName visible: isMyCard - color: "#C5C5C5" - anchors.left: parent.left - anchors.leftMargin: -10 + // Size width: parent.width + 70 height: 35 + // Anchors + anchors.top: parent.top + anchors.left: parent.left + anchors.leftMargin: -10 + // Style + color: "#C5C5C5" border.color: hifi.colors.blueHighlight border.width: 0 TextInput { @@ -126,7 +130,10 @@ Item { } // Spacer for DisplayName for my card Rectangle { + id: myDisplayNameSpacer width: myDisplayName.width + // Anchors + anchors.top: myDisplayName.bottom height: 5 visible: isMyCard opacity: 0 @@ -160,7 +167,7 @@ Item { // Size width: parent.width // Anchors - anchors.top: displayNameText.bottom + anchors.top: isMyCard ? myDisplayNameSpacer.bottom : displayNameText.bottom // Text Size size: thisNameCard.usernameTextHeight // Text Positioning @@ -182,7 +189,7 @@ Item { Rectangle { id: nameCardVUMeter // Size - width: ((gainSlider.value - gainSlider.minimumValue)/(gainSlider.maximumValue - gainSlider.minimumValue)) * parent.width + width: isMyCard ? gainSlider.width : ((gainSlider.value - gainSlider.minimumValue)/(gainSlider.maximumValue - gainSlider.minimumValue)) * parent.width height: 8 // Anchors anchors.top: spacer.bottom diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index 8fa8fe8514..68ad3f811c 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -346,11 +346,6 @@ Rectangle { visible: iAmAdmin color: hifi.colors.lightGrayText } - function letterbox(message) { - letterboxMessage.text = message; - letterboxMessage.visible = true - - } // This Rectangle refers to the [?] popup button next to "NAMES" Rectangle { color: hifi.colors.tableBackgroundLight @@ -411,9 +406,6 @@ Rectangle { onExited: adminHelpText.color = hifi.colors.redHighlight } } - LetterboxMessage { - id: letterboxMessage - } } function findSessionIndex(sessionId, optionalData) { // no findIndex in .qml diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 0381363ef3..0350e73d2e 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1094,7 +1094,7 @@ void AvatarData::setSkeletonModelURL(const QUrl& skeletonModelURL) { void AvatarData::setDisplayName(const QString& displayName) { _displayName = displayName; - DependencyManager::get()->killNodeWithUUID(getSessionUUID()); + DependencyManager::get()->getDomainHandler().softReset(); qCDebug(avatars) << "Changing display name for avatar to" << displayName; } diff --git a/scripts/system/pal.js b/scripts/system/pal.js index c6ac1056de..6fd386b00f 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -242,7 +242,6 @@ pal.fromQml.connect(function (message) { // messages are {method, params}, like MyAvatar.displayName = message.params; } break; - default: default: print('Unrecognized message from Pal.qml:', JSON.stringify(message)); } From 3b56f46206a3267c8016c9959c90958f343f5fb3 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 16 Jan 2017 13:18:24 -0800 Subject: [PATCH 05/10] Style changes --- interface/resources/qml/hifi/NameCard.qml | 34 ++++++++++++++--------- libraries/avatars/src/AvatarData.cpp | 3 +- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index b389891255..367ef3b25b 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -28,7 +28,7 @@ Item { property string uuid: "" property string displayName: "" property string userName: "" - property int displayTextHeight: 18 + property real displayNameTextPixelSize: 18 property int usernameTextHeight: 12 property real audioLevel: 0.0 property bool isMyCard: false @@ -68,7 +68,7 @@ Item { anchors.left: parent.left anchors.leftMargin: -10 // Style - color: "#C5C5C5" + color: hifi.colors.textFieldLightBackground border.color: hifi.colors.blueHighlight border.width: 0 TextInput { @@ -77,23 +77,30 @@ Item { text: thisNameCard.displayName maximumLength: 64 clip: true + // Size + width: parent.width + height: parent.height // Anchors - anchors.fill: parent + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left anchors.leftMargin: 10 anchors.rightMargin: editGlyph.implicitWidth + editGlyph.anchors.rightMargin - // Text Positioning - verticalAlignment: TextInput.AlignVCenter - horizontalAlignment: TextInput.AlignLeft // Style color: hifi.colors.darkGray FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } font.family: firaSansSemiBold.name - font.pointSize: thisNameCard.displayTextHeight + font.pixelSize: displayNameTextPixelSize + selectionColor: hifi.colors.blueHighlight + selectedTextColor: "black" + // Text Positioning + verticalAlignment: TextInput.AlignVCenter + horizontalAlignment: TextInput.AlignLeft // Signals onEditingFinished: { pal.sendToScript({method: 'displayNameUpdate', params: text}) focus = false myDisplayName.border.width = 0 + color = hifi.colors.darkGray } } MouseArea { @@ -101,23 +108,24 @@ Item { acceptedButtons: Qt.LeftButton hoverEnabled: true onClicked: { - myDisplayName.border.width = 3 + myDisplayName.border.width = 1 myDisplayNameText.focus ? myDisplayNameText.cursorPosition = myDisplayNameText.positionAt(mouseX, mouseY, TextInput.CursorOnCharacter) : myDisplayNameText.selectAll(); myDisplayNameText.focus = true + myDisplayNameText.color = "black" } onDoubleClicked: { myDisplayNameText.selectAll(); myDisplayNameText.focus = true; } onEntered: myDisplayName.color = hifi.colors.lightGrayText - onExited: myDisplayName.color = "#C5C5C5" + onExited: myDisplayName.color = hifi.colors.textFieldLightBackground } // Edit pencil glyph HiFiGlyphs { id: editGlyph text: hifi.glyphs.editPencil - // Size - size: thisNameCard.displayTextHeight*1.5 + // Text Size + size: displayNameTextPixelSize*1.5 // Anchors anchors.right: parent.right anchors.rightMargin: 5 @@ -150,7 +158,7 @@ Item { // Anchors anchors.top: parent.top // Text Size - size: thisNameCard.displayTextHeight + size: displayNameTextPixelSize // Text Positioning verticalAlignment: Text.AlignVCenter // Style @@ -189,7 +197,7 @@ Item { Rectangle { id: nameCardVUMeter // Size - width: isMyCard ? gainSlider.width : ((gainSlider.value - gainSlider.minimumValue)/(gainSlider.maximumValue - gainSlider.minimumValue)) * parent.width + width: isMyCard ? myDisplayName.width - 20 : ((gainSlider.value - gainSlider.minimumValue)/(gainSlider.maximumValue - gainSlider.minimumValue)) * parent.width height: 8 // Anchors anchors.top: spacer.bottom diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 0350e73d2e..3d09be0679 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1047,7 +1047,7 @@ bool AvatarData::processAvatarIdentity(const Identity& identity) { } if (identity.displayName != _displayName) { - setDisplayName(identity.displayName); + _displayName = identity.displayName; hasIdentityChanged = true; } maybeUpdateSessionDisplayNameFromTransport(identity.sessionDisplayName); @@ -1094,6 +1094,7 @@ void AvatarData::setSkeletonModelURL(const QUrl& skeletonModelURL) { void AvatarData::setDisplayName(const QString& displayName) { _displayName = displayName; + DependencyManager::get()->getDomainHandler().softReset(); qCDebug(avatars) << "Changing display name for avatar to" << displayName; From e98a40c30e287897fddef8be2fe20f256f7a8485 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 16 Jan 2017 14:43:30 -0800 Subject: [PATCH 06/10] Does this work? --- assignment-client/src/avatars/AvatarMixer.cpp | 12 +++++++++--- .../src/avatars/AvatarMixerClientData.h | 6 +++--- libraries/avatars/src/AvatarData.cpp | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 11cbd73970..8ac2f3922b 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -262,8 +262,13 @@ void AvatarMixer::broadcastAvatarData() { // setup a PacketList for the avatarPackets auto avatarPacketList = NLPacketList::create(PacketType::BulkAvatarData); - if (avatar.getSessionDisplayName().isEmpty() && // We haven't set it yet... - nodeData->getReceivedIdentity()) { // ... but we have processed identity (with possible displayName). + if (nodeData->getAvatarSessionDisplayNameMustChange()) { // ... but we have processed identity (with possible displayName). + const QString& existingBaseDisplayName = nodeData->getBaseDisplayName(); + // No sense guarding against very rare case of a node with no entry, as this will work without the guard and do one less lookup in the common case. + if (--_sessionDisplayNames[existingBaseDisplayName].second <= 0) { + _sessionDisplayNames.remove(existingBaseDisplayName); + } + QString baseName = avatar.getDisplayName().trimmed(); const QRegularExpression curses{ "fuck|shit|damn|cock|cunt" }; // POC. We may eventually want something much more elaborate (subscription?). baseName = baseName.replace(curses, "*"); // Replace rather than remove, so that people have a clue that the person's a jerk. @@ -280,6 +285,7 @@ void AvatarMixer::broadcastAvatarData() { highWater++; soFar.second++; // refcount nodeData->flagIdentityChange(); + nodeData->setAvatarSessionDisplayNameMustChange(false); sendIdentityPacket(nodeData, node); // Tell new node about its sessionUUID. Others will find out below. } @@ -584,7 +590,7 @@ void AvatarMixer::handleAvatarIdentityPacket(QSharedPointer mes if (avatar.processAvatarIdentity(identity)) { QMutexLocker nodeDataLocker(&nodeData->getMutex()); nodeData->flagIdentityChange(); - nodeData->setReceivedIdentity(); + nodeData->setAvatarSessionDisplayNameMustChange(); } } } diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index f18cfdde1b..38db2e74d2 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -53,8 +53,8 @@ public: HRCTime getIdentityChangeTimestamp() const { return _identityChangeTimestamp; } void flagIdentityChange() { _identityChangeTimestamp = p_high_resolution_clock::now(); } - bool getReceivedIdentity() const { return _gotIdentity; } - void setReceivedIdentity() { _gotIdentity = true; } + bool getAvatarSessionDisplayNameMustChange() const { return _avatarSessionDisplayNameMustChange; } + void setAvatarSessionDisplayNameMustChange(bool set = true) { _avatarSessionDisplayNameMustChange = set; } void setFullRateDistance(float fullRateDistance) { _fullRateDistance = fullRateDistance; } float getFullRateDistance() const { return _fullRateDistance; } @@ -112,7 +112,7 @@ private: std::unordered_set _hasReceivedFirstPacketsFrom; HRCTime _identityChangeTimestamp; - bool _gotIdentity { false }; + bool _avatarSessionDisplayNameMustChange{ false }; float _fullRateDistance = FLT_MAX; float _maxAvatarDistance = FLT_MAX; diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 3d09be0679..1fb68fce14 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1094,8 +1094,9 @@ void AvatarData::setSkeletonModelURL(const QUrl& skeletonModelURL) { void AvatarData::setDisplayName(const QString& displayName) { _displayName = displayName; + _sessionDisplayName = ""; - DependencyManager::get()->getDomainHandler().softReset(); + sendIdentityPacket(); qCDebug(avatars) << "Changing display name for avatar to" << displayName; } From e72c25736e804bbd625c5855b6d85e7b15086eff Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 16 Jan 2017 15:21:18 -0800 Subject: [PATCH 07/10] Cleanup --- assignment-client/src/avatars/AvatarMixer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 8ac2f3922b..4127719b7b 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -262,9 +262,8 @@ void AvatarMixer::broadcastAvatarData() { // setup a PacketList for the avatarPackets auto avatarPacketList = NLPacketList::create(PacketType::BulkAvatarData); - if (nodeData->getAvatarSessionDisplayNameMustChange()) { // ... but we have processed identity (with possible displayName). + if (nodeData->getAvatarSessionDisplayNameMustChange()) { const QString& existingBaseDisplayName = nodeData->getBaseDisplayName(); - // No sense guarding against very rare case of a node with no entry, as this will work without the guard and do one less lookup in the common case. if (--_sessionDisplayNames[existingBaseDisplayName].second <= 0) { _sessionDisplayNames.remove(existingBaseDisplayName); } @@ -286,7 +285,7 @@ void AvatarMixer::broadcastAvatarData() { soFar.second++; // refcount nodeData->flagIdentityChange(); nodeData->setAvatarSessionDisplayNameMustChange(false); - sendIdentityPacket(nodeData, node); // Tell new node about its sessionUUID. Others will find out below. + sendIdentityPacket(nodeData, node); // Tell node whose name changed about its new session display name. Others will find out below. } // this is an AGENT we have received head data from @@ -590,7 +589,7 @@ void AvatarMixer::handleAvatarIdentityPacket(QSharedPointer mes if (avatar.processAvatarIdentity(identity)) { QMutexLocker nodeDataLocker(&nodeData->getMutex()); nodeData->flagIdentityChange(); - nodeData->setAvatarSessionDisplayNameMustChange(); + nodeData->setAvatarSessionDisplayNameMustChange(true); } } } From 1e8effdcc42d85b6326b0c4d240088e23b36cee1 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 16 Jan 2017 15:28:53 -0800 Subject: [PATCH 08/10] Packet verison bump --- libraries/networking/src/udt/PacketHeaders.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index c012ed8f67..9bbd139138 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -211,7 +211,8 @@ enum class AvatarMixerPacketVersion : PacketVersion { HandControllerJoints, HasKillAvatarReason, SessionDisplayName, - Unignore + Unignore, + ImmediateSessionDisplayNameUpdates }; enum class DomainConnectRequestVersion : PacketVersion { From 246f5fb7f5da02172c45e8c8032bb8274ffd8ef0 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 17 Jan 2017 11:51:09 -0800 Subject: [PATCH 09/10] Add log; fix whitespace --- assignment-client/src/avatars/AvatarMixer.cpp | 4 +++- libraries/networking/src/udt/PacketHeaders.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 4127719b7b..cd866cecb2 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -280,12 +280,14 @@ void AvatarMixer::broadcastAvatarData() { QPair& soFar = _sessionDisplayNames[baseName]; // Inserts and answers 0, 0 if not already present, which is what we want. int& highWater = soFar.first; nodeData->setBaseDisplayName(baseName); - avatar.setSessionDisplayName((highWater > 0) ? baseName + "_" + QString::number(highWater) : baseName); + QString sessionDisplayName = (highWater > 0) ? baseName + "_" + QString::number(highWater) : baseName; + avatar.setSessionDisplayName(sessionDisplayName); highWater++; soFar.second++; // refcount nodeData->flagIdentityChange(); nodeData->setAvatarSessionDisplayNameMustChange(false); sendIdentityPacket(nodeData, node); // Tell node whose name changed about its new session display name. Others will find out below. + qDebug() << "Giving session display name" << sessionDisplayName << "to node with ID" << node->getUUID(); } // this is an AGENT we have received head data from diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 9bbd139138..5cef6013d9 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -212,7 +212,7 @@ enum class AvatarMixerPacketVersion : PacketVersion { HasKillAvatarReason, SessionDisplayName, Unignore, - ImmediateSessionDisplayNameUpdates + ImmediateSessionDisplayNameUpdates }; enum class DomainConnectRequestVersion : PacketVersion { From 59ff970d5b400867506418da8761442fdca6dc3d Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Tue, 17 Jan 2017 15:01:02 -0800 Subject: [PATCH 10/10] CR feedback --- interface/resources/qml/hifi/NameCard.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/hifi/NameCard.qml b/interface/resources/qml/hifi/NameCard.qml index 367ef3b25b..2725ea1617 100644 --- a/interface/resources/qml/hifi/NameCard.qml +++ b/interface/resources/qml/hifi/NameCard.qml @@ -75,7 +75,7 @@ Item { id: myDisplayNameText // Properties text: thisNameCard.displayName - maximumLength: 64 + maximumLength: 256 clip: true // Size width: parent.width @@ -84,7 +84,8 @@ Item { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: 10 - anchors.rightMargin: editGlyph.implicitWidth + editGlyph.anchors.rightMargin + anchors.right: parent.right + anchors.rightMargin: editGlyph.width + editGlyph.anchors.rightMargin // Style color: hifi.colors.darkGray FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } @@ -98,6 +99,7 @@ Item { // Signals onEditingFinished: { pal.sendToScript({method: 'displayNameUpdate', params: text}) + cursorPosition = 0 focus = false myDisplayName.border.width = 0 color = hifi.colors.darkGray