Commit 36f1536b authored by Zach's avatar Zach
Browse files

Merge pull request #1807 from ctrlaltca/game_sizes

Correctly save and retrieve docks size in game tabs
parents 93d4f787 a8c72332
...@@ -78,6 +78,39 @@ const QByteArray LayoutsSettings::getGamePlayAreaGeometry() ...@@ -78,6 +78,39 @@ const QByteArray LayoutsSettings::getGamePlayAreaGeometry()
return getValue("layouts/gameplayarea_geometry").toByteArray(); return getValue("layouts/gameplayarea_geometry").toByteArray();
} }
const QSize LayoutsSettings::getGameCardInfoSize()
{
QVariant previous = getValue("layouts/gameplayarea_CardInfoSize");
return previous == QVariant() ? QSize(250,360) : previous.toSize();
}
void LayoutsSettings::setGameCardInfoSize(const QSize &value)
{
setValue(value,"layouts/gameplayarea_CardInfoSize");
}
const QSize LayoutsSettings::getGameMessageLayoutSize()
{
QVariant previous = getValue("layouts/gameplayarea_MessageLayoutSize");
return previous == QVariant() ? QSize(250,250) : previous.toSize();
}
void LayoutsSettings::setGameMessageLayoutSize(const QSize &value)
{
setValue(value,"layouts/gameplayarea_MessageLayoutSize");
}
const QSize LayoutsSettings::getGamePlayerListSize()
{
QVariant previous = getValue("layouts/gameplayarea_PlayerListSize");
return previous == QVariant() ? QSize(250,50) : previous.toSize();
}
void LayoutsSettings::setGamePlayerListSize(const QSize &value)
{
setValue(value,"layouts/gameplayarea_PlayerListSize");
}
void LayoutsSettings::setReplayPlayAreaGeometry(const QByteArray &value) void LayoutsSettings::setReplayPlayAreaGeometry(const QByteArray &value)
{ {
setValue(value,"layouts/replayplayarea_geometry"); setValue(value,"layouts/replayplayarea_geometry");
...@@ -97,3 +130,47 @@ const QByteArray LayoutsSettings::getReplayPlayAreaGeometry() ...@@ -97,3 +130,47 @@ const QByteArray LayoutsSettings::getReplayPlayAreaGeometry()
{ {
return getValue("layouts/replayplayarea_geometry").toByteArray(); return getValue("layouts/replayplayarea_geometry").toByteArray();
} }
const QSize LayoutsSettings::getReplayCardInfoSize()
{
QVariant previous = getValue("layouts/replayplayarea_CardInfoSize");
return previous == QVariant() ? QSize(250,360) : previous.toSize();
}
void LayoutsSettings::setReplayCardInfoSize(const QSize &value)
{
setValue(value,"layouts/replayplayarea_CardInfoSize");
}
const QSize LayoutsSettings::getReplayMessageLayoutSize()
{
QVariant previous = getValue("layouts/replayplayarea_MessageLayoutSize");
return previous == QVariant() ? QSize(250,200) : previous.toSize();
}
void LayoutsSettings::setReplayMessageLayoutSize(const QSize &value)
{
setValue(value,"layouts/replayplayarea_MessageLayoutSize");
}
const QSize LayoutsSettings::getReplayPlayerListSize()
{
QVariant previous = getValue("layouts/replayplayarea_PlayerListSize");
return previous == QVariant() ? QSize(250,50) : previous.toSize();
}
void LayoutsSettings::setReplayPlayerListSize(const QSize &value)
{
setValue(value,"layouts/replayplayarea_PlayerListSize");
}
const QSize LayoutsSettings::getReplayReplaySize()
{
QVariant previous = getValue("layouts/replayplayarea_ReplaySize");
return previous == QVariant() ? QSize(900,100) : previous.toSize();
}
void LayoutsSettings::setReplayReplaySize(const QSize &value)
{
setValue(value,"layouts/replayplayarea_ReplaySize");
}
\ No newline at end of file
...@@ -15,20 +15,38 @@ public: ...@@ -15,20 +15,38 @@ public:
void setDeckEditorCardSize(const QSize &value); void setDeckEditorCardSize(const QSize &value);
void setDeckEditorDeckSize(const QSize &value); void setDeckEditorDeckSize(const QSize &value);
void setDeckEditorFilterSize(const QSize &value); void setDeckEditorFilterSize(const QSize &value);
void setGamePlayAreaGeometry(const QByteArray &value); void setGamePlayAreaGeometry(const QByteArray &value);
void setGamePlayAreaState(const QByteArray &value); void setGamePlayAreaState(const QByteArray &value);
void setGameCardInfoSize(const QSize &value);
void setGameMessageLayoutSize(const QSize &value);
void setGamePlayerListSize(const QSize &value);
void setReplayPlayAreaGeometry(const QByteArray &value); void setReplayPlayAreaGeometry(const QByteArray &value);
void setReplayPlayAreaState(const QByteArray &value); void setReplayPlayAreaState(const QByteArray &value);
void setReplayCardInfoSize(const QSize &value);
void setReplayMessageLayoutSize(const QSize &value);
void setReplayPlayerListSize(const QSize &value);
void setReplayReplaySize(const QSize &value);
const QByteArray getDeckEditorLayoutState(); const QByteArray getDeckEditorLayoutState();
const QByteArray getDeckEditorGeometry(); const QByteArray getDeckEditorGeometry();
const QSize getDeckEditorCardSize(); const QSize getDeckEditorCardSize();
const QSize getDeckEditorDeckSize(); const QSize getDeckEditorDeckSize();
const QSize getDeckEditorFilterSize(); const QSize getDeckEditorFilterSize();
const QByteArray getGamePlayAreaLayoutState(); const QByteArray getGamePlayAreaLayoutState();
const QByteArray getGamePlayAreaGeometry(); const QByteArray getGamePlayAreaGeometry();
const QSize getGameCardInfoSize();
const QSize getGameMessageLayoutSize();
const QSize getGamePlayerListSize();
const QByteArray getReplayPlayAreaLayoutState(); const QByteArray getReplayPlayAreaLayoutState();
const QByteArray getReplayPlayAreaGeometry(); const QByteArray getReplayPlayAreaGeometry();
const QSize getReplayCardInfoSize();
const QSize getReplayMessageLayoutSize();
const QSize getReplayPlayerListSize();
const QSize getReplayReplaySize();
signals: signals:
public slots: public slots:
......
...@@ -362,6 +362,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay) ...@@ -362,6 +362,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
refreshShortcuts(); refreshShortcuts();
messageLog->logReplayStarted(gameInfo.game_id()); messageLog->logReplayStarted(gameInfo.game_id());
this->installEventFilter(this);
QTimer::singleShot(0, this, SLOT(loadLayout())); QTimer::singleShot(0, this, SLOT(loadLayout()));
} }
...@@ -410,6 +411,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client ...@@ -410,6 +411,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
for (int i = gameInfo.game_types_size() - 1; i >= 0; i--) for (int i = gameInfo.game_types_size() - 1; i >= 0; i--)
gameTypes.append(roomGameTypes.find(gameInfo.game_types(i)).value()); gameTypes.append(roomGameTypes.find(gameInfo.game_types(i)).value());
this->installEventFilter(this);
QTimer::singleShot(0, this, SLOT(loadLayout())); QTimer::singleShot(0, this, SLOT(loadLayout()));
} }
...@@ -426,14 +428,7 @@ void TabGame::emitUserEvent() { ...@@ -426,14 +428,7 @@ void TabGame::emitUserEvent() {
TabGame::~TabGame() TabGame::~TabGame()
{ {
if(replay) if(replay)
{
settingsCache->layouts().setReplayPlayAreaState(saveState());
settingsCache->layouts().setReplayPlayAreaGeometry(saveGeometry());
delete replay; delete replay;
} else {
settingsCache->layouts().setGamePlayAreaState(saveState());
settingsCache->layouts().setGamePlayAreaGeometry(saveGeometry());
}
QMapIterator<int, Player *> i(players); QMapIterator<int, Player *> i(players);
while (i.hasNext()) while (i.hasNext())
...@@ -445,13 +440,13 @@ TabGame::~TabGame() ...@@ -445,13 +440,13 @@ TabGame::~TabGame()
void TabGame::retranslateUi() void TabGame::retranslateUi()
{ {
QString tabText = getTabText() + " - "; QString tabText = " | " + (replay ? tr("Replay") : tr("Game")) + " #" + QString::number(gameInfo.game_id());
cardInfoDock->setWindowTitle((cardInfoDock->isWindow() ? tabText : QString()) + tr("Card Info")); cardInfoDock->setWindowTitle(tr("Card Info") + (cardInfoDock->isWindow() ? tabText : QString()));
playerListDock->setWindowTitle((playerListDock->isWindow() ? tabText : QString()) + tr("Player List")); playerListDock->setWindowTitle(tr("Player List") + (playerListDock->isWindow() ? tabText : QString()));
messageLayoutDock->setWindowTitle((messageLayoutDock->isWindow() ? tabText : QString()) + tr("Messages")); messageLayoutDock->setWindowTitle(tr("Messages") + (messageLayoutDock->isWindow() ? tabText : QString()));
if(replayDock) if(replayDock)
replayDock->setWindowTitle((replayDock->isWindow() ? tabText : QString()) + tr("Replay Timeline")); replayDock->setWindowTitle(tr("Replay Timeline") + (replayDock->isWindow() ? tabText : QString()));
if (phasesMenu) { if (phasesMenu) {
for (int i = 0; i < phaseActions.size(); ++i) for (int i = 0; i < phaseActions.size(); ++i)
...@@ -1170,7 +1165,7 @@ QString TabGame::getTabText() const ...@@ -1170,7 +1165,7 @@ QString TabGame::getTabText() const
QString tabText; QString tabText;
if (replay) if (replay)
tabText.append(tr("REPLAY ")); tabText.append(tr("Replay") + " ");
if (!gameTypeInfo.isEmpty()) if (!gameTypeInfo.isEmpty())
tabText.append(gameTypeInfo + " "); tabText.append(gameTypeInfo + " ");
if (!gameDesc.isEmpty()) { if (!gameDesc.isEmpty()) {
...@@ -1335,9 +1330,25 @@ void TabGame::loadLayout() ...@@ -1335,9 +1330,25 @@ void TabGame::loadLayout()
{ {
restoreGeometry(settingsCache->layouts().getReplayPlayAreaGeometry()); restoreGeometry(settingsCache->layouts().getReplayPlayAreaGeometry());
restoreState(settingsCache->layouts().getReplayPlayAreaLayoutState()); restoreState(settingsCache->layouts().getReplayPlayAreaLayoutState());
cardInfoDock->setMinimumSize(settingsCache->layouts().getReplayCardInfoSize());
cardInfoDock->setMaximumSize(settingsCache->layouts().getReplayCardInfoSize());
messageLayoutDock->setMinimumSize(settingsCache->layouts().getReplayMessageLayoutSize());
messageLayoutDock->setMaximumSize(settingsCache->layouts().getReplayMessageLayoutSize());
playerListDock->setMinimumSize(settingsCache->layouts().getReplayPlayerListSize());
playerListDock->setMaximumSize(settingsCache->layouts().getReplayPlayerListSize());
replayDock->setMinimumSize(settingsCache->layouts().getReplayReplaySize());
replayDock->setMaximumSize(settingsCache->layouts().getReplayReplaySize());
} else { } else {
restoreGeometry(settingsCache->layouts().getGamePlayAreaGeometry()); restoreGeometry(settingsCache->layouts().getGamePlayAreaGeometry());
restoreState(settingsCache->layouts().getGamePlayAreaLayoutState()); restoreState(settingsCache->layouts().getGamePlayAreaLayoutState());
cardInfoDock->setMinimumSize(settingsCache->layouts().getGameCardInfoSize());
cardInfoDock->setMaximumSize(settingsCache->layouts().getGameCardInfoSize());
messageLayoutDock->setMinimumSize(settingsCache->layouts().getGameMessageLayoutSize());
messageLayoutDock->setMaximumSize(settingsCache->layouts().getGameMessageLayoutSize());
playerListDock->setMinimumSize(settingsCache->layouts().getGamePlayerListSize());
playerListDock->setMaximumSize(settingsCache->layouts().getGamePlayerListSize());
} }
aCardInfoDockVisible->setChecked(cardInfoDock->isVisible()); aCardInfoDockVisible->setChecked(cardInfoDock->isVisible());
...@@ -1358,6 +1369,26 @@ void TabGame::loadLayout() ...@@ -1358,6 +1369,26 @@ void TabGame::loadLayout()
aReplayDockFloating->setEnabled(aReplayDockVisible->isChecked()); aReplayDockFloating->setEnabled(aReplayDockVisible->isChecked());
aReplayDockFloating->setChecked(replayDock->isFloating()); aReplayDockFloating->setChecked(replayDock->isFloating());
} }
QTimer::singleShot(100, this, SLOT(freeDocksSize()));
}
void TabGame::freeDocksSize()
{
cardInfoDock->setMinimumSize(100, 100);
cardInfoDock->setMaximumSize(5000, 5000);
messageLayoutDock->setMinimumSize(100, 100);
messageLayoutDock->setMaximumSize(5000, 5000);
playerListDock->setMinimumSize(100,100);
playerListDock->setMaximumSize(5000,5000);
if(replayDock)
{
replayDock->setMinimumSize(100,100);
replayDock->setMaximumSize(5000,5000);
}
} }
void TabGame::actResetLayout() void TabGame::actResetLayout()
...@@ -1389,7 +1420,25 @@ void TabGame::actResetLayout() ...@@ -1389,7 +1420,25 @@ void TabGame::actResetLayout()
addDockWidget(Qt::BottomDockWidgetArea, replayDock); addDockWidget(Qt::BottomDockWidgetArea, replayDock);
aReplayDockVisible->setChecked(true); aReplayDockVisible->setChecked(true);
aReplayDockFloating->setChecked(false); aReplayDockFloating->setChecked(false);
cardInfoDock->setMinimumSize(250,360);
cardInfoDock->setMaximumSize(250,360);
messageLayoutDock->setMinimumSize(250,200);
messageLayoutDock->setMaximumSize(250,200);
playerListDock->setMinimumSize(250,50);
playerListDock->setMaximumSize(250,50);
replayDock->setMinimumSize(900,100);
replayDock->setMaximumSize(900,100);
} else {
cardInfoDock->setMinimumSize(250,360);
cardInfoDock->setMaximumSize(250,360);
messageLayoutDock->setMinimumSize(250,250);
messageLayoutDock->setMaximumSize(250,250);
playerListDock->setMinimumSize(250,50);
playerListDock->setMaximumSize(250,50);
} }
QTimer::singleShot(100, this, SLOT(freeDocksSize()));
} }
void TabGame::createPlayAreaWidget(bool bReplay) void TabGame::createPlayAreaWidget(bool bReplay)
...@@ -1595,6 +1644,23 @@ bool TabGame::eventFilter(QObject * o, QEvent * e) ...@@ -1595,6 +1644,23 @@ bool TabGame::eventFilter(QObject * o, QEvent * e)
} }
} }
if( o == this && e->type() == QEvent::Hide){
if(replay)
{
settingsCache->layouts().setReplayPlayAreaState(saveState());
settingsCache->layouts().setReplayPlayAreaGeometry(saveGeometry());
settingsCache->layouts().setReplayCardInfoSize(cardInfoDock->size());
settingsCache->layouts().setReplayMessageLayoutSize(messageLayoutDock->size());
settingsCache->layouts().setReplayPlayerListSize(playerListDock->size());
settingsCache->layouts().setReplayReplaySize(replayDock->size());
} else {
settingsCache->layouts().setGamePlayAreaState(saveState());
settingsCache->layouts().setGamePlayAreaGeometry(saveGeometry());
settingsCache->layouts().setGameCardInfoSize(cardInfoDock->size());
settingsCache->layouts().setGameMessageLayoutSize(messageLayoutDock->size());
settingsCache->layouts().setGamePlayerListSize(playerListDock->size());
}
}
return false; return false;
} }
......
...@@ -223,6 +223,7 @@ private slots: ...@@ -223,6 +223,7 @@ private slots:
void loadLayout(); void loadLayout();
void actCompleterChanged(); void actCompleterChanged();
void actResetLayout(); void actResetLayout();
void freeDocksSize();
bool eventFilter(QObject *o, QEvent *e); bool eventFilter(QObject *o, QEvent *e);
void dockVisibleTriggered(); void dockVisibleTriggered();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment