Skip to content

Commit

Permalink
show NGC group name on joining (fixed)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Sep 23, 2023
1 parent e21a7e7 commit ccf8220
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,23 @@ void Core::onNgcSelfJoin(Tox* tox, uint32_t group_number, void* vCore)
std::ignore = tox;
Core* core = static_cast<Core*>(vCore);
qDebug() << QString("onNgcSelfJoin:gn #%1").arg(group_number);
Tox_Err_Group_State_Queries error;
QString name;
size_t titleSize = tox_group_get_name_size(tox, group_number, &error);
const GroupId persistentId = core->getGroupPersistentId(group_number, 1);
const QString defaultName = persistentId.toString().left(8);
if (PARSE_ERR(error) || !titleSize) {
std::vector<uint8_t> nameBuf(titleSize);
tox_group_get_name(tox, group_number, nameBuf.data(), &error);
if (PARSE_ERR(error)) {
name = ToxString(nameBuf.data(), titleSize).getQString();
} else {
name = defaultName;
}
} else {
name = defaultName;
}
emit core->NGCGroupSetTitle((Settings::NGC_GROUPNUM_OFFSET + group_number), persistentId, name);
emit core->saveRequest();
}

Expand Down
1 change: 1 addition & 0 deletions src/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public slots:
void groupTitleChanged(int groupnumber, const QString& author, const QString& title);
void groupPeerAudioPlaying(int groupnumber, ToxPk peerPk);
void groupSentFailed(int groupId);
void NGCGroupSetTitle(uint32_t groupnumber, const GroupId& groupId, const QString& title);
void groupJoined(int groupnumber, GroupId groupId);
void actionSentResult(uint32_t friendId, const QString& action, int success);

Expand Down
11 changes: 11 additions & 0 deletions src/widget/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ void Widget::onCoreChanged(Core& core_)
connect(core, &Core::groupPeerNameChanged, this, &Widget::onGroupPeerNameChanged);
connect(core, &Core::groupTitleChanged, this, &Widget::onGroupTitleChanged);
connect(core, &Core::groupPeerAudioPlaying, this, &Widget::onGroupPeerAudioPlaying);
connect(core, &Core::NGCGroupSetTitle, this, &Widget::onNGCGroupSetTitle);
connect(core, &Core::emptyGroupCreated, this, &Widget::onEmptyGroupCreated);
connect(core, &Core::groupJoined, this, &Widget::onGroupJoined);
connect(core, &Core::friendTypingChanged, this, &Widget::onFriendTypingChanged);
Expand Down Expand Up @@ -2364,6 +2365,16 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId)
return newgroup;
}

void Widget::onNGCGroupSetTitle(uint32_t groupnumber, const GroupId& groupId, const QString& title)
{
Group* g = groupList->findGroup(groupId);
if (groupnumber >= Settings::NGC_GROUPNUM_OFFSET) {
qDebug() << "NGC group:change title" << title;
g->setTitle(QString(), title);
chatListWidget->itemsChanged();
}
}

void Widget::onEmptyGroupCreated(uint32_t groupnumber, const GroupId& groupId, const QString& title)
{
Group* group = createGroup(groupnumber, groupId);
Expand Down
1 change: 1 addition & 0 deletions src/widget/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public slots:
void onExtReceiptReceived(uint32_t friendNumber, uint64_t receiptId);
void onFriendRequestReceived(const ToxPk& friendPk, const QString& message);
void onFileReceiveRequested(const ToxFile& file);
void onNGCGroupSetTitle(uint32_t groupnumber, const GroupId& groupId, const QString& title);
void onEmptyGroupCreated(uint32_t groupnumber, const GroupId& groupId, const QString& title);
void onGroupJoined(int groupNum, const GroupId& groupId);
void onGroupInviteReceived(const GroupInvite& inviteInfo);
Expand Down

0 comments on commit ccf8220

Please sign in to comment.