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:
parent
a9b76253af
commit
8f9efc7805
|
@ -62,6 +62,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
{
|
{
|
||||||
QPoint pos = event->globalPos();
|
QPoint pos = event->globalPos();
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
menu.addAction("Copy friend ID");
|
||||||
menu.addAction("Remove friend");
|
menu.addAction("Remove friend");
|
||||||
QMenu* inviteMenu = menu.addMenu("Invite in group");
|
QMenu* inviteMenu = menu.addMenu("Invite in group");
|
||||||
QMap<QAction*, Group*> groupActions;
|
QMap<QAction*, Group*> groupActions;
|
||||||
|
@ -76,7 +77,12 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
||||||
QAction* selectedItem = menu.exec(pos);
|
QAction* selectedItem = menu.exec(pos);
|
||||||
if (selectedItem)
|
if (selectedItem)
|
||||||
{
|
{
|
||||||
if (selectedItem->text() == "Remove friend")
|
if (selectedItem->text() == "Copy friend ID")
|
||||||
|
{
|
||||||
|
emit copyFriendIdToClipboard(friendId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (selectedItem->text() == "Remove friend")
|
||||||
{
|
{
|
||||||
hide();
|
hide();
|
||||||
emit removeFriend(friendId);
|
emit removeFriend(friendId);
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void friendWidgetClicked(FriendWidget* widget);
|
void friendWidgetClicked(FriendWidget* widget);
|
||||||
void removeFriend(int friendId);
|
void removeFriend(int friendId);
|
||||||
|
void copyFriendIdToClipboard(int friendId);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int friendId;
|
int friendId;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
Widget *Widget::instance{nullptr};
|
Widget *Widget::instance{nullptr};
|
||||||
|
|
||||||
|
@ -378,6 +379,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
||||||
layout->addWidget(newfriend->widget);
|
layout->addWidget(newfriend->widget);
|
||||||
connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*)));
|
connect(newfriend->widget, SIGNAL(friendWidgetClicked(FriendWidget*)), this, SLOT(onFriendWidgetClicked(FriendWidget*)));
|
||||||
connect(newfriend->widget, SIGNAL(removeFriend(int)), this, SLOT(removeFriend(int)));
|
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(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(sendFile(int32_t,QString,QByteArray)), core, SLOT(sendFile(int32_t,QString,QByteArray)));
|
||||||
connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
|
connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
|
||||||
|
@ -541,6 +543,17 @@ void Widget::removeFriend(int friendId)
|
||||||
onAddClicked();
|
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)
|
void Widget::onGroupInviteReceived(int32_t friendId, uint8_t* publicKey)
|
||||||
{
|
{
|
||||||
int groupId = core->joinGroupchat(friendId, publicKey);
|
int groupId = core->joinGroupchat(friendId, publicKey);
|
||||||
|
|
|
@ -86,6 +86,7 @@ private slots:
|
||||||
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change);
|
||||||
void onGroupWidgetClicked(GroupWidget* widget);
|
void onGroupWidgetClicked(GroupWidget* widget);
|
||||||
void removeFriend(int friendId);
|
void removeFriend(int friendId);
|
||||||
|
void copyFriendIdToClipboard(int friendId);
|
||||||
void removeGroup(int groupId);
|
void removeGroup(int groupId);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user