add deck hash copying functions (#3882)

This commit is contained in:
ebbit1q 2020-01-13 16:11:19 +01:00 committed by Zach H
parent 0ff7472ce5
commit 7bfefee073
5 changed files with 32 additions and 5 deletions

View file

@ -278,11 +278,26 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
bool online,
int playerId)
{
showContextMenu(pos, userName, userLevel, online, playerId, QString());
}
void UserContextMenu::showContextMenu(const QPoint &pos,
const QString &userName,
UserLevelFlags userLevel,
bool online,
int playerId,
const QString &deckHash)
{
QAction *aCopyToClipBoard;
aUserName->setText(userName);
QMenu *menu = new QMenu(static_cast<QWidget *>(parent()));
menu->addAction(aUserName);
menu->addSeparator();
if (!deckHash.isEmpty()) {
aCopyToClipBoard = new QAction(tr("Copy hash to clipboard"), this);
menu->addAction(aCopyToClipBoard);
}
menu->addAction(aDetails);
menu->addAction(aShowGames);
menu->addAction(aChat);
@ -351,9 +366,9 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
infoWidget->updateInfo(userName);
} else if (actionClicked == aChat)
} else if (actionClicked == aChat) {
emit openMessageDialog(userName, true);
else if (actionClicked == aShowGames) {
} else if (actionClicked == aShowGames) {
Command_GetGamesOfUser cmd;
cmd.set_user_name(userName.toStdString());
@ -438,6 +453,9 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
SLOT(warnUserHistory_processResponse(Response)));
client->sendCommand(pend);
} else if (actionClicked == aCopyToClipBoard) {
QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(deckHash);
}
delete menu;