Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
tab_supervisor.h
Go to the documentation of this file.
1
7
8#ifndef TAB_SUPERVISOR_H
9#define TAB_SUPERVISOR_H
10
11#include "../interface/widgets/server/game_link.h"
13
14#include <QAbstractButton>
15#include <QList>
16#include <QLoggingCategory>
17#include <QMap>
18#include <QMenu>
19#include <QProxyStyle>
20#include <QSize>
21#include <QString>
22#include <QTabWidget>
24#include <qtmetamacros.h>
25
26class TabCardArtRules;
28class QAction;
29class QWidget;
30class TabArchidekt;
33class TabEdhRec;
34class TabEdhRecMain;
36struct LoadedDeck;
37
38inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");
39
40class UserListManager;
41class AbstractClient;
42class Tab;
43class TabServer;
44class TabRoom;
45class TabHome;
46class TabGame;
47class TabDeckStorage;
48class TabReplays;
49class TabAdmin;
50class TabMessage;
51class TabReport;
52class TabModeration;
53class TabAccount;
54class TabDeckEditor;
55class TabDeveloper;
56class TabLog;
57class TabPublicDecks;
58class RoomEvent;
63class ServerInfo_Room;
64class ServerInfo_User;
65class GameReplay;
66
67class MacOSTabFixStyle : public QProxyStyle
68{
69 Q_OBJECT
70public:
71 QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override;
72};
73
74class CloseButton : public QAbstractButton
75{
76 Q_OBJECT
77public:
78 explicit CloseButton(QWidget *parent = nullptr);
79 [[nodiscard]] QSize sizeHint() const override;
80 [[nodiscard]] QSize minimumSizeHint() const override
81 {
82 return sizeHint();
83 }
84
85protected:
86 void enterEvent(QEnterEvent *event) override;
87 void leaveEvent(QEvent *event) override;
88 void paintEvent(QPaintEvent *event) override;
89};
90
91class TabSupervisor : public QTabWidget
92{
93 Q_OBJECT
94
95public:
101
102private:
107 QMenu *tabsMenu;
127
131
132 int myAddTab(Tab *tab, QAction *manager = nullptr);
133 void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager);
134 static QString sanitizeTabName(QString dirty);
135 static QString sanitizeHtml(QString dirty);
136 void resetTabsMenu();
138 void joinGameByIntent(int gameId, int roomId, bool asSpectator);
139
140public:
141 explicit TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent = nullptr);
142 ~TabSupervisor() override;
143 void retranslateUi();
144 void initStartupTabs();
145 void start(const ServerInfo_User &userInfo);
146 void startLocal(const QList<AbstractClient *> &_clients);
147 void stop();
148 [[nodiscard]] bool getIsLocalGame() const
149 {
150 return isLocalGame;
151 }
152 [[nodiscard]] int getGameCount() const
153 {
154 return gameTabs.size();
155 }
156 [[nodiscard]] TabAccount *getTabAccount() const
157 {
158 return tabAccount;
159 }
160 [[nodiscard]] ServerInfo_User *getUserInfo() const
161 {
162 return userInfo;
163 }
164 [[nodiscard]] AbstractClient *getClient() const;
165 [[nodiscard]] AbstractClient *getServerClient() const
166 {
167 return client;
168 }
169 [[nodiscard]] UserListManager *getUserListManager() const
170 {
171 return userListManager;
172 }
173 [[nodiscard]] TabServer *getTabServer() const
174 {
175 return tabServer;
176 }
177 [[nodiscard]] const QMap<int, TabRoom *> &getRoomTabs() const
178 {
179 return roomTabs;
180 }
182 {
183 return deckEditorTabs;
184 }
185 [[nodiscard]] QList<GameInviteOption> getGameInviteLinksForRoom(int roomId) const;
186 void sendInviteToUser(const QString &userName, const QString &inviteText);
187 [[nodiscard]] bool getAdminLocked() const;
188 [[nodiscard]] bool canOverrideGameRestrictions() const;
189 void closeEvent(QCloseEvent *event) override;
190 bool switchToGameTabIfAlreadyExists(const int gameId);
191 static void actShowPopup(const QString &message);
192signals:
193 void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
195 void adminLockChanged(bool lock);
197 void cockatriceLinkActivated(const QString &url);
198
199public slots:
200 void openDeckInNewTab(const LoadedDeck &deckToOpen);
201 TabDeckEditor *addDeckEditorTab(const LoadedDeck &deckToOpen);
206 TabEdhRec *addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander = false);
207 void openReplay(GameReplay *replay);
208 void joinReportGame(int gameId, int roomId);
210 void joinGameFromUserCard(int gameId, int roomId, bool asSpectator);
211 void openTabModeration(const QString &userName = {});
213 void maximizeMainWindow();
214 void actTabVisualDeckStorage(bool checked);
215 void actTabReplays(bool checked);
216 void openTabServer();
217 void addRoomTab(const ServerInfo_Room &info, bool setCurrent);
218 void openTabPublicDecks(const QString &userName);
219private slots:
220 void refreshShortcuts();
221
222 void actTabHome(bool checked);
223 void actTabServer(bool checked);
224 void actTabAccount(bool checked);
225 void actTabDeckStorage(bool checked);
226 void actTabAdmin(bool checked);
227 void actTabLog(bool checked);
228 void actTabReport(bool checked);
229 void actTabModeration(bool checked);
230 void actTabDeveloper(bool checked);
231
233 void openTabHome();
234 void openTabAccount();
235 void openTabDeckStorage();
236 void openTabReplays();
237 void openTabAdmin();
238 void actTabCardArtRules(bool checked);
239 void openTabCardArtRules();
240 void openTabLog();
241 void openTabReport();
242 void openTabDeveloper();
243
244 void updateCurrent(int index);
245 void updatePingTime(int value, int max);
247 void gameJoined(const Event_GameJoined &event);
248 void localGameJoined(const Event_GameJoined &event);
249 void gameLeft(TabGame *tab);
250 void roomLeft(TabRoom *tab);
252 TabMessage *addMessageTab(const QString &userName, bool focus);
253 void replayLeft(TabGame *tab);
254 void processUserLeft(const QString &userName);
256 void talkLeft(TabMessage *tab);
258 void tabUserEvent(bool globalEvent);
259 void updateTabText(Tab *tab, const QString &newTabText);
260 void processRoomEvent(const RoomEvent &event);
263 void processNotifyUserEvent(const Event_NotifyUser &event);
264};
265
266#endif
QSharedPointer< CardInfo > CardInfoPtr
Definition card_info.cpp:15
Definition abstract_client.h:73
AbstractTabDeckEditor is the base class for all deck editor tabs.
Definition abstract_tab_deck_editor.h:77
void leaveEvent(QEvent *event) override
Definition tab_supervisor.cpp:122
void paintEvent(QPaintEvent *event) override
Definition tab_supervisor.cpp:128
QSize sizeHint() const override
Definition tab_supervisor.cpp:108
QSize minimumSizeHint() const override
Definition tab_supervisor.h:80
void enterEvent(QEnterEvent *event) override
Definition tab_supervisor.cpp:116
CloseButton(QWidget *parent=nullptr)
Definition tab_supervisor.cpp:101
Definition tab_supervisor.h:68
QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override
Definition tab_supervisor.cpp:89
Definition remote_connection_controller.h:20
Definition game.h:18
Definition tab_account.h:35
Definition tab_admin.h:39
Tab for browsing, searching, and filtering Archidekt decks.
Definition tab_archidekt.h:47
Definition tab_card_art_rules.h:62
TabDeckEditorVisual provides a fully-featured deck editor tab with an enhanced visual interface....
Definition tab_deck_editor_visual.h:66
TabDeckEditor provides a fully-featured deck editor tab. It extends AbstractTabDeckEditor.
Definition tab_deck_editor.h:49
Definition tab_deck_storage_visual.h:27
Definition tab_deck_storage.h:36
Definition tab_developer.h:27
Definition tab_edhrec_main.h:31
Definition tab_edhrec.h:23
Definition tab_game.h:67
Definition tab_home.h:20
Definition tab_logs.h:32
Definition tab_message.h:32
Definition tab_moderation.h:26
A visual grid of the public decks published by another user.
Definition tab_public_decks.h:36
Definition tab_replays.h:35
Definition tab_report.h:29
Definition tab_room.h:59
Definition tab_server.h:51
void actTabLog(bool checked)
Definition tab_supervisor.cpp:877
QAction * aTabCardArtRules
Definition tab_supervisor.h:130
QAction * aTabLog
Definition tab_supervisor.h:130
QList< TabGame * > replayTabs
Definition tab_supervisor.h:122
TabEdhRecMain * addEdhrecMainTab()
Definition tab_supervisor.cpp:1336
TabDeckStorageVisual * tabVisualDeckStorage
Definition tab_supervisor.h:109
int getGameCount() const
Definition tab_supervisor.h:152
void refreshShortcuts()
Definition tab_supervisor.cpp:341
void openTabAdmin()
Definition tab_supervisor.cpp:840
QAction * aTabAccount
Definition tab_supervisor.h:129
void openTabHome()
Definition tab_supervisor.cpp:693
ServerInfo_User * getUserInfo() const
Definition tab_supervisor.h:160
QAction * aTabVisualDeckEditor
Definition tab_supervisor.h:128
static QString sanitizeHtml(QString dirty)
Definition tab_supervisor.cpp:390
QMenu * tabsMenu
Definition tab_supervisor.h:107
void openTabDeckStorage()
Definition tab_supervisor.cpp:792
UserListManager * getUserListManager() const
Definition tab_supervisor.h:169
QMap< int, TabGame * > gameTabs
Definition tab_supervisor.h:121
void roomLeft(TabRoom *tab)
Definition tab_supervisor.cpp:1075
void openTabVisualDeckStorage()
Definition tab_supervisor.cpp:717
TabAccount * getTabAccount() const
Definition tab_supervisor.h:156
void actTabVisualDeckStorage(bool checked)
Definition tab_supervisor.cpp:704
void joinReportGame(int gameId, int roomId)
Definition tab_supervisor.cpp:1138
void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager)
Definition tab_supervisor.cpp:499
void actTabModeration(bool checked)
Definition tab_supervisor.cpp:930
void gameLeft(TabGame *tab)
Definition tab_supervisor.cpp:1047
void actTabDeveloper(bool checked)
Definition tab_supervisor.cpp:959
QMap< QString, TabMessage * > messageTabs
Definition tab_supervisor.h:123
const QMap< int, TabRoom * > & getRoomTabs() const
Definition tab_supervisor.h:177
void tabUserEvent(bool globalEvent)
Definition tab_supervisor.cpp:1384
QList< AbstractClient * > localClients
Definition tab_supervisor.h:106
QAction * aTabAdmin
Definition tab_supervisor.h:129
AbstractClient * getClient() const
Definition tab_supervisor.cpp:380
void processUserJoined(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:1486
TabServer * tabServer
Definition tab_supervisor.h:110
QAction * aTabVisualDeckStorage
Definition tab_supervisor.h:128
void talkLeft(TabMessage *tab)
Definition tab_supervisor.cpp:1227
void actTabAccount(bool checked)
Definition tab_supervisor.cpp:756
QAction * aTabReport
Definition tab_supervisor.h:130
void processUserMessageEvent(const Event_UserMessage &event)
Definition tab_supervisor.cpp:1422
TabAdmin * tabAdmin
Definition tab_supervisor.h:114
TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent=nullptr)
Definition tab_supervisor.cpp:155
void openTabReplays()
Definition tab_supervisor.cpp:817
bool getIsLocalGame() const
Definition tab_supervisor.h:148
void gameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:1009
void openTabPublicDecks(const QString &userName)
Definition tab_supervisor.cpp:1085
TabReplays * tabReplays
Definition tab_supervisor.h:113
void processUserLeft(const QString &userName)
Definition tab_supervisor.cpp:1478
TabDeckEditorVisual * addVisualDeckEditorTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:1324
static QString sanitizeTabName(QString dirty)
Definition tab_supervisor.cpp:385
bool switchToGameTabIfAlreadyExists(const int gameId)
Definition tab_supervisor.cpp:1612
void closeEvent(QCloseEvent *event) override
Definition tab_supervisor.cpp:359
void actTabDeckStorage(bool checked)
Definition tab_supervisor.cpp:781
TabModeration * tabModeration
Definition tab_supervisor.h:118
TabHome * tabHome
Definition tab_supervisor.h:108
void addRoomTab(const ServerInfo_Room &info, bool setCurrent)
Definition tab_supervisor.cpp:1061
void openTabDeveloper()
Definition tab_supervisor.cpp:969
void actTabReplays(bool checked)
Definition tab_supervisor.cpp:804
void startLocal(const QList< AbstractClient * > &_clients)
Definition tab_supervisor.cpp:594
void publicDecksClosed(TabPublicDecks *tab)
Definition tab_supervisor.cpp:1099
bool canOverrideGameRestrictions() const
Definition tab_supervisor.cpp:1540
void joinGameFromUserCard(int gameId, int roomId, bool asSpectator)
Definition tab_supervisor.cpp:1143
void switchToFirstAvailableNetworkTab()
Definition tab_supervisor.cpp:1109
void openTabServer()
Definition tab_supervisor.cpp:739
TabEdhRec * addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander=false)
Definition tab_supervisor.cpp:1362
QMap< int, TabRoom * > roomTabs
Definition tab_supervisor.h:120
void actTabAdmin(bool checked)
Definition tab_supervisor.cpp:829
void openTabAccount()
Definition tab_supervisor.cpp:767
TabDeveloper * tabDeveloper
Definition tab_supervisor.h:119
AbstractClient * client
Definition tab_supervisor.h:104
void joinGameByIntent(int gameId, int roomId, bool asSpectator)
Definition tab_supervisor.cpp:1155
int myAddTab(Tab *tab, QAction *manager=nullptr)
Definition tab_supervisor.cpp:476
void processRoomEvent(const RoomEvent &event)
Definition tab_supervisor.cpp:1403
void cockatriceLinkActivated(const QString &url)
void openReplay(GameReplay *replay)
Definition tab_supervisor.cpp:1120
void actTabReport(bool checked)
Definition tab_supervisor.cpp:905
QAction * aTabReplays
Definition tab_supervisor.h:129
QAction * aTabDeveloper
Definition tab_supervisor.h:130
DeckEditorType
Definition tab_supervisor.h:97
@ VisualDeckEditor
Definition tab_supervisor.h:99
@ ClassicDeckEditor
Definition tab_supervisor.h:98
QList< GameInviteOption > getGameInviteLinksForRoom(int roomId) const
Definition tab_supervisor.cpp:1237
void resetTabsMenu()
Definition tab_supervisor.cpp:516
UserListManager * userListManager
Definition tab_supervisor.h:105
void openTabReport()
Definition tab_supervisor.cpp:916
void updatePingTime(int value, int max)
Definition tab_supervisor.cpp:980
bool isLocalGame
Definition tab_supervisor.h:126
QAction * aTabDeckEditor
Definition tab_supervisor.h:128
QList< AbstractTabDeckEditor * > deckEditorTabs
Definition tab_supervisor.h:125
void actTabServer(bool checked)
Definition tab_supervisor.cpp:728
QAction * aTabVisualDatabaseDisplay
Definition tab_supervisor.h:129
void stop()
Definition tab_supervisor.cpp:617
void adminLockChanged(bool lock)
void sendInviteToUser(const QString &userName, const QString &inviteText)
Definition tab_supervisor.cpp:1277
TabLog * tabLog
Definition tab_supervisor.h:116
void replayLeft(TabGame *tab)
Definition tab_supervisor.cpp:1129
void processGameEventContainer(const GameEventContainer &cont)
Definition tab_supervisor.cpp:1411
TabMessage * addMessageTab(const QString &userName, bool focus)
Definition tab_supervisor.cpp:1179
void maximizeMainWindow()
Definition tab_supervisor.cpp:1222
void openTabLog()
Definition tab_supervisor.cpp:888
QAction * aTabDeckStorage
Definition tab_supervisor.h:129
QList< AbstractTabDeckEditor * > getDeckEditorTabs() const
Definition tab_supervisor.h:181
void deckEditorClosed(AbstractTabDeckEditor *tab)
Definition tab_supervisor.cpp:1374
TabAccount * tabAccount
Definition tab_supervisor.h:111
TabDeckEditor * addDeckEditorTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:1312
QAction * aTabServer
Definition tab_supervisor.h:129
void actTabCardArtRules(bool checked)
Definition tab_supervisor.cpp:852
void openTabModeration(const QString &userName={})
Definition tab_supervisor.cpp:941
AbstractClient * getServerClient() const
Definition tab_supervisor.h:165
void localGameEnded()
void showWindowIfHidden()
void setMenu(const QList< QMenu * > &newMenuList=QList< QMenu * >())
QMap< QString, TabPublicDecks * > publicDecksTabs
Definition tab_supervisor.h:124
void openTabCardArtRules()
Definition tab_supervisor.cpp:863
QAction * aTabArchidekt
Definition tab_supervisor.h:128
void updateCurrent(int index)
Definition tab_supervisor.cpp:1512
void start(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:531
void localGameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:1031
TabArchidekt * addArchidektTab()
Definition tab_supervisor.cpp:1345
void retranslateUi()
Definition tab_supervisor.cpp:272
ServerInfo_User * userInfo
Definition tab_supervisor.h:103
TabDeckStorage * tabDeckStorage
Definition tab_supervisor.h:112
void updateTabText(Tab *tab, const QString &newTabText)
Definition tab_supervisor.cpp:1396
void updateLatencyTooltip(const LatencyTracker::Stats &stats)
Definition tab_supervisor.cpp:992
void actTabHome(bool checked)
Definition tab_supervisor.cpp:683
QAction * aTabModeration
Definition tab_supervisor.h:130
TabCardArtRules * tabCardArtRules
Definition tab_supervisor.h:115
void processNotifyUserEvent(const Event_NotifyUser &event)
Definition tab_supervisor.cpp:1545
static void actShowPopup(const QString &message)
Definition tab_supervisor.cpp:1467
TabServer * getTabServer() const
Definition tab_supervisor.h:173
TabVisualDatabaseDisplay * addVisualDatabaseDisplayTab()
Definition tab_supervisor.cpp:1354
QAction * aTabEdhRec
Definition tab_supervisor.h:128
void initStartupTabs()
Definition tab_supervisor.cpp:416
void openDeckInNewTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:1290
TabReport * tabReport
Definition tab_supervisor.h:117
bool getAdminLocked() const
Definition tab_supervisor.cpp:1532
QAction * aTabHome
Definition tab_supervisor.h:128
Definition tab_visual_database_display.h:20
Definition tab.h:22
Definition user_list_manager.h:31
Q_LOGGING_CATEGORY(CrashReportLog, "crash_report")
Definition event_game_joined.proto:5
Definition event_notify_user.proto:3
Definition event_user_message.proto:3
Definition game_event_container.proto:4
Definition game_replay.proto:4
Definition latency_tracker.h:29
Represents a deck that was loaded from somewhere. Contains the DeckList itself, as well as info about...
Definition loaded_deck.h:14
Definition room_event.proto:2
Definition serverinfo_room.proto:6
Definition serverinfo_user.proto:2