Cockatrice 2026-06-27-Development-3.1.0-beta.3
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/user/user_list_proxy.h"
20
21#include <QAbstractButton>
22#include <QLoggingCategory>
23#include <QMap>
24#include <QProxyStyle>
25#include <QTabWidget>
26
27class TabCardArtRules;
28inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");
29
30class UserListManager;
31class QMenu;
32class AbstractClient;
33class Tab;
34class TabServer;
35class TabRoom;
36class TabHome;
37class TabGame;
38class TabDeckStorage;
39class TabReplays;
40class TabAdmin;
41class TabMessage;
42class TabAccount;
43class TabDeckEditor;
44class TabLog;
45class RoomEvent;
46class GameEventContainer;
47class Event_GameJoined;
48class Event_UserMessage;
49class Event_NotifyUser;
50class ServerInfo_Room;
51class ServerInfo_User;
52class GameReplay;
53class DeckList;
54
55class MacOSTabFixStyle : public QProxyStyle
56{
57 Q_OBJECT
58public:
59 QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override;
60};
61
62class CloseButton : public QAbstractButton
63{
64 Q_OBJECT
65public:
66 explicit CloseButton(QWidget *parent = nullptr);
67 [[nodiscard]] QSize sizeHint() const override;
68 [[nodiscard]] QSize minimumSizeHint() const override
69 {
70 return sizeHint();
71 }
72
73protected:
74#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
75 void enterEvent(QEnterEvent *event) override;
76#else
77 void enterEvent(QEvent *event) override;
78#endif
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:
95 ServerInfo_User *userInfo;
98 QList<AbstractClient *> localClients;
99 QMenu *tabsMenu;
109 QMap<int, TabRoom *> roomTabs;
110 QMap<int, TabGame *> gameTabs;
111 QList<TabGame *> replayTabs;
112 QMap<QString, TabMessage *> messageTabs;
113 QList<AbstractTabDeckEditor *> deckEditorTabs;
115
119
120 int myAddTab(Tab *tab, QAction *manager = nullptr);
121 void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager);
122 static QString sanitizeTabName(QString dirty);
123 static QString sanitizeHtml(QString dirty);
124 void resetTabsMenu();
125
126public:
127 explicit TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent = nullptr);
128 ~TabSupervisor() override;
129 void retranslateUi();
130 void initStartupTabs();
131 void start(const ServerInfo_User &userInfo);
132 void startLocal(const QList<AbstractClient *> &_clients);
133 void stop();
134 [[nodiscard]] bool getIsLocalGame() const
135 {
136 return isLocalGame;
137 }
138 [[nodiscard]] int getGameCount() const
139 {
140 return gameTabs.size();
141 }
142 [[nodiscard]] TabAccount *getTabAccount() const
143 {
144 return tabAccount;
145 }
146 [[nodiscard]] ServerInfo_User *getUserInfo() const
147 {
148 return userInfo;
149 }
150 [[nodiscard]] AbstractClient *getClient() const;
151 [[nodiscard]] UserListManager *getUserListManager() const
152 {
153 return userListManager;
154 }
155 [[nodiscard]] const QMap<int, TabRoom *> &getRoomTabs() const
156 {
157 return roomTabs;
158 }
159 [[nodiscard]] QList<AbstractTabDeckEditor *> getDeckEditorTabs() const
160 {
161 return deckEditorTabs;
162 }
163 [[nodiscard]] bool getAdminLocked() const;
164 void closeEvent(QCloseEvent *event) override;
165 bool switchToGameTabIfAlreadyExists(const int gameId);
166 static void actShowPopup(const QString &message);
167signals:
168 void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
170 void adminLockChanged(bool lock);
172
173public slots:
174 void openDeckInNewTab(const LoadedDeck &deckToOpen);
175 TabDeckEditor *addDeckEditorTab(const LoadedDeck &deckToOpen);
180 TabEdhRec *addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander = false);
181 void openReplay(GameReplay *replay);
183 void maximizeMainWindow();
184 void actTabVisualDeckStorage(bool checked);
185 void actTabReplays(bool checked);
186private slots:
187 void refreshShortcuts();
188
189 void actTabHome(bool checked);
190 void actTabServer(bool checked);
191 void actTabAccount(bool checked);
192 void actTabDeckStorage(bool checked);
193 void actTabAdmin(bool checked);
194 void actTabLog(bool checked);
195
197 void openTabHome();
198 void openTabServer();
199 void openTabAccount();
200 void openTabDeckStorage();
201 void openTabReplays();
202 void openTabAdmin();
203 void actTabCardArtRules(bool checked);
204 void openTabCardArtRules();
205 void openTabLog();
206
207 void updateCurrent(int index);
208 void updatePingTime(int value, int max);
209 void gameJoined(const Event_GameJoined &event);
210 void localGameJoined(const Event_GameJoined &event);
211 void gameLeft(TabGame *tab);
212 void addRoomTab(const ServerInfo_Room &info, bool setCurrent);
213 void roomLeft(TabRoom *tab);
214 TabMessage *addMessageTab(const QString &userName, bool focus);
215 void replayLeft(TabGame *tab);
216 void processUserLeft(const QString &userName);
217 void processUserJoined(const ServerInfo_User &userInfo);
218 void talkLeft(TabMessage *tab);
220 void tabUserEvent(bool globalEvent);
221 void updateTabText(Tab *tab, const QString &newTabText);
222 void processRoomEvent(const RoomEvent &event);
223 void processGameEventContainer(const GameEventContainer &cont);
224 void processUserMessageEvent(const Event_UserMessage &event);
225 void processNotifyUserEvent(const Event_NotifyUser &event);
226};
227
228#endif
Defines the AbstractTabDeckEditor class, which provides a base for deck editor tabs in the applicatio...
QSharedPointer< CardInfo > CardInfoPtr
Definition card_info.cpp:20
Definition abstract_client.h:51
AbstractTabDeckEditor is the base class for all deck editor tabs.
Definition abstract_tab_deck_editor.h:93
void leaveEvent(QEvent *event) override
Definition tab_supervisor.cpp:78
void paintEvent(QPaintEvent *event) override
Definition tab_supervisor.cpp:84
QSize sizeHint() const override
Definition tab_supervisor.cpp:60
QSize minimumSizeHint() const override
Definition tab_supervisor.h:68
void enterEvent(QEnterEvent *event) override
Definition tab_supervisor.cpp:69
CloseButton(QWidget *parent=nullptr)
Definition tab_supervisor.cpp:53
Represents a complete deck, including metadata, zones, cards, and sideboard plans.
Definition deck_list.h:63
Definition tab_supervisor.h:56
QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override
Definition tab_supervisor.cpp:41
Definition tab_account.h:27
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:57
Definition tab_home.h:18
Definition tab_logs.h:32
Definition tab_message.h:24
Definition tab_replays.h:28
Definition tab_room.h:49
Definition tab_server.h:48
void actTabLog(bool checked)
Definition tab_supervisor.cpp:715
QAction * aTabCardArtRules
Definition tab_supervisor.h:118
QAction * aTabLog
Definition tab_supervisor.h:118
QList< TabGame * > replayTabs
Definition tab_supervisor.h:111
TabEdhRecMain * addEdhrecMainTab()
Definition tab_supervisor.cpp:952
TabDeckStorageVisual * tabVisualDeckStorage
Definition tab_supervisor.h:101
int getGameCount() const
Definition tab_supervisor.h:138
void refreshShortcuts()
Definition tab_supervisor.cpp:271
void openTabAdmin()
Definition tab_supervisor.cpp:679
QAction * aTabAccount
Definition tab_supervisor.h:117
void openTabHome()
Definition tab_supervisor.cpp:537
ServerInfo_User * getUserInfo() const
Definition tab_supervisor.h:146
QAction * aTabVisualDeckEditor
Definition tab_supervisor.h:116
static QString sanitizeHtml(QString dirty)
Definition tab_supervisor.cpp:318
QMenu * tabsMenu
Definition tab_supervisor.h:99
void openTabDeckStorage()
Definition tab_supervisor.cpp:631
UserListManager * getUserListManager() const
Definition tab_supervisor.h:151
QMap< int, TabGame * > gameTabs
Definition tab_supervisor.h:110
void roomLeft(TabRoom *tab)
Definition tab_supervisor.cpp:814
void openTabVisualDeckStorage()
Definition tab_supervisor.cpp:561
TabAccount * getTabAccount() const
Definition tab_supervisor.h:142
void actTabVisualDeckStorage(bool checked)
Definition tab_supervisor.cpp:548
void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager)
Definition tab_supervisor.cpp:385
void gameLeft(TabGame *tab)
Definition tab_supervisor.cpp:787
~TabSupervisor() override
Definition tab_supervisor.cpp:200
QMap< QString, TabMessage * > messageTabs
Definition tab_supervisor.h:112
const QMap< int, TabRoom * > & getRoomTabs() const
Definition tab_supervisor.h:155
void tabUserEvent(bool globalEvent)
Definition tab_supervisor.cpp:1000
QList< AbstractClient * > localClients
Definition tab_supervisor.h:98
QAction * aTabAdmin
Definition tab_supervisor.h:117
AbstractClient * getClient() const
Definition tab_supervisor.cpp:308
void processUserJoined(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:1088
TabServer * tabServer
Definition tab_supervisor.h:102
QAction * aTabVisualDeckStorage
Definition tab_supervisor.h:116
void talkLeft(TabMessage *tab)
Definition tab_supervisor.cpp:891
void actTabAccount(bool checked)
Definition tab_supervisor.cpp:595
void processUserMessageEvent(const Event_UserMessage &event)
Definition tab_supervisor.cpp:1038
TabAdmin * tabAdmin
Definition tab_supervisor.h:106
TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent=nullptr)
Definition tab_supervisor.cpp:111
void openTabReplays()
Definition tab_supervisor.cpp:656
bool getIsLocalGame() const
Definition tab_supervisor.h:134
void gameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:749
TabReplays * tabReplays
Definition tab_supervisor.h:105
void processUserLeft(const QString &userName)
Definition tab_supervisor.cpp:1080
TabDeckEditorVisual * addVisualDeckEditorTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:940
static QString sanitizeTabName(QString dirty)
Definition tab_supervisor.cpp:313
bool switchToGameTabIfAlreadyExists(const int gameId)
Definition tab_supervisor.cpp:1191
void closeEvent(QCloseEvent *event) override
Definition tab_supervisor.cpp:287
void actTabDeckStorage(bool checked)
Definition tab_supervisor.cpp:620
TabHome * tabHome
Definition tab_supervisor.h:100
void addRoomTab(const ServerInfo_Room &info, bool setCurrent)
Definition tab_supervisor.cpp:801
void actTabReplays(bool checked)
Definition tab_supervisor.cpp:643
void startLocal(const QList< AbstractClient * > &_clients)
Definition tab_supervisor.cpp:457
void switchToFirstAvailableNetworkTab()
Definition tab_supervisor.cpp:824
void openTabServer()
Definition tab_supervisor.cpp:583
TabEdhRec * addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander=false)
Definition tab_supervisor.cpp:978
QMap< int, TabRoom * > roomTabs
Definition tab_supervisor.h:109
void actTabAdmin(bool checked)
Definition tab_supervisor.cpp:668
void openTabAccount()
Definition tab_supervisor.cpp:606
AbstractClient * client
Definition tab_supervisor.h:96
int myAddTab(Tab *tab, QAction *manager=nullptr)
Definition tab_supervisor.cpp:363
void processRoomEvent(const RoomEvent &event)
Definition tab_supervisor.cpp:1019
void openReplay(GameReplay *replay)
Definition tab_supervisor.cpp:835
QAction * aTabReplays
Definition tab_supervisor.h:117
DeckEditorType
Definition tab_supervisor.h:89
@ VisualDeckEditor
Definition tab_supervisor.h:91
@ ClassicDeckEditor
Definition tab_supervisor.h:90
void resetTabsMenu()
Definition tab_supervisor.cpp:402
UserListManager * userListManager
Definition tab_supervisor.h:97
void updatePingTime(int value, int max)
Definition tab_supervisor.cpp:737
bool isLocalGame
Definition tab_supervisor.h:114
QAction * aTabDeckEditor
Definition tab_supervisor.h:116
QList< AbstractTabDeckEditor * > deckEditorTabs
Definition tab_supervisor.h:113
void actTabServer(bool checked)
Definition tab_supervisor.cpp:572
QAction * aTabVisualDatabaseDisplay
Definition tab_supervisor.h:117
void stop()
Definition tab_supervisor.cpp:477
void adminLockChanged(bool lock)
TabLog * tabLog
Definition tab_supervisor.h:108
void replayLeft(TabGame *tab)
Definition tab_supervisor.cpp:844
void processGameEventContainer(const GameEventContainer &cont)
Definition tab_supervisor.cpp:1027
TabMessage * addMessageTab(const QString &userName, bool focus)
Definition tab_supervisor.cpp:853
void maximizeMainWindow()
Definition tab_supervisor.cpp:886
void openTabLog()
Definition tab_supervisor.cpp:726
QAction * aTabDeckStorage
Definition tab_supervisor.h:117
QList< AbstractTabDeckEditor * > getDeckEditorTabs() const
Definition tab_supervisor.h:159
void deckEditorClosed(AbstractTabDeckEditor *tab)
Definition tab_supervisor.cpp:990
TabAccount * tabAccount
Definition tab_supervisor.h:103
TabDeckEditor * addDeckEditorTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:928
QAction * aTabServer
Definition tab_supervisor.h:117
void actTabCardArtRules(bool checked)
Definition tab_supervisor.cpp:691
void localGameEnded()
void showWindowIfHidden()
void setMenu(const QList< QMenu * > &newMenuList=QList< QMenu * >())
void openTabCardArtRules()
Definition tab_supervisor.cpp:701
QAction * aTabArchidekt
Definition tab_supervisor.h:116
void updateCurrent(int index)
Definition tab_supervisor.cpp:1114
void start(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:417
void localGameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:771
TabArchidekt * addArchidektTab()
Definition tab_supervisor.cpp:961
void retranslateUi()
Definition tab_supervisor.cpp:214
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:1012
void actTabHome(bool checked)
Definition tab_supervisor.cpp:527
TabCardArtRules * tabCardArtRules
Definition tab_supervisor.h:107
void processNotifyUserEvent(const Event_NotifyUser &event)
Definition tab_supervisor.cpp:1142
static void actShowPopup(const QString &message)
Definition tab_supervisor.cpp:1069
TabVisualDatabaseDisplay * addVisualDatabaseDisplayTab()
Definition tab_supervisor.cpp:970
QAction * aTabEdhRec
Definition tab_supervisor.h:116
void initStartupTabs()
Definition tab_supervisor.cpp:339
void openDeckInNewTab(const LoadedDeck &deckToOpen)
Definition tab_supervisor.cpp:906
bool getAdminLocked() const
Definition tab_supervisor.cpp:1134
QAction * aTabHome
Definition tab_supervisor.h:116
Definition tab_visual_database_display.h:14
Definition tab.h:18
Definition user_list_manager.h:27
Represents a deck that was loaded from somewhere. Contains the DeckList itself, as well as info about...
Definition loaded_deck.h:14
Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor")