From 1f33e34d8f6c1ffd2af42047bdef8361557b528b Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 19 Mar 2015 16:43:27 +0100 Subject: [PATCH] Add tooltips to tabs --- cockatrice/src/tab_supervisor.cpp | 25 +- cockatrice/src/tab_supervisor.h | 1 + cockatrice/translations/cockatrice_en.ts | 297 ++++++++++++----------- 3 files changed, 178 insertions(+), 145 deletions(-) diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index d9f3a517..6e44eae4 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -126,7 +126,10 @@ void TabSupervisor::retranslateUi() for (int i = 0; i < tabs.size(); ++i) if (tabs[i]) { - setTabText(indexOf(tabs[i]), sanitizeTabName(tabs[i]->getTabText())); + int idx = indexOf(tabs[i]); + QString tabText = tabs[i]->getTabText(); + setTabText(idx, sanitizeTabName(tabText)); + setTabToolTip(idx, sanitizeHtml(tabText)); tabs[i]->retranslateUi(); } } @@ -158,11 +161,25 @@ QString TabSupervisor::sanitizeTabName(QString dirty) const return dirty.replace("&", "&&"); } +QString TabSupervisor::sanitizeHtml(QString dirty) const +{ + return dirty + .replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace("\"", """); +} + int TabSupervisor::myAddTab(Tab *tab) { connect(tab, SIGNAL(userEvent(bool)), this, SLOT(tabUserEvent(bool))); connect(tab, SIGNAL(tabTextChanged(Tab *, QString)), this, SLOT(updateTabText(Tab *, QString))); - return addTab(tab, sanitizeTabName(tab->getTabText())); + + QString tabText = tab->getTabText(); + int idx = addTab(tab, sanitizeTabName(tabText)); + setTabToolTip(idx, sanitizeHtml(tabText)); + + return idx; } void TabSupervisor::start(const ServerInfo_User &_userInfo) @@ -457,7 +474,9 @@ void TabSupervisor::tabUserEvent(bool globalEvent) void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText) { - setTabText(indexOf(tab), newTabText); + int idx = indexOf(tab); + setTabText(idx, sanitizeTabName(newTabText)); + setTabToolTip(idx, sanitizeHtml(newTabText)); } void TabSupervisor::processRoomEvent(const RoomEvent &event) diff --git a/cockatrice/src/tab_supervisor.h b/cockatrice/src/tab_supervisor.h index 595572ad..d5706bf7 100644 --- a/cockatrice/src/tab_supervisor.h +++ b/cockatrice/src/tab_supervisor.h @@ -59,6 +59,7 @@ private: int myAddTab(Tab *tab); void addCloseButtonToTab(Tab *tab, int tabIndex); QString sanitizeTabName(QString dirty) const; + QString sanitizeHtml(QString dirty) const; public: TabSupervisor(AbstractClient *_client, QWidget *parent = 0); ~TabSupervisor(); diff --git a/cockatrice/translations/cockatrice_en.ts b/cockatrice/translations/cockatrice_en.ts index e506fba1..e655f96a 100644 --- a/cockatrice/translations/cockatrice_en.ts +++ b/cockatrice/translations/cockatrice_en.ts @@ -37,76 +37,81 @@ AppearanceSettingsPage - + Zone background pictures - + Hand background: - + Stack background: - + Table background: - + Player info background: - + Card back: - + Card rendering - + Display card names on cards having a picture - - - Hand layout - - - - - Display hand horizontally (wastes space) - - - Table grid layout - - - - - Invert vertical coordinate + Scale cards on mouse over + Hand layout + + + + + Display hand horizontally (wastes space) + + + + + Table grid layout + + + + + Invert vertical coordinate + + + + Minimum player count for multi-column layout: - - - - - + + + + + Choose path @@ -574,12 +579,12 @@ This is only saved for moderators and cannot be seen by the banned person. DeckEditorSettingsPage - + Enable &price tag feature from deckbrew.com - + General @@ -1087,19 +1092,19 @@ This is only saved for moderators and cannot be seen by the banned person. DlgSettings - - - + + + Error - + Unknown Error loading card database - + Your card database is invalid. Cockatrice may not function correctly with an invalid database @@ -1110,7 +1115,7 @@ Would you like to change your database location setting? - + Your card database version is too old. This can cause problems loading card information or images @@ -1121,7 +1126,7 @@ Would you like to change your database location setting? - + Your card database did not finish loading Please file a ticket at http://github.com/Daenyth/Cockatrice/issues with your cards.xml attached @@ -1130,21 +1135,21 @@ Would you like to change your database location setting? - + File Error loading your card database. Would you like to change your database location setting? - + Your card database was loaded but contains no cards. Would you like to change your database location setting? - + Unknown card database load status Please file a ticket at http://github.com/Daenyth/Cockatrice/issues @@ -1153,42 +1158,42 @@ Would you like to change your database location setting? - + The path to your deck directory is invalid. Would you like to go back and set the correct path? - + The path to your card pictures directory is invalid. Would you like to go back and set the correct path? - + Settings - + General - + Appearance - + User interface - + Deck editor - + Chat Settings @@ -1196,100 +1201,100 @@ Would you like to change your database location setting? GameSelector - + C&reate - + &Join - - - - - - - - - + + + + + + + + + Error - + Please join the appropriate room first. - + Wrong password. - + Spectators are not allowed in this game. - + The game is already full. - + The game does not exist any more. - + This game is only open to registered users. - + This game is only open to its creator's buddies. - + You are being ignored by the creator of this game. - + Join game - + Password: - + Please join the respective room first. - + Games - + &Filter games - + C&lear filter - + J&oin as spectator @@ -1776,16 +1781,6 @@ Local version is %1, remote version is %2. &Help - - - Are you sure? - - - - - There are still open games. Are you sure you want to quit? - - MessageLogWidget @@ -2995,62 +2990,62 @@ Local version is %1, remote version is %2. MessagesSettingsPage - + &Add - + &Remove - + Chat settings - + Enable chat mentions - + In-game message macros - + Ignore unregistered users in main chat - + Ignore chat room messages sent by unregistered users. - + Ignore private messages sent by unregistered users. - + Invert text color - + (Color is hexadecimal) - + Add message - + Message: @@ -3609,7 +3604,7 @@ Local version is %1, remote version is %2. - + Number: @@ -3634,27 +3629,27 @@ Local version is %1, remote version is %2. - + Set power/toughness - + Please enter the new PT: - + Set annotation - + Please enter the new annotation: - + Set counters @@ -4074,42 +4069,42 @@ Local version is %1, remote version is %2. - + Are you sure? - + The decklist has been modified. Do you want to save the changes? - + Load deck - - - + + + Error - + The deck could not be saved. - - + + The deck could not be saved. Please check that the directory is writable and try again. - + Save deck @@ -4342,17 +4337,17 @@ Please enter a name: - + You have been kicked out of the game. - + Replay %1: %2 - + Game %1: %2 @@ -4361,7 +4356,7 @@ Please enter a name: TabMessage - Personal &talk + Private &chat @@ -4369,6 +4364,11 @@ Please enter a name: &Leave + + + %1 - Private chat + + This user is ignoring you. @@ -4384,11 +4384,6 @@ Please enter a name: %1 has joined the server. - - - Talking to %1 - - TabReplays @@ -4453,37 +4448,42 @@ Please enter a name: TabRoom - - &Say: + + F12 - Chat + &Say: - &Room + Chat - &Leave room + &Room - &Clear chat + &Leave room + &Clear chat + + + + Chat Settings... - + You are flooding the chat. Please wait a couple of seconds. @@ -4496,6 +4496,19 @@ Please enter a name: + + TabSupervisor + + + Are you sure? + + + + + There are still open games. Are you sure you want to quit? + + + TabUserLists @@ -4523,7 +4536,7 @@ Please enter a name: - Direct &chat + Private &chat @@ -4649,62 +4662,62 @@ Please enter a name: UserInterfaceSettingsPage - + General interface settings - + Enable notifications in taskbar - + Notify in the taskbar for game events while you are spectating - + &Double-click cards to play them (instead of single-click) - + &Play all nonlands onto the stack (not the battlefield) by default - + Animation settings - + &Tap/untap animation - + Enable &sounds - + Path to sounds directory: - + Test system sound engine - + Sound settings - + Choose path