From 058b913455b33d11960beaaa0a363847e40dcb95 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 7 Feb 2016 21:58:51 +0100 Subject: [PATCH 1/3] Game: save and restore dock sizes --- cockatrice/src/settings/layoutssettings.cpp | 77 +++++++++++++++++++++ cockatrice/src/settings/layoutssettings.h | 18 +++++ cockatrice/src/tab_game.cpp | 62 +++++++++++++++-- cockatrice/src/tab_game.h | 1 + 4 files changed, 151 insertions(+), 7 deletions(-) diff --git a/cockatrice/src/settings/layoutssettings.cpp b/cockatrice/src/settings/layoutssettings.cpp index a7d2c7498..de301b7b1 100644 --- a/cockatrice/src/settings/layoutssettings.cpp +++ b/cockatrice/src/settings/layoutssettings.cpp @@ -78,6 +78,39 @@ const QByteArray LayoutsSettings::getGamePlayAreaGeometry() 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) { setValue(value,"layouts/replayplayarea_geometry"); @@ -97,3 +130,47 @@ const QByteArray LayoutsSettings::getReplayPlayAreaGeometry() { 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 diff --git a/cockatrice/src/settings/layoutssettings.h b/cockatrice/src/settings/layoutssettings.h index b6282c908..d67ec1aa6 100644 --- a/cockatrice/src/settings/layoutssettings.h +++ b/cockatrice/src/settings/layoutssettings.h @@ -15,20 +15,38 @@ public: void setDeckEditorCardSize(const QSize &value); void setDeckEditorDeckSize(const QSize &value); void setDeckEditorFilterSize(const QSize &value); + void setGamePlayAreaGeometry(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 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 getDeckEditorGeometry(); const QSize getDeckEditorCardSize(); const QSize getDeckEditorDeckSize(); const QSize getDeckEditorFilterSize(); + const QByteArray getGamePlayAreaLayoutState(); const QByteArray getGamePlayAreaGeometry(); + const QSize getGameCardInfoSize(); + const QSize getGameMessageLayoutSize(); + const QSize getGamePlayerListSize(); + const QByteArray getReplayPlayAreaLayoutState(); const QByteArray getReplayPlayAreaGeometry(); + const QSize getReplayCardInfoSize(); + const QSize getReplayMessageLayoutSize(); + const QSize getReplayPlayerListSize(); + const QSize getReplayReplaySize(); signals: public slots: diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 0f8d80507..3b56d1261 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -362,6 +362,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay) refreshShortcuts(); messageLog->logReplayStarted(gameInfo.game_id()); + this->installEventFilter(this); QTimer::singleShot(0, this, SLOT(loadLayout())); } @@ -410,6 +411,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList &_client for (int i = gameInfo.game_types_size() - 1; i >= 0; i--) gameTypes.append(roomGameTypes.find(gameInfo.game_types(i)).value()); + this->installEventFilter(this); QTimer::singleShot(0, this, SLOT(loadLayout())); } @@ -426,14 +428,7 @@ void TabGame::emitUserEvent() { TabGame::~TabGame() { if(replay) - { - settingsCache->layouts().setReplayPlayAreaState(saveState()); - settingsCache->layouts().setReplayPlayAreaGeometry(saveGeometry()); delete replay; - } else { - settingsCache->layouts().setGamePlayAreaState(saveState()); - settingsCache->layouts().setGamePlayAreaGeometry(saveGeometry()); - } QMapIterator i(players); while (i.hasNext()) @@ -1335,9 +1330,25 @@ void TabGame::loadLayout() { restoreGeometry(settingsCache->layouts().getReplayPlayAreaGeometry()); 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 { restoreGeometry(settingsCache->layouts().getGamePlayAreaGeometry()); 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()); @@ -1358,6 +1369,26 @@ void TabGame::loadLayout() aReplayDockFloating->setEnabled(aReplayDockVisible->isChecked()); 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() @@ -1595,6 +1626,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; } diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index bed00b04f..526445836 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -223,6 +223,7 @@ private slots: void loadLayout(); void actCompleterChanged(); void actResetLayout(); + void freeDocksSize(); bool eventFilter(QObject *o, QEvent *e); void dockVisibleTriggered(); From ae8296a50e5c003537b7862748dddb4b2f993e70 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 11 Feb 2016 18:29:50 +0100 Subject: [PATCH 2/3] Game tab: reset docks sizes on "reset layout" --- cockatrice/src/tab_game.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 3b56d1261..8330e9185 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -1420,7 +1420,25 @@ void TabGame::actResetLayout() addDockWidget(Qt::BottomDockWidgetArea, replayDock); aReplayDockVisible->setChecked(true); 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) From a8c723326dcca545b57c2dde4804fe96da4e0c67 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 12 Feb 2016 14:49:37 +0100 Subject: [PATCH 3/3] Game tab: use short title for undocked wdgets fix #1777 --- cockatrice/src/tab_game.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 8330e9185..075f9880b 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -440,13 +440,13 @@ TabGame::~TabGame() 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")); - playerListDock->setWindowTitle((playerListDock->isWindow() ? tabText : QString()) + tr("Player List")); - messageLayoutDock->setWindowTitle((messageLayoutDock->isWindow() ? tabText : QString()) + tr("Messages")); + cardInfoDock->setWindowTitle(tr("Card Info") + (cardInfoDock->isWindow() ? tabText : QString())); + playerListDock->setWindowTitle(tr("Player List") + (playerListDock->isWindow() ? tabText : QString())); + messageLayoutDock->setWindowTitle(tr("Messages") + (messageLayoutDock->isWindow() ? tabText : QString())); if(replayDock) - replayDock->setWindowTitle((replayDock->isWindow() ? tabText : QString()) + tr("Replay Timeline")); + replayDock->setWindowTitle(tr("Replay Timeline") + (replayDock->isWindow() ? tabText : QString())); if (phasesMenu) { for (int i = 0; i < phaseActions.size(); ++i) @@ -1165,7 +1165,7 @@ QString TabGame::getTabText() const QString tabText; if (replay) - tabText.append(tr("REPLAY ")); + tabText.append(tr("Replay") + " "); if (!gameTypeInfo.isEmpty()) tabText.append(gameTypeInfo + " "); if (!gameDesc.isEmpty()) {