mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 16:32:16 -07:00
refactor the opening to a separate method
This commit is contained in:
parent
3de75cbd60
commit
c5a423f11e
2 changed files with 92 additions and 49 deletions
|
|
@ -466,114 +466,149 @@ void TabSupervisor::actTabVisualDeckStorage(bool checked)
|
||||||
{
|
{
|
||||||
SettingsCache::instance().setTabVisualDeckStorageOpen(checked);
|
SettingsCache::instance().setTabVisualDeckStorageOpen(checked);
|
||||||
if (checked && !tabVisualDeckStorage) {
|
if (checked && !tabVisualDeckStorage) {
|
||||||
tabVisualDeckStorage = new TabDeckStorageVisual(this);
|
openTabVisualDeckStorage(true);
|
||||||
myAddTab(tabVisualDeckStorage, !isReopeningTabs, aTabVisualDeckStorage);
|
|
||||||
connect(tabVisualDeckStorage, &Tab::closed, this, [this] {
|
|
||||||
tabVisualDeckStorage = nullptr;
|
|
||||||
aTabVisualDeckStorage->setChecked(false);
|
|
||||||
});
|
|
||||||
} else if (!checked && tabVisualDeckStorage) {
|
} else if (!checked && tabVisualDeckStorage) {
|
||||||
tabVisualDeckStorage->closeRequest();
|
tabVisualDeckStorage->closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::openTabVisualDeckStorage(bool setCurrent)
|
||||||
|
{
|
||||||
|
tabVisualDeckStorage = new TabDeckStorageVisual(this);
|
||||||
|
myAddTab(tabVisualDeckStorage, setCurrent, aTabVisualDeckStorage);
|
||||||
|
connect(tabVisualDeckStorage, &Tab::closed, this, [this] {
|
||||||
|
tabVisualDeckStorage = nullptr;
|
||||||
|
aTabVisualDeckStorage->setChecked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::actTabServer(bool checked)
|
void TabSupervisor::actTabServer(bool checked)
|
||||||
{
|
{
|
||||||
SettingsCache::instance().setTabServerOpen(checked);
|
SettingsCache::instance().setTabServerOpen(checked);
|
||||||
if (checked && !tabServer) {
|
if (checked && !tabServer) {
|
||||||
tabServer = new TabServer(this, client);
|
openTabServer(true);
|
||||||
connect(tabServer, &TabServer::roomJoined, this, &TabSupervisor::addRoomTab);
|
|
||||||
myAddTab(tabServer, !isReopeningTabs, aTabServer);
|
|
||||||
connect(tabServer, &Tab::closed, this, [this] {
|
|
||||||
tabServer = nullptr;
|
|
||||||
aTabServer->setChecked(false);
|
|
||||||
});
|
|
||||||
} else if (!checked && tabServer) {
|
} else if (!checked && tabServer) {
|
||||||
tabServer->closeRequest();
|
tabServer->closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::openTabServer(bool setCurrent)
|
||||||
|
{
|
||||||
|
tabServer = new TabServer(this, client);
|
||||||
|
connect(tabServer, &TabServer::roomJoined, this, &TabSupervisor::addRoomTab);
|
||||||
|
myAddTab(tabServer, setCurrent, aTabServer);
|
||||||
|
connect(tabServer, &Tab::closed, this, [this] {
|
||||||
|
tabServer = nullptr;
|
||||||
|
aTabServer->setChecked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::actTabAccount(bool checked)
|
void TabSupervisor::actTabAccount(bool checked)
|
||||||
{
|
{
|
||||||
SettingsCache::instance().setTabAccountOpen(checked);
|
SettingsCache::instance().setTabAccountOpen(checked);
|
||||||
if (checked && !tabAccount) {
|
if (checked && !tabAccount) {
|
||||||
tabAccount = new TabAccount(this, client, *userInfo);
|
openTabAccount(true);
|
||||||
connect(tabAccount, &TabAccount::openMessageDialog, this, &TabSupervisor::addMessageTab);
|
|
||||||
connect(tabAccount, &TabAccount::userJoined, this, &TabSupervisor::processUserJoined);
|
|
||||||
connect(tabAccount, &TabAccount::userLeft, this, &TabSupervisor::processUserLeft);
|
|
||||||
myAddTab(tabAccount, !isReopeningTabs, aTabAccount);
|
|
||||||
connect(tabAccount, &Tab::closed, this, [this] {
|
|
||||||
tabAccount = nullptr;
|
|
||||||
aTabAccount->setChecked(false);
|
|
||||||
});
|
|
||||||
} else if (!checked && tabAccount) {
|
} else if (!checked && tabAccount) {
|
||||||
tabAccount->closeRequest();
|
tabAccount->closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::openTabAccount(bool setCurrent)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
connect(tabAccount, &Tab::closed, this, [this] {
|
||||||
|
tabAccount = nullptr;
|
||||||
|
aTabAccount->setChecked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::actTabDeckStorage(bool checked)
|
void TabSupervisor::actTabDeckStorage(bool checked)
|
||||||
{
|
{
|
||||||
SettingsCache::instance().setTabDeckStorageOpen(checked);
|
SettingsCache::instance().setTabDeckStorageOpen(checked);
|
||||||
if (checked && !tabDeckStorage) {
|
if (checked && !tabDeckStorage) {
|
||||||
tabDeckStorage = new TabDeckStorage(this, client, userInfo);
|
openTabDeckStorage(true);
|
||||||
connect(tabDeckStorage, &TabDeckStorage::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
|
|
||||||
myAddTab(tabDeckStorage, !isReopeningTabs, aTabDeckStorage);
|
|
||||||
connect(tabDeckStorage, &Tab::closed, this, [this] {
|
|
||||||
tabDeckStorage = nullptr;
|
|
||||||
aTabDeckStorage->setChecked(false);
|
|
||||||
});
|
|
||||||
} else if (!checked && tabDeckStorage) {
|
} else if (!checked && tabDeckStorage) {
|
||||||
tabDeckStorage->closeRequest();
|
tabDeckStorage->closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::openTabDeckStorage(bool setCurrent)
|
||||||
|
{
|
||||||
|
tabDeckStorage = new TabDeckStorage(this, client, userInfo);
|
||||||
|
connect(tabDeckStorage, &TabDeckStorage::openDeckEditor, this, &TabSupervisor::addDeckEditorTab);
|
||||||
|
myAddTab(tabDeckStorage, setCurrent, aTabDeckStorage);
|
||||||
|
connect(tabDeckStorage, &Tab::closed, this, [this] {
|
||||||
|
tabDeckStorage = nullptr;
|
||||||
|
aTabDeckStorage->setChecked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::actTabReplays(bool checked)
|
void TabSupervisor::actTabReplays(bool checked)
|
||||||
{
|
{
|
||||||
SettingsCache::instance().setTabReplaysOpen(checked);
|
SettingsCache::instance().setTabReplaysOpen(checked);
|
||||||
if (checked && !tabReplays) {
|
if (checked && !tabReplays) {
|
||||||
tabReplays = new TabReplays(this, client, userInfo);
|
openTabReplays(true);
|
||||||
connect(tabReplays, &TabReplays::openReplay, this, &TabSupervisor::openReplay);
|
|
||||||
myAddTab(tabReplays, !isReopeningTabs, aTabReplays);
|
|
||||||
connect(tabReplays, &Tab::closed, this, [this] {
|
|
||||||
tabReplays = nullptr;
|
|
||||||
aTabReplays->setChecked(false);
|
|
||||||
});
|
|
||||||
} else if (!checked && tabReplays) {
|
} else if (!checked && tabReplays) {
|
||||||
tabReplays->closeRequest();
|
tabReplays->closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::openTabReplays(bool setCurrent)
|
||||||
|
{
|
||||||
|
tabReplays = new TabReplays(this, client, userInfo);
|
||||||
|
connect(tabReplays, &TabReplays::openReplay, this, &TabSupervisor::openReplay);
|
||||||
|
myAddTab(tabReplays, setCurrent, aTabReplays);
|
||||||
|
connect(tabReplays, &Tab::closed, this, [this] {
|
||||||
|
tabReplays = nullptr;
|
||||||
|
aTabReplays->setChecked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::actTabAdmin(bool checked)
|
void TabSupervisor::actTabAdmin(bool checked)
|
||||||
{
|
{
|
||||||
SettingsCache::instance().setTabAdminOpen(checked);
|
SettingsCache::instance().setTabAdminOpen(checked);
|
||||||
if (checked && !tabAdmin) {
|
if (checked && !tabAdmin) {
|
||||||
tabAdmin = new TabAdmin(this, client, (userInfo->user_level() & ServerInfo_User::IsAdmin));
|
openTabAdmin(true);
|
||||||
connect(tabAdmin, &TabAdmin::adminLockChanged, this, &TabSupervisor::adminLockChanged);
|
|
||||||
myAddTab(tabAdmin, !isReopeningTabs, aTabAdmin);
|
|
||||||
connect(tabAdmin, &Tab::closed, this, [this] {
|
|
||||||
tabAdmin = nullptr;
|
|
||||||
aTabAdmin->setChecked(false);
|
|
||||||
});
|
|
||||||
} else if (!checked && tabAdmin) {
|
} else if (!checked && tabAdmin) {
|
||||||
tabAdmin->closeRequest();
|
tabAdmin->closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::openTabAdmin(bool setCurrent)
|
||||||
|
{
|
||||||
|
tabAdmin = new TabAdmin(this, client, (userInfo->user_level() & ServerInfo_User::IsAdmin));
|
||||||
|
connect(tabAdmin, &TabAdmin::adminLockChanged, this, &TabSupervisor::adminLockChanged);
|
||||||
|
myAddTab(tabAdmin, setCurrent, aTabAdmin);
|
||||||
|
connect(tabAdmin, &Tab::closed, this, [this] {
|
||||||
|
tabAdmin = nullptr;
|
||||||
|
aTabAdmin->setChecked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::actTabLog(bool checked)
|
void TabSupervisor::actTabLog(bool checked)
|
||||||
{
|
{
|
||||||
SettingsCache::instance().setTabLogOpen(checked);
|
SettingsCache::instance().setTabLogOpen(checked);
|
||||||
if (checked && !tabLog) {
|
if (checked && !tabLog) {
|
||||||
tabLog = new TabLog(this, client);
|
openTabLog(true);
|
||||||
myAddTab(tabLog, !isReopeningTabs, aTabLog);
|
|
||||||
connect(tabLog, &Tab::closed, this, [this] {
|
|
||||||
tabLog = nullptr;
|
|
||||||
aTabAdmin->setChecked(false);
|
|
||||||
});
|
|
||||||
} else if (!checked && tabLog) {
|
} else if (!checked && tabLog) {
|
||||||
tabLog->closeRequest();
|
tabLog->closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabSupervisor::openTabLog(bool setCurrent)
|
||||||
|
{
|
||||||
|
tabLog = new TabLog(this, client);
|
||||||
|
myAddTab(tabLog, setCurrent, aTabLog);
|
||||||
|
connect(tabLog, &Tab::closed, this, [this] {
|
||||||
|
tabLog = nullptr;
|
||||||
|
aTabAdmin->setChecked(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void TabSupervisor::updatePingTime(int value, int max)
|
void TabSupervisor::updatePingTime(int value, int max)
|
||||||
{
|
{
|
||||||
if (!tabServer)
|
if (!tabServer)
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,14 @@ private slots:
|
||||||
void actTabAdmin(bool checked);
|
void actTabAdmin(bool checked);
|
||||||
void actTabLog(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 updateCurrent(int index);
|
void updateCurrent(int index);
|
||||||
void updatePingTime(int value, int max);
|
void updatePingTime(int value, int max);
|
||||||
void gameJoined(const Event_GameJoined &event);
|
void gameJoined(const Event_GameJoined &event);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue