add deck hash copying functions (#3882)
This commit is contained in:
parent
0ff7472ce5
commit
7bfefee073
5 changed files with 32 additions and 5 deletions
|
@ -216,6 +216,7 @@ void PlayerListWidget::showContextMenu(const QPoint &pos, const QModelIndex &ind
|
|||
const QString &userName = index.sibling(index.row(), 4).data(Qt::UserRole).toString();
|
||||
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
|
||||
UserLevelFlags userLevel(index.sibling(index.row(), 3).data(Qt::UserRole).toInt());
|
||||
QString deckHash = index.sibling(index.row(), 5).data().toString();
|
||||
|
||||
userContextMenu->showContextMenu(pos, userName, userLevel, true, playerId);
|
||||
userContextMenu->showContextMenu(pos, userName, userLevel, true, playerId, deckHash);
|
||||
}
|
||||
|
|
|
@ -121,8 +121,10 @@ void TabDeckEditor::createDeckDock()
|
|||
auto *hashSizePolicy = new QSizePolicy();
|
||||
hashSizePolicy->setHorizontalPolicy(QSizePolicy::Fixed);
|
||||
hashLabel1->setSizePolicy(*hashSizePolicy);
|
||||
hashLabel = new QLabel;
|
||||
hashLabel = new QLineEdit;
|
||||
hashLabel->setObjectName("hashLabel");
|
||||
hashLabel->setReadOnly(true);
|
||||
hashLabel->setFrame(false);
|
||||
|
||||
auto *lowerLayout = new QGridLayout;
|
||||
lowerLayout->setObjectName("lowerLayout");
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
QLabel *commentsLabel;
|
||||
QTextEdit *commentsEdit;
|
||||
QLabel *hashLabel1;
|
||||
QLabel *hashLabel;
|
||||
QLineEdit *hashLabel;
|
||||
FilterTreeModel *filterModel;
|
||||
QTreeView *filterView;
|
||||
KeySignals filterViewKeySignals;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -53,6 +53,12 @@ public:
|
|||
UserLevelFlags userLevel,
|
||||
bool online = true,
|
||||
int playerId = -1);
|
||||
void showContextMenu(const QPoint &pos,
|
||||
const QString &userName,
|
||||
UserLevelFlags userLevel,
|
||||
bool online,
|
||||
int playerId,
|
||||
const QString &deckHash);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue