1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #2839

apprb (4):
      Groupchats: fix user list update
      Grouplist: tracking of the friend's alias changing (fix: #1847)
      Fix #2600: Missing username in group chat
      Check for empty username in a groupchat
This commit is contained in:
sudden6 2016-03-26 12:36:48 +01:00
commit 631c37aef1
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
4 changed files with 25 additions and 10 deletions

View File

@ -27,6 +27,8 @@
#include "src/persistence/settings.h"
#include "src/persistence/profile.h"
#include "src/nexus.h"
#include "src/grouplist.h"
#include "src/group.h"
Friend::Friend(uint32_t FriendId, const ToxId &UserId)
: userName{Core::getInstance()->getPeerName(UserId)},
@ -88,6 +90,11 @@ void Friend::setAlias(QString name)
GUI::setWindowTitle(dispName);
emit displayedNameChanged(getFriendWidget(), getStatus(), hasNewEvents);
for (Group *g : GroupList::getAllGroups())
{
g->regeneratePeerList();
}
}
void Friend::setStatusMessage(QString message)

View File

@ -54,8 +54,12 @@ void Group::updatePeer(int peerId, QString name)
toxids[toxid] = name;
Friend *f = FriendList::findFriend(id);
if (f != nullptr && f->hasAlias())
{
peers[peerId] = f->getDisplayedName();
toxids[toxid] = f->getDisplayedName();
}
else
{
widget->onUserListChanged();
chatForm->onUserListChanged();
@ -91,8 +95,11 @@ void Group::regeneratePeerList()
QString toxid = id.publicKey;
toxids[toxid] = peers[i];
if (toxids[toxid].isEmpty())
toxids[toxid] = tr("<Empty>", "Placeholder when someone's name in a group chat is empty");
Friend *f = FriendList::findFriend(id);
if (f)
if (f != nullptr && f->hasAlias())
{
peers[i] = f->getDisplayedName();
toxids[toxid] = f->getDisplayedName();

View File

@ -35,6 +35,7 @@
#include <QPushButton>
#include <QMimeData>
#include <QDragEnterEvent>
#include <QtAlgorithms>
GroupChatForm::GroupChatForm(Group* chatGroup)
: group(chatGroup), inCall{false}
@ -181,7 +182,7 @@ void GroupChatForm::onUserListChanged()
peerLabels.clear();
// the list needs peers in peernumber order, nameLayout needs alphabetical
QMap<QString, QLabel*> orderizer;
QList<QLabel*> nickLabelList;
// first traverse in peer number order, storing the QLabels as necessary
QStringList names = group->getPeerList();
@ -193,7 +194,7 @@ void GroupChatForm::onUserListChanged()
if (!tooltip.isEmpty())
peerLabels[i]->setToolTip(tooltip);
peerLabels[i]->setTextFormat(Qt::PlainText);
orderizer[names[i]] = peerLabels[i];
nickLabelList.append(peerLabels[i]);
if (group->isSelfPeerNumber(i))
peerLabels[i]->setStyleSheet("QLabel {color : green;}");
@ -205,10 +206,10 @@ void GroupChatForm::onUserListChanged()
static_cast<GroupNetCamView*>(netcam)->clearPeers();
// now alphabetize and add to layout
names.sort(Qt::CaseInsensitive);
qSort(nickLabelList.begin(), nickLabelList.end(), [](QLabel *a, QLabel *b){return a->text().toLower() < b->text().toLower();});
for (unsigned i=0; i<nNames; ++i)
{
QLabel* label = orderizer[names[i]];
QLabel *label = nickLabelList.at(i);
if (i != nNames - 1)
label->setText(label->text() + ", ");

View File

@ -1500,13 +1500,9 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
g = createGroup(groupnumber);
}
QString name = Nexus::getCore()->getGroupPeerName(groupnumber, peernumber);
TOX_CHAT_CHANGE change = static_cast<TOX_CHAT_CHANGE>(Change);
if (change == TOX_CHAT_CHANGE_PEER_ADD)
{
if (name.isEmpty())
name = tr("<Unknown>", "Placeholder when we don't know someone's name in a group chat");
// g->addPeer(peernumber,name);
g->regeneratePeerList();
// g->getChatForm()->addSystemInfoMessage(tr("%1 has joined the chat").arg(name), "white", QDateTime::currentDateTime());
@ -1521,6 +1517,10 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
}
else if (change == TOX_CHAT_CHANGE_PEER_NAME) // core overwrites old name before telling us it changed...
{
QString name = Nexus::getCore()->getGroupPeerName(groupnumber, peernumber);
if (name.isEmpty())
name = tr("<Empty>", "Placeholder when someone's name in a group chat is empty");
g->updatePeer(peernumber, name);
}
}