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:
commit
631c37aef1
@ -27,6 +27,8 @@
|
|||||||
#include "src/persistence/settings.h"
|
#include "src/persistence/settings.h"
|
||||||
#include "src/persistence/profile.h"
|
#include "src/persistence/profile.h"
|
||||||
#include "src/nexus.h"
|
#include "src/nexus.h"
|
||||||
|
#include "src/grouplist.h"
|
||||||
|
#include "src/group.h"
|
||||||
|
|
||||||
Friend::Friend(uint32_t FriendId, const ToxId &UserId)
|
Friend::Friend(uint32_t FriendId, const ToxId &UserId)
|
||||||
: userName{Core::getInstance()->getPeerName(UserId)},
|
: userName{Core::getInstance()->getPeerName(UserId)},
|
||||||
@ -88,6 +90,11 @@ void Friend::setAlias(QString name)
|
|||||||
GUI::setWindowTitle(dispName);
|
GUI::setWindowTitle(dispName);
|
||||||
|
|
||||||
emit displayedNameChanged(getFriendWidget(), getStatus(), hasNewEvents);
|
emit displayedNameChanged(getFriendWidget(), getStatus(), hasNewEvents);
|
||||||
|
|
||||||
|
for (Group *g : GroupList::getAllGroups())
|
||||||
|
{
|
||||||
|
g->regeneratePeerList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Friend::setStatusMessage(QString message)
|
void Friend::setStatusMessage(QString message)
|
||||||
|
@ -54,8 +54,12 @@ void Group::updatePeer(int peerId, QString name)
|
|||||||
toxids[toxid] = name;
|
toxids[toxid] = name;
|
||||||
|
|
||||||
Friend *f = FriendList::findFriend(id);
|
Friend *f = FriendList::findFriend(id);
|
||||||
|
|
||||||
if (f != nullptr && f->hasAlias())
|
if (f != nullptr && f->hasAlias())
|
||||||
|
{
|
||||||
|
peers[peerId] = f->getDisplayedName();
|
||||||
|
toxids[toxid] = f->getDisplayedName();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
widget->onUserListChanged();
|
widget->onUserListChanged();
|
||||||
chatForm->onUserListChanged();
|
chatForm->onUserListChanged();
|
||||||
@ -91,8 +95,11 @@ void Group::regeneratePeerList()
|
|||||||
|
|
||||||
QString toxid = id.publicKey;
|
QString toxid = id.publicKey;
|
||||||
toxids[toxid] = peers[i];
|
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);
|
Friend *f = FriendList::findFriend(id);
|
||||||
if (f)
|
if (f != nullptr && f->hasAlias())
|
||||||
{
|
{
|
||||||
peers[i] = f->getDisplayedName();
|
peers[i] = f->getDisplayedName();
|
||||||
toxids[toxid] = f->getDisplayedName();
|
toxids[toxid] = f->getDisplayedName();
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
|
#include <QtAlgorithms>
|
||||||
|
|
||||||
GroupChatForm::GroupChatForm(Group* chatGroup)
|
GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
: group(chatGroup), inCall{false}
|
: group(chatGroup), inCall{false}
|
||||||
@ -181,7 +182,7 @@ void GroupChatForm::onUserListChanged()
|
|||||||
peerLabels.clear();
|
peerLabels.clear();
|
||||||
|
|
||||||
// the list needs peers in peernumber order, nameLayout needs alphabetical
|
// 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
|
// first traverse in peer number order, storing the QLabels as necessary
|
||||||
QStringList names = group->getPeerList();
|
QStringList names = group->getPeerList();
|
||||||
@ -193,7 +194,7 @@ void GroupChatForm::onUserListChanged()
|
|||||||
if (!tooltip.isEmpty())
|
if (!tooltip.isEmpty())
|
||||||
peerLabels[i]->setToolTip(tooltip);
|
peerLabels[i]->setToolTip(tooltip);
|
||||||
peerLabels[i]->setTextFormat(Qt::PlainText);
|
peerLabels[i]->setTextFormat(Qt::PlainText);
|
||||||
orderizer[names[i]] = peerLabels[i];
|
nickLabelList.append(peerLabels[i]);
|
||||||
if (group->isSelfPeerNumber(i))
|
if (group->isSelfPeerNumber(i))
|
||||||
peerLabels[i]->setStyleSheet("QLabel {color : green;}");
|
peerLabels[i]->setStyleSheet("QLabel {color : green;}");
|
||||||
|
|
||||||
@ -205,10 +206,10 @@ void GroupChatForm::onUserListChanged()
|
|||||||
static_cast<GroupNetCamView*>(netcam)->clearPeers();
|
static_cast<GroupNetCamView*>(netcam)->clearPeers();
|
||||||
|
|
||||||
// now alphabetize and add to layout
|
// 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)
|
for (unsigned i=0; i<nNames; ++i)
|
||||||
{
|
{
|
||||||
QLabel* label = orderizer[names[i]];
|
QLabel *label = nickLabelList.at(i);
|
||||||
if (i != nNames - 1)
|
if (i != nNames - 1)
|
||||||
label->setText(label->text() + ", ");
|
label->setText(label->text() + ", ");
|
||||||
|
|
||||||
|
@ -1500,13 +1500,9 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
|
|||||||
g = createGroup(groupnumber);
|
g = createGroup(groupnumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString name = Nexus::getCore()->getGroupPeerName(groupnumber, peernumber);
|
|
||||||
TOX_CHAT_CHANGE change = static_cast<TOX_CHAT_CHANGE>(Change);
|
TOX_CHAT_CHANGE change = static_cast<TOX_CHAT_CHANGE>(Change);
|
||||||
if (change == TOX_CHAT_CHANGE_PEER_ADD)
|
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->addPeer(peernumber,name);
|
||||||
g->regeneratePeerList();
|
g->regeneratePeerList();
|
||||||
// g->getChatForm()->addSystemInfoMessage(tr("%1 has joined the chat").arg(name), "white", QDateTime::currentDateTime());
|
// 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...
|
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);
|
g->updatePeer(peernumber, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user