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

Add option to copy friend's ID to the system clipboard

This commit is contained in:
Kevin Flynn 2014-07-01 14:50:07 -07:00
parent a9b76253af
commit 8f9efc7805
4 changed files with 22 additions and 1 deletions

View File

@ -62,6 +62,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
{
QPoint pos = event->globalPos();
QMenu menu;
menu.addAction("Copy friend ID");
menu.addAction("Remove friend");
QMenu* inviteMenu = menu.addMenu("Invite in group");
QMap<QAction*, Group*> groupActions;
@ -76,7 +77,12 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
QAction* selectedItem = menu.exec(pos);
if (selectedItem)
{
if (selectedItem->text() == "Remove friend")
if (selectedItem->text() == "Copy friend ID")
{
emit copyFriendIdToClipboard(friendId);
return;
}
else if (selectedItem->text() == "Remove friend")
{
hide();
emit removeFriend(friendId);

View File

@ -22,6 +22,7 @@ public:
signals:
void friendWidgetClicked(FriendWidget* widget);
void removeFriend(int friendId);
void copyFriendIdToClipboard(int friendId);
public:
int friendId;

View File

@ -20,6 +20,7 @@
#include <QDesktopWidget>
#include <QCursor>
#include <QSettings>
#include <QClipboard>
Widget *Widget::instance{nullptr};
@ -378,6 +379,7 @@ void Widget::addFriend(int friendId, const QString &userId)
layout->addWidget(newfriend->widget);
connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*)));
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
connect(newfriend->chatForm, SIGNAL(sendFile(int32_t,QString,QByteArray)), core, SLOT(sendFile(int32_t,QString,QByteArray)));
connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
@ -541,6 +543,17 @@ void Widget::removeFriend(int friendId)
onAddClicked();
}
void Widget::copyFriendIdToClipboard(int friendId)
{
Friend* f = FriendList::findFriend(friendId);
if (f != nullptr)
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(f->userId, QClipboard::Clipboard);
clipboard->deleteLater();
}
}
void Widget::onGroupInviteReceived(int32_t friendId, uint8_t* publicKey)
{
int groupId = core->joinGroupchat(friendId, publicKey);

View File

@ -86,6 +86,7 @@ private slots:
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
void onGroupWidgetClicked(GroupWidget* widget);
void removeFriend(int friendId);
void copyFriendIdToClipboard(int friendId);
void removeGroup(int groupId);
protected slots: