mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 10:03:26 -08:00
TabModeration gains an Open alt graph button plus alts-table double-click, both routing to the User Alts tab. UserContextMenu gains an Investigate alts action. TabAlts gains row double-click navigation with a Back history stack so moderators can walk the alt graph without retyping names.
140 lines
5 KiB
C++
140 lines
5 KiB
C++
/**
|
|
* @file user_context_menu.h
|
|
* @ingroup Lobby
|
|
*/
|
|
//! \todo Document this file.
|
|
|
|
#ifndef USER_CONTEXT_MENU_H
|
|
#define USER_CONTEXT_MENU_H
|
|
|
|
#include "../../interface/widgets/server/game_link.h"
|
|
|
|
#include <QList>
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <functional>
|
|
#include <libcockatrice/network/server/remote/user_level.h>
|
|
#include <qtmetamacros.h>
|
|
#include <utility>
|
|
|
|
class AbstractGame;
|
|
class UserListProxy;
|
|
class AbstractClient;
|
|
class ChatView;
|
|
class CommandContainer;
|
|
class QAction;
|
|
class QPoint;
|
|
class Response;
|
|
class TabSupervisor;
|
|
class QWidget;
|
|
|
|
class UserContextMenu : public QObject
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
AbstractClient *client;
|
|
TabSupervisor *tabSupervisor;
|
|
const UserListProxy *userListProxy;
|
|
AbstractGame *game;
|
|
|
|
QAction *aUserName;
|
|
QAction *aDetails;
|
|
QAction *aShowGames;
|
|
QAction *aViewPublicDecks;
|
|
QAction *aChat;
|
|
QAction *aAddToBuddyList, *aRemoveFromBuddyList;
|
|
QAction *aAddToIgnoreList, *aRemoveFromIgnoreList;
|
|
QAction *aKick;
|
|
QAction *aReport;
|
|
QAction *aBan, *aBanHistory;
|
|
QAction *aPromoteToMod, *aDemoteFromMod;
|
|
QAction *aPromoteToJudge, *aDemoteFromJudge;
|
|
QAction *aPromoteToDeveloper, *aDemoteFromDeveloper;
|
|
QAction *aWarnUser, *aWarnHistory;
|
|
QAction *aGetAdminNotes;
|
|
std::function<QList<GameInviteOption>()> gameInviteLinkProvider;
|
|
QAction *aInvestigateUser;
|
|
QAction *aInvestigateAlts;
|
|
signals:
|
|
void openMessageDialog(const QString &userName, bool focus);
|
|
private slots:
|
|
void banUser_processUserInfoResponse(const Response &resp);
|
|
void warnUser_processGetWarningsListResponse(const Response &r);
|
|
void warnUser_processUserInfoResponse(const Response &resp);
|
|
void banUserHistory_processResponse(const Response &resp);
|
|
void warnUserHistory_processResponse(const Response &resp);
|
|
void getAdminNotes_processResponse(const Response &resp);
|
|
void adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer);
|
|
void banUser_dialogFinished();
|
|
void warnUser_dialogFinished();
|
|
void updateAdminNotes_dialogFinished();
|
|
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
|
|
|
public:
|
|
UserContextMenu(TabSupervisor *_tabSupervisor, QWidget *_parent, AbstractGame *_game = 0);
|
|
void retranslateUi();
|
|
void showContextMenu(const QPoint &pos,
|
|
const QString &userName,
|
|
UserLevelFlags userLevel,
|
|
bool online = true,
|
|
int playerId = -1);
|
|
void showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, ChatView *chatView);
|
|
void showContextMenu(const QPoint &pos,
|
|
const QString &userName,
|
|
UserLevelFlags userLevel,
|
|
bool online,
|
|
int playerId,
|
|
const QString &deckHash,
|
|
ChatView *chatView = nullptr);
|
|
|
|
const UserListProxy *getUserListProxy() const
|
|
{
|
|
return userListProxy;
|
|
}
|
|
|
|
void setGameInviteLinkProvider(std::function<QList<GameInviteOption>()> provider)
|
|
{
|
|
gameInviteLinkProvider = std::move(provider);
|
|
}
|
|
|
|
/**
|
|
* The games currently inviteable for @p userName, honoring the room's
|
|
* buddy-only setting (the inviter must be the game's creator and the
|
|
* target a buddy of theirs). Empty when there is no live provider.
|
|
*/
|
|
QList<GameInviteOption> inviteOptionsForUser(const QString &userName) const;
|
|
|
|
/** Whether at least one invite link is currently available for @p userName. */
|
|
bool hasGameInviteLink(const QString &userName) const
|
|
{
|
|
return !inviteOptionsForUser(userName).isEmpty();
|
|
}
|
|
|
|
// Individual action entry points — used by UserInfoPopup to trigger
|
|
// actions without re-running the full context menu flow.
|
|
void execChat(const QString &userName);
|
|
void execInvite(const QString &userName);
|
|
void execDetails(const QString &userName);
|
|
void execShowGames(const QString &userName);
|
|
void execViewPublicDecks(const QString &userName);
|
|
void execAddToBuddy(const QString &userName);
|
|
void execRemoveFromBuddy(const QString &userName);
|
|
void execAddToIgnore(const QString &userName);
|
|
void execRemoveFromIgnore(const QString &userName);
|
|
void execKick(int playerId);
|
|
void execBan(const QString &userName);
|
|
void execWarn(const QString &userName);
|
|
void execBanHistory(const QString &userName);
|
|
void execWarnHistory(const QString &userName);
|
|
void execAdminNotes(const QString &userName);
|
|
void execInvestigateUser(const QString &userName);
|
|
void execInvestigateAlts(const QString &userName);
|
|
void execAdjustMod(const QString &userName, bool shouldBeMod);
|
|
void execAdjustJudge(const QString &userName, bool shouldBeJudge);
|
|
void execAdjustDeveloper(const QString &userName, bool shouldBeDeveloper);
|
|
|
|
private:
|
|
void execInvite(const QString &userName, const GameInviteOption &option);
|
|
};
|
|
|
|
#endif
|