mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-27 00:14:40 -07:00
[Client] Add copy-game-link action to the game menu (#7139)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
078e67c56f
commit
94943f7ff3
3 changed files with 24 additions and 3 deletions
|
|
@ -319,7 +319,7 @@ void GameSelector::customContextMenu(const QPoint &point)
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
QAction copyLink(tr("Copy Game Link"));
|
QAction copyLink(tr("Cop&y game link"));
|
||||||
connect(©Link, &QAction::triggered, this, [=, this]() {
|
connect(©Link, &QAction::triggered, this, [=, this]() {
|
||||||
const ServerInfo_Game &gameInfo = gameListModel->getGame(index.data(Qt::UserRole).toInt());
|
const ServerInfo_Game &gameInfo = gameListModel->getGame(index.data(Qt::UserRole).toInt());
|
||||||
QGuiApplication::clipboard()->setText(makeGameJoinLink(client->serverName(), client->serverPort(),
|
QGuiApplication::clipboard()->setText(makeGameJoinLink(client->serverName(), client->serverPort(),
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include "../interface/card_picture_loader/card_picture_loader.h"
|
#include "../interface/card_picture_loader/card_picture_loader.h"
|
||||||
#include "../interface/widgets/cards/card_info_frame_widget.h"
|
#include "../interface/widgets/cards/card_info_frame_widget.h"
|
||||||
#include "../interface/widgets/dialogs/dlg_create_game.h"
|
#include "../interface/widgets/dialogs/dlg_create_game.h"
|
||||||
|
#include "../interface/widgets/server/game_link.h"
|
||||||
#include "../interface/widgets/server/user/user_list_manager.h"
|
#include "../interface/widgets/server/user/user_list_manager.h"
|
||||||
#include "../interface/widgets/utility/completer_utils.h"
|
#include "../interface/widgets/utility/completer_utils.h"
|
||||||
#include "../interface/widgets/utility/line_edit_completer.h"
|
#include "../interface/widgets/utility/line_edit_completer.h"
|
||||||
|
|
@ -33,6 +34,8 @@
|
||||||
#include "tab_supervisor.h"
|
#include "tab_supervisor.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
|
@ -331,6 +334,9 @@ void TabGame::retranslateUi()
|
||||||
if (aGameInfo) {
|
if (aGameInfo) {
|
||||||
aGameInfo->setText(tr("Game &information"));
|
aGameInfo->setText(tr("Game &information"));
|
||||||
}
|
}
|
||||||
|
if (aCopyGameLink) {
|
||||||
|
aCopyGameLink->setText(tr("Cop&y game link"));
|
||||||
|
}
|
||||||
if (aConcede) {
|
if (aConcede) {
|
||||||
if (game->getPlayerManager()->isMainPlayerConceded()) {
|
if (game->getPlayerManager()->isMainPlayerConceded()) {
|
||||||
aConcede->setText(tr("Un&concede"));
|
aConcede->setText(tr("Un&concede"));
|
||||||
|
|
@ -498,6 +504,15 @@ void TabGame::actGameInfo()
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabGame::actCopyGameLink()
|
||||||
|
{
|
||||||
|
const QString link =
|
||||||
|
makeGameJoinLink(tabSupervisor->getClient()->serverName(), tabSupervisor->getClient()->serverPort(),
|
||||||
|
game->getGameMetaInfo()->proto().room_id(), game->getGameMetaInfo()->gameId(),
|
||||||
|
QString::fromStdString(game->getGameMetaInfo()->proto().description()));
|
||||||
|
QApplication::clipboard()->setText(link);
|
||||||
|
}
|
||||||
|
|
||||||
void TabGame::actConcede()
|
void TabGame::actConcede()
|
||||||
{
|
{
|
||||||
PlayerLogic *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer());
|
PlayerLogic *player = game->getPlayerManager()->getActiveLocalPlayer(game->getGameState()->getActivePlayer());
|
||||||
|
|
@ -986,6 +1001,9 @@ void TabGame::createMenuItems()
|
||||||
connect(aRotateViewCCW, &QAction::triggered, this, &TabGame::actRotateViewCCW);
|
connect(aRotateViewCCW, &QAction::triggered, this, &TabGame::actRotateViewCCW);
|
||||||
aGameInfo = new QAction(this);
|
aGameInfo = new QAction(this);
|
||||||
connect(aGameInfo, &QAction::triggered, this, &TabGame::actGameInfo);
|
connect(aGameInfo, &QAction::triggered, this, &TabGame::actGameInfo);
|
||||||
|
aCopyGameLink = new QAction(this);
|
||||||
|
aCopyGameLink->setEnabled(!tabSupervisor->getIsLocalGame() && !tabSupervisor->getClient()->serverName().isEmpty());
|
||||||
|
connect(aCopyGameLink, &QAction::triggered, this, &TabGame::actCopyGameLink);
|
||||||
aConcede = new QAction(this);
|
aConcede = new QAction(this);
|
||||||
connect(aConcede, &QAction::triggered, this, &TabGame::actConcede);
|
connect(aConcede, &QAction::triggered, this, &TabGame::actConcede);
|
||||||
if (!game->getGameMetaInfo()->started()) {
|
if (!game->getGameMetaInfo()->started()) {
|
||||||
|
|
@ -1024,6 +1042,7 @@ void TabGame::createMenuItems()
|
||||||
gameMenu->addAction(aRotateViewCCW);
|
gameMenu->addAction(aRotateViewCCW);
|
||||||
gameMenu->addSeparator();
|
gameMenu->addSeparator();
|
||||||
gameMenu->addAction(aGameInfo);
|
gameMenu->addAction(aGameInfo);
|
||||||
|
gameMenu->addAction(aCopyGameLink);
|
||||||
gameMenu->addAction(aConcede);
|
gameMenu->addAction(aConcede);
|
||||||
gameMenu->addAction(aFocusChat);
|
gameMenu->addAction(aFocusChat);
|
||||||
gameMenu->addAction(aLeaveGame);
|
gameMenu->addAction(aLeaveGame);
|
||||||
|
|
@ -1046,6 +1065,7 @@ void TabGame::createReplayMenuItems()
|
||||||
aRotateViewCCW = nullptr;
|
aRotateViewCCW = nullptr;
|
||||||
aResetLayout = nullptr;
|
aResetLayout = nullptr;
|
||||||
aGameInfo = nullptr;
|
aGameInfo = nullptr;
|
||||||
|
aCopyGameLink = nullptr;
|
||||||
aConcede = nullptr;
|
aConcede = nullptr;
|
||||||
aFocusChat = nullptr;
|
aFocusChat = nullptr;
|
||||||
aLeaveGame = new QAction(this);
|
aLeaveGame = new QAction(this);
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,8 @@ private:
|
||||||
QAction *playersSeparator;
|
QAction *playersSeparator;
|
||||||
QMenu *gameMenu, *viewMenu;
|
QMenu *gameMenu, *viewMenu;
|
||||||
TearOffMenu *phasesMenu;
|
TearOffMenu *phasesMenu;
|
||||||
QAction *aGameInfo, *aConcede, *aLeaveGame, *aNextPhase, *aNextPhaseAction, *aNextTurn, *aReverseTurn,
|
QAction *aGameInfo, *aConcede, *aCopyGameLink, *aLeaveGame, *aNextPhase, *aNextPhaseAction, *aNextTurn,
|
||||||
*aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout, *aResetReplayLayout;
|
*aReverseTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout, *aResetReplayLayout;
|
||||||
QAction *aFocusChat;
|
QAction *aFocusChat;
|
||||||
QList<QAction *> phaseActions;
|
QList<QAction *> phaseActions;
|
||||||
QAction *aCardMenu;
|
QAction *aCardMenu;
|
||||||
|
|
@ -148,6 +148,7 @@ private slots:
|
||||||
|
|
||||||
void actGameInfo();
|
void actGameInfo();
|
||||||
void actConcede();
|
void actConcede();
|
||||||
|
void actCopyGameLink();
|
||||||
void actRemoveLocalArrows();
|
void actRemoveLocalArrows();
|
||||||
void actRotateViewCW();
|
void actRotateViewCW();
|
||||||
void actRotateViewCCW();
|
void actRotateViewCCW();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue