Commit b0378544 authored by Max-Wilhelm Bruker's avatar Max-Wilhelm Bruker
Browse files

added icon for expiration lock button, added close button to replay tab, minor GUI fixes

parent acb03c2b
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -63,6 +63,11 @@ QSize ReplayTimelineWidget::sizeHint() const ...@@ -63,6 +63,11 @@ QSize ReplayTimelineWidget::sizeHint() const
return QSize(-1, 50); return QSize(-1, 50);
} }
QSize ReplayTimelineWidget::minimumSizeHint() const
{
return QSize(400, 50);
}
void ReplayTimelineWidget::replayTimerTimeout() void ReplayTimelineWidget::replayTimerTimeout()
{ {
currentTime += 200; currentTime += 200;
......
...@@ -27,6 +27,7 @@ public: ...@@ -27,6 +27,7 @@ public:
ReplayTimelineWidget(QWidget *parent = 0); ReplayTimelineWidget(QWidget *parent = 0);
void setTimeline(const QList<int> &_replayTimeline); void setTimeline(const QList<int> &_replayTimeline);
QSize sizeHint() const; QSize sizeHint() const;
QSize minimumSizeHint() const;
void setTimeScaleFactor(qreal _timeScaleFactor); void setTimeScaleFactor(qreal _timeScaleFactor);
int getCurrentEvent() const { return currentEvent; } int getCurrentEvent() const { return currentEvent; }
public slots: public slots:
......
...@@ -213,6 +213,8 @@ TabGame::TabGame(GameReplay *_replay) ...@@ -213,6 +213,8 @@ TabGame::TabGame(GameReplay *_replay)
replay(_replay), replay(_replay),
currentReplayStep(0) currentReplayStep(0)
{ {
setAttribute(Qt::WA_DeleteOnClose);
gameId = replay->game_info().game_id(); gameId = replay->game_info().game_id();
gameDescription = QString::fromStdString(replay->game_info().description()); gameDescription = QString::fromStdString(replay->game_info().description());
...@@ -323,12 +325,13 @@ TabGame::TabGame(GameReplay *_replay) ...@@ -323,12 +325,13 @@ TabGame::TabGame(GameReplay *_replay)
aNextTurn = 0; aNextTurn = 0;
aRemoveLocalArrows = 0; aRemoveLocalArrows = 0;
aConcede = 0; aConcede = 0;
aLeaveGame = new QAction(this); aLeaveGame = 0;
connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame())); aCloseReplay = new QAction(this);
connect(aCloseReplay, SIGNAL(triggered()), this, SLOT(actLeaveGame()));
phasesMenu = 0; phasesMenu = 0;
tabMenu = new QMenu(this); tabMenu = new QMenu(this);
tabMenu->addAction(aLeaveGame); tabMenu->addAction(aCloseReplay);
retranslateUi(); retranslateUi();
setLayout(superMainLayout); setLayout(superMainLayout);
...@@ -424,6 +427,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client ...@@ -424,6 +427,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
connect(aConcede, SIGNAL(triggered()), this, SLOT(actConcede())); connect(aConcede, SIGNAL(triggered()), this, SLOT(actConcede()));
aLeaveGame = new QAction(this); aLeaveGame = new QAction(this);
connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame())); connect(aLeaveGame, SIGNAL(triggered()), this, SLOT(actLeaveGame()));
aCloseReplay = 0;
phasesMenu = new QMenu(this); phasesMenu = new QMenu(this);
for (int i = 0; i < phasesToolbar->phaseCount(); ++i) { for (int i = 0; i < phasesToolbar->phaseCount(); ++i) {
...@@ -502,8 +506,14 @@ void TabGame::retranslateUi() ...@@ -502,8 +506,14 @@ void TabGame::retranslateUi()
aConcede->setText(tr("&Concede")); aConcede->setText(tr("&Concede"));
aConcede->setShortcut(tr("F2")); aConcede->setShortcut(tr("F2"));
} }
aLeaveGame->setText(tr("&Leave game")); if (aLeaveGame) {
aLeaveGame->setShortcut(tr("Ctrl+Q")); 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) if (sayLabel)
sayLabel->setText(tr("&Say:")); sayLabel->setText(tr("&Say:"));
...@@ -613,8 +623,9 @@ void TabGame::actLeaveGame() ...@@ -613,8 +623,9 @@ void TabGame::actLeaveGame()
if (!spectator) 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) 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; return;
sendGameCommand(Command_LeaveGame()); if (!replay)
sendGameCommand(Command_LeaveGame());
deleteLater(); deleteLater();
} }
......
...@@ -134,7 +134,7 @@ private: ...@@ -134,7 +134,7 @@ private:
ZoneViewLayout *zoneLayout; ZoneViewLayout *zoneLayout;
QAction *playersSeparator; QAction *playersSeparator;
QMenu *phasesMenu; QMenu *phasesMenu;
QAction *aConcede, *aLeaveGame, *aNextPhase, *aNextTurn, *aRemoveLocalArrows; QAction *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows;
QList<QAction *> phaseActions; QList<QAction *> phaseActions;
Player *addPlayer(int playerId, const ServerInfo_User &info); Player *addPlayer(int playerId, const ServerInfo_User &info);
......
...@@ -209,6 +209,11 @@ void TabSupervisor::stop() ...@@ -209,6 +209,11 @@ void TabSupervisor::stop()
gameIterator.next().value()->deleteLater(); gameIterator.next().value()->deleteLater();
gameTabs.clear(); gameTabs.clear();
QListIterator<TabGame *> replayIterator(replayTabs);
while (replayIterator.hasNext())
replayIterator.next()->deleteLater();
replayTabs.clear();
QMapIterator<QString, TabMessage *> messageIterator(messageTabs); QMapIterator<QString, TabMessage *> messageIterator(messageTabs);
while (messageIterator.hasNext()) while (messageIterator.hasNext())
messageIterator.next().value()->deleteLater(); messageIterator.next().value()->deleteLater();
...@@ -272,7 +277,8 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event) ...@@ -272,7 +277,8 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
void TabSupervisor::gameLeft(TabGame *tab) void TabSupervisor::gameLeft(TabGame *tab)
{ {
emit setMenu(0); if (tab == currentWidget())
emit setMenu(0);
gameTabs.remove(tab->getGameId()); gameTabs.remove(tab->getGameId());
removeTab(indexOf(tab)); removeTab(indexOf(tab));
...@@ -295,12 +301,31 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent) ...@@ -295,12 +301,31 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
void TabSupervisor::roomLeft(TabRoom *tab) void TabSupervisor::roomLeft(TabRoom *tab)
{ {
emit setMenu(0); if (tab == currentWidget())
emit setMenu(0);
roomTabs.remove(tab->getRoomId()); roomTabs.remove(tab->getRoomId());
removeTab(indexOf(tab)); 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) TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
{ {
if (receiverName == QString::fromStdString(userInfo->name())) if (receiverName == QString::fromStdString(userInfo->name()))
...@@ -316,15 +341,10 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus ...@@ -316,15 +341,10 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
return tab; return tab;
} }
void TabSupervisor::openReplay(GameReplay *replay)
{
TabGame *replayTab = new TabGame(replay);
myAddTab(replayTab);
}
void TabSupervisor::talkLeft(TabMessage *tab) void TabSupervisor::talkLeft(TabMessage *tab)
{ {
emit setMenu(0); if (tab == currentWidget())
emit setMenu(0);
messageTabs.remove(tab->getUserName()); messageTabs.remove(tab->getUserName());
removeTab(indexOf(tab)); removeTab(indexOf(tab));
......
...@@ -50,6 +50,7 @@ private: ...@@ -50,6 +50,7 @@ private:
TabAdmin *tabAdmin; TabAdmin *tabAdmin;
QMap<int, TabRoom *> roomTabs; QMap<int, TabRoom *> roomTabs;
QMap<int, TabGame *> gameTabs; QMap<int, TabGame *> gameTabs;
QList<TabGame *> replayTabs;
QMap<QString, TabMessage *> messageTabs; QMap<QString, TabMessage *> messageTabs;
int myAddTab(Tab *tab); int myAddTab(Tab *tab);
void addCloseButtonToTab(Tab *tab, int tabIndex); void addCloseButtonToTab(Tab *tab, int tabIndex);
...@@ -81,6 +82,7 @@ private slots: ...@@ -81,6 +82,7 @@ private slots:
void roomLeft(TabRoom *tab); void roomLeft(TabRoom *tab);
TabMessage *addMessageTab(const QString &userName, bool focus); TabMessage *addMessageTab(const QString &userName, bool focus);
void openReplay(GameReplay *replay); void openReplay(GameReplay *replay);
void replayLeft(TabGame *tab);
void processUserLeft(const QString &userName); void processUserLeft(const QString &userName);
void processUserJoined(const QString &userName); void processUserJoined(const QString &userName);
void talkLeft(TabMessage *tab); void talkLeft(TabMessage *tab);
......
...@@ -38,6 +38,8 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event) ...@@ -38,6 +38,8 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
WndDeckEditor::WndDeckEditor(QWidget *parent) WndDeckEditor::WndDeckEditor(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
{ {
setAttribute(Qt::WA_DeleteOnClose);
aSearch = new QAction(tr("&Search..."), this); aSearch = new QAction(tr("&Search..."), this);
aSearch->setIcon(QIcon(":/resources/icon_search.svg")); aSearch->setIcon(QIcon(":/resources/icon_search.svg"));
connect(aSearch, SIGNAL(triggered()), this, SLOT(actSearch())); connect(aSearch, SIGNAL(triggered()), this, SLOT(actSearch()));
......
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