summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commandhandler.cpp1
-rw-r--r--src/gui/chat.cpp10
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/widgets/chattab.cpp7
-rw-r--r--src/gui/widgets/chattab.h2
-rw-r--r--src/gui/widgets/whispertab.cpp9
-rw-r--r--src/gui/widgets/whispertab.h2
7 files changed, 31 insertions, 2 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index b315b628..7ccd7d80 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -163,6 +163,7 @@ void CommandHandler::handleHelp(const std::string &args)
localChatTab->chatLog(_("/msg > Send a private message to a user"));
localChatTab->chatLog(_("/whisper > Alias of msg"));
localChatTab->chatLog(_("/w > Alias of msg"));
+ localChatTab->chatLog(_("/close > Close the whisper tab (only works in whisper tabs)"));
#ifdef TMWSERV_SUPPORT
localChatTab->chatLog(_("/list > Display all public channels"));
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 7861bdb6..b0b15dbc 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -232,7 +232,10 @@ bool ChatWindow::isInputFocused()
void ChatWindow::removeTab(ChatTab *tab)
{
// Prevent removal of the local chat tab
- if (tab != localChatTab) mChatTabs->removeTab(tab);
+ if (tab == localChatTab)
+ return;
+
+ mChatTabs->removeTab(tab);
}
void ChatWindow::addTab(ChatTab *tab)
@@ -250,6 +253,11 @@ void ChatWindow::addTab(ChatTab *tab)
logic();
}
+void ChatWindow::removeWhisper(std::string nick)
+{
+ mWhispers.erase(nick);
+}
+
void ChatWindow::chatSend(std::string &msg)
{
ChatTab *tab = getFocused();
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 7c080960..177aa38f 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -194,6 +194,8 @@ class ChatWindow : public Window,
/** Add the tab to the window */
void addTab(ChatTab *tab);
+ void removeWhisper(std::string nick);
+
void adjustTabSize();
#ifdef EATHENA_SUPPORT
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 120d4e21..46116a37 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -290,7 +290,7 @@ void ChatTab::chatSend(std::string &msg)
}
else
{
- commandHandler->handleCommand(std::string(msg, 1));
+ handleCommand(std::string(msg, 1));
}
}
@@ -322,3 +322,8 @@ void ChatTab::sendChat(std::string &msg) {
return;
#endif
}
+
+void ChatTab::handleCommand(std::string msg)
+{
+ commandHandler->handleCommand(msg);
+}
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index a478abeb..14c4c130 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -108,6 +108,8 @@ class ChatTab : public Tab
virtual void sendChat(std::string &msg);
+ virtual void handleCommand(std::string msg);
+
ScrollArea *mScrollArea;
BrowserBox *mTextOutput;
//Recorder *mRecorder;
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index ba469c00..8af8d427 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -55,6 +55,7 @@ WhisperTab::WhisperTab(const std::string &nick) :
WhisperTab::~WhisperTab()
{
+ chatWindow->removeWhisper(mNick);
}
void WhisperTab::sendChat(std::string &msg) {
@@ -76,3 +77,11 @@ void WhisperTab::sendChat(std::string &msg) {
chatLog(strprintf(_("%s: %s"), player_node->getName().c_str(),
msg.c_str()), BY_PLAYER, false);
}
+
+void WhisperTab::handleCommand(std::string msg)
+{
+ if (msg == "close")
+ delete this;
+ else
+ ChatTab::handleCommand(msg);
+}
diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h
index e3ebf0f3..6f9db1ee 100644
--- a/src/gui/widgets/whispertab.h
+++ b/src/gui/widgets/whispertab.h
@@ -48,6 +48,8 @@ class WhisperTab : public ChatTab
void sendChat(std::string &msg);
+ void handleCommand(std::string msg);
+
private:
std::string mNick;
};