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();
|
const QString &userName = index.sibling(index.row(), 4).data(Qt::UserRole).toString();
|
||||||
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
|
int playerId = index.sibling(index.row(), 4).data(Qt::UserRole + 1).toInt();
|
||||||
UserLevelFlags userLevel(index.sibling(index.row(), 3).data(Qt::UserRole).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();
|
auto *hashSizePolicy = new QSizePolicy();
|
||||||
hashSizePolicy->setHorizontalPolicy(QSizePolicy::Fixed);
|
hashSizePolicy->setHorizontalPolicy(QSizePolicy::Fixed);
|
||||||
hashLabel1->setSizePolicy(*hashSizePolicy);
|
hashLabel1->setSizePolicy(*hashSizePolicy);
|
||||||
hashLabel = new QLabel;
|
hashLabel = new QLineEdit;
|
||||||
hashLabel->setObjectName("hashLabel");
|
hashLabel->setObjectName("hashLabel");
|
||||||
|
hashLabel->setReadOnly(true);
|
||||||
|
hashLabel->setFrame(false);
|
||||||
|
|
||||||
auto *lowerLayout = new QGridLayout;
|
auto *lowerLayout = new QGridLayout;
|
||||||
lowerLayout->setObjectName("lowerLayout");
|
lowerLayout->setObjectName("lowerLayout");
|
||||||
|
|
|
@ -121,7 +121,7 @@ private:
|
||||||
QLabel *commentsLabel;
|
QLabel *commentsLabel;
|
||||||
QTextEdit *commentsEdit;
|
QTextEdit *commentsEdit;
|
||||||
QLabel *hashLabel1;
|
QLabel *hashLabel1;
|
||||||
QLabel *hashLabel;
|
QLineEdit *hashLabel;
|
||||||
FilterTreeModel *filterModel;
|
FilterTreeModel *filterModel;
|
||||||
QTreeView *filterView;
|
QTreeView *filterView;
|
||||||
KeySignals filterViewKeySignals;
|
KeySignals filterViewKeySignals;
|
||||||
|
|
|
@ -278,11 +278,26 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
|
||||||
bool online,
|
bool online,
|
||||||
int playerId)
|
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);
|
aUserName->setText(userName);
|
||||||
|
|
||||||
QMenu *menu = new QMenu(static_cast<QWidget *>(parent()));
|
QMenu *menu = new QMenu(static_cast<QWidget *>(parent()));
|
||||||
menu->addAction(aUserName);
|
menu->addAction(aUserName);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
if (!deckHash.isEmpty()) {
|
||||||
|
aCopyToClipBoard = new QAction(tr("Copy hash to clipboard"), this);
|
||||||
|
menu->addAction(aCopyToClipBoard);
|
||||||
|
}
|
||||||
menu->addAction(aDetails);
|
menu->addAction(aDetails);
|
||||||
menu->addAction(aShowGames);
|
menu->addAction(aShowGames);
|
||||||
menu->addAction(aChat);
|
menu->addAction(aChat);
|
||||||
|
@ -351,9 +366,9 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
|
||||||
Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||||
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
|
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
infoWidget->updateInfo(userName);
|
infoWidget->updateInfo(userName);
|
||||||
} else if (actionClicked == aChat)
|
} else if (actionClicked == aChat) {
|
||||||
emit openMessageDialog(userName, true);
|
emit openMessageDialog(userName, true);
|
||||||
else if (actionClicked == aShowGames) {
|
} else if (actionClicked == aShowGames) {
|
||||||
Command_GetGamesOfUser cmd;
|
Command_GetGamesOfUser cmd;
|
||||||
cmd.set_user_name(userName.toStdString());
|
cmd.set_user_name(userName.toStdString());
|
||||||
|
|
||||||
|
@ -438,6 +453,9 @@ void UserContextMenu::showContextMenu(const QPoint &pos,
|
||||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this,
|
||||||
SLOT(warnUserHistory_processResponse(Response)));
|
SLOT(warnUserHistory_processResponse(Response)));
|
||||||
client->sendCommand(pend);
|
client->sendCommand(pend);
|
||||||
|
} else if (actionClicked == aCopyToClipBoard) {
|
||||||
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
|
clipboard->setText(deckHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete menu;
|
delete menu;
|
||||||
|
|
|
@ -53,6 +53,12 @@ public:
|
||||||
UserLevelFlags userLevel,
|
UserLevelFlags userLevel,
|
||||||
bool online = true,
|
bool online = true,
|
||||||
int playerId = -1);
|
int playerId = -1);
|
||||||
|
void showContextMenu(const QPoint &pos,
|
||||||
|
const QString &userName,
|
||||||
|
UserLevelFlags userLevel,
|
||||||
|
bool online,
|
||||||
|
int playerId,
|
||||||
|
const QString &deckHash);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue