mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
group title support
This commit is contained in:
parent
3bc6909c96
commit
71c34b9d69
19
src/core.cpp
19
src/core.cpp
|
@ -269,6 +269,7 @@ void Core::start()
|
||||||
tox_callback_group_invite(tox, onGroupInvite, this);
|
tox_callback_group_invite(tox, onGroupInvite, this);
|
||||||
tox_callback_group_message(tox, onGroupMessage, this);
|
tox_callback_group_message(tox, onGroupMessage, this);
|
||||||
tox_callback_group_namelist_change(tox, onGroupNamelistChange, this);
|
tox_callback_group_namelist_change(tox, onGroupNamelistChange, this);
|
||||||
|
tox_callback_group_title(tox, onGroupTitleChange, this);
|
||||||
tox_callback_group_action(tox, onGroupAction, this);
|
tox_callback_group_action(tox, onGroupAction, this);
|
||||||
tox_callback_file_send_request(tox, onFileSendRequestCallback, this);
|
tox_callback_file_send_request(tox, onFileSendRequestCallback, this);
|
||||||
tox_callback_file_control(tox, onFileControlCallback, this);
|
tox_callback_file_control(tox, onFileControlCallback, this);
|
||||||
|
@ -518,6 +519,16 @@ void Core::onGroupNamelistChange(Tox*, int groupnumber, int peernumber, uint8_t
|
||||||
emit static_cast<Core*>(core)->groupNamelistChanged(groupnumber, peernumber, change);
|
emit static_cast<Core*>(core)->groupNamelistChanged(groupnumber, peernumber, change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::onGroupTitleChange(Tox*, int groupnumber, int peernumber, const uint8_t* title, uint8_t len, void* _core)
|
||||||
|
{
|
||||||
|
qDebug() << "Core: group" << groupnumber << "title changed by" << peernumber;
|
||||||
|
Core* core = static_cast<Core*>(_core);
|
||||||
|
QString author;
|
||||||
|
if (peernumber >= 0 && !tox_group_peernumber_is_ours(core->tox, groupnumber, peernumber))
|
||||||
|
author = core->getGroupPeerName(groupnumber, peernumber);
|
||||||
|
emit core->groupTitleChanged(groupnumber, author, CString::toString(title, len));
|
||||||
|
}
|
||||||
|
|
||||||
void Core::onFileSendRequestCallback(Tox*, int32_t friendnumber, uint8_t filenumber, uint64_t filesize,
|
void Core::onFileSendRequestCallback(Tox*, int32_t friendnumber, uint8_t filenumber, uint64_t filesize,
|
||||||
const uint8_t *filename, uint16_t filename_length, void *core)
|
const uint8_t *filename, uint16_t filename_length, void *core)
|
||||||
{
|
{
|
||||||
|
@ -816,6 +827,14 @@ void Core::sendGroupAction(int groupId, const QString& message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::changeGroupTitle(int groupId, const QString& title)
|
||||||
|
{
|
||||||
|
CString cTitle(title);
|
||||||
|
int err = tox_group_set_title(tox, groupId, cTitle.data(), cTitle.size());
|
||||||
|
if (!err)
|
||||||
|
emit groupTitleChanged(groupId, "", title);
|
||||||
|
}
|
||||||
|
|
||||||
void Core::sendFile(int32_t friendId, QString Filename, QString FilePath, long long filesize)
|
void Core::sendFile(int32_t friendId, QString Filename, QString FilePath, long long filesize)
|
||||||
{
|
{
|
||||||
QMutexLocker mlocker(&fileSendMutex);
|
QMutexLocker mlocker(&fileSendMutex);
|
||||||
|
|
|
@ -98,6 +98,7 @@ public slots:
|
||||||
int sendMessage(int friendId, const QString& message);
|
int sendMessage(int friendId, const QString& message);
|
||||||
void sendGroupMessage(int groupId, const QString& message);
|
void sendGroupMessage(int groupId, const QString& message);
|
||||||
void sendGroupAction(int groupId, const QString& message);
|
void sendGroupAction(int groupId, const QString& message);
|
||||||
|
void changeGroupTitle(int groupId, const QString& title);
|
||||||
int sendAction(int friendId, const QString& action);
|
int sendAction(int friendId, const QString& action);
|
||||||
void sendTyping(int friendId, bool typing);
|
void sendTyping(int friendId, bool typing);
|
||||||
|
|
||||||
|
@ -157,6 +158,7 @@ signals:
|
||||||
void groupInviteReceived(int friendnumber, uint8_t type, QByteArray publicKey);
|
void groupInviteReceived(int friendnumber, uint8_t type, QByteArray publicKey);
|
||||||
void groupMessageReceived(int groupnumber, const QString& message, const QString& author, bool isAction);
|
void groupMessageReceived(int groupnumber, const QString& message, const QString& author, bool isAction);
|
||||||
void groupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
void groupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||||
|
void groupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
||||||
|
|
||||||
void usernameSet(const QString& username);
|
void usernameSet(const QString& username);
|
||||||
void statusMessageSet(const QString& message);
|
void statusMessageSet(const QString& message);
|
||||||
|
@ -166,6 +168,7 @@ signals:
|
||||||
|
|
||||||
void messageSentResult(int friendId, const QString& message, int messageId);
|
void messageSentResult(int friendId, const QString& message, int messageId);
|
||||||
void groupSentResult(int groupId, const QString& message, int result);
|
void groupSentResult(int groupId, const QString& message, int result);
|
||||||
|
void actionSentResult(int friendId, const QString& action, int success);
|
||||||
|
|
||||||
void receiptRecieved(int friedId, int receipt);
|
void receiptRecieved(int friedId, int receipt);
|
||||||
|
|
||||||
|
@ -221,6 +224,7 @@ private:
|
||||||
static void onGroupInvite(Tox *tox, int friendnumber, uint8_t type, const uint8_t *data, uint16_t length,void *userdata);
|
static void onGroupInvite(Tox *tox, int friendnumber, uint8_t type, const uint8_t *data, uint16_t length,void *userdata);
|
||||||
static void onGroupMessage(Tox *tox, int groupnumber, int friendgroupnumber, const uint8_t * message, uint16_t length, void *userdata);
|
static void onGroupMessage(Tox *tox, int groupnumber, int friendgroupnumber, const uint8_t * message, uint16_t length, void *userdata);
|
||||||
static void onGroupNamelistChange(Tox *tox, int groupnumber, int peernumber, uint8_t change, void *userdata);
|
static void onGroupNamelistChange(Tox *tox, int groupnumber, int peernumber, uint8_t change, void *userdata);
|
||||||
|
static void onGroupTitleChange(Tox*, int groupnumber, int peernumber, const uint8_t* title, uint8_t len, void* _core);
|
||||||
static void onFileSendRequestCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize,
|
static void onFileSendRequestCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize,
|
||||||
const uint8_t *filename, uint16_t filename_length, void *userdata);
|
const uint8_t *filename, uint16_t filename_length, void *userdata);
|
||||||
static void onFileControlCallback(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
|
static void onFileControlCallback(Tox *tox, int32_t friendnumber, uint8_t receive_send, uint8_t filenumber,
|
||||||
|
|
|
@ -69,3 +69,9 @@ void Group::updatePeer(int peerId, QString name)
|
||||||
widget->onUserListChanged();
|
widget->onUserListChanged();
|
||||||
chatForm->onUserListChanged();
|
chatForm->onUserListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Group::setName(const QString& name)
|
||||||
|
{
|
||||||
|
widget->setName(name);
|
||||||
|
chatForm->setName(name);
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
void addPeer(int peerId, QString name);
|
void addPeer(int peerId, QString name);
|
||||||
void removePeer(int peerId);
|
void removePeer(int peerId);
|
||||||
void updatePeer(int peerId, QString newName);
|
void updatePeer(int peerId, QString newName);
|
||||||
|
void setName(const QString& name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int groupId;
|
int groupId;
|
||||||
|
|
|
@ -52,6 +52,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
nameLabel->setText(group->widget->getName());
|
nameLabel->setText(group->widget->getName());
|
||||||
|
nameLabel->setEditable(true);
|
||||||
|
|
||||||
nusersLabel->setFont(Style::getFont(Style::Medium));
|
nusersLabel->setFont(Style::getFont(Style::Medium));
|
||||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
||||||
|
@ -80,6 +81,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
connect(callButton, &QPushButton::clicked, this, &GroupChatForm::onCallClicked);
|
connect(callButton, &QPushButton::clicked, this, &GroupChatForm::onCallClicked);
|
||||||
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
||||||
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
|
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
|
||||||
|
connect(nameLabel, &CroppingLabel::textChanged, this, [=](QString s, QString) {emit groupTitleChanged(group->groupId, s);} );
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,9 @@ public:
|
||||||
void keyPressEvent(QKeyEvent* ev);
|
void keyPressEvent(QKeyEvent* ev);
|
||||||
void keyReleaseEvent(QKeyEvent* ev);
|
void keyReleaseEvent(QKeyEvent* ev);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void groupTitleChanged(int groupnum, const QString& name);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onSendTriggered();
|
void onSendTriggered();
|
||||||
void onMicMuteToggle();
|
void onMicMuteToggle();
|
||||||
|
|
|
@ -137,3 +137,8 @@ void GroupWidget::keyReleaseEvent(QKeyEvent* ev)
|
||||||
if (g)
|
if (g)
|
||||||
g->chatForm->keyReleaseEvent(ev);
|
g->chatForm->keyReleaseEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GroupWidget::setName(const QString& name)
|
||||||
|
{
|
||||||
|
nameLabel->setText(name);
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
void updateStatusLight();
|
void updateStatusLight();
|
||||||
void setChatForm(Ui::MainWindow &);
|
void setChatForm(Ui::MainWindow &);
|
||||||
void resetEventFlags();
|
void resetEventFlags();
|
||||||
|
void setName(const QString& name);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void groupWidgetClicked(GroupWidget* widget);
|
void groupWidgetClicked(GroupWidget* widget);
|
||||||
|
|
|
@ -222,6 +222,7 @@ void Widget::init()
|
||||||
connect(core, &Core::groupInviteReceived, this, &Widget::onGroupInviteReceived);
|
connect(core, &Core::groupInviteReceived, this, &Widget::onGroupInviteReceived);
|
||||||
connect(core, &Core::groupMessageReceived, this, &Widget::onGroupMessageReceived);
|
connect(core, &Core::groupMessageReceived, this, &Widget::onGroupMessageReceived);
|
||||||
connect(core, &Core::groupNamelistChanged, this, &Widget::onGroupNamelistChanged);
|
connect(core, &Core::groupNamelistChanged, this, &Widget::onGroupNamelistChanged);
|
||||||
|
connect(core, &Core::groupTitleChanged, this, &Widget::onGroupTitleChanged);
|
||||||
connect(core, &Core::emptyGroupCreated, this, &Widget::onEmptyGroupCreated);
|
connect(core, &Core::emptyGroupCreated, this, &Widget::onEmptyGroupCreated);
|
||||||
connect(core, &Core::avInvite, this, &Widget::playRingtone);
|
connect(core, &Core::avInvite, this, &Widget::playRingtone);
|
||||||
connect(core, &Core::blockingClearContacts, this, &Widget::clearContactsList, Qt::BlockingQueuedConnection);
|
connect(core, &Core::blockingClearContacts, this, &Widget::clearContactsList, Qt::BlockingQueuedConnection);
|
||||||
|
@ -847,7 +848,7 @@ void Widget::removeFriend(Friend* f, bool fake)
|
||||||
FriendList::removeFriend(f->getFriendID(), fake);
|
FriendList::removeFriend(f->getFriendID(), fake);
|
||||||
core->removeFriend(f->getFriendID(), fake);
|
core->removeFriend(f->getFriendID(), fake);
|
||||||
delete f;
|
delete f;
|
||||||
if (ui->mainHead->layout()->isEmpty()) // tux3: this should have covered the case of the bug you "fixed" 5 lines above
|
if (ui->mainHead->layout()->isEmpty())
|
||||||
onAddClicked();
|
onAddClicked();
|
||||||
|
|
||||||
contactListWidget->hide();
|
contactListWidget->hide();
|
||||||
|
@ -951,6 +952,17 @@ void Widget::onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t Cha
|
||||||
g->updatePeer(peernumber,core->getGroupPeerName(groupnumber, peernumber));
|
g->updatePeer(peernumber,core->getGroupPeerName(groupnumber, peernumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::onGroupTitleChanged(int groupnumber, const QString& author, const QString& title)
|
||||||
|
{
|
||||||
|
Group* g = GroupList::findGroup(groupnumber);
|
||||||
|
if (!g)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g->setName(title);
|
||||||
|
if (!author.isEmpty())
|
||||||
|
g->chatForm->addSystemInfoMessage(tr("%1 has set the title to %2").arg(author, title), "silver", QDateTime::currentDateTime());
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::removeGroup(Group* g, bool fake)
|
void Widget::removeGroup(Group* g, bool fake)
|
||||||
{
|
{
|
||||||
g->widget->setAsInactiveChatroom();
|
g->widget->setAsInactiveChatroom();
|
||||||
|
@ -999,6 +1011,7 @@ Group *Widget::createGroup(int groupId)
|
||||||
connect(newgroup->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->chatForm, SLOT(focusInput()));
|
connect(newgroup->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newgroup->chatForm, SLOT(focusInput()));
|
||||||
connect(newgroup->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
|
connect(newgroup->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendGroupMessage(int,QString)));
|
||||||
connect(newgroup->chatForm, SIGNAL(sendAction(int,QString)), core, SLOT(sendGroupAction(int,QString)));
|
connect(newgroup->chatForm, SIGNAL(sendAction(int,QString)), core, SLOT(sendGroupAction(int,QString)));
|
||||||
|
connect(newgroup->chatForm, &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
||||||
return newgroup;
|
return newgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ private slots:
|
||||||
void onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray invite);
|
void onGroupInviteReceived(int32_t friendId, uint8_t type, QByteArray invite);
|
||||||
void onGroupMessageReceived(int groupnumber, const QString& message, const QString& author, bool isAction);
|
void onGroupMessageReceived(int groupnumber, const QString& message, const QString& author, bool isAction);
|
||||||
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||||
|
void onGroupTitleChanged(int groupnumber, const QString& author, const QString& title);
|
||||||
void removeFriend(int friendId);
|
void removeFriend(int friendId);
|
||||||
void copyFriendIdToClipboard(int friendId);
|
void copyFriendIdToClipboard(int friendId);
|
||||||
void removeGroup(int groupId);
|
void removeGroup(int groupId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user