summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-16 00:45:25 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-16 00:45:25 +0300
commit8a068ecd9dd6d41ba49f258107b09b98a8ea1a6d (patch)
treef966d817a42a069fef3958f241ae256c255e6ef1
parentd074efe8597cbc21375c59d7e6ee17296b4c4899 (diff)
downloadplus-8a068ecd9dd6d41ba49f258107b09b98a8ea1a6d.tar.gz
plus-8a068ecd9dd6d41ba49f258107b09b98a8ea1a6d.tar.bz2
plus-8a068ecd9dd6d41ba49f258107b09b98a8ea1a6d.tar.xz
plus-8a068ecd9dd6d41ba49f258107b09b98a8ea1a6d.zip
Add hotkey to close selected chat tab.
-rw-r--r--src/game.cpp5
-rw-r--r--src/gui/chatwindow.cpp16
-rw-r--r--src/gui/chatwindow.h5
-rw-r--r--src/keyboardconfig.cpp3
-rw-r--r--src/keyboardconfig.h1
5 files changed, 30 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 259317545..623d2a069 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -716,6 +716,11 @@ void Game::handleInput()
socialWindow->nextTab();
return;
}
+ else if (keyboard.isKeyActive(keyboard.KEY_CLOSE_CHAT_TAB))
+ {
+ chatWindow->closeTab();
+ return;
+ }
}
const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 29ce3bace..c266374ef 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -396,6 +396,22 @@ void ChatWindow::nextTab()
mChatTabs->setSelectedTab(tab);
}
+void ChatWindow::closeTab()
+{
+ if (!mChatTabs)
+ return;
+
+ int idx = mChatTabs->getSelectedTabIndex();
+ Tab *tab = mChatTabs->getTabByIndex(idx);
+ if (!tab)
+ return;
+ WhisperTab *whisper = dynamic_cast<WhisperTab*>(tab);
+ if (!whisper)
+ return;
+
+ whisper->handleCommand("close", "");
+}
+
void ChatWindow::defaultTab()
{
if (mChatTabs)
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index 05e039c60..b6a37ef79 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -130,6 +130,11 @@ class ChatWindow : public Window,
void nextTab();
/**
+ * Close current chat tab
+ */
+ void closeTab();
+
+ /**
* Switch to the default tab
*/
void defaultTab();
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index ff504ca2d..8ad38ab76 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -274,6 +274,9 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
KeyboardConfig::GRP_DEFAULT | KeyboardConfig::GRP_GUI},
{"keyChatNextTab", SDLK_KP9, N_("Next Chat Tab"),
KeyboardConfig::GRP_DEFAULT | KeyboardConfig::GRP_GUI},
+ {"keyChatCloseTab", KeyboardConfig::KEY_NO_VALUE,
+ N_("Close current Chat Tab"), KeyboardConfig::GRP_DEFAULT
+ | KeyboardConfig::GRP_GUI},
{"keyChatPrevHistory", SDLK_KP7, N_("Previous chat line"),
KeyboardConfig::GRP_CHAT},
{"keyChatNextHistory", SDLK_KP9, N_("Next chat line"),
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index 1d264b039..43bb1c17f 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -276,6 +276,7 @@ class KeyboardConfig
KEY_SCROLL_CHAT_DOWN,
KEY_PREV_CHAT_TAB,
KEY_NEXT_CHAT_TAB,
+ KEY_CLOSE_CHAT_TAB,
KEY_CHAT_PREV_HISTORY,
KEY_CHAT_NEXT_HISTORY,
KEY_AUTOCOMPLETE_CHAT,