diff --git a/cockatrice/resources/lock.svg b/cockatrice/resources/lock.svg new file mode 100644 index 00000000..ab32a23e --- /dev/null +++ b/cockatrice/resources/lock.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cockatrice/src/replay_timeline_widget.cpp b/cockatrice/src/replay_timeline_widget.cpp index 552b3a35..071cb7b6 100644 --- a/cockatrice/src/replay_timeline_widget.cpp +++ b/cockatrice/src/replay_timeline_widget.cpp @@ -63,6 +63,11 @@ QSize ReplayTimelineWidget::sizeHint() const return QSize(-1, 50); } +QSize ReplayTimelineWidget::minimumSizeHint() const +{ + return QSize(400, 50); +} + void ReplayTimelineWidget::replayTimerTimeout() { currentTime += 200; diff --git a/cockatrice/src/replay_timeline_widget.h b/cockatrice/src/replay_timeline_widget.h index d5fd0ce4..3a1b6712 100644 --- a/cockatrice/src/replay_timeline_widget.h +++ b/cockatrice/src/replay_timeline_widget.h @@ -27,6 +27,7 @@ public: ReplayTimelineWidget(QWidget *parent = 0); void setTimeline(const QList &_replayTimeline); QSize sizeHint() const; + QSize minimumSizeHint() const; void setTimeScaleFactor(qreal _timeScaleFactor); int getCurrentEvent() const { return currentEvent; } public slots: diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index bb606ab5..27b15485 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -213,6 +213,8 @@ TabGame::TabGame(GameReplay *_replay) replay(_replay), currentReplayStep(0) { + setAttribute(Qt::WA_DeleteOnClose); + gameId = replay->game_info().game_id(); gameDescription = QString::fromStdString(replay->game_info().description()); @@ -323,12 +325,13 @@ TabGame::TabGame(GameReplay *_replay) aNextTurn = 0; aRemoveLocalArrows = 0; aConcede = 0; - aLeaveGame = new QAction(this); - connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame())); + aLeaveGame = 0; + aCloseReplay = new QAction(this); + connect(aCloseReplay, SIGNAL(triggered()), this, SLOT(actLeaveGame())); phasesMenu = 0; tabMenu = new QMenu(this); - tabMenu->addAction(aLeaveGame); + tabMenu->addAction(aCloseReplay); retranslateUi(); setLayout(superMainLayout); @@ -424,6 +427,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList &_client connect(aConcede, SIGNAL(triggered()), this, SLOT(actConcede())); aLeaveGame = new QAction(this); connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame())); + aCloseReplay = 0; phasesMenu = new QMenu(this); for (int i = 0; i < phasesToolbar->phaseCount(); ++i) { @@ -502,8 +506,14 @@ void TabGame::retranslateUi() aConcede->setText(tr("&Concede")); aConcede->setShortcut(tr("F2")); } - aLeaveGame->setText(tr("&Leave game")); - aLeaveGame->setShortcut(tr("Ctrl+Q")); + if (aLeaveGame) { + aLeaveGame->setText(tr("&Leave game")); + aLeaveGame->setShortcut(tr("Ctrl+Q")); + } + if (aCloseReplay) { + aCloseReplay->setText(tr("C&lose replay")); + aCloseReplay->setShortcut(tr("Ctrl+Q")); + } if (sayLabel) sayLabel->setText(tr("&Say:")); @@ -613,8 +623,9 @@ void TabGame::actLeaveGame() if (!spectator) if (QMessageBox::question(this, tr("Leave game"), tr("Are you sure you want to leave this game?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) return; - - sendGameCommand(Command_LeaveGame()); + + if (!replay) + sendGameCommand(Command_LeaveGame()); deleteLater(); } diff --git a/cockatrice/src/tab_game.h b/cockatrice/src/tab_game.h index 8c40a6fe..bb4dda88 100644 --- a/cockatrice/src/tab_game.h +++ b/cockatrice/src/tab_game.h @@ -134,7 +134,7 @@ private: ZoneViewLayout *zoneLayout; QAction *playersSeparator; QMenu *phasesMenu; - QAction *aConcede, *aLeaveGame, *aNextPhase, *aNextTurn, *aRemoveLocalArrows; + QAction *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows; QList phaseActions; Player *addPlayer(int playerId, const ServerInfo_User &info); diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index 02ab078e..6e23afcc 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -209,6 +209,11 @@ void TabSupervisor::stop() gameIterator.next().value()->deleteLater(); gameTabs.clear(); + QListIterator replayIterator(replayTabs); + while (replayIterator.hasNext()) + replayIterator.next()->deleteLater(); + replayTabs.clear(); + QMapIterator messageIterator(messageTabs); while (messageIterator.hasNext()) messageIterator.next().value()->deleteLater(); @@ -272,7 +277,8 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event) void TabSupervisor::gameLeft(TabGame *tab) { - emit setMenu(0); + if (tab == currentWidget()) + emit setMenu(0); gameTabs.remove(tab->getGameId()); removeTab(indexOf(tab)); @@ -295,12 +301,31 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent) void TabSupervisor::roomLeft(TabRoom *tab) { - emit setMenu(0); - + if (tab == currentWidget()) + emit setMenu(0); + roomTabs.remove(tab->getRoomId()); removeTab(indexOf(tab)); } +void TabSupervisor::openReplay(GameReplay *replay) +{ + TabGame *replayTab = new TabGame(replay); + connect(replayTab, SIGNAL(gameClosing(TabGame *)), this, SLOT(replayLeft(TabGame *))); + int tabIndex = myAddTab(replayTab); + addCloseButtonToTab(replayTab, tabIndex); + replayTabs.append(replayTab); + setCurrentWidget(replayTab); +} + +void TabSupervisor::replayLeft(TabGame *tab) +{ + if (tab == currentWidget()) + emit setMenu(0); + + replayTabs.removeAt(replayTabs.indexOf(tab)); +} + TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus) { if (receiverName == QString::fromStdString(userInfo->name())) @@ -316,15 +341,10 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus return tab; } -void TabSupervisor::openReplay(GameReplay *replay) -{ - TabGame *replayTab = new TabGame(replay); - myAddTab(replayTab); -} - void TabSupervisor::talkLeft(TabMessage *tab) { - emit setMenu(0); + if (tab == currentWidget()) + emit setMenu(0); messageTabs.remove(tab->getUserName()); removeTab(indexOf(tab)); diff --git a/cockatrice/src/tab_supervisor.h b/cockatrice/src/tab_supervisor.h index 9a60998e..9f72cc4e 100644 --- a/cockatrice/src/tab_supervisor.h +++ b/cockatrice/src/tab_supervisor.h @@ -50,6 +50,7 @@ private: TabAdmin *tabAdmin; QMap roomTabs; QMap gameTabs; + QList replayTabs; QMap messageTabs; int myAddTab(Tab *tab); void addCloseButtonToTab(Tab *tab, int tabIndex); @@ -81,6 +82,7 @@ private slots: void roomLeft(TabRoom *tab); TabMessage *addMessageTab(const QString &userName, bool focus); void openReplay(GameReplay *replay); + void replayLeft(TabGame *tab); void processUserLeft(const QString &userName); void processUserJoined(const QString &userName); void talkLeft(TabMessage *tab); diff --git a/cockatrice/src/window_deckeditor.cpp b/cockatrice/src/window_deckeditor.cpp index c8723f0a..b7d9b836 100644 --- a/cockatrice/src/window_deckeditor.cpp +++ b/cockatrice/src/window_deckeditor.cpp @@ -38,6 +38,8 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event) WndDeckEditor::WndDeckEditor(QWidget *parent) : QMainWindow(parent) { + setAttribute(Qt::WA_DeleteOnClose); + aSearch = new QAction(tr("&Search..."), this); aSearch->setIcon(QIcon(":/resources/icon_search.svg")); connect(aSearch, SIGNAL(triggered()), this, SLOT(actSearch()));