Cockatrice 2026-09-01-Development-3.1.0-beta.10
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
12#include "../interface/widgets/server/game_link.h"
13#include "../interface/widgets/server/user/user_list_proxy.h"
21
22#include <QAbstractButton>
23#include <QLoggingCategory>
24#include <QMap>
25#include <QProxyStyle>
26#include <QTabWidget>
28
29class TabCardArtRules;
30inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");
31
32class UserListManager;
33class QMenu;
34class AbstractClient;
35class Tab;
36class TabServer;
37class TabRoom;
38class TabHome;
39class TabGame;
40class TabDeckStorage;
41class TabReplays;
42class TabAdmin;
43class TabMessage;
44class TabReport;
45class TabModeration;
46class TabAccount;
47class TabDeckEditor;
48class TabLog;
49class RoomEvent;
54class ServerInfo_Room;
55class ServerInfo_User;
56class GameReplay;
57class DeckList;
58
59class MacOSTabFixStyle : public QProxyStyle
60{
61 Q_OBJECT
62public:
63 QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override;
64};
65
66class CloseButton : public QAbstractButton
67{
68 Q_OBJECT
69public:
70 explicit CloseButton(QWidget *parent = nullptr);
71 [[nodiscard]] QSize sizeHint() const override;
72 [[nodiscard]] QSize minimumSizeHint() const override
73 {
74 return sizeHint();
75 }
76
77protected:
78 void enterEvent(QEnterEvent *event) override;
79 void leaveEvent(QEvent *event) override;
80 void paintEvent(QPaintEvent *event) override;
81};
82
83class TabSupervisor : public QTabWidget
84{
85 Q_OBJECT
86
87public:
93
94private:
98 QList<AbstractClient *> localClients;
99 QMenu *tabsMenu;
111 QMap<int, TabRoom *> roomTabs;
112 QMap<int, TabGame *> gameTabs;
113 QList<TabGame *> replayTabs;
114 QMap<QString, TabMessage *> messageTabs;
115 QList<AbstractTabDeckEditor *> deckEditorTabs;
117
121
122 int myAddTab(Tab *tab, QAction *manager = nullptr);
123 void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager);
124 static QString sanitizeTabName(QString dirty);
125 static QString sanitizeHtml(QString dirty);
126 void resetTabsMenu();
127
128public:
129 explicit TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent = nullptr);
130 ~TabSupervisor() override;
131 void retranslateUi();
132 void initStartupTabs();
133 void start(const ServerInfo_User &userInfo);
134 void startLocal(const QList<AbstractClient *> &_clients);
135 void stop();
136 [[nodiscard]] bool getIsLocalGame() const
137 {
138 return isLocalGame;
139 }
140 [[nodiscard]] int getGameCount() const
141 {
142 return gameTabs.size();
143 }
144 [[nodiscard]] TabAccount *getTabAccount() const
145 {
146 return tabAccount;
147 }
148 [[nodiscard]] ServerInfo_User *getUserInfo() const
149 {
150 return userInfo;
151 }
152 [[nodiscard]] AbstractClient *getClient() const;
153 [[nodiscard]] UserListManager *getUserListManager() const
154 {
155 return userListManager;
156 }
157 [[nodiscard]] TabServer *getTabServer() const
158 {
159 return tabServer;
160 }
161 [[nodiscard]] const QMap<int, TabRoom *> &getRoomTabs() const
162 {
163 return roomTabs;
164 }
165 [[nodiscard]] QList<AbstractTabDeckEditor *> getDeckEditorTabs() const
166 {
167 return deckEditorTabs;
168 }
169 [[nodiscard]] QList<GameInviteOption> getGameInviteLinksForRoom(int roomId) const;
170 void sendInviteToUser(const QString &userName, const QString &inviteText);
171 [[nodiscard]] bool getAdminLocked() const;
172 void closeEvent(QCloseEvent *event) override;
173 bool switchToGameTabIfAlreadyExists(const int gameId);
174 static void actShowPopup(const QString &message);
175signals:
176 void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
178 void adminLockChanged(bool lock);
180 void cockatriceLinkActivated(const QString &url);
181
182public slots:
183 void openDeckInNewTab(const LoadedDeck &deckToOpen);
184 TabDeckEditor *addDeckEditorTab(const LoadedDeck &deckToOpen);
189 TabEdhRec *addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander = false);
190 void openReplay(GameReplay *replay);
191 void joinReportGame(int gameId, int roomId);
192 void openTabModeration(const QString &userName = {});
194 void maximizeMainWindow();
195 void actTabVisualDeckStorage(bool checked);
196 void actTabReplays(bool checked);
197 void openTabServer();
198 void addRoomTab(const ServerInfo_Room &info, bool setCurrent);
199private slots:
200 void refreshShortcuts();
201
202 void actTabHome(bool checked);
203 void actTabServer(bool checked);
204 void actTabAccount(bool checked);
205 void actTabDeckStorage(bool checked);
206 void actTabAdmin(bool checked);
207 void actTabLog(bool checked);
208 void actTabReport(bool checked);
209 void actTabModeration(bool checked);
210
212 void openTabHome();
213 void openTabAccount();
214 void openTabDeckStorage();
215 void openTabReplays();
216 void openTabAdmin();
217 void actTabCardArtRules(bool checked);
218 void openTabCardArtRules();
219 void openTabLog();
220 void openTabReport();
221
222 void updateCurrent(int index);
223 void updatePingTime(int value, int max);
225 void gameJoined(const Event_GameJoined &event);
226 void localGameJoined(const Event_GameJoined &event);
227 void gameLeft(TabGame *tab);
228 void roomLeft(TabRoom *tab);
229 TabMessage *addMessageTab(const QString &userName, bool focus);
230 void replayLeft(TabGame *tab);
231 void processUserLeft(const QString &userName);
233 void talkLeft(TabMessage *tab);
235 void tabUserEvent(bool globalEvent);
236 void updateTabText(Tab *tab, const QString &newTabText);
237 void processRoomEvent(const RoomEvent &event);
240 void processNotifyUserEvent(const Event_NotifyUser &event);
241};
242
243#endif
Defines the AbstractTabDeckEditor class, which provides a base for deck editor tabs in the applicatio...
QSharedPointer< CardInfo > CardInfoPtr
Definition card_info.cpp:19
Definition abstract_client.h:57
AbstractTabDeckEditor is the base class for all deck editor tabs.
Definition abstract_tab_deck_editor.h:94
void leaveEvent(QEvent *event) override
Definition tab_supervisor.cpp:85
void paintEvent(QPaintEvent *event) override
Definition tab_supervisor.cpp:91
QSize sizeHint() const override
Definition tab_supervisor.cpp:71
QSize minimumSizeHint() const override
Definition tab_supervisor.h:72
void enterEvent(QEnterEvent *event) override
Definition tab_supervisor.cpp:79
CloseButton(QWidget *parent=nullptr)
Definition tab_supervisor.cpp:64
Represents a complete deck, including metadata, zones, cards, and sideboard plans.
Definition deck_list.h:63
Definition tab_supervisor.h:60
QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override
Definition tab_supervisor.cpp:52
Definition tab_account.h:28
Definition tab_admin.h:37
Tab for browsing, searching, and filtering Archidekt decks.
Definition tab_archidekt.h:38
Definition tab_card_art_rules.h:50
TabDeckEditorVisual provides a fully-featured deck editor tab with an enhanced visual interface....
Definition tab_deck_editor_visual.h:55
TabDeckEditor provides a fully-featured deck editor tab. It extends AbstractTabDeckEditor.
Definition tab_deck_editor.h:55
Definition tab_deck_storage_visual.h:26
Definition tab_deck_storage.h:29
Definition tab_edhrec_main.h:22
Definition tab_edhrec.h:17
Definition tab_game.h:59
Definition tab_home.h:18
Definition tab_logs.h:32
Definition tab_message.h:25
Definition tab_moderation.h:22
Definition tab_replays.h:28
Definition tab_report.h:24
Definition tab_room.h:51
Definition tab_server.h:48
void actTabLog(bool checked)
Definition tab_supervisor.cpp:809
QAction * aTabCardArtRules
Definition tab_supervisor.h:120
QAction * aTabLog
Definition tab_supervisor.h:120
QList< TabGame * > replayTabs
Definition tab_supervisor.h:113
TabEdhRecMain * addEdhrecMainTab()
Definition tab_supervisor.cpp:1192
TabDeckStorageVisual * tabVisualDeckStorage
Definition tab_supervisor.h:101
int getGameCount() const
Definition tab_supervisor.h:140
void refreshShortcuts()
Definition tab_supervisor.cpp:294
void openTabAdmin()
Definition tab_supervisor.cpp:772
QAction * aTabAccount
Definition tab_supervisor.h:119
void openTabHome()
Definition tab_supervisor.cpp:625
ServerInfo_User * getUserInfo() const
Definition tab_supervisor.h:148
QAction * aTabVisualDeckEditor
Definition tab_supervisor.h:118
static QString sanitizeHtml(QString dirty)
Definition tab_supervisor.cpp:343
QMenu * tabsMenu
Definition tab_supervisor.h:99
void openTabDeckStorage()
Definition tab_supervisor.cpp:724
UserListManager * getUserListManager() const
Definition tab_supervisor.h:153
QMap< int, TabGame * > gameTabs
Definition tab_supervisor.h:112
void roomLeft(TabRoom *tab)
Definition tab_supervisor.cpp:979
void openTabVisualDeckStorage()
Definition tab_supervisor.cpp:649
TabAccount * getTabAccount() const
Definition tab_supervisor.h:144
void actTabVisualDeckStorage(bool checked)
Definition tab_supervisor.cpp:636
void joinReportGame(int gameId, int roomId)
Definition tab_supervisor.cpp:1018
void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager)
Definition tab_supervisor.cpp:452
void actTabModeration(bool checked)
Definition tab_supervisor.cpp:855
void gameLeft(TabGame *tab)
Definition tab_supervisor.cpp:951
~TabSupervisor() override
Definition tab_supervisor.cpp:217
QMap< QString, TabMessage * > messageTabs
Definition tab_supervisor.h:114
const QMap< int, TabRoom * > & getRoomTabs() const
Definition tab_supervisor.h:161
void tabUserEvent(bool globalEvent)
Definition tab_supervisor.cpp:1240
QList< AbstractClient * > localClients
Definition tab_supervisor.h:98
QAction * aTabAdmin
Definition tab_supervisor.h:119
AbstractClient * getClient() const
Definition tab_supervisor.cpp:333
void processUserJoined(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:1328
TabServer * tabServer
Definition tab_supervisor.h:102
QAction * aTabVisualDeckStorage
Definition tab_supervisor.h:118
void talkLeft(TabMessage *tab)
Definition tab_supervisor.cpp:1083
void actTabAccount(bool checked)
Definition tab_supervisor.cpp:688
QAction * aTabReport
Definition tab_supervisor.h:120
void processUserMessageEvent(const Event_UserMessage &event)
Definition tab_supervisor.cpp:1278
TabAdmin * tabAdmin
Definition tab_supervisor.h:106
TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent=nullptr)
Definition tab_supervisor.cpp:118
void openTabReplays()
Definition tab_supervisor.cpp:749
bool getIsLocalGame() const
Definition tab_supervisor.h:136
void gameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:913
TabReplays * tabReplays
Definition tab_supervisor.h:105
void processUserLeft(const QString &userName)
Definition tab_supervisor.cpp:1320
TabDeckEditorVisual * addVisualDeckEditorTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:1180
static QString sanitizeTabName(QString dirty)
Definition tab_supervisor.cpp:338
bool switchToGameTabIfAlreadyExists(const int gameId)
Definition tab_supervisor.cpp:1449
void closeEvent(QCloseEvent *event) override
Definition tab_supervisor.cpp:312
void actTabDeckStorage(bool checked)
Definition tab_supervisor.cpp:713
TabModeration * tabModeration
Definition tab_supervisor.h:110
TabHome * tabHome
Definition tab_supervisor.h:100
void addRoomTab(const ServerInfo_Room &info, bool setCurrent)
Definition tab_supervisor.cpp:965
void actTabReplays(bool checked)
Definition tab_supervisor.cpp:736
void startLocal(const QList< AbstractClient * > &_clients)
Definition tab_supervisor.cpp:534
void switchToFirstAvailableNetworkTab()
Definition tab_supervisor.cpp:989
void openTabServer()
Definition tab_supervisor.cpp:671
TabEdhRec * addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander=false)
Definition tab_supervisor.cpp:1218
QMap< int, TabRoom * > roomTabs
Definition tab_supervisor.h:111
void actTabAdmin(bool checked)
Definition tab_supervisor.cpp:761
void openTabAccount()
Definition tab_supervisor.cpp:699
AbstractClient * client
Definition tab_supervisor.h:96
int myAddTab(Tab *tab, QAction *manager=nullptr)
Definition tab_supervisor.cpp:429
void processRoomEvent(const RoomEvent &event)
Definition tab_supervisor.cpp:1259
void cockatriceLinkActivated(const QString &url)
void openReplay(GameReplay *replay)
Definition tab_supervisor.cpp:1000
void actTabReport(bool checked)
Definition tab_supervisor.cpp:831
QAction * aTabReplays
Definition tab_supervisor.h:119
DeckEditorType
Definition tab_supervisor.h:89
@ VisualDeckEditor
Definition tab_supervisor.h:91
@ ClassicDeckEditor
Definition tab_supervisor.h:90
QList< GameInviteOption > getGameInviteLinksForRoom(int roomId) const
Definition tab_supervisor.cpp:1093
void resetTabsMenu()
Definition tab_supervisor.cpp:469
UserListManager * userListManager
Definition tab_supervisor.h:97
void openTabReport()
Definition tab_supervisor.cpp:842
void updatePingTime(int value, int max)
Definition tab_supervisor.cpp:884
bool isLocalGame
Definition tab_supervisor.h:116
QAction * aTabDeckEditor
Definition tab_supervisor.h:118
QList< AbstractTabDeckEditor * > deckEditorTabs
Definition tab_supervisor.h:115
void actTabServer(bool checked)
Definition tab_supervisor.cpp:660
QAction * aTabVisualDatabaseDisplay
Definition tab_supervisor.h:119
void stop()
Definition tab_supervisor.cpp:556
void adminLockChanged(bool lock)
void sendInviteToUser(const QString &userName, const QString &inviteText)
Definition tab_supervisor.cpp:1133
TabLog * tabLog
Definition tab_supervisor.h:108
void replayLeft(TabGame *tab)
Definition tab_supervisor.cpp:1009
void processGameEventContainer(const GameEventContainer &cont)
Definition tab_supervisor.cpp:1267
TabMessage * addMessageTab(const QString &userName, bool focus)
Definition tab_supervisor.cpp:1042
void maximizeMainWindow()
Definition tab_supervisor.cpp:1078
void openTabLog()
Definition tab_supervisor.cpp:820
QAction * aTabDeckStorage
Definition tab_supervisor.h:119
QList< AbstractTabDeckEditor * > getDeckEditorTabs() const
Definition tab_supervisor.h:165
void deckEditorClosed(AbstractTabDeckEditor *tab)
Definition tab_supervisor.cpp:1230
TabAccount * tabAccount
Definition tab_supervisor.h:103
TabDeckEditor * addDeckEditorTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:1168
QAction * aTabServer
Definition tab_supervisor.h:119
void actTabCardArtRules(bool checked)
Definition tab_supervisor.cpp:784
void openTabModeration(const QString &userName={})
Definition tab_supervisor.cpp:866
void localGameEnded()
void showWindowIfHidden()
void setMenu(const QList< QMenu * > &newMenuList=QList< QMenu * >())
void openTabCardArtRules()
Definition tab_supervisor.cpp:795
QAction * aTabArchidekt
Definition tab_supervisor.h:118
void updateCurrent(int index)
Definition tab_supervisor.cpp:1354
void start(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:484
void localGameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:935
TabArchidekt * addArchidektTab()
Definition tab_supervisor.cpp:1201
void retranslateUi()
Definition tab_supervisor.cpp:231
ServerInfo_User * userInfo
Definition tab_supervisor.h:95
TabDeckStorage * tabDeckStorage
Definition tab_supervisor.h:104
void updateTabText(Tab *tab, const QString &newTabText)
Definition tab_supervisor.cpp:1252
void updateLatencyTooltip(const LatencyTracker::Stats &stats)
Definition tab_supervisor.cpp:896
void actTabHome(bool checked)
Definition tab_supervisor.cpp:615
QAction * aTabModeration
Definition tab_supervisor.h:120
TabCardArtRules * tabCardArtRules
Definition tab_supervisor.h:107
void processNotifyUserEvent(const Event_NotifyUser &event)
Definition tab_supervisor.cpp:1382
static void actShowPopup(const QString &message)
Definition tab_supervisor.cpp:1309
TabServer * getTabServer() const
Definition tab_supervisor.h:157
TabVisualDatabaseDisplay * addVisualDatabaseDisplayTab()
Definition tab_supervisor.cpp:1210
QAction * aTabEdhRec
Definition tab_supervisor.h:118
void initStartupTabs()
Definition tab_supervisor.cpp:369
void openDeckInNewTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:1146
TabReport * tabReport
Definition tab_supervisor.h:109
bool getAdminLocked() const
Definition tab_supervisor.cpp:1374
QAction * aTabHome
Definition tab_supervisor.h:118
Definition tab_visual_database_display.h:14
Definition tab.h:18
Definition user_list_manager.h:27
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:27
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:5
Definition serverinfo_user.proto:2
Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor")