Add Case Sensitive option for Lobby Notify.

This commit is contained in:
Phenom 2016-08-07 19:00:23 +02:00
parent dea776a61a
commit d0482707c5
4 changed files with 75 additions and 41 deletions

View File

@ -38,8 +38,9 @@ ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) :
_bCheckForNickName = Settings->valueFromGroup(_group, "CheckForNickName", true).toBool(); _bCheckForNickName = Settings->valueFromGroup(_group, "CheckForNickName", true).toBool();
_bCountUnRead = Settings->valueFromGroup(_group, "CountUnRead", true).toBool(); _bCountUnRead = Settings->valueFromGroup(_group, "CountUnRead", true).toBool();
_bCountSpecificText = Settings->valueFromGroup(_group, "CountSpecificText").toBool(); _bCountSpecificText = Settings->valueFromGroup(_group, "CountSpecificText", false).toBool();
_textToNotify = Settings->valueFromGroup(_group, "TextToNotify").toStringList(); _textToNotify = Settings->valueFromGroup(_group, "TextToNotify").toStringList();
_bTextCaseSensitive = Settings->valueFromGroup(_group, "TextCaseSensitive", false).toBool();
} }
bool ChatLobbyUserNotify::hasSetting(QString *name, QString *group) bool ChatLobbyUserNotify::hasSetting(QString *name, QString *group)
@ -88,6 +89,14 @@ void ChatLobbyUserNotify::setTextToNotify(QString value)
setTextToNotify(list); setTextToNotify(list);
} }
void ChatLobbyUserNotify::setTextCaseSensitive(bool value)
{
if (_bTextCaseSensitive != value) {
_bTextCaseSensitive = value;
Settings->setValueToGroup(_group, "TextCaseSensitive", value);
}
}
QIcon ChatLobbyUserNotify::getIcon() QIcon ChatLobbyUserNotify::getIcon()
{ {
return QIcon(":/images/chat_32.png"); 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())); bGetNickName = checkWord(msg, QString::fromUtf8(details.mNickname.c_str()));
} }
bool bFoundTextToNotify = false; bool bFoundTextToNotify = false;
if(_bCountSpecificText) if(_bCountSpecificText)
for (QStringList::Iterator it = _textToNotify.begin(); it != _textToNotify.end(); ++it) { for (QStringList::Iterator it = _textToNotify.begin(); it != _textToNotify.end(); ++it) {
bFoundTextToNotify |= checkWord(msg, (*it)); bFoundTextToNotify |= checkWord(msg, (*it));
} }
if ((bGetNickName || bFoundTextToNotify || _bCountUnRead)){ if ((bGetNickName || bFoundTextToNotify || _bCountUnRead)){
QString strAnchor = time.toString(Qt::ISODate); QString strAnchor = time.toString(Qt::ISODate);
@ -272,7 +281,7 @@ bool ChatLobbyUserNotify::checkWord(QString message, QString word)
{ {
bool bFound = false; bool bFound = false;
int nFound = -1; int nFound = -1;
if (((nFound=message.indexOf(word)) != -1) if (((nFound=message.indexOf(word,0,_bTextCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive)) != -1)
&& (!word.isEmpty())) { && (!word.isEmpty())) {
QString eow=" ~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="; // end of word QString eow=" ~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="; // end of word
bool bFirstCharEOW = (nFound==0)?true:(eow.indexOf(message.at(nFound-1)) != -1); bool bFirstCharEOW = (nFound==0)?true:(eow.indexOf(message.at(nFound-1)) != -1);

View File

@ -55,11 +55,13 @@ public:
bool isCheckForNickName() { return _bCheckForNickName;} bool isCheckForNickName() { return _bCheckForNickName;}
void setCountUnRead(bool value); void setCountUnRead(bool value);
bool isCountUnRead() { return _bCountUnRead;} bool isCountUnRead() { return _bCountUnRead;}
void setCountSpecificText(bool value); void setCountSpecificText(bool value);
bool isCountSpecificText() { return _bCountSpecificText;} bool isCountSpecificText() { return _bCountSpecificText;}
void setTextToNotify(QStringList); void setTextToNotify(QStringList);
void setTextToNotify(QString); void setTextToNotify(QString);
QString textToNotify() { return _textToNotify.join("\n");} QString textToNotify() { return _textToNotify.join("\n");}
void setTextCaseSensitive(bool value);
bool isTextCaseSensitive() {return _bTextCaseSensitive;}
signals: signals:
void countChanged(ChatLobbyId id, unsigned int count); void countChanged(ChatLobbyId id, unsigned int count);
@ -84,10 +86,12 @@ private:
typedef std::map<QString, MsgData> msg_map; typedef std::map<QString, MsgData> msg_map;
typedef std::map<ChatLobbyId, msg_map> lobby_map; typedef std::map<ChatLobbyId, msg_map> lobby_map;
lobby_map _listMsg; lobby_map _listMsg;
QStringList _textToNotify;
bool _bCheckForNickName;
bool _bCountUnRead; bool _bCountUnRead;
bool _bCountSpecificText; bool _bCheckForNickName;
bool _bCountSpecificText;
QStringList _textToNotify;
bool _bTextCaseSensitive;
}; };
#endif // CHATLOBBYUSERNOTIFY_H #endif // CHATLOBBYUSERNOTIFY_H

View File

@ -44,7 +44,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
connect(ui.testToasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); connect(ui.testToasterButton, SIGNAL(clicked()), this, SLOT(testToaster()));
connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool)));
connect(NotifyQt::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(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(); ui.notify_Blogs->hide();
@ -257,6 +257,7 @@ NotifyPage::save(QString &/*errmsg*/)
mChatLobbyUserNotify->setCheckForNickName(ui.chatLobbies_CheckNickName->isChecked()) ; mChatLobbyUserNotify->setCheckForNickName(ui.chatLobbies_CheckNickName->isChecked()) ;
mChatLobbyUserNotify->setCountSpecificText(ui.chatLobbies_CountFollowingText->isChecked()) ; mChatLobbyUserNotify->setCountSpecificText(ui.chatLobbies_CountFollowingText->isChecked()) ;
mChatLobbyUserNotify->setTextToNotify(ui.chatLobbies_TextToNotify->document()->toPlainText()); mChatLobbyUserNotify->setTextToNotify(ui.chatLobbies_TextToNotify->document()->toPlainText());
mChatLobbyUserNotify->setTextCaseSensitive(ui.chatLobbies_TextCaseSensitive->isChecked());
} }
load(); load();
return true; return true;
@ -348,11 +349,12 @@ void NotifyPage::load()
notifyToggled(); notifyToggled();
if (mChatLobbyUserNotify){ if (mChatLobbyUserNotify){
ui.chatLobbies_TextToNotify->setEnabled(mChatLobbyUserNotify->isCountSpecificText()) ;
ui.chatLobbies_CountFollowingText->setChecked(mChatLobbyUserNotify->isCountSpecificText()) ;
ui.chatLobbies_CountUnRead->setChecked(mChatLobbyUserNotify->isCountUnRead()); ui.chatLobbies_CountUnRead->setChecked(mChatLobbyUserNotify->isCountUnRead());
ui.chatLobbies_CheckNickName->setChecked(mChatLobbyUserNotify->isCheckForNickName()); 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_TextToNotify->setPlainText(mChatLobbyUserNotify->textToNotify());
ui.chatLobbies_TextCaseSensitive->setChecked(mChatLobbyUserNotify->isTextCaseSensitive());
} }
} }

View File

@ -10,7 +10,7 @@
<height>512</height> <height>512</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="NotifyPageVLayout">
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
@ -20,21 +20,30 @@
<attribute name="title"> <attribute name="title">
<string>Feed</string> <string>Feed</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="tabFeedVLayout">
<item> <item>
<widget class="QGroupBox" name="notify_ForumNewMsg"> <widget class="QGroupBox" name="newsFeedGroupBox">
<property name="title"> <property name="title">
<string>News Feed</string> <string>News Feed</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="notify_ForumNewMsgHLayout">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="notify_VLayout">
<item> <item>
<widget class="QCheckBox" name="notify_Peers"> <widget class="QCheckBox" name="notify_Peers">
<property name="text"> <property name="text">
@ -104,7 +113,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="testFeedVLayout">
<item> <item>
<widget class="QPushButton" name="testFeedButton"> <widget class="QPushButton" name="testFeedButton">
<property name="text"> <property name="text">
@ -113,7 +122,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="testFeedVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -135,7 +144,7 @@
<property name="title"> <property name="title">
<string>Message</string> <string>Message</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="messageGroupBoxVLayout">
<item> <item>
<widget class="QCheckBox" name="message_ConnectAttempt"> <widget class="QCheckBox" name="message_ConnectAttempt">
<property name="text"> <property name="text">
@ -147,7 +156,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="tabFeedVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -165,7 +174,7 @@
<attribute name="title"> <attribute name="title">
<string>Toasters</string> <string>Toasters</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_11"> <layout class="QVBoxLayout" name="tabToastersVLayout">
<item> <item>
<widget class="QPushButton" name="pushButtonDisableAll"> <widget class="QPushButton" name="pushButtonDisableAll">
<property name="toolTip"> <property name="toolTip">
@ -180,11 +189,11 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="toasterGroupBox">
<property name="title"> <property name="title">
<string>Toasters</string> <string>Toasters</string>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="toasterGroupBoxVLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>9</number> <number>9</number>
</property> </property>
@ -192,9 +201,9 @@
<number>9</number> <number>9</number>
</property> </property>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="popup_HLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="popupVLayout">
<item> <item>
<widget class="QCheckBox" name="popup_Connect"> <widget class="QCheckBox" name="popup_Connect">
<property name="text"> <property name="text">
@ -250,7 +259,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="testToasterVLayout">
<item> <item>
<widget class="QPushButton" name="testToasterButton"> <widget class="QPushButton" name="testToasterButton">
<property name="text"> <property name="text">
@ -259,7 +268,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_3"> <spacer name="testToasterVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -276,7 +285,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="positionGLayout">
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelToasterPosition"> <widget class="QLabel" name="labelToasterPosition">
<property name="sizePolicy"> <property name="sizePolicy">
@ -355,7 +364,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_6"> <spacer name="tabToastersVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -376,7 +385,7 @@
<attribute name="title"> <attribute name="title">
<string>Systray</string> <string>Systray</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_12"> <layout class="QVBoxLayout" name="tabSystrayVLayout">
<item> <item>
<widget class="QGroupBox" name="trayNotifyGroupBox"> <widget class="QGroupBox" name="trayNotifyGroupBox">
<property name="title"> <property name="title">
@ -390,7 +399,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="systrayMessageGroupBox">
<property name="title"> <property name="title">
<string>Systray message</string> <string>Systray message</string>
</property> </property>
@ -413,7 +422,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_4"> <spacer name="tabSystrayVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@ -431,7 +440,7 @@
<attribute name="title"> <attribute name="title">
<string>Chat Lobbies</string> <string>Chat Lobbies</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="tabChatLobbiesVLayout">
<item> <item>
<widget class="QCheckBox" name="chatLobbies_CountUnRead"> <widget class="QCheckBox" name="chatLobbies_CountUnRead">
<property name="text"> <property name="text">
@ -457,7 +466,17 @@
<widget class="QPlainTextEdit" name="chatLobbies_TextToNotify"/> <widget class="QPlainTextEdit" name="chatLobbies_TextToNotify"/>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_5"> <widget class="QCheckBox" name="chatLobbies_TextCaseSensitive">
<property name="toolTip">
<string>Checked, if the identity and the text above occurences must be in the same case to trigger count.</string>
</property>
<property name="text">
<string>Case sensitive</string>
</property>
</widget>
</item>
<item>
<spacer name="tabChatLobbiesVSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>