gui: chat: add power to copy person's id to clipboard via rmb

This commit is contained in:
chelovechishko 2022-04-02 22:19:28 +09:00
parent 04636a8b6e
commit 47fc1902af
2 changed files with 17 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QWidgetAction>
#include <QClipboard>
#include "ChatLobbyDialog.h"
@ -98,6 +99,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
distantChatAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Start private chat"), this);
sendMessageAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send Message"), this);
showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this);
copyIdAct = new QAction(QIcon(), tr("Copy ID to clipboard"), this);
QActionGroup *sortgrp = new QActionGroup(this);
actionSortByName = new QAction(QIcon(), tr("Sort by Name"), this);
@ -118,6 +120,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(voteNeutralAct, SIGNAL(triggered()), this, SLOT(voteParticipant()));
connect(voteNegativeAct, SIGNAL(triggered()), this, SLOT(voteParticipant()));
connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showInPeopleTab()));
connect(copyIdAct, SIGNAL(triggered()), this, SLOT(copyId()));
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
@ -290,6 +293,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
contextMnu->addAction(voteNeutralAct);
contextMnu->addAction(voteNegativeAct);
contextMnu->addAction(showInPeopleAct);
contextMnu->addAction(copyIdAct);
distantChatAct->setEnabled(false);
sendMessageAct->setEnabled(false);
@ -300,6 +304,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
voteNeutralAct->setEnabled(false);
voteNegativeAct->setEnabled(false);
showInPeopleAct->setEnabled(idList.count() == 1);
copyIdAct->setEnabled(idList.count() == 1);
distantChatAct->setData(QVariant::fromValue(idList));
sendMessageAct->setData(QVariant::fromValue(idList));
@ -311,6 +316,9 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QList<RsGxs
RsGxsId gxsid = idList.at(0);
if (!gxsid.isNull())
copyIdAct->setData(QString::fromStdString(gxsid.toStdString()));
if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid))
{
distantChatAct->setEnabled(true);
@ -379,6 +387,13 @@ void ChatLobbyDialog::showInPeopleTab()
idDialog->navigate(nickname);
}
void ChatLobbyDialog::copyId()
{
QAction* the_action = qobject_cast<QAction*>(sender());
if (the_action)
QApplication::clipboard()->setText(the_action->data().toString()) ;
}
void ChatLobbyDialog::init(const ChatId &/*id*/, const QString &/*title*/)
{
ChatLobbyInfo linfo ;

View File

@ -62,6 +62,7 @@ private slots:
void inviteFriends() ;
void filterChanged(const QString &text);
void showInPeopleTab();
void copyId();
void toggleWindowed(){setWindowed(!isWindowed());}
void setWindowed(bool windowed);
@ -131,6 +132,7 @@ private:
QWidgetAction *checkableAction;
QAction *sendMessageAct;
QAction *showInPeopleAct;
QAction *copyIdAct;
GxsIdChooser *ownIdChooser ;
//icons cache