diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp index bed476b7f..774f387ba 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp @@ -38,8 +38,9 @@ ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) : _bCheckForNickName = Settings->valueFromGroup(_group, "CheckForNickName", true).toBool(); _bCountUnRead = Settings->valueFromGroup(_group, "CountUnRead", true).toBool(); - _bCountSpecificText = Settings->valueFromGroup(_group, "CountSpecificText").toBool(); - _textToNotify = Settings->valueFromGroup(_group, "TextToNotify").toStringList(); + _bCountSpecificText = Settings->valueFromGroup(_group, "CountSpecificText", false).toBool(); + _textToNotify = Settings->valueFromGroup(_group, "TextToNotify").toStringList(); + _bTextCaseSensitive = Settings->valueFromGroup(_group, "TextCaseSensitive", false).toBool(); } bool ChatLobbyUserNotify::hasSetting(QString *name, QString *group) @@ -88,6 +89,14 @@ void ChatLobbyUserNotify::setTextToNotify(QString value) setTextToNotify(list); } +void ChatLobbyUserNotify::setTextCaseSensitive(bool value) +{ + if (_bTextCaseSensitive != value) { + _bTextCaseSensitive = value; + Settings->setValueToGroup(_group, "TextCaseSensitive", value); + } +} + QIcon ChatLobbyUserNotify::getIcon() { return QIcon(":/images/chat_32.png"); @@ -249,12 +258,12 @@ void ChatLobbyUserNotify::chatLobbyNewMessage(ChatLobbyId lobby_id, QDateTime ti bGetNickName = checkWord(msg, QString::fromUtf8(details.mNickname.c_str())); } - bool bFoundTextToNotify = false; + bool bFoundTextToNotify = false; - if(_bCountSpecificText) - for (QStringList::Iterator it = _textToNotify.begin(); it != _textToNotify.end(); ++it) { - bFoundTextToNotify |= checkWord(msg, (*it)); - } + if(_bCountSpecificText) + for (QStringList::Iterator it = _textToNotify.begin(); it != _textToNotify.end(); ++it) { + bFoundTextToNotify |= checkWord(msg, (*it)); + } if ((bGetNickName || bFoundTextToNotify || _bCountUnRead)){ QString strAnchor = time.toString(Qt::ISODate); @@ -272,7 +281,7 @@ bool ChatLobbyUserNotify::checkWord(QString message, QString word) { bool bFound = false; int nFound = -1; - if (((nFound=message.indexOf(word)) != -1) + if (((nFound=message.indexOf(word,0,_bTextCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive)) != -1) && (!word.isEmpty())) { QString eow=" ~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="; // end of word bool bFirstCharEOW = (nFound==0)?true:(eow.indexOf(message.at(nFound-1)) != -1); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h index 04941b006..d55310f9d 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h @@ -55,11 +55,13 @@ public: bool isCheckForNickName() { return _bCheckForNickName;} void setCountUnRead(bool value); bool isCountUnRead() { return _bCountUnRead;} - void setCountSpecificText(bool value); - bool isCountSpecificText() { return _bCountSpecificText;} - void setTextToNotify(QStringList); + void setCountSpecificText(bool value); + bool isCountSpecificText() { return _bCountSpecificText;} + void setTextToNotify(QStringList); void setTextToNotify(QString); QString textToNotify() { return _textToNotify.join("\n");} + void setTextCaseSensitive(bool value); + bool isTextCaseSensitive() {return _bTextCaseSensitive;} signals: void countChanged(ChatLobbyId id, unsigned int count); @@ -84,10 +86,12 @@ private: typedef std::map msg_map; typedef std::map lobby_map; lobby_map _listMsg; - QStringList _textToNotify; - bool _bCheckForNickName; + bool _bCountUnRead; - bool _bCountSpecificText; + bool _bCheckForNickName; + bool _bCountSpecificText; + QStringList _textToNotify; + bool _bTextCaseSensitive; }; #endif // CHATLOBBYUSERNOTIFY_H diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 8c03befe6..1c31af679 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -44,7 +44,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.testToasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); connect(NotifyQt::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool))); - connect(ui.chatLobbies_CountFollowingText,SIGNAL(toggled(bool)),ui.chatLobbies_TextToNotify,SLOT(setEnabled(bool))) ; + connect(ui.chatLobbies_CountFollowingText,SIGNAL(toggled(bool)),ui.chatLobbies_TextToNotify,SLOT(setEnabled(bool))); ui.notify_Blogs->hide(); @@ -257,6 +257,7 @@ NotifyPage::save(QString &/*errmsg*/) mChatLobbyUserNotify->setCheckForNickName(ui.chatLobbies_CheckNickName->isChecked()) ; mChatLobbyUserNotify->setCountSpecificText(ui.chatLobbies_CountFollowingText->isChecked()) ; mChatLobbyUserNotify->setTextToNotify(ui.chatLobbies_TextToNotify->document()->toPlainText()); + mChatLobbyUserNotify->setTextCaseSensitive(ui.chatLobbies_TextCaseSensitive->isChecked()); } load(); return true; @@ -348,11 +349,12 @@ void NotifyPage::load() notifyToggled(); if (mChatLobbyUserNotify){ - ui.chatLobbies_TextToNotify->setEnabled(mChatLobbyUserNotify->isCountSpecificText()) ; - ui.chatLobbies_CountFollowingText->setChecked(mChatLobbyUserNotify->isCountSpecificText()) ; ui.chatLobbies_CountUnRead->setChecked(mChatLobbyUserNotify->isCountUnRead()); ui.chatLobbies_CheckNickName->setChecked(mChatLobbyUserNotify->isCheckForNickName()); + ui.chatLobbies_CountFollowingText->setChecked(mChatLobbyUserNotify->isCountSpecificText()) ; + ui.chatLobbies_TextToNotify->setEnabled(mChatLobbyUserNotify->isCountSpecificText()) ; ui.chatLobbies_TextToNotify->setPlainText(mChatLobbyUserNotify->textToNotify()); + ui.chatLobbies_TextCaseSensitive->setChecked(mChatLobbyUserNotify->isTextCaseSensitive()); } } diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui index 56f38c647..b3f4063a1 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.ui +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -10,7 +10,7 @@ 512 - + @@ -20,21 +20,30 @@ Feed - + - + News Feed - + 0 - + + 6 + + + 6 + + + 6 + + 6 - + @@ -104,7 +113,7 @@ - + @@ -113,7 +122,7 @@ - + Qt::Vertical @@ -135,7 +144,7 @@ Message - + @@ -147,7 +156,7 @@ - + Qt::Vertical @@ -165,7 +174,7 @@ Toasters - + @@ -180,11 +189,11 @@ - + Toasters - + 9 @@ -192,9 +201,9 @@ 9 - + - + @@ -250,7 +259,7 @@ - + @@ -259,7 +268,7 @@ - + Qt::Vertical @@ -276,7 +285,7 @@ - + @@ -355,7 +364,7 @@ - + Qt::Vertical @@ -376,7 +385,7 @@ Systray - + @@ -390,7 +399,7 @@ - + Systray message @@ -413,7 +422,7 @@ - + Qt::Vertical @@ -431,7 +440,7 @@ Chat Lobbies - + @@ -457,7 +466,17 @@ - + + + Checked, if the identity and the text above occurences must be in the same case to trigger count. + + + Case sensitive + + + + + Qt::Vertical