summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-29 00:45:50 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-29 00:47:23 +0300
commitd7a8fb0f709677b76cbd63e9a48a466a4940b6fb (patch)
tree7a4cd71809b8992f9e2d11d8aa212a7acc181480 /src
parent47cebf2c33561324ab800ec6ab8e5267b6550b1f (diff)
downloadplus-d7a8fb0f709677b76cbd63e9a48a466a4940b6fb.tar.gz
plus-d7a8fb0f709677b76cbd63e9a48a466a4940b6fb.tar.bz2
plus-d7a8fb0f709677b76cbd63e9a48a466a4940b6fb.tar.xz
plus-d7a8fb0f709677b76cbd63e9a48a466a4940b6fb.zip
Highlight window header with * if got new chat message with minimized window.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp41
-rw-r--r--src/client.h7
-rw-r--r--src/gui/widgets/chattab.cpp1
3 files changed, 42 insertions, 7 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 7df9febd6..3b4bc3203 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -276,7 +276,8 @@ Client::Client(const Options &options) :
mIsMinimized(false),
mInputFocused(true),
mMouseFocused(true),
- mGuiAlpha(1.0f)
+ mGuiAlpha(1.0f),
+ mNewMessageFlag(false)
{
mInstance = this;
}
@@ -395,18 +396,20 @@ void Client::gameInit()
if (mOptions.test.empty())
{
- SDL_WM_SetCaption(strprintf("%s %s",
+ mCaption = strprintf("%s %s",
branding.getStringValue("appName").c_str(),
- SMALL_VERSION).c_str(), nullptr);
+ SMALL_VERSION);
}
else
{
- SDL_WM_SetCaption(strprintf(
+ mCaption = strprintf(
"Please wait - VIDEO MODE TEST - %s %s - Please wait",
branding.getStringValue("appName").c_str(),
- SMALL_VERSION).c_str(), nullptr);
+ SMALL_VERSION);
}
+ SDL_WM_SetCaption(mCaption.c_str(), nullptr);
+
const ResourceManager *const resman = ResourceManager::getInstance();
if (!resman->setWriteDir(mLocalDataDir))
@@ -2566,3 +2569,31 @@ void Client::applyKeyRepeat()
SDL_EnableKeyRepeat(config.getIntValue("repeateDelay"),
config.getIntValue("repeateInterval"));
}
+
+void Client::setIsMinimized(const bool n)
+{
+ Client *client = instance();
+ if (!client)
+ return;
+
+ client->mIsMinimized = n;
+ if (!n && client->mNewMessageFlag)
+ {
+ client->mNewMessageFlag = false;
+ SDL_WM_SetCaption(client->mCaption.c_str(), nullptr);
+ }
+}
+
+void Client::newChatMessage()
+{
+ Client *client = instance();
+ if (!client)
+ return;
+
+ if (!client->mNewMessageFlag && client->mIsMinimized)
+ {
+ // show * on window caption
+ SDL_WM_SetCaption(("*" + client->mCaption).c_str(), nullptr);
+ client->mNewMessageFlag = true;
+ }
+}
diff --git a/src/client.h b/src/client.h
index 393e4cb73..78e8eaf58 100644
--- a/src/client.h
+++ b/src/client.h
@@ -248,8 +248,9 @@ public:
static bool getIsMinimized()
{ return instance()->mIsMinimized; }
- static void setIsMinimized(const bool n)
- { instance()->mIsMinimized = n; }
+ static void setIsMinimized(const bool n);
+
+ static void newChatMessage();
static bool getInputFocused()
{ return instance()->mInputFocused; }
@@ -386,6 +387,8 @@ private:
bool mInputFocused;
bool mMouseFocused;
float mGuiAlpha;
+ std::string mCaption;
+ bool mNewMessageFlag;
FPSmanager mFpsManager;
};
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 8d983921e..e35105692 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -319,6 +319,7 @@ void ChatTab::chatLog(std::string line, Own own,
chatWindow->unHideWindow();
playNewMessageSound();
}
+ Client::newChatMessage();
}
}
}