revert adding the param to myAddTab

This commit is contained in:
RickyRister 2025-02-26 08:48:56 -08:00
parent 8ab0852ae2
commit 8cc74b4df5
2 changed files with 60 additions and 49 deletions

View file

@ -286,13 +286,13 @@ void TabSupervisor::initStartupTabs()
addDeckEditorTab(nullptr);
if (SettingsCache::instance().getTabVisualDeckStorageOpen()) {
openTabVisualDeckStorage(false);
openTabVisualDeckStorage();
}
if (SettingsCache::instance().getTabDeckStorageOpen()) {
openTabDeckStorage(false);
openTabDeckStorage();
}
if (SettingsCache::instance().getTabReplaysOpen()) {
openTabReplays(false);
openTabReplays();
}
}
@ -300,12 +300,11 @@ void TabSupervisor::initStartupTabs()
* Adds the tab to the TabSupervisor's tab bar.
*
* @param tab The Tab to add
* @param setCurrent Whether to set the current tab to that tab afterward.
* @param manager The menu action that corresponds to this tab, if this is a single-instance managed tab. Pass in
* nullptr if this is not a managed tab.
* @return The index of the added tab in the tab widget's tab menu
*/
int TabSupervisor::myAddTab(Tab *tab, bool setCurrent, QAction *manager)
int TabSupervisor::myAddTab(Tab *tab, QAction *manager)
{
connect(tab, &TabGame::userEvent, this, &TabSupervisor::tabUserEvent);
connect(tab, &TabGame::tabTextChanged, this, &TabSupervisor::updateTabText);
@ -316,10 +315,6 @@ int TabSupervisor::myAddTab(Tab *tab, bool setCurrent, QAction *manager)
addCloseButtonToTab(tab, idx, manager);
if (setCurrent) {
setCurrentWidget(tab);
}
return idx;
}
@ -372,10 +367,10 @@ void TabSupervisor::start(const ServerInfo_User &_userInfo)
tabsMenu->addAction(aTabAccount);
if (SettingsCache::instance().getTabServerOpen()) {
openTabServer(false);
openTabServer();
}
if (SettingsCache::instance().getTabAccountOpen()) {
openTabAccount(false);
openTabAccount();
}
updatePingTime(0, -1);
@ -386,10 +381,10 @@ void TabSupervisor::start(const ServerInfo_User &_userInfo)
tabsMenu->addAction(aTabLog);
if (SettingsCache::instance().getTabAdminOpen()) {
openTabAdmin(false);
openTabAdmin();
}
if (SettingsCache::instance().getTabLogOpen()) {
openTabLog(false);
openTabLog();
}
}
@ -472,16 +467,17 @@ void TabSupervisor::actTabVisualDeckStorage(bool checked)
{
SettingsCache::instance().setTabVisualDeckStorageOpen(checked);
if (checked && !tabVisualDeckStorage) {
openTabVisualDeckStorage(true);
openTabVisualDeckStorage();
setCurrentWidget(tabVisualDeckStorage);
} else if (!checked && tabVisualDeckStorage) {
tabVisualDeckStorage->closeRequest();
}
}
void TabSupervisor::openTabVisualDeckStorage(bool setCurrent)
void TabSupervisor::openTabVisualDeckStorage()
{
tabVisualDeckStorage = new TabDeckStorageVisual(this);
myAddTab(tabVisualDeckStorage, setCurrent, aTabVisualDeckStorage);
myAddTab(tabVisualDeckStorage, aTabVisualDeckStorage);
connect(tabVisualDeckStorage, &Tab::closed, this, [this] {
tabVisualDeckStorage = nullptr;
aTabVisualDeckStorage->setChecked(false);
@ -493,17 +489,18 @@ void TabSupervisor::actTabServer(bool checked)
{
SettingsCache::instance().setTabServerOpen(checked);
if (checked && !tabServer) {
openTabServer(true);
openTabServer();
setCurrentWidget(tabServer);
} else if (!checked && tabServer) {
tabServer->closeRequest();
}
}
void TabSupervisor::openTabServer(bool setCurrent)
void TabSupervisor::openTabServer()
{
tabServer = new TabServer(this, client);
connect(tabServer, &TabServer::roomJoined, this, &TabSupervisor::addRoomTab);
myAddTab(tabServer, setCurrent, aTabServer);
myAddTab(tabServer, aTabServer);
connect(tabServer, &Tab::closed, this, [this] {
tabServer = nullptr;
aTabServer->setChecked(false);
@ -515,19 +512,20 @@ void TabSupervisor::actTabAccount(bool checked)
{
SettingsCache::instance().setTabAccountOpen(checked);
if (checked && !tabAccount) {
openTabAccount(true);
openTabAccount();
setCurrentWidget(tabAccount);
} else if (!checked && tabAccount) {
tabAccount->closeRequest();
}
}
void TabSupervisor::openTabAccount(bool setCurrent)
void TabSupervisor::openTabAccount()
{
tabAccount = new TabAccount(this, client, *userInfo);
connect(tabAccount, &TabAccount::openMessageDialog, this, &TabSupervisor::addMessageTab);
connect(tabAccount, &TabAccount::userJoined, this, &TabSupervisor::processUserJoined);
connect(tabAccount, &TabAccount::userLeft, this, &TabSupervisor::processUserLeft);
myAddTab(tabAccount, setCurrent, aTabAccount);
myAddTab(tabAccount, aTabAccount);
connect(tabAccount, &Tab::closed, this, [this] {
tabAccount = nullptr;
aTabAccount->setChecked(false);
@ -539,17 +537,18 @@ void TabSupervisor::actTabDeckStorage(bool checked)
{
SettingsCache::instance().setTabDeckStorageOpen(checked);
if (checked && !tabDeckStorage) {
openTabDeckStorage(true);
openTabDeckStorage();
setCurrentWidget(tabDeckStorage);
} else if (!checked && tabDeckStorage) {
tabDeckStorage->closeRequest();
}
}
void TabSupervisor::openTabDeckStorage(bool setCurrent)
void TabSupervisor::openTabDeckStorage()
{
tabDeckStorage = new TabDeckStorage(this, client, userInfo);
connect(tabDeckStorage, &TabDeckStorage::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
myAddTab(tabDeckStorage, setCurrent, aTabDeckStorage);
myAddTab(tabDeckStorage, aTabDeckStorage);
connect(tabDeckStorage, &Tab::closed, this, [this] {
tabDeckStorage = nullptr;
aTabDeckStorage->setChecked(false);
@ -561,17 +560,18 @@ void TabSupervisor::actTabReplays(bool checked)
{
SettingsCache::instance().setTabReplaysOpen(checked);
if (checked && !tabReplays) {
openTabReplays(true);
openTabReplays();
setCurrentWidget(tabReplays);
} else if (!checked && tabReplays) {
tabReplays->closeRequest();
}
}
void TabSupervisor::openTabReplays(bool setCurrent)
void TabSupervisor::openTabReplays()
{
tabReplays = new TabReplays(this, client, userInfo);
connect(tabReplays, &TabReplays::openReplay, this, &TabSupervisor::openReplay);
myAddTab(tabReplays, setCurrent, aTabReplays);
myAddTab(tabReplays, aTabReplays);
connect(tabReplays, &Tab::closed, this, [this] {
tabReplays = nullptr;
aTabReplays->setChecked(false);
@ -583,17 +583,18 @@ void TabSupervisor::actTabAdmin(bool checked)
{
SettingsCache::instance().setTabAdminOpen(checked);
if (checked && !tabAdmin) {
openTabAdmin(true);
openTabAdmin();
setCurrentWidget(tabAdmin);
} else if (!checked && tabAdmin) {
tabAdmin->closeRequest();
}
}
void TabSupervisor::openTabAdmin(bool setCurrent)
void TabSupervisor::openTabAdmin()
{
tabAdmin = new TabAdmin(this, client, (userInfo->user_level() & ServerInfo_User::IsAdmin));
connect(tabAdmin, &TabAdmin::adminLockChanged, this, &TabSupervisor::adminLockChanged);
myAddTab(tabAdmin, setCurrent, aTabAdmin);
myAddTab(tabAdmin, aTabAdmin);
connect(tabAdmin, &Tab::closed, this, [this] {
tabAdmin = nullptr;
aTabAdmin->setChecked(false);
@ -605,16 +606,17 @@ void TabSupervisor::actTabLog(bool checked)
{
SettingsCache::instance().setTabLogOpen(checked);
if (checked && !tabLog) {
openTabLog(true);
openTabLog();
setCurrentWidget(tabLog);
} else if (!checked && tabLog) {
tabLog->closeRequest();
}
}
void TabSupervisor::openTabLog(bool setCurrent)
void TabSupervisor::openTabLog()
{
tabLog = new TabLog(this, client);
myAddTab(tabLog, setCurrent, aTabLog);
myAddTab(tabLog, aTabLog);
connect(tabLog, &Tab::closed, this, [this] {
tabLog = nullptr;
aTabAdmin->setChecked(false);
@ -647,8 +649,9 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
connect(tab, &TabGame::gameClosing, this, &TabSupervisor::gameLeft);
connect(tab, &TabGame::openMessageDialog, this, &TabSupervisor::addMessageTab);
connect(tab, &TabGame::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
myAddTab(tab, true);
myAddTab(tab);
gameTabs.insert(event.game_info().game_id(), tab);
setCurrentWidget(tab);
}
void TabSupervisor::localGameJoined(const Event_GameJoined &event)
@ -656,8 +659,9 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
auto *tab = new TabGame(this, localClients, event, QMap<int, QString>());
connect(tab, &TabGame::gameClosing, this, &TabSupervisor::gameLeft);
connect(tab, &TabGame::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
myAddTab(tab, true);
myAddTab(tab);
gameTabs.insert(event.game_info().game_id(), tab);
setCurrentWidget(tab);
for (int i = 1; i < localClients.size(); ++i) {
Command_JoinGame cmd;
@ -684,8 +688,10 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
connect(tab, &TabRoom::maximizeClient, this, &TabSupervisor::maximizeMainWindow);
connect(tab, &TabRoom::roomClosing, this, &TabSupervisor::roomLeft);
connect(tab, &TabRoom::openMessageDialog, this, &TabSupervisor::addMessageTab);
myAddTab(tab, setCurrent);
myAddTab(tab);
roomTabs.insert(info.room_id(), tab);
if (setCurrent)
setCurrentWidget(tab);
}
void TabSupervisor::roomLeft(TabRoom *tab)
@ -701,8 +707,9 @@ void TabSupervisor::openReplay(GameReplay *replay)
{
auto *replayTab = new TabGame(this, replay);
connect(replayTab, &TabGame::gameClosing, this, &TabSupervisor::replayLeft);
myAddTab(replayTab, true);
myAddTab(replayTab);
replayTabs.append(replayTab);
setCurrentWidget(replayTab);
}
void TabSupervisor::replayLeft(TabGame *tab)
@ -736,8 +743,10 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
tab = new TabMessage(this, client, *userInfo, otherUser);
connect(tab, &TabMessage::talkClosing, this, &TabSupervisor::talkLeft);
connect(tab, &TabMessage::maximizeClient, this, &TabSupervisor::maximizeMainWindow);
myAddTab(tab, focus);
myAddTab(tab);
messageTabs.insert(receiverName, tab);
if (focus)
setCurrentWidget(tab);
return tab;
}
@ -762,8 +771,9 @@ TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
tab->setDeck(new DeckLoader(*deckToOpen));
connect(tab, &TabDeckEditor::deckEditorClosing, this, &TabSupervisor::deckEditorClosed);
connect(tab, &TabDeckEditor::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
myAddTab(tab, true);
myAddTab(tab);
deckEditorTabs.append(tab);
setCurrentWidget(tab);
return tab;
}
@ -774,7 +784,8 @@ TabEdhRec *TabSupervisor::addEdhrecTab(const CardInfoPtr &cardToQuery, bool isCo
tab->setCard(cardToQuery, isCommander);
}
myAddTab(tab, true);
myAddTab(tab);
setCurrentWidget(tab);
return tab;
}

View file

@ -93,7 +93,7 @@ private:
QAction *aTabDeckEditor, *aTabVisualDeckStorage, *aTabServer, *aTabAccount, *aTabDeckStorage, *aTabReplays,
*aTabAdmin, *aTabLog;
int myAddTab(Tab *tab, bool setCurrent, QAction *manager = nullptr);
int myAddTab(Tab *tab, QAction *manager = nullptr);
void addCloseButtonToTab(Tab *tab, int tabIndex, QAction *manager);
static QString sanitizeTabName(QString dirty);
static QString sanitizeHtml(QString dirty);
@ -162,13 +162,13 @@ private slots:
void actTabAdmin(bool checked);
void actTabLog(bool checked);
void openTabVisualDeckStorage(bool setCurrent);
void openTabServer(bool setCurrent);
void openTabAccount(bool setCurrent);
void openTabDeckStorage(bool setCurrent);
void openTabReplays(bool setCurrent);
void openTabAdmin(bool setCurrent);
void openTabLog(bool setCurrent);
void openTabVisualDeckStorage();
void openTabServer();
void openTabAccount();
void openTabDeckStorage();
void openTabReplays();
void openTabAdmin();
void openTabLog();
void updateCurrent(int index);
void updatePingTime(int value, int max);