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

This commit is contained in:
Max-Wilhelm Bruker 2012-03-04 12:05:28 +01:00
parent acb03c2bf2
commit b0378544c4
8 changed files with 162 additions and 18 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 316 KiB

View file

@ -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;

View file

@ -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:

View file

@ -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)
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
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()
aConcede->setText(tr("&Concede")); aConcede->setText(tr("&Concede"));
aConcede->setShortcut(tr("F2")); aConcede->setShortcut(tr("F2"));
} }
if (aLeaveGame) {
aLeaveGame->setText(tr("&Leave game")); aLeaveGame->setText(tr("&Leave game"));
aLeaveGame->setShortcut(tr("Ctrl+Q")); 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:"));
@ -614,6 +624,7 @@ void TabGame::actLeaveGame()
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;
if (!replay)
sendGameCommand(Command_LeaveGame()); sendGameCommand(Command_LeaveGame());
deleteLater(); deleteLater();
} }

View file

@ -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);

View file

@ -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,6 +277,7 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
void TabSupervisor::gameLeft(TabGame *tab) void TabSupervisor::gameLeft(TabGame *tab)
{ {
if (tab == currentWidget())
emit setMenu(0); emit setMenu(0);
gameTabs.remove(tab->getGameId()); gameTabs.remove(tab->getGameId());
@ -295,12 +301,31 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
void TabSupervisor::roomLeft(TabRoom *tab) void TabSupervisor::roomLeft(TabRoom *tab)
{ {
if (tab == currentWidget())
emit setMenu(0); 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,14 +341,9 @@ 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)
{ {
if (tab == currentWidget())
emit setMenu(0); emit setMenu(0);
messageTabs.remove(tab->getUserName()); messageTabs.remove(tab->getUserName());

View file

@ -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:
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);

View file

@ -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()));