Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform 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
27inline Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor");
28
29class UserListManager;
30class QMenu;
31class AbstractClient;
32class Tab;
33class TabServer;
34class TabRoom;
35class TabHome;
36class TabGame;
37class TabDeckStorage;
38class TabReplays;
39class TabAdmin;
40class TabMessage;
41class TabAccount;
42class TabDeckEditor;
43class TabLog;
44class RoomEvent;
45class GameEventContainer;
46class Event_GameJoined;
47class Event_UserMessage;
48class Event_NotifyUser;
49class ServerInfo_Room;
50class ServerInfo_User;
51class GameReplay;
52class DeckList;
53
54class MacOSTabFixStyle : public QProxyStyle
55{
56 Q_OBJECT
57public:
58 QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override;
59};
60
61class CloseButton : public QAbstractButton
62{
63 Q_OBJECT
64public:
65 explicit CloseButton(QWidget *parent = nullptr);
66 [[nodiscard]] QSize sizeHint() const override;
67 [[nodiscard]] QSize minimumSizeHint() const override
68 {
69 return sizeHint();
70 }
71
72protected:
73#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
74 void enterEvent(QEnterEvent *event) override;
75#else
76 void enterEvent(QEvent *event) override;
77#endif
78 void leaveEvent(QEvent *event) override;
79 void paintEvent(QPaintEvent *event) override;
80};
81
82class TabSupervisor : public QTabWidget
83{
84 Q_OBJECT
85
86public:
92
93private:
94 ServerInfo_User *userInfo;
97 QList<AbstractClient *> localClients;
98 QMenu *tabsMenu;
107 QMap<int, TabRoom *> roomTabs;
108 QMap<int, TabGame *> gameTabs;
109 QList<TabGame *> replayTabs;
110 QMap<QString, TabMessage *> messageTabs;
111 QList<AbstractTabDeckEditor *> deckEditorTabs;
113
116
117 int myAddTab(Tab *tab, QAction *manager = nullptr);
118 void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager);
119 static QString sanitizeTabName(QString dirty);
120 static QString sanitizeHtml(QString dirty);
121 void resetTabsMenu();
122
123public:
124 explicit TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent = nullptr);
125 ~TabSupervisor() override;
126 void retranslateUi();
127 void initStartupTabs();
128 void start(const ServerInfo_User &userInfo);
129 void startLocal(const QList<AbstractClient *> &_clients);
130 void stop();
131 [[nodiscard]] bool getIsLocalGame() const
132 {
133 return isLocalGame;
134 }
135 [[nodiscard]] int getGameCount() const
136 {
137 return gameTabs.size();
138 }
139 [[nodiscard]] TabAccount *getTabAccount() const
140 {
141 return tabAccount;
142 }
143 [[nodiscard]] ServerInfo_User *getUserInfo() const
144 {
145 return userInfo;
146 }
147 [[nodiscard]] AbstractClient *getClient() const;
148 [[nodiscard]] const UserListManager *getUserListManager() const
149 {
150 return userListManager;
151 }
152 [[nodiscard]] const QMap<int, TabRoom *> &getRoomTabs() const
153 {
154 return roomTabs;
155 }
156 [[nodiscard]] QList<AbstractTabDeckEditor *> getDeckEditorTabs() const
157 {
158 return deckEditorTabs;
159 }
160 [[nodiscard]] bool getAdminLocked() const;
161 void closeEvent(QCloseEvent *event) override;
162 bool switchToGameTabIfAlreadyExists(const int gameId);
163 static void actShowPopup(const QString &message);
164signals:
165 void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
167 void adminLockChanged(bool lock);
169
170public slots:
171 void openDeckInNewTab(DeckLoader *deckToOpen);
172 TabDeckEditor *addDeckEditorTab(DeckLoader *deckToOpen);
173 TabDeckEditorVisual *addVisualDeckEditorTab(DeckLoader *deckToOpen);
177 TabEdhRec *addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander = false);
178 void openReplay(GameReplay *replay);
180 void maximizeMainWindow();
181 void actTabVisualDeckStorage(bool checked);
182 void actTabReplays(bool checked);
183private slots:
184 void refreshShortcuts();
185
186 void actTabHome(bool checked);
187 void actTabServer(bool checked);
188 void actTabAccount(bool checked);
189 void actTabDeckStorage(bool checked);
190 void actTabAdmin(bool checked);
191 void actTabLog(bool checked);
192
194 void openTabHome();
195 void openTabServer();
196 void openTabAccount();
197 void openTabDeckStorage();
198 void openTabReplays();
199 void openTabAdmin();
200 void openTabLog();
201
202 void updateCurrent(int index);
203 void updatePingTime(int value, int max);
204 void gameJoined(const Event_GameJoined &event);
205 void localGameJoined(const Event_GameJoined &event);
206 void gameLeft(TabGame *tab);
207 void addRoomTab(const ServerInfo_Room &info, bool setCurrent);
208 void roomLeft(TabRoom *tab);
209 TabMessage *addMessageTab(const QString &userName, bool focus);
210 void replayLeft(TabGame *tab);
211 void processUserLeft(const QString &userName);
212 void processUserJoined(const ServerInfo_User &userInfo);
213 void talkLeft(TabMessage *tab);
215 void tabUserEvent(bool globalEvent);
216 void updateTabText(Tab *tab, const QString &newTabText);
217 void processRoomEvent(const RoomEvent &event);
218 void processGameEventContainer(const GameEventContainer &cont);
219 void processUserMessageEvent(const Event_UserMessage &event);
220 void processNotifyUserEvent(const Event_NotifyUser &event);
221};
222
223#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:92
void leaveEvent(QEvent *event) override
Definition tab_supervisor.cpp:77
void paintEvent(QPaintEvent *event) override
Definition tab_supervisor.cpp:83
QSize sizeHint() const override
Definition tab_supervisor.cpp:59
QSize minimumSizeHint() const override
Definition tab_supervisor.h:67
void enterEvent(QEnterEvent *event) override
Definition tab_supervisor.cpp:68
CloseButton(QWidget *parent=nullptr)
Definition tab_supervisor.cpp:52
Represents a complete deck, including metadata, zones, cards, and sideboard plans.
Definition deck_list.h:127
Definition tab_supervisor.h:55
QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override
Definition tab_supervisor.cpp:40
Definition tab_account.h:27
Definition tab_admin.h:37
Tab for browsing, searching, and filtering Archidekt decks.
Definition tab_archidekt.h:29
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:56
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:673
QAction * aTabLog
Definition tab_supervisor.h:115
QList< TabGame * > replayTabs
Definition tab_supervisor.h:109
TabEdhRecMain * addEdhrecMainTab()
Definition tab_supervisor.cpp:899
TabDeckStorageVisual * tabVisualDeckStorage
Definition tab_supervisor.h:100
int getGameCount() const
Definition tab_supervisor.h:135
void refreshShortcuts()
Definition tab_supervisor.cpp:257
void openTabAdmin()
Definition tab_supervisor.cpp:661
QAction * aTabAccount
Definition tab_supervisor.h:115
void openTabHome()
Definition tab_supervisor.cpp:519
ServerInfo_User * getUserInfo() const
Definition tab_supervisor.h:143
QAction * aTabVisualDeckEditor
Definition tab_supervisor.h:114
static QString sanitizeHtml(QString dirty)
Definition tab_supervisor.cpp:304
QMenu * tabsMenu
Definition tab_supervisor.h:98
void openTabDeckStorage()
Definition tab_supervisor.cpp:613
QMap< int, TabGame * > gameTabs
Definition tab_supervisor.h:108
void roomLeft(TabRoom *tab)
Definition tab_supervisor.cpp:765
void openTabVisualDeckStorage()
Definition tab_supervisor.cpp:543
TabAccount * getTabAccount() const
Definition tab_supervisor.h:139
void actTabVisualDeckStorage(bool checked)
Definition tab_supervisor.cpp:530
void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager)
Definition tab_supervisor.cpp:371
const UserListManager * getUserListManager() const
Definition tab_supervisor.h:148
void gameLeft(TabGame *tab)
Definition tab_supervisor.cpp:741
~TabSupervisor() override
Definition tab_supervisor.cpp:191
QMap< QString, TabMessage * > messageTabs
Definition tab_supervisor.h:110
const QMap< int, TabRoom * > & getRoomTabs() const
Definition tab_supervisor.h:152
void tabUserEvent(bool globalEvent)
Definition tab_supervisor.cpp:946
QList< AbstractClient * > localClients
Definition tab_supervisor.h:97
QAction * aTabAdmin
Definition tab_supervisor.h:115
AbstractClient * getClient() const
Definition tab_supervisor.cpp:294
void processUserJoined(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:1021
TabServer * tabServer
Definition tab_supervisor.h:101
QAction * aTabVisualDeckStorage
Definition tab_supervisor.h:114
void talkLeft(TabMessage *tab)
Definition tab_supervisor.cpp:837
void actTabAccount(bool checked)
Definition tab_supervisor.cpp:577
void processUserMessageEvent(const Event_UserMessage &event)
Definition tab_supervisor.cpp:981
TabAdmin * tabAdmin
Definition tab_supervisor.h:105
TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget *parent=nullptr)
Definition tab_supervisor.cpp:106
void openTabReplays()
Definition tab_supervisor.cpp:638
bool getIsLocalGame() const
Definition tab_supervisor.h:131
void gameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:705
TabReplays * tabReplays
Definition tab_supervisor.h:104
void processUserLeft(const QString &userName)
Definition tab_supervisor.cpp:1014
static QString sanitizeTabName(QString dirty)
Definition tab_supervisor.cpp:299
bool switchToGameTabIfAlreadyExists(const int gameId)
Definition tab_supervisor.cpp:1120
void closeEvent(QCloseEvent *event) override
Definition tab_supervisor.cpp:273
void actTabDeckStorage(bool checked)
Definition tab_supervisor.cpp:602
TabHome * tabHome
Definition tab_supervisor.h:99
void addRoomTab(const ServerInfo_Room &info, bool setCurrent)
Definition tab_supervisor.cpp:753
void actTabReplays(bool checked)
Definition tab_supervisor.cpp:625
void startLocal(const QList< AbstractClient * > &_clients)
Definition tab_supervisor.cpp:441
void switchToFirstAvailableNetworkTab()
Definition tab_supervisor.cpp:774
void openTabServer()
Definition tab_supervisor.cpp:565
TabEdhRec * addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCommander=false)
Definition tab_supervisor.cpp:925
QMap< int, TabRoom * > roomTabs
Definition tab_supervisor.h:107
void actTabAdmin(bool checked)
Definition tab_supervisor.cpp:650
void openTabAccount()
Definition tab_supervisor.cpp:588
AbstractClient * client
Definition tab_supervisor.h:95
int myAddTab(Tab *tab, QAction *manager=nullptr)
Definition tab_supervisor.cpp:349
void processRoomEvent(const RoomEvent &event)
Definition tab_supervisor.cpp:964
void openReplay(GameReplay *replay)
Definition tab_supervisor.cpp:785
QAction * aTabReplays
Definition tab_supervisor.h:115
DeckEditorType
Definition tab_supervisor.h:88
@ VisualDeckEditor
Definition tab_supervisor.h:90
@ ClassicDeckEditor
Definition tab_supervisor.h:89
void resetTabsMenu()
Definition tab_supervisor.cpp:388
UserListManager * userListManager
Definition tab_supervisor.h:96
TabDeckEditor * addDeckEditorTab(DeckLoader *deckToOpen)
Definition tab_supervisor.cpp:873
void updatePingTime(int value, int max)
Definition tab_supervisor.cpp:695
bool isLocalGame
Definition tab_supervisor.h:112
QAction * aTabDeckEditor
Definition tab_supervisor.h:114
QList< AbstractTabDeckEditor * > deckEditorTabs
Definition tab_supervisor.h:111
void actTabServer(bool checked)
Definition tab_supervisor.cpp:554
QAction * aTabVisualDatabaseDisplay
Definition tab_supervisor.h:115
void stop()
Definition tab_supervisor.cpp:460
void adminLockChanged(bool lock)
TabLog * tabLog
Definition tab_supervisor.h:106
void replayLeft(TabGame *tab)
Definition tab_supervisor.cpp:794
void processGameEventContainer(const GameEventContainer &cont)
Definition tab_supervisor.cpp:971
TabMessage * addMessageTab(const QString &userName, bool focus)
Definition tab_supervisor.cpp:802
void maximizeMainWindow()
Definition tab_supervisor.cpp:832
void openTabLog()
Definition tab_supervisor.cpp:684
QAction * aTabDeckStorage
Definition tab_supervisor.h:115
QList< AbstractTabDeckEditor * > getDeckEditorTabs() const
Definition tab_supervisor.h:156
void openDeckInNewTab(DeckLoader *deckToOpen)
Definition tab_supervisor.cpp:851
void deckEditorClosed(AbstractTabDeckEditor *tab)
Definition tab_supervisor.cpp:937
TabAccount * tabAccount
Definition tab_supervisor.h:102
QAction * aTabServer
Definition tab_supervisor.h:115
void localGameEnded()
void showWindowIfHidden()
void setMenu(const QList< QMenu * > &newMenuList=QList< QMenu * >())
QAction * aTabArchidekt
Definition tab_supervisor.h:114
void updateCurrent(int index)
Definition tab_supervisor.cpp:1046
void start(const ServerInfo_User &userInfo)
Definition tab_supervisor.cpp:403
void localGameJoined(const Event_GameJoined &event)
Definition tab_supervisor.cpp:725
TabDeckEditorVisual * addVisualDeckEditorTab(DeckLoader *deckToOpen)
Definition tab_supervisor.cpp:886
TabArchidekt * addArchidektTab()
Definition tab_supervisor.cpp:908
void retranslateUi()
Definition tab_supervisor.cpp:205
ServerInfo_User * userInfo
Definition tab_supervisor.h:94
TabDeckStorage * tabDeckStorage
Definition tab_supervisor.h:103
void updateTabText(Tab *tab, const QString &newTabText)
Definition tab_supervisor.cpp:957
void actTabHome(bool checked)
Definition tab_supervisor.cpp:509
void processNotifyUserEvent(const Event_NotifyUser &event)
Definition tab_supervisor.cpp:1072
static void actShowPopup(const QString &message)
Definition tab_supervisor.cpp:1003
TabVisualDatabaseDisplay * addVisualDatabaseDisplayTab()
Definition tab_supervisor.cpp:917
QAction * aTabEdhRec
Definition tab_supervisor.h:114
void initStartupTabs()
Definition tab_supervisor.cpp:325
bool getAdminLocked() const
Definition tab_supervisor.cpp:1065
QAction * aTabHome
Definition tab_supervisor.h:114
Definition tab_visual_database_display.h:14
Definition tab.h:18
Definition user_list_manager.h:27
TODO: Document this.
TODO: Document this.
TODO: Document this.
TODO: Document this.
Q_LOGGING_CATEGORY(TabSupervisorLog, "tab_supervisor")
TODO: Document this.