From e40460bdcc608b89ee890c46b1dee467362a9354 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 26 Mar 2015 22:17:48 +0000 Subject: [PATCH] new notify capability of chat lobbies: message counting, nickname occurrence counting and specific text counting. Also sorts out notify tab in Settings (Patch from Phenom, slightly modified: gui layout/text + added a flag to enable/disable user defined text grep) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8082 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 90 ++- retroshare-gui/src/gui/ChatLobbyWidget.h | 12 +- .../src/gui/chat/ChatLobbyDialog.cpp | 2 +- retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 2 +- .../src/gui/chat/ChatLobbyUserNotify.cpp | 278 ++++++- .../src/gui/chat/ChatLobbyUserNotify.h | 52 +- retroshare-gui/src/gui/chat/ChatWidget.cpp | 155 +++- retroshare-gui/src/gui/chat/ChatWidget.h | 8 + retroshare-gui/src/gui/chat/ChatWidget.ui | 94 ++- retroshare-gui/src/gui/common/UserNotify.cpp | 8 +- retroshare-gui/src/gui/common/UserNotify.h | 4 + retroshare-gui/src/gui/settings/ChatPage.cpp | 2 + retroshare-gui/src/gui/settings/ChatPage.ui | 7 + .../src/gui/settings/NotifyPage.cpp | 20 + retroshare-gui/src/gui/settings/NotifyPage.h | 3 + retroshare-gui/src/gui/settings/NotifyPage.ui | 687 ++++++++++-------- .../src/gui/settings/rsharesettings.cpp | 10 + .../src/gui/settings/rsharesettings.h | 3 + 18 files changed, 1045 insertions(+), 392 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 898dfd3f1..d48e2cf6c 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -55,6 +55,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) ui.setupUi(this); m_bProcessSettings = false; + myChatLobbyUserNotify = NULL; QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged())); QObject::connect( NotifyQt::getInstance(), SIGNAL(chatLobbyEvent(qulonglong,int,const QString&,const QString&)), this, SLOT(displayChatLobbyEvent(qulonglong,int,const QString&,const QString&))); @@ -194,12 +195,29 @@ ChatLobbyWidget::~ChatLobbyWidget() UserNotify *ChatLobbyWidget::getUserNotify(QObject *parent) { - ChatLobbyUserNotify *notify = new ChatLobbyUserNotify(parent); - connect(this, SIGNAL(unreadCountChanged(uint)), notify, SLOT(unreadCountChanged(uint))); - - notify->unreadCountChanged(unreadCount()); - - return notify; + if (!myChatLobbyUserNotify){ + myChatLobbyUserNotify = new ChatLobbyUserNotify(parent); + connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int))); + } + return myChatLobbyUserNotify; +} + +void ChatLobbyWidget::updateNotify(ChatLobbyId id, unsigned int count) +{ + ChatLobbyDialog *dialog=NULL; + dialog=_lobby_infos[id].dialog; + if(!dialog) return; + + QToolButton* notifyButton=dialog->getChatWidget()->getNotifyButton(); + if (!notifyButton) return; + dialog->getChatWidget()->setNotify(myChatLobbyUserNotify); + if (count>0){ + notifyButton->setVisible(true); + notifyButton->setIcon(_lobby_infos[id].default_icon); + notifyButton->setToolTip(QString("(%1)").arg(count)); + } else { + notifyButton->setVisible(false); + } } void ChatLobbyWidget::lobbyTreeWidgetCustomPopupMenu(QPoint) @@ -332,7 +350,7 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d) connect(d,SIGNAL(lobbyLeave(ChatLobbyId)),this,SLOT(unsubscribeChatLobby(ChatLobbyId))) ; connect(d,SIGNAL(typingEventReceived(ChatLobbyId)),this,SLOT(updateTypingStatus(ChatLobbyId))) ; - connect(d,SIGNAL(messageReceived(ChatLobbyId)),this,SLOT(updateMessageChanged(ChatLobbyId))) ; + connect(d,SIGNAL(messageReceived(bool,ChatLobbyId,QDateTime,QString,QString)),this,SLOT(updateMessageChanged(bool,ChatLobbyId,QDateTime,QString,QString))) ; connect(d,SIGNAL(peerJoined(ChatLobbyId)),this,SLOT(updatePeerEntering(ChatLobbyId))) ; connect(d,SIGNAL(peerLeft(ChatLobbyId)),this,SLOT(updatePeerLeaving(ChatLobbyId))) ; @@ -340,7 +358,6 @@ void ChatLobbyWidget::addChatPage(ChatLobbyDialog *d) _lobby_infos[id].dialog = d ; _lobby_infos[id].default_icon = QIcon() ; _lobby_infos[id].last_typing_event = time(NULL) ; - _lobby_infos[id].unread_count = 0; ChatLobbyInfo linfo ; if(rsMsgs->getChatLobbyInfo(id,linfo)) @@ -619,6 +636,7 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item) else ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ; } + void ChatLobbyWidget::subscribeChatLobbyAs() { QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem(); @@ -638,6 +656,31 @@ void ChatLobbyWidget::subscribeChatLobbyAs() if(rsMsgs->joinVisibleChatLobby(id,gxs_id)) ChatDialog::chatFriend(ChatId(id),true) ; } + +void ChatLobbyWidget::showLobbyAnchor(ChatLobbyId id, QString anchor) +{ + QTreeWidgetItem *item = getTreeWidgetItem(id) ; + + if(item != NULL) { + if(item->type() == TYPE_LOBBY) { + + if(_lobby_infos.find(id) == _lobby_infos.end()) { + showBlankPage(id) ; + } else { + //ChatLobbyDialog cldChatLobby =_lobby_infos[id].dialog; + ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ; + ChatLobbyDialog *cldCW=NULL ; + if (NULL != (cldCW = dynamic_cast(ui.stackedWidget->currentWidget()))) + cldCW->getChatWidget()->scrollToAnchor(anchor); + + ui.lobbyTreeWidget->setCurrentItem(item); + } + + } + } + +} + void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item) { if (item == NULL || item->type() != TYPE_LOBBY) { @@ -810,9 +853,12 @@ void ChatLobbyWidget::unsubscribeChatLobby(ChatLobbyId id) if(it != _lobby_infos.end()) { + if (myChatLobbyUserNotify){ + myChatLobbyUserNotify->chatLobbyCleared(id, ""); + } + ui.stackedWidget->removeWidget(it->second.dialog) ; _lobby_infos.erase(it) ; - emit unreadCountChanged(unreadCount()); } // Unsubscribe the chat lobby @@ -852,10 +898,7 @@ void ChatLobbyWidget::updateCurrentLobby() int iPrivacyLevel= item->parent()->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt(); QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE); _lobby_infos[id].default_icon = icon ; - _lobby_infos[id].unread_count = 0; item->setIcon(COLUMN_NAME, icon) ; - - emit unreadCountChanged(unreadCount()); } } @@ -863,19 +906,21 @@ void ChatLobbyWidget::updateCurrentLobby() filterItems(ui.filterLineEdit->text()); } } -void ChatLobbyWidget::updateMessageChanged(ChatLobbyId id) +void ChatLobbyWidget::updateMessageChanged(bool incoming, ChatLobbyId id, QDateTime time, QString senderName, QString msg) { QTreeWidgetItem *current_item = ui.lobbyTreeWidget->currentItem(); + bool bIsCurrentItem = (current_item != NULL && current_item->data(COLUMN_DATA, ROLE_ID).toULongLong() == id); + + if (myChatLobbyUserNotify){ + if (incoming) myChatLobbyUserNotify->chatLobbyNewMessage(id, time, senderName, msg); + } // Don't show anything for current lobby. // - if(current_item != NULL && current_item->data(COLUMN_DATA, ROLE_ID).toULongLong() == id) + if(bIsCurrentItem) return ; _lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ; - ++_lobby_infos[id].unread_count; - - emit unreadCountChanged(unreadCount()); QTreeWidgetItem *item = getTreeWidgetItem(id) ; @@ -1054,14 +1099,3 @@ int ChatLobbyWidget::getNumColVisible() } return iNumColVis; } - -uint ChatLobbyWidget::unreadCount() -{ - uint count = 0; - - for (std::map::iterator it = _lobby_infos.begin(); it != _lobby_infos.end(); ++it) { - count += it->second.unread_count; - } - - return count; -} diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index 3296a51c4..7f0dd483a 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -4,6 +4,7 @@ #include #include "ui_ChatLobbyWidget.h" #include "RsAutoUpdatePage.h" +#include "chat/ChatLobbyUserNotify.h" #define IMAGE_CHATLOBBY ":/images/chat_32.png" @@ -20,7 +21,6 @@ struct ChatLobbyInfoStruct QIcon default_icon ; ChatLobbyDialog *dialog ; time_t last_typing_event ; - uint unread_count; }; class ChatLobbyWidget : public RsAutoUpdatePage @@ -38,12 +38,13 @@ public: virtual QString pageName() const { return tr("Chat Lobbies") ; } //MainPage virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); + virtual UserNotify *getUserNotify(QObject *parent); //MainPage virtual void updateDisplay(); void setCurrentChatPage(ChatLobbyDialog *) ; // used by ChatLobbyDialog to raise. void addChatPage(ChatLobbyDialog *) ; + void showLobbyAnchor(ChatLobbyId id, QString anchor) ; uint unreadCount(); @@ -66,7 +67,7 @@ protected slots: void subscribeChatLobbyAs() ; void updateTypingStatus(ChatLobbyId id) ; void resetLobbyTreeIcons() ; - void updateMessageChanged(ChatLobbyId); + void updateMessageChanged(bool incoming, ChatLobbyId, QDateTime time, QString senderName, QString msg); void updatePeerEntering(ChatLobbyId); void updatePeerLeaving(ChatLobbyId); void autoSubscribeItem(); @@ -75,11 +76,12 @@ private slots: void filterColumnChanged(int); void filterItems(const QString &text); - void setShowUserCountColumn(bool show); void setShowTopicColumn(bool show); void setShowSubscribeColumn(bool show); + void updateNotify(ChatLobbyId id, unsigned int count) ; + private: void autoSubscribeLobby(QTreeWidgetItem *item); void subscribeChatLobby(ChatLobbyId id) ; @@ -109,6 +111,8 @@ private: QAction* showSubscribeAct; int getNumColVisible(); + ChatLobbyUserNotify* myChatLobbyUserNotify; + /* UI - from Designer */ Ui::ChatLobbyWidget ui; }; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index c9c3ec6cd..9de02c70c 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -336,7 +336,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ; ui.chatWidget->addChatMsg(msg.incoming, name, sendTime, recvTime, message, ChatWidget::MSGTYPE_NORMAL); - emit messageReceived(id()) ; + emit messageReceived(msg.incoming, id(), sendTime, name, message) ; // This is a trick to translate HTML into text. QTextEdit editor; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index d850e1ad9..d52950b1e 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -56,7 +56,7 @@ private slots: signals: void lobbyLeave(ChatLobbyId) ; void typingEventReceived(ChatLobbyId) ; - void messageReceived(ChatLobbyId) ; + void messageReceived(bool incoming, ChatLobbyId lobby_id, QDateTime time, QString senderName, QString msg) ; void peerJoined(ChatLobbyId) ; void peerLeft(ChatLobbyId) ; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp index 6bb7b5c28..2c63ec19f 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.cpp @@ -19,23 +19,77 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ +#include +#include #include "ChatLobbyUserNotify.h" #include "gui/notifyqt.h" #include "gui/MainWindow.h" +#include "gui/ChatLobbyWidget.h" +#include "gui/settings/rsharesettings.h" +#include "util/DateTime.h" +#include ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) : UserNotify(parent) { + _name = tr("Chat Lobbies"); + _group = "ChatLobby"; + + _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(); } bool ChatLobbyUserNotify::hasSetting(QString *name, QString *group) { - if (name) *name = tr("Chat Lobbies"); - if (group) *group = "ChatLobby"; + if (name) *name = _name; + if (group) *group = _group; return true; } +void ChatLobbyUserNotify::setCheckForNickName(bool value) +{ + if (_bCheckForNickName != value) { + _bCheckForNickName = value; + Settings->setValueToGroup(_group, "CheckForNickName", value); + } +} + +void ChatLobbyUserNotify::setCountUnRead(bool value) +{ + if (_bCountUnRead != value) { + _bCountUnRead = value; + Settings->setValueToGroup(_group, "CountUnRead", value); + } +} + +void ChatLobbyUserNotify::setCountSpecificText(bool value) +{ + if (_bCountSpecificText != value) { + _bCountSpecificText = value; + Settings->setValueToGroup(_group, "CountSpecificText", value); + } +} +void ChatLobbyUserNotify::setTextToNotify(QStringList value) +{ + if (_textToNotify != value) { + _textToNotify = value; + Settings->setValueToGroup(_group, "TextToNotify", value); + } +} + +void ChatLobbyUserNotify::setTextToNotify(QString value) +{ + QRegExp regExp("([ ~!@#$%^&*()_+{}|:\"<>?,./;'[\\]\\\\\\-=\\t\\n\\r])"); //RegExp for End of Word + QStringList list = value.split(regExp); + QString newValue = list.join("\n"); + while(newValue.contains("\n\n")) newValue.replace("\n\n","\n"); + list = newValue.split("\n"); + setTextToNotify(list); +} + QIcon ChatLobbyUserNotify::getIcon() { return QIcon(":/images/chat_32.png"); @@ -48,17 +102,229 @@ QIcon ChatLobbyUserNotify::getMainIcon(bool hasNew) unsigned int ChatLobbyUserNotify::getNewCount() { - return mUnreadCount; + int iNum=0; + for (lobby_map::iterator itCL=_listMsg.begin(); itCL!=_listMsg.end(); ++itCL) { + iNum+=itCL->second.size(); + if (itCL->second.size()==0) _listMsg.erase(itCL); + } + return iNum; +} + +QString ChatLobbyUserNotify::getTrayMessage(bool plural) +{ + return plural ? tr("You have %1 new messages") : tr("You have %1 new message"); +} + +QString ChatLobbyUserNotify::getNotifyMessage(bool plural) +{ + return plural ? tr("%1 new messages") : tr("%1 new message"); } void ChatLobbyUserNotify::iconClicked() { - MainWindow::showWindow(MainWindow::ChatLobby); + /// Tray icon Menu /// + QMenu* trayMenu = new QMenu(MainWindow::getInstance()); + std::list lobbies; + rsMsgs->getChatLobbyList(lobbies); + bool doUpdate=false; + + for (lobby_map::iterator itCL=_listMsg.begin(); itCL!=_listMsg.end();++itCL) { + /// Create a menu per lobby /// + bool bFound=false; + QString strLobbyName=tr("Unknown Lobby"); + QIcon icoLobby=QIcon(); + std::list::const_iterator lobbyIt; + for (lobbyIt = lobbies.begin(); lobbyIt != lobbies.end(); ++lobbyIt) { + ChatLobbyId clId = *lobbyIt; + if (clId==itCL->first) { + ChatLobbyInfo clInfo; + if (rsMsgs->getChatLobbyInfo(clId,clInfo)) + strLobbyName=QString::fromUtf8(clInfo.lobby_name.c_str()) ; + icoLobby=(clInfo.lobby_flags & RS_CHAT_LOBBY_FLAGS_PUBLIC) ? QIcon(":/images/chat_red24.png") : QIcon(":/images/chat_x24.png"); + bFound=true; + break; + } + } + + if (bFound){ + makeSubMenu(trayMenu, icoLobby, strLobbyName, itCL->first); + } else { + _listMsg.erase(itCL); + doUpdate=true; + } + } + + if (notifyCombined()) { + QSystemTrayIcon* trayIcon=getTrayIcon(); + if (trayIcon!=NULL) trayIcon->setContextMenu(trayMenu); + } else { + QAction* action=getNotifyIcon(); + if (action!=NULL) { + action->setMenu(trayMenu); + } + } + + QString strName=tr("Remove All"); + QAction *pAction = new QAction( QIcon(), strName, trayMenu); + ActionTag actionTag={0x0, "", true}; + pAction->setData(qVariantFromValue(actionTag)); + connect(trayMenu, SIGNAL(triggered(QAction*)), this, SLOT(subMenuClicked(QAction*))); + connect(trayMenu, SIGNAL(hovered(QAction*)), this, SLOT(subMenuHovered(QAction*))); + trayMenu->addAction(pAction); + + trayMenu->exec(QCursor::pos()); + if (doUpdate) updateIcon(); + } -void ChatLobbyUserNotify::unreadCountChanged(unsigned int unreadCount) +void ChatLobbyUserNotify::makeSubMenu(QMenu* parentMenu, QIcon icoLobby, QString strLobbyName, ChatLobbyId id) { - mUnreadCount = unreadCount; + lobby_map::iterator itCL=_listMsg.find(id); + if (itCL==_listMsg.end()) return; + msg_map msgMap = itCL->second; + + unsigned int msgCount=msgMap.size(); + + if(!parentMenu) parentMenu = new QMenu(MainWindow::getInstance()); + QMenu *lobbyMenu = parentMenu->addMenu(icoLobby, strLobbyName); + connect(lobbyMenu, SIGNAL(triggered(QAction*)), this, SLOT(subMenuClicked(QAction*))); + connect(lobbyMenu, SIGNAL(hovered(QAction*)), this, SLOT(subMenuHovered(QAction*))); + + lobbyMenu->setToolTip(getNotifyMessage(msgCount>1).arg(msgCount)); + + for (msg_map::iterator itMsg=msgMap.begin(); itMsg!=msgMap.end(); ++itMsg) { + /// initialize menu /// + QString strName=itMsg->first; + MsgData msgData=itMsg->second; + QTextDocument doc; + doc.setHtml(msgData.text); + strName.append(":").append(doc.toPlainText().left(30).replace(QString("\n"),QString(" "))); + QAction *pAction = new QAction( icoLobby, strName, lobbyMenu); + pAction->setToolTip(doc.toPlainText()); + ActionTag actionTag={itCL->first, itMsg->first, false}; + pAction->setData(qVariantFromValue(actionTag)); + lobbyMenu->addAction(pAction); + } + + QString strName=tr("Remove All"); + QAction *pAction = new QAction( icoLobby, strName, lobbyMenu); + ActionTag actionTag={itCL->first, "", true}; + pAction->setData(qVariantFromValue(actionTag)); + lobbyMenu->addAction(pAction); + +} + +void ChatLobbyUserNotify::iconHovered() +{ + iconClicked(); +} + + +void ChatLobbyUserNotify::chatLobbyNewMessage(ChatLobbyId lobby_id, QDateTime time, QString senderName, QString msg) +{ + + bool bGetNickName = false; + if (_bCheckForNickName) { + RsGxsId gxs_id; + rsMsgs->getIdentityForChatLobby(lobby_id,gxs_id); + RsIdentityDetails details ; + rsIdentity->getIdDetails(gxs_id,details) ; + bGetNickName = checkWord(msg, QString::fromUtf8(details.mNickname.c_str())); + } + + bool bFoundTextToNotify = false; + + 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); + strAnchor.append("_").append(senderName); + MsgData msgData; + msgData.text=msg; + msgData.unread=!(bGetNickName || bFoundTextToNotify); + + _listMsg[lobby_id][strAnchor]=msgData; + emit countChanged(lobby_id, _listMsg[lobby_id].size()); + updateIcon(); +} +} + +bool ChatLobbyUserNotify::checkWord(QString message, QString word) +{ + bool bFound = false; + int nFound = -1; + if (((nFound=message.indexOf(word)) != -1) + && (!word.isEmpty())) { + QString eow=" ~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="; // end of word + bool bFirstCharEOW = (nFound==0)?true:(eow.indexOf(message.at(nFound-1)) != -1); + bool bLastCharEOW = ((nFound+word.length()-1) < message.length()) + ?(eow.indexOf(message.at(nFound+word.length())) != -1) + :true; + bFound = (bFirstCharEOW && bLastCharEOW); + } + return bFound; +} + +void ChatLobbyUserNotify::chatLobbyCleared(ChatLobbyId lobby_id, QString anchor, bool onlyUnread /*=false*/) +{ + bool changed = anchor.isEmpty(); + unsigned int count=0; + if (lobby_id==0) return; + lobby_map::iterator itCL=_listMsg.find(lobby_id); + if (itCL!=_listMsg.end()) { + if (!anchor.isEmpty()) { + msg_map::iterator itMsg=itCL->second.find(anchor); + if (itMsg!=itCL->second.end()) { + MsgData msgData = itMsg->second; + if(!onlyUnread || msgData.unread) { + itCL->second.erase(itMsg); + changed=true; + } + } + count = itCL->second.size(); + } + if (count==0) _listMsg.erase(itCL); + } + if (changed) emit countChanged(lobby_id, count); + updateIcon(); +} + +void ChatLobbyUserNotify::subMenuClicked(QAction* action) +{ + ActionTag actionTag=action->data().value(); + if(!actionTag.removeALL){ + MainWindow::showWindow(MainWindow::ChatLobby); + ChatLobbyWidget *chatLobbyWidget = dynamic_cast(MainWindow::getPage(MainWindow::ChatLobby)); + if (chatLobbyWidget) chatLobbyWidget->showLobbyAnchor(actionTag.cli ,actionTag.timeStamp); + } + + lobby_map::iterator itCL=_listMsg.find(actionTag.cli); + if (itCL!=_listMsg.end()) { + unsigned int count=0; + if(!actionTag.removeALL){ + msg_map::iterator itMsg=itCL->second.find(actionTag.timeStamp); + if (itMsg!=itCL->second.end()) itCL->second.erase(itMsg); + count = itCL->second.size(); + } + if (count==0) _listMsg.erase(itCL); + emit countChanged(actionTag.cli, count); + } else if(actionTag.cli==0x0){ + for(itCL=_listMsg.begin();itCL!=_listMsg.end();++itCL){ + emit countChanged(itCL->first, 0); + _listMsg.erase(itCL); + } + } + QMenu *lobbyMenu=dynamic_cast(action->parent()); + if (lobbyMenu) lobbyMenu->removeAction(action); updateIcon(); } + +void ChatLobbyUserNotify::subMenuHovered(QAction* action) +{ + QMenu *lobbyMenu=dynamic_cast(action->parent()); + if (lobbyMenu) lobbyMenu->setToolTip(action->toolTip()); +} diff --git a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h index 5e7d0e034..04941b006 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyUserNotify.h @@ -23,6 +23,22 @@ #define CHATLOBBYUSERNOTIFY_H #include "gui/common/UserNotify.h" +#include +#include +#include + +struct ActionTag { + ChatLobbyId cli; + QString timeStamp; + bool removeALL; +}; +Q_DECLARE_METATYPE(ActionTag) + +struct MsgData { + QString text; + bool unread; +}; +Q_DECLARE_METATYPE(MsgData) class ChatLobbyUserNotify : public UserNotify { @@ -32,18 +48,46 @@ public: ChatLobbyUserNotify(QObject *parent = 0); virtual bool hasSetting(QString *name, QString *group); + void makeSubMenu(QMenu* parentMenu, QIcon icoLobby, QString strLobbyName, ChatLobbyId id); + void chatLobbyNewMessage(ChatLobbyId lobby_id, QDateTime time, QString senderName, QString msg); + void chatLobbyCleared(ChatLobbyId lobby_id, QString anchor, bool onlyUnread=false); + void setCheckForNickName(bool value); + bool isCheckForNickName() { return _bCheckForNickName;} + void setCountUnRead(bool value); + bool isCountUnRead() { return _bCountUnRead;} + void setCountSpecificText(bool value); + bool isCountSpecificText() { return _bCountSpecificText;} + void setTextToNotify(QStringList); + void setTextToNotify(QString); + QString textToNotify() { return _textToNotify.join("\n");} -public slots: - void unreadCountChanged(uint unreadCount); +signals: + void countChanged(ChatLobbyId id, unsigned int count); + +private slots: + void subMenuClicked(QAction* action); + void subMenuHovered(QAction* action); private: virtual QIcon getIcon(); virtual QIcon getMainIcon(bool hasNew); virtual unsigned int getNewCount(); + virtual QString getTrayMessage(bool plural); + virtual QString getNotifyMessage(bool plural); virtual void iconClicked(); + virtual void iconHovered(); + bool checkWord(QString msg, QString word); -private: - uint mUnreadCount; + QString _name; + QString _group; + + typedef std::map msg_map; + typedef std::map lobby_map; + lobby_map _listMsg; + QStringList _textToNotify; + bool _bCheckForNickName; + bool _bCountUnRead; + bool _bCountSpecificText; }; #endif // CHATLOBBYUSERNOTIFY_H diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 8ed319ae4..33b644162 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -31,10 +31,12 @@ #include #include #include +#include #include #include "ChatWidget.h" #include "ui_ChatWidget.h" +#include "gui/MainWindow.h" #include "gui/notifyqt.h" #include "gui/RetroShareLink.h" #include "gui/settings/rsharesettings.h" @@ -44,9 +46,11 @@ #include "gui/common/StatusDefs.h" #include "gui/common/FilesDefs.h" #include "gui/common/Emoticons.h" +#include "gui/chat/ChatLobbyDialog.h" #include "util/misc.h" #include "util/HandleRichText.h" -#include "gui/chat/ChatUserNotify.h" +#include "gui/chat/ChatUserNotify.h"//For BradCast +#include "util/DateTime.h" #include #include @@ -104,6 +108,9 @@ ChatWidget::ChatWidget(QWidget *parent) : connect(ui->searchButton, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuSearchButton(QPoint))); connect(ui->actionSearch_History, SIGNAL(triggered()), this, SLOT(searchHistory())); + notify=NULL; + ui->notifyButton->setVisible(false); + ui->markButton->setToolTip(tr("Mark this selected text
Ctrl+M")); connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendChat())); @@ -135,7 +142,8 @@ ChatWidget::ChatWidget(QWidget *parent) : ui->infoFrame->setVisible(false); ui->statusMessageLabel->hide(); - ui->searchframe->hide(); + ui->actionSearch_History->setChecked(Settings->getChatSearchShowBarByDefault()); + searchHistory(); setAcceptDrops(true); ui->chatTextEdit->setAcceptDrops(false); @@ -156,8 +164,11 @@ ChatWidget::ChatWidget(QWidget *parent) : menu->addAction(ui->actionSearch_History); ui->pushtoolsButton->setMenu(menu); - ui->chatTextEdit->installEventFilter(this); ui->textBrowser->installEventFilter(this); + ui->textBrowser->viewport()->installEventFilter(this); + ui->chatTextEdit->installEventFilter(this); + //ui->textBrowser->setMouseTracking(true); + //ui->chatTextEdit->setMouseTracking(true); #if QT_VERSION < 0x040700 // embedded images are not supported before QT 4.7.0 @@ -375,7 +386,8 @@ void ChatWidget::processSettings(bool load) bool ChatWidget::eventFilter(QObject *obj, QEvent *event) { - if (obj == ui->textBrowser || obj == ui->leSearch || obj == ui->chatTextEdit) { + if (obj == ui->textBrowser || obj == ui->textBrowser->viewport() + || obj == ui->leSearch || obj == ui->chatTextEdit) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); @@ -419,24 +431,109 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event) } } + + if (chatType() == CHATTYPE_LOBBY) { + if ((event->type() == QEvent::KeyPress) + || (event->type() == QEvent::MouseMove) + || (event->type() == QEvent::Enter) + || (event->type() == QEvent::Leave) + || (event->type() == QEvent::Wheel) + || (event->type() == QEvent::ToolTip) ) { + + QTextCursor cursor = ui->textBrowser->cursorForPosition(QPoint(0, 0)); + QPoint bottom_right(ui->textBrowser->viewport()->width() - 1, ui->textBrowser->viewport()->height() - 1); + int end_pos = ui->textBrowser->cursorForPosition(bottom_right).position(); + cursor.setPosition(end_pos, QTextCursor::KeepAnchor); + + if (!cursor.selectedText().isEmpty()){ + QRegExp rx("toUtf8(); + std::string stdString=std::string(bytArray.begin(),bytArray.end()); + if (notify) notify->chatLobbyCleared(chatId.toLobbyId() + ,QString::fromUtf8(stdString.c_str()) + ,obj != ui->textBrowser && obj != ui->textBrowser->viewport());//, true); + } } + } + } + } + } + if (obj == ui->textBrowser) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); if (keyEvent) { if (keyEvent->key() == Qt::Key_Delete ) { - // Delete pressed - if (ui->textBrowser->textCursor().selectedText().length()>0) + // Delete key pressed + if (ui->textBrowser->textCursor().selectedText().length() > 0) { + if (chatType() == CHATTYPE_LOBBY) { + QRegExp rx("textBrowser->textCursor().selection().toHtml(); + QStringList anchors; + int pos=0; + while ((pos = rx.indexIn(sel,pos)) != -1) { + anchors << rx.cap(1); + pos += rx.matchedLength(); + } + + for (QStringList::iterator it=anchors.begin();it!=anchors.end();++it) { + QByteArray bytArray=it->toUtf8(); + std::string stdString=std::string(bytArray.begin(),bytArray.end()); + if (notify) notify->chatLobbyCleared(chatId.toLobbyId(), QString::fromUtf8(stdString.c_str())); + } + + } ui->textBrowser->textCursor().deleteChar(); } + } + if (keyEvent->key() == Qt::Key_M && keyEvent->modifiers() == Qt::ControlModifier) { on_markButton_clicked(!ui->markButton->isChecked()); } } } + + if (event->type() == QEvent::ToolTip) { + QHelpEvent* helpEvent = static_cast(event); + QTextCursor cursor = ui->textBrowser->cursorForPosition(helpEvent->pos()); + cursor.select(QTextCursor::WordUnderCursor); + QString toolTipText = ""; + if (!cursor.selectedText().isEmpty()){ + QRegExp rx("globalPos(), toolTipText); + return true; + } else { + QToolTip::hideText(); + } + } + } else if (obj == ui->chatTextEdit) { if (event->type() == QEvent::KeyPress) { @@ -691,6 +788,35 @@ void ChatWidget::focusDialog() ui->chatTextEdit->setFocus(); } +QToolButton* ChatWidget::getNotifyButton() +{ + if (ui) if (ui->notifyButton) return ui->notifyButton; + return NULL; +} + +void ChatWidget::setNotify(ChatLobbyUserNotify *clun) +{ + if(clun) notify=clun; +} + +void ChatWidget::on_notifyButton_clicked() +{ + if(!notify) return; + if (chatType() != CHATTYPE_LOBBY) return; + + QMenu* menu = new QMenu(MainWindow::getInstance()); + QIcon icoLobby=(ui->notifyButton->icon()); + + notify->makeSubMenu(menu, icoLobby, title, chatId.toLobbyId()); + menu->exec(ui->notifyButton->mapToGlobal(ui->notifyButton->geometry().bottomLeft())); + +} + +void ChatWidget::scrollToAnchor(QString anchor) +{ + ui->textBrowser->scrollToAnchor(anchor); +} + void ChatWidget::setWelcomeMessage(QString &text) { ui->textBrowser->setText(text); @@ -752,8 +878,12 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime } QString formattedMessage = RsHtml().formatText(ui->textBrowser->document(), message, formatTextFlag, backgroundColor, desiredContrast); - QString formatMsg = chatStyle.formatMessage(type, name, incoming ? sendTime : recvTime, formattedMessage, formatFlag); + QDateTime dtTimestamp=incoming ? sendTime : recvTime; + QString formatMsg = chatStyle.formatMessage(type, name, dtTimestamp, formattedMessage, formatFlag); + QString timeStamp = dtTimestamp.toString(Qt::ISODate); + formatMsg.prepend(QString("").arg(timeStamp).arg(name)); + //To call this anchor do: ui->textBrowser->scrollToAnchor(QString("%1_%2").arg(timeStamp).arg(name)); ui->textBrowser->textCursor().setBlockFormat(QTextBlockFormat ()); ui->textBrowser->append(formatMsg); @@ -1074,13 +1204,13 @@ bool ChatWidget::findText(const QString& qsStringToFind, bool bBackWard, bool bF qtcCurrent=qtcHighLight; if (bMoveToCursor || bForceMove) ui->textBrowser->setTextCursor(qtcHighLight); - }//if (bFirstFound && (qtcHighLight.position()>qtcCurrent.position())) + } if (uiFoundCounttextBrowser->clear(); on_searchButton_clicked(false); ui->markButton->setChecked(false); + if (chatType() == CHATTYPE_LOBBY) { + if (notify) notify->chatLobbyCleared(chatId.toLobbyId(),""); + } } void ChatWidget::deleteChatHistory() @@ -1434,7 +1567,7 @@ void ChatWidget::updateTitle() ui->titleLabel->setText(RsHtml::plainText(name) + "@" + RsHtml::plainText(title)); } -void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QString& status_string) +void ChatWidget::updatePeersCustomStateString(const QString& /*peer_id*/, const QString& /*status_string*/) { QString status_text; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 2950cba65..abd6ae628 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -27,10 +27,12 @@ #include #include #include +#include #include "gui/common/HashBox.h" #include "gui/common/RsButtonOnText.h" #include "ChatStyle.h" #include "gui/style/RSStyle.h" +#include "ChatLobbyUserNotify.h" #include #include @@ -84,6 +86,9 @@ public: bool isTyping() { return typing; } void focusDialog(); + QToolButton* getNotifyButton(); + void setNotify(ChatLobbyUserNotify* clun); + void scrollToAnchor(QString anchor); void addToParent(QWidget *newParent); void removeFromParent(QWidget *oldParent); @@ -162,6 +167,8 @@ private slots: void toogle_MoveToCursor(); void toogle_SeachWithoutLimit(); + void on_notifyButton_clicked(); + void on_markButton_clicked(bool bValue); void chooseColor(); @@ -237,6 +244,7 @@ private: QCompleter *completer; QList mChatWidgetHolder; + ChatLobbyUserNotify* notify; Ui::ChatWidget *ui; }; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index f84275962..746345ec7 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -115,7 +115,7 @@ 0 - + @@ -159,7 +159,68 @@ + + + + + 28 + 28 + + + + + 28 + 28 + + + + Qt::NoFocus + + + + :/images/chat_red24.png:/images/chat_red24.png + + + + 24 + 24 + + + + true + + + + + + + 14 + 28 + + + + + 14 + 28 + + + + Qt::NoFocus + + + + :/images/arrow-right.png:/images/arrow-right.png + + + true + + + + + + + @@ -185,7 +246,7 @@ - + @@ -226,35 +287,6 @@ - - - - - - - - 14 - 28 - - - - - 14 - 28 - - - - Qt::NoFocus - - - - :/images/arrow-right.png:/images/arrow-right.png - - - true - - - diff --git a/retroshare-gui/src/gui/common/UserNotify.cpp b/retroshare-gui/src/gui/common/UserNotify.cpp index 7f8dc4e94..96cbf554b 100644 --- a/retroshare-gui/src/gui/common/UserNotify.cpp +++ b/retroshare-gui/src/gui/common/UserNotify.cpp @@ -116,6 +116,7 @@ void UserNotify::createIcons(QMenu *notifyMenu) if (mNotifyIcon == NULL) { mNotifyIcon = notifyMenu->addAction(getIcon(), "", this, SLOT(trayIconClicked())); mNotifyIcon->setVisible(false); + connect(mNotifyIcon, SIGNAL(hovered()), this, SLOT(trayIconHovered())); } } else { DELETE_OBJECT(mNotifyIcon); @@ -212,11 +213,16 @@ QString UserNotify::getNotifyMessage(bool plural) void UserNotify::trayIconClicked(QSystemTrayIcon::ActivationReason e) { - if (e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) { + if (e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick || e == QSystemTrayIcon::Context) { iconClicked(); } } +void UserNotify::trayIconHovered() +{ + iconHovered(); +} + void UserNotify::blink(bool on) { if (mTrayIcon) { diff --git a/retroshare-gui/src/gui/common/UserNotify.h b/retroshare-gui/src/gui/common/UserNotify.h index 1bda86fcc..42005982a 100644 --- a/retroshare-gui/src/gui/common/UserNotify.h +++ b/retroshare-gui/src/gui/common/UserNotify.h @@ -40,6 +40,8 @@ public: void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem); void createIcons(QMenu *notifyMenu); + QSystemTrayIcon* getTrayIcon(){ return mTrayIcon;} + QAction* getNotifyIcon(){ return mNotifyIcon;} virtual bool hasSetting(QString */*name*/, QString */*group*/) { return false; } bool notifyEnabled(); @@ -55,6 +57,7 @@ public slots: private slots: void trayIconClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger); + void trayIconHovered(); void blink(bool on); protected: @@ -70,6 +73,7 @@ private: virtual QString getNotifyMessage(bool plural); virtual void iconClicked() {} + virtual void iconHovered() {} private: QToolButton *mMainToolButton; diff --git a/retroshare-gui/src/gui/settings/ChatPage.cpp b/retroshare-gui/src/gui/settings/ChatPage.cpp index e7a1b5d33..6b48bf002 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.cpp +++ b/retroshare-gui/src/gui/settings/ChatPage.cpp @@ -131,6 +131,7 @@ ChatPage::save(QString &/*errmsg*/) Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked()); + Settings->setChatSearchShowBarByDefault(ui.cbSearch_ShowBar->isChecked()); Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value()); Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked()); Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked()); @@ -233,6 +234,7 @@ ChatPage::load() ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn()); + ui.cbSearch_ShowBar->setChecked(Settings->getChatSearchShowBarByDefault()); ui.sbSearch_CharToStart->setValue(Settings->getChatSearchCharToStartSearch()); ui.cbSearch_CaseSensitively->setChecked(Settings->getChatSearchCaseSensitively()); ui.cbSearch_WholeWords->setChecked(Settings->getChatSearchWholeWords()); diff --git a/retroshare-gui/src/gui/settings/ChatPage.ui b/retroshare-gui/src/gui/settings/ChatPage.ui index cc27e0fa4..43dadb5d2 100644 --- a/retroshare-gui/src/gui/settings/ChatPage.ui +++ b/retroshare-gui/src/gui/settings/ChatPage.ui @@ -314,6 +314,13 @@ 0 + + + + Show Bar by default + + + diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 6e2f8e56d..af91d10c9 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -43,6 +43,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.toasterButton, 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))) ; ui.notify_Blogs->hide(); @@ -74,6 +75,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) const QList &userNotifyList = MainWindow::getInstance()->getUserNotifyList(); QList::const_iterator it; row = 0; + mChatLobbyUserNotify = 0; for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) { UserNotify *userNotify = *it; @@ -96,6 +98,9 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) ui.notifyLayout->addWidget(blinkCheckBox, row++, 2); mUserNotifySettingList.push_back(UserNotifySetting(userNotify, enabledCheckBox, combinedCheckBox, blinkCheckBox)); + + //To get ChatLobbyUserNotify Settings + if (!mChatLobbyUserNotify) mChatLobbyUserNotify = dynamic_cast(*it); } /* Hide platform specific features */ @@ -205,6 +210,12 @@ NotifyPage::save(QString &/*errmsg*/) Settings->setToasterMargin(QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value())); + if (mChatLobbyUserNotify){ + mChatLobbyUserNotify->setCountUnRead(ui.chatLobbies_CountUnRead->isChecked()) ; + mChatLobbyUserNotify->setCheckForNickName(ui.chatLobbies_CheckNickName->isChecked()) ; + mChatLobbyUserNotify->setCountSpecificText(ui.chatLobbies_CountFollowingText->isChecked()) ; + mChatLobbyUserNotify->setTextToNotify(ui.chatLobbies_TextToNotify->document()->toPlainText()); + } load(); return true; } @@ -282,6 +293,15 @@ void NotifyPage::load() } notifyToggled(); + + ui.chatLobbies_TextToNotify->setEnabled(mChatLobbyUserNotify->isCountSpecificText()) ; + ui.chatLobbies_CountFollowingText->setChecked(mChatLobbyUserNotify->isCountSpecificText()) ; + + if (mChatLobbyUserNotify){ + ui.chatLobbies_CountUnRead->setChecked(mChatLobbyUserNotify->isCountUnRead()); + ui.chatLobbies_CheckNickName->setChecked(mChatLobbyUserNotify->isCheckForNickName()); + ui.chatLobbies_TextToNotify->setPlainText(mChatLobbyUserNotify->textToNotify()); + } } void NotifyPage::notifyToggled() diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index 88603c591..69d52fc5a 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -25,6 +25,8 @@ #include #include "ui_NotifyPage.h" +#include "gui/chat/ChatLobbyUserNotify.h" + class UserNotify; class FeedNotify; @@ -79,6 +81,7 @@ private slots: private: uint getNewsFlags(); uint getNotifyFlags(); + ChatLobbyUserNotify* mChatLobbyUserNotify; QList mFeedNotifySettingList; QList mUserNotifySettingList; diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui index 8e25187dc..d2109e678 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.ui +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -10,247 +10,103 @@ 512 - + - - - - - News Feed - - - - 0 - - - 6 - - - - - - - Friend Connect - - - - - - - Channels - - - - - - - Forums - - - - - - - Posted - - - - - - - Blogs - - - - - - - Messages - - - - - - - Chat - - - - - - - Security - - - - - - - - - - - - - - Test - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - Systray Icon - - - - - - - - - - - - Message - - - - - - Connect attempt + + + 3 + + + + Feed + + + + + + News Feed + + + + 0 + + + 6 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Disable All Toaster temporarily - - - Disable All Toasters - - - true - - - - - - - Toasters - - - - 9 - - - 9 - - - - + - + Friend Connect - + - New Message + Channels - + - Download completed + Forums - + - Private Chat + Posted - + - Group Chat + Blogs - + - Chat Lobby + Messages - + - Connect attempt + Chat + + + + Security + + + + + + - + - + Test - + Qt::Vertical @@ -265,126 +121,347 @@ - - - - - - - - 0 - 0 - - + + + + + + Message + + + + - Position - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - X Margin - - - - - - - - 0 - 0 - - - - 20 - - - - - - - - 0 - 0 - - - - Y Margin - - - - - - - - 0 - 0 - - - - 20 + Connect attempt - - - - - - - - Systray message - - - - - - Group chat + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Toasters + + + + + + Disable All Toaster temporarily + + + Disable All Toasters + + + true + + + + + + + Toasters + + + + 9 - - - - - - Chat lobbies + + 9 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + + + + + + Friend Connect + + + + + + + New Message + + + + + + + Download completed + + + + + + + Private Chat + + + + + + + Group Chat + + + + + + + Chat Lobby + + + + + + + Connect attempt + + + + + + + + + + + Test + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + 0 + 0 + + + + Position + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + X Margin + + + + + + + + 0 + 0 + + + + 20 + + + + + + + + 0 + 0 + + + + Y Margin + + + + + + + + 0 + 0 + + + + 20 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Systray + + + + + + Systray Icon + + + + + + + + + + + + Systray message + + + + + + Group chat + + + + + + + Chat lobbies + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Chat Lobbies + + + + + + Count all unread messages + + + + + + + Count occurences of my current nickname + + + + + + + Count occurences of any of the following texts (separate by newlines): + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index da361b77a..9f42a2bb2 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -496,6 +496,16 @@ void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue) setValueToGroup("Chat", "SendMessageWithCtrlReturn", bValue); } +bool RshareSettings::getChatSearchShowBarByDefault() +{ + return valueFromGroup("Chat", "SearchShowBarByDefault", false).toBool(); +} + +void RshareSettings::setChatSearchShowBarByDefault(bool bValue) +{ + setValueToGroup("Chat", "SearchShowBarByDefault", bValue); +} + void RshareSettings::setChatSearchCharToStartSearch(int iValue) { setValueToGroup("Chat", "SearchCharToStartSearch", iValue); diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 36246b2be..d00e20e8c 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -202,6 +202,9 @@ public: bool getChatSendMessageWithCtrlReturn(); void setChatSendMessageWithCtrlReturn(bool bValue); + bool getChatSearchShowBarByDefault(); + void setChatSearchShowBarByDefault(bool bValue); + void setChatSearchCharToStartSearch(int iValue); int getChatSearchCharToStartSearch();