mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-03 03:53:56 -07:00
translation fix; minor improvement
This commit is contained in:
parent
5efb92e2d6
commit
3d5ba34aaf
17 changed files with 107 additions and 52 deletions
|
|
@ -7,12 +7,16 @@ class QMenu;
|
|||
|
||||
class Tab : public QWidget {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void userEvent();
|
||||
protected:
|
||||
QMenu *tabMenu;
|
||||
public:
|
||||
Tab(QWidget *parent = 0)
|
||||
: QWidget(parent), tabMenu(0) { }
|
||||
QMenu *getTabMenu() const { return tabMenu; }
|
||||
virtual QString getTabText() const = 0;
|
||||
virtual void retranslateUi() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ void TabChatChannel::processJoinChannelEvent(Event_ChatJoinChannel *event)
|
|||
{
|
||||
textEdit->append(tr("%1 has joined the channel.").arg(event->getPlayerName()));
|
||||
playerList->addItem(event->getPlayerName());
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabChatChannel::processLeaveChannelEvent(Event_ChatLeaveChannel *event)
|
||||
|
|
@ -90,6 +91,7 @@ void TabChatChannel::processLeaveChannelEvent(Event_ChatLeaveChannel *event)
|
|||
delete playerList->takeItem(i);
|
||||
break;
|
||||
}
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabChatChannel::processSayEvent(Event_ChatSay *event)
|
||||
|
|
@ -98,5 +100,5 @@ void TabChatChannel::processSayEvent(Event_ChatSay *event)
|
|||
textEdit->append(QString("<font color=\"blue\">%1</font").arg(event->getMessage()));
|
||||
else
|
||||
textEdit->append(QString("<font color=\"red\">%1:</font> %2").arg(event->getPlayerName()).arg(event->getMessage()));
|
||||
QApplication::alert(this);
|
||||
emit userEvent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public:
|
|||
void retranslateUi();
|
||||
void processChatEvent(ChatEvent *event);
|
||||
QString getChannelName() const { return channelName; }
|
||||
QString getTabText() const { return channelName; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ private slots:
|
|||
public:
|
||||
TabDeckStorage(Client *_client);
|
||||
void retranslateUi();
|
||||
QString getTabText() const { return tr("Deck storage"); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
#include "arrowitem.h"
|
||||
#include "main.h"
|
||||
|
||||
TabGame::TabGame(Client *_client, int _gameId, int _localPlayerId, bool _spectator, bool _resuming)
|
||||
: Tab(), client(_client), gameId(_gameId), localPlayerId(_localPlayerId), spectator(_spectator), started(false), resuming(_resuming), currentPhase(-1)
|
||||
TabGame::TabGame(Client *_client, int _gameId, const QString &_gameDescription, int _localPlayerId, bool _spectator, bool _resuming)
|
||||
: Tab(), client(_client), gameId(_gameId), gameDescription(_gameDescription), localPlayerId(_localPlayerId), spectator(_spectator), started(false), resuming(_resuming), currentPhase(-1)
|
||||
{
|
||||
zoneLayout = new ZoneViewLayout;
|
||||
scene = new GameScene(zoneLayout, this);
|
||||
|
|
@ -244,6 +244,7 @@ void TabGame::processGameEvent(GameEvent *event)
|
|||
break;
|
||||
}
|
||||
player->processGameEvent(event);
|
||||
emit userEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -307,6 +308,7 @@ void TabGame::eventGameStateChanged(Event_GameStateChanged *event)
|
|||
stopGame();
|
||||
zoneLayout->clear();
|
||||
}
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventJoin(Event_Join *event)
|
||||
|
|
@ -321,6 +323,7 @@ void TabGame::eventJoin(Event_Join *event)
|
|||
messageLog->logJoin(newPlayer);
|
||||
playerListWidget->addPlayer(playerInfo);
|
||||
}
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventLeave(Event_Leave *event)
|
||||
|
|
@ -338,12 +341,14 @@ void TabGame::eventLeave(Event_Leave *event)
|
|||
playerListWidget->removePlayer(playerId);
|
||||
spectators.remove(playerId);
|
||||
}
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventGameClosed(Event_GameClosed * /*event*/)
|
||||
{
|
||||
started = false;
|
||||
messageLog->logGameClosed();
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
Player *TabGame::setActivePlayer(int id)
|
||||
|
|
@ -358,6 +363,7 @@ Player *TabGame::setActivePlayer(int id)
|
|||
i.value()->setActive(i.value() == player);
|
||||
}
|
||||
currentPhase = -1;
|
||||
emit userEvent();
|
||||
return player;
|
||||
}
|
||||
|
||||
|
|
@ -367,6 +373,7 @@ void TabGame::eventSetActivePlayer(Event_SetActivePlayer *event)
|
|||
if (!player)
|
||||
return;
|
||||
messageLog->logSetActivePlayer(player);
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabGame::setActivePhase(int phase)
|
||||
|
|
@ -383,6 +390,7 @@ void TabGame::eventSetActivePhase(Event_SetActivePhase *event)
|
|||
if (currentPhase != phase)
|
||||
messageLog->logSetActivePhase(phase);
|
||||
setActivePhase(phase);
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
void TabGame::eventPing(Event_Ping *event)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class TabGame : public Tab {
|
|||
private:
|
||||
Client *client;
|
||||
int gameId;
|
||||
QString gameDescription;
|
||||
int localPlayerId;
|
||||
bool spectator;
|
||||
QMap<int, Player *> players;
|
||||
|
|
@ -95,11 +96,12 @@ private slots:
|
|||
void actNextPhase();
|
||||
void actNextTurn();
|
||||
public:
|
||||
TabGame(Client *_client, int _gameId, int _localPlayerId, bool _spectator, bool _resuming);
|
||||
TabGame(Client *_client, int _gameId, const QString &_gameDescription, int _localPlayerId, bool _spectator, bool _resuming);
|
||||
~TabGame();
|
||||
void retranslateUi();
|
||||
const QMap<int, Player *> &getPlayers() const { return players; }
|
||||
int getGameId() const { return gameId; }
|
||||
QString getTabText() const { return tr("Game %1: %2").arg(gameId).arg(gameDescription); }
|
||||
|
||||
void processGameEvent(GameEvent *event);
|
||||
public slots:
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ private:
|
|||
public:
|
||||
TabServer(Client *_client, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
QString getTabText() const { return tr("Server"); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <QApplication>
|
||||
#include "tab_supervisor.h"
|
||||
#include "client.h"
|
||||
#include "tab_server.h"
|
||||
|
|
@ -16,22 +17,28 @@ TabSupervisor:: TabSupervisor(QWidget *parent)
|
|||
|
||||
void TabSupervisor::retranslateUi()
|
||||
{
|
||||
if (tabServer) {
|
||||
setTabText(0, tr("Server"));
|
||||
tabServer->retranslateUi();
|
||||
}
|
||||
if (tabDeckStorage) {
|
||||
setTabText(1, tr("Deck storage"));
|
||||
tabDeckStorage->retranslateUi();
|
||||
}
|
||||
|
||||
QList<Tab *> tabs;
|
||||
if (tabServer)
|
||||
tabs.append(tabServer);
|
||||
if (tabDeckStorage)
|
||||
tabs.append(tabDeckStorage);
|
||||
QMapIterator<QString, TabChatChannel *> chatChannelIterator(chatChannelTabs);
|
||||
while (chatChannelIterator.hasNext())
|
||||
chatChannelIterator.next().value()->retranslateUi();
|
||||
|
||||
tabs.append(chatChannelIterator.next().value());
|
||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
||||
while (gameIterator.hasNext())
|
||||
gameIterator.next().value()->retranslateUi();
|
||||
tabs.append(gameIterator.next().value());
|
||||
|
||||
for (int i = 0; i < tabs.size(); ++i) {
|
||||
setTabText(indexOf(tabs[i]), tabs[i]->getTabText());
|
||||
tabs[i]->retranslateUi();
|
||||
}
|
||||
}
|
||||
|
||||
void TabSupervisor::myAddTab(Tab *tab)
|
||||
{
|
||||
connect(tab, SIGNAL(userEvent()), this, SLOT(tabUserEvent()));
|
||||
addTab(tab, tab->getTabText());
|
||||
}
|
||||
|
||||
void TabSupervisor::start(Client *_client)
|
||||
|
|
@ -44,11 +51,11 @@ void TabSupervisor::start(Client *_client)
|
|||
|
||||
tabServer = new TabServer(client);
|
||||
connect(tabServer, SIGNAL(chatChannelJoined(const QString &)), this, SLOT(addChatChannelTab(const QString &)));
|
||||
addTab(tabServer, QString());
|
||||
myAddTab(tabServer);
|
||||
updatePingTime(0, -1);
|
||||
|
||||
tabDeckStorage = new TabDeckStorage(client);
|
||||
addTab(tabDeckStorage, QString());
|
||||
myAddTab(tabDeckStorage);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
|
@ -89,9 +96,9 @@ void TabSupervisor::updatePingTime(int value, int max)
|
|||
|
||||
void TabSupervisor::gameJoined(Event_GameJoined *event)
|
||||
{
|
||||
TabGame *tab = new TabGame(client, event->getGameId(), event->getPlayerId(), event->getSpectator(), event->getResuming());
|
||||
TabGame *tab = new TabGame(client, event->getGameId(), event->getGameDescription(), event->getPlayerId(), event->getSpectator(), event->getResuming());
|
||||
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
|
||||
addTab(tab, tr("Game %1").arg(event->getGameId()));
|
||||
myAddTab(tab);
|
||||
gameTabs.insert(event->getGameId(), tab);
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
|
|
@ -108,7 +115,7 @@ void TabSupervisor::addChatChannelTab(const QString &channelName)
|
|||
{
|
||||
TabChatChannel *tab = new TabChatChannel(client, channelName);
|
||||
connect(tab, SIGNAL(channelClosing(TabChatChannel *)), this, SLOT(chatChannelLeft(TabChatChannel *)));
|
||||
addTab(tab, channelName);
|
||||
myAddTab(tab);
|
||||
chatChannelTabs.insert(channelName, tab);
|
||||
setCurrentWidget(tab);
|
||||
}
|
||||
|
|
@ -121,6 +128,13 @@ void TabSupervisor::chatChannelLeft(TabChatChannel *tab)
|
|||
removeTab(indexOf(tab));
|
||||
}
|
||||
|
||||
void TabSupervisor::tabUserEvent()
|
||||
{
|
||||
Tab *tab = static_cast<Tab *>(sender());
|
||||
// XXX Mark tab as changed (exclamation mark icon?)
|
||||
QApplication::alert(this);
|
||||
}
|
||||
|
||||
void TabSupervisor::processChatEvent(ChatEvent *event)
|
||||
{
|
||||
TabChatChannel *tab = chatChannelTabs.value(event->getChannel(), 0);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
class QMenu;
|
||||
class Client;
|
||||
class Tab;
|
||||
class TabServer;
|
||||
class TabChatChannel;
|
||||
class TabGame;
|
||||
|
|
@ -22,6 +23,7 @@ private:
|
|||
TabDeckStorage *tabDeckStorage;
|
||||
QMap<QString, TabChatChannel *> chatChannelTabs;
|
||||
QMap<int, TabGame *> gameTabs;
|
||||
void myAddTab(Tab *tab);
|
||||
public:
|
||||
TabSupervisor(QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
|
|
@ -36,6 +38,7 @@ private slots:
|
|||
void gameLeft(TabGame *tab);
|
||||
void addChatChannelTab(const QString &channelName);
|
||||
void chatChannelLeft(TabChatChannel *tab);
|
||||
void tabUserEvent();
|
||||
void processChatEvent(ChatEvent *event);
|
||||
void processGameEvent(GameEvent *event);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ void MainWindow::retranslateUi()
|
|||
aExit->setText(tr("&Exit"));
|
||||
|
||||
cockatriceMenu->setTitle(tr("&Cockatrice"));
|
||||
|
||||
tabSupervisor->retranslateUi();
|
||||
}
|
||||
|
||||
void MainWindow::createActions()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue