mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-04 04:23:55 -07:00
[TabGame] Don't create replay dock if not replay tab (#6527)
* [TabGame] Don't create replay dock if not replay tab * use replayDock to determine if replay tab * null check replayManager in dtor
This commit is contained in:
parent
84483c56d7
commit
c7c7bf550a
2 changed files with 15 additions and 14 deletions
|
|
@ -97,12 +97,11 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
|
||||||
createMessageDock();
|
createMessageDock();
|
||||||
createPlayAreaWidget();
|
createPlayAreaWidget();
|
||||||
createDeckViewContainerWidget();
|
createDeckViewContainerWidget();
|
||||||
createReplayDock(nullptr);
|
replayDock = nullptr;
|
||||||
|
|
||||||
addDockWidget(Qt::RightDockWidgetArea, cardInfoDock);
|
addDockWidget(Qt::RightDockWidgetArea, cardInfoDock);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, playerListDock);
|
addDockWidget(Qt::RightDockWidgetArea, playerListDock);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, messageLayoutDock);
|
addDockWidget(Qt::RightDockWidgetArea, messageLayoutDock);
|
||||||
replayDock->setHidden(true);
|
|
||||||
|
|
||||||
mainWidget = new QStackedWidget(this);
|
mainWidget = new QStackedWidget(this);
|
||||||
mainWidget->addWidget(deckViewContainerWidget);
|
mainWidget->addWidget(deckViewContainerWidget);
|
||||||
|
|
@ -256,13 +255,15 @@ void TabGame::emitUserEvent()
|
||||||
|
|
||||||
TabGame::~TabGame()
|
TabGame::~TabGame()
|
||||||
{
|
{
|
||||||
delete replayManager->replay;
|
if (replayManager) {
|
||||||
|
delete replayManager->replay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::updatePlayerListDockTitle()
|
void TabGame::updatePlayerListDockTitle()
|
||||||
{
|
{
|
||||||
QString tabText = " | " + (replayManager->replay ? tr("Replay") : tr("Game")) + " #" +
|
QString type = replayDock ? tr("Replay") : tr("Game");
|
||||||
QString::number(game->getGameMetaInfo()->gameId());
|
QString tabText = " | " + type + " #" + QString::number(game->getGameMetaInfo()->gameId());
|
||||||
QString userCountInfo =
|
QString userCountInfo =
|
||||||
QString(" %1/%2").arg(game->getPlayerManager()->getPlayerCount()).arg(game->getGameMetaInfo()->maxPlayers());
|
QString(" %1/%2").arg(game->getPlayerManager()->getPlayerCount()).arg(game->getGameMetaInfo()->maxPlayers());
|
||||||
playerListDock->setWindowTitle(tr("Player List") + userCountInfo +
|
playerListDock->setWindowTitle(tr("Player List") + userCountInfo +
|
||||||
|
|
@ -271,8 +272,8 @@ void TabGame::updatePlayerListDockTitle()
|
||||||
|
|
||||||
void TabGame::retranslateUi()
|
void TabGame::retranslateUi()
|
||||||
{
|
{
|
||||||
QString tabText = " | " + (replayManager->replay ? tr("Replay") : tr("Game")) + " #" +
|
QString type = replayDock ? tr("Replay") : tr("Game");
|
||||||
QString::number(game->getGameMetaInfo()->gameId());
|
QString tabText = " | " + type + " #" + QString::number(game->getGameMetaInfo()->gameId());
|
||||||
|
|
||||||
updatePlayerListDockTitle();
|
updatePlayerListDockTitle();
|
||||||
cardInfoDock->setWindowTitle(tr("Card Info") + (cardInfoDock->isWindow() ? tabText : QString()));
|
cardInfoDock->setWindowTitle(tr("Card Info") + (cardInfoDock->isWindow() ? tabText : QString()));
|
||||||
|
|
@ -318,7 +319,7 @@ void TabGame::retranslateUi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aLeaveGame) {
|
if (aLeaveGame) {
|
||||||
if (replayManager->replay) {
|
if (replayDock) {
|
||||||
aLeaveGame->setText(tr("C&lose replay"));
|
aLeaveGame->setText(tr("C&lose replay"));
|
||||||
} else {
|
} else {
|
||||||
aLeaveGame->setText(tr("&Leave game"));
|
aLeaveGame->setText(tr("&Leave game"));
|
||||||
|
|
@ -517,7 +518,7 @@ bool TabGame::leaveGame()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!replayManager->replay)
|
if (!replayDock)
|
||||||
emit gameLeft();
|
emit gameLeft();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -904,7 +905,7 @@ QString TabGame::getTabText() const
|
||||||
QString gameId(QString::number(game->getGameMetaInfo()->gameId()));
|
QString gameId(QString::number(game->getGameMetaInfo()->gameId()));
|
||||||
|
|
||||||
QString tabText;
|
QString tabText;
|
||||||
if (replayManager->replay)
|
if (replayDock)
|
||||||
tabText.append(tr("Replay") + " ");
|
tabText.append(tr("Replay") + " ");
|
||||||
if (!gameTypeInfo.isEmpty())
|
if (!gameTypeInfo.isEmpty())
|
||||||
tabText.append(gameTypeInfo + " ");
|
tabText.append(gameTypeInfo + " ");
|
||||||
|
|
@ -1085,7 +1086,7 @@ void TabGame::createViewMenuItems()
|
||||||
void TabGame::loadLayout()
|
void TabGame::loadLayout()
|
||||||
{
|
{
|
||||||
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
||||||
if (replayManager->replay) {
|
if (replayDock) {
|
||||||
restoreGeometry(layouts.getReplayPlayAreaGeometry());
|
restoreGeometry(layouts.getReplayPlayAreaGeometry());
|
||||||
restoreState(layouts.getReplayPlayAreaLayoutState());
|
restoreState(layouts.getReplayPlayAreaLayoutState());
|
||||||
|
|
||||||
|
|
@ -1121,7 +1122,7 @@ void TabGame::loadLayout()
|
||||||
aMessageLayoutDockFloating->setChecked(messageLayoutDock->isFloating());
|
aMessageLayoutDockFloating->setChecked(messageLayoutDock->isFloating());
|
||||||
aPlayerListDockFloating->setChecked(playerListDock->isFloating());
|
aPlayerListDockFloating->setChecked(playerListDock->isFloating());
|
||||||
|
|
||||||
if (replayManager->replay) {
|
if (replayDock) {
|
||||||
aReplayDockVisible->setChecked(replayDock->isVisible());
|
aReplayDockVisible->setChecked(replayDock->isVisible());
|
||||||
aReplayDockFloating->setEnabled(aReplayDockVisible->isChecked());
|
aReplayDockFloating->setEnabled(aReplayDockVisible->isChecked());
|
||||||
aReplayDockFloating->setChecked(replayDock->isFloating());
|
aReplayDockFloating->setChecked(replayDock->isFloating());
|
||||||
|
|
@ -1380,7 +1381,7 @@ void TabGame::createMessageDock(bool bReplay)
|
||||||
void TabGame::hideEvent(QHideEvent *event)
|
void TabGame::hideEvent(QHideEvent *event)
|
||||||
{
|
{
|
||||||
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
LayoutsSettings &layouts = SettingsCache::instance().layouts();
|
||||||
if (replayManager->replay) {
|
if (replayDock) {
|
||||||
layouts.setReplayPlayAreaState(saveState());
|
layouts.setReplayPlayAreaState(saveState());
|
||||||
layouts.setReplayPlayAreaGeometry(saveGeometry());
|
layouts.setReplayPlayAreaGeometry(saveGeometry());
|
||||||
layouts.setReplayCardInfoSize(cardInfoDock->size());
|
layouts.setReplayCardInfoSize(cardInfoDock->size());
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class TabGame : public Tab
|
||||||
private:
|
private:
|
||||||
AbstractGame *game;
|
AbstractGame *game;
|
||||||
const UserListProxy *userListProxy;
|
const UserListProxy *userListProxy;
|
||||||
ReplayManager *replayManager;
|
ReplayManager *replayManager = nullptr;
|
||||||
QStringList gameTypes;
|
QStringList gameTypes;
|
||||||
QCompleter *completer;
|
QCompleter *completer;
|
||||||
QStringList autocompleteUserList;
|
QStringList autocompleteUserList;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue