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

Add group invite context menu to friends

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-06-28 10:53:38 +02:00
parent 1f11f7bad8
commit f906d5b8f4
5 changed files with 27 additions and 3 deletions

View File

@ -7,8 +7,8 @@ However, it is not a fork.
<h2>Features</h2> <h2>Features</h2>
- Friends chat - One to one chat with friends
- Group chats (experimental, can only accept invitations) - Group chats
- File transfers, with previewing of images - File transfers, with previewing of images
- Audio calls - Audio calls

View File

@ -786,6 +786,7 @@ QList<QString> Core::getGroupPeerNames(int groupId) const
int Core::joinGroupchat(int32_t friendnumber, uint8_t* friend_group_public_key) const int Core::joinGroupchat(int32_t friendnumber, uint8_t* friend_group_public_key) const
{ {
qDebug() << QString("Trying to join groupchat invite by friend %1").arg(friendnumber);
return tox_join_groupchat(tox, friendnumber, friend_group_public_key); return tox_join_groupchat(tox, friendnumber, friend_group_public_key);
} }
@ -1162,3 +1163,8 @@ void Core::sendCallAudio(int callId, ToxAv* toxav)
QThread::msleep(5); QThread::msleep(5);
} }
} }
void Core::groupInviteFriend(int friendId, int groupId)
{
tox_invite_friend(tox, friendId, groupId);
}

1
core.h
View File

@ -116,6 +116,7 @@ public slots:
void acceptFriendRequest(const QString& userId); void acceptFriendRequest(const QString& userId);
void requestFriendship(const QString& friendAddress, const QString& message); void requestFriendship(const QString& friendAddress, const QString& message);
void groupInviteFriend(int friendId, int groupId);
void removeFriend(int friendId); void removeFriend(int friendId);
void removeGroup(int groupId); void removeGroup(int groupId);

View File

@ -25,7 +25,6 @@ int main(int argc, char *argv[])
* Adjust all status icons to match the mockup, including scooting the friendslist ones to the left and making the user one the same size * Adjust all status icons to match the mockup, including scooting the friendslist ones to the left and making the user one the same size
* Sidepanel (friendlist) should be resizeable * Sidepanel (friendlist) should be resizeable
* The online/offline/away status at the top (our) is way too big i think (follow the mockup/uTox) * The online/offline/away status at the top (our) is way too big i think (follow the mockup/uTox)
* In-chat messages should have line wrapping
* An extra side panel for groupchats, like Venom does (?) * An extra side panel for groupchats, like Venom does (?)
* *
*/ */

View File

@ -1,4 +1,8 @@
#include "friendwidget.h" #include "friendwidget.h"
#include "group.h"
#include "grouplist.h"
#include "groupwidget.h"
#include "widget.h"
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>
@ -52,6 +56,15 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
QPoint pos = event->globalPos(); QPoint pos = event->globalPos();
QMenu menu; QMenu menu;
menu.addAction("Remove friend"); menu.addAction("Remove friend");
QMenu* inviteMenu = menu.addMenu("Invite in group");
QMap<QAction*, Group*> groupActions;
for (Group* group : GroupList::groupList)
{
QAction* groupAction = inviteMenu->addAction(group->widget->name.text());
groupActions[groupAction] = group;
}
if (groupActions.isEmpty())
inviteMenu->setEnabled(false);
QAction* selectedItem = menu.exec(pos); QAction* selectedItem = menu.exec(pos);
if (selectedItem) if (selectedItem)
@ -62,6 +75,11 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
emit removeFriend(friendId); emit removeFriend(friendId);
return; return;
} }
else if (groupActions.contains(selectedItem))
{
Group* group = groupActions[selectedItem];
Widget::getInstance()->getCore()->groupInviteFriend(friendId, group->groupId);
}
} }
} }