mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -04:00
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
This commit is contained in:
parent
9d2b6faf9c
commit
e40460bdcc
18 changed files with 1045 additions and 392 deletions
|
@ -55,6 +55,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags)
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
m_bProcessSettings = false;
|
m_bProcessSettings = false;
|
||||||
|
myChatLobbyUserNotify = NULL;
|
||||||
|
|
||||||
QObject::connect( NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged()));
|
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&)));
|
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)
|
UserNotify *ChatLobbyWidget::getUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
ChatLobbyUserNotify *notify = new ChatLobbyUserNotify(parent);
|
if (!myChatLobbyUserNotify){
|
||||||
connect(this, SIGNAL(unreadCountChanged(uint)), notify, SLOT(unreadCountChanged(uint)));
|
myChatLobbyUserNotify = new ChatLobbyUserNotify(parent);
|
||||||
|
connect(myChatLobbyUserNotify, SIGNAL(countChanged(ChatLobbyId, unsigned int)), this, SLOT(updateNotify(ChatLobbyId, unsigned int)));
|
||||||
|
}
|
||||||
|
return myChatLobbyUserNotify;
|
||||||
|
}
|
||||||
|
|
||||||
notify->unreadCountChanged(unreadCount());
|
void ChatLobbyWidget::updateNotify(ChatLobbyId id, unsigned int count)
|
||||||
|
{
|
||||||
|
ChatLobbyDialog *dialog=NULL;
|
||||||
|
dialog=_lobby_infos[id].dialog;
|
||||||
|
if(!dialog) return;
|
||||||
|
|
||||||
return notify;
|
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)
|
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(lobbyLeave(ChatLobbyId)),this,SLOT(unsubscribeChatLobby(ChatLobbyId))) ;
|
||||||
connect(d,SIGNAL(typingEventReceived(ChatLobbyId)),this,SLOT(updateTypingStatus(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(peerJoined(ChatLobbyId)),this,SLOT(updatePeerEntering(ChatLobbyId))) ;
|
||||||
connect(d,SIGNAL(peerLeft(ChatLobbyId)),this,SLOT(updatePeerLeaving(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].dialog = d ;
|
||||||
_lobby_infos[id].default_icon = QIcon() ;
|
_lobby_infos[id].default_icon = QIcon() ;
|
||||||
_lobby_infos[id].last_typing_event = time(NULL) ;
|
_lobby_infos[id].last_typing_event = time(NULL) ;
|
||||||
_lobby_infos[id].unread_count = 0;
|
|
||||||
|
|
||||||
ChatLobbyInfo linfo ;
|
ChatLobbyInfo linfo ;
|
||||||
if(rsMsgs->getChatLobbyInfo(id,linfo))
|
if(rsMsgs->getChatLobbyInfo(id,linfo))
|
||||||
|
@ -619,6 +636,7 @@ void ChatLobbyWidget::showLobby(QTreeWidgetItem *item)
|
||||||
else
|
else
|
||||||
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
|
ui.stackedWidget->setCurrentWidget(_lobby_infos[id].dialog) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::subscribeChatLobbyAs()
|
void ChatLobbyWidget::subscribeChatLobbyAs()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
|
QTreeWidgetItem *item = ui.lobbyTreeWidget->currentItem();
|
||||||
|
@ -638,6 +656,31 @@ void ChatLobbyWidget::subscribeChatLobbyAs()
|
||||||
if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
|
if(rsMsgs->joinVisibleChatLobby(id,gxs_id))
|
||||||
ChatDialog::chatFriend(ChatId(id),true) ;
|
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<ChatLobbyDialog *>(ui.stackedWidget->currentWidget())))
|
||||||
|
cldCW->getChatWidget()->scrollToAnchor(anchor);
|
||||||
|
|
||||||
|
ui.lobbyTreeWidget->setCurrentItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
|
void ChatLobbyWidget::subscribeChatLobbyAtItem(QTreeWidgetItem *item)
|
||||||
{
|
{
|
||||||
if (item == NULL || item->type() != TYPE_LOBBY) {
|
if (item == NULL || item->type() != TYPE_LOBBY) {
|
||||||
|
@ -810,9 +853,12 @@ void ChatLobbyWidget::unsubscribeChatLobby(ChatLobbyId id)
|
||||||
|
|
||||||
if(it != _lobby_infos.end())
|
if(it != _lobby_infos.end())
|
||||||
{
|
{
|
||||||
|
if (myChatLobbyUserNotify){
|
||||||
|
myChatLobbyUserNotify->chatLobbyCleared(id, "");
|
||||||
|
}
|
||||||
|
|
||||||
ui.stackedWidget->removeWidget(it->second.dialog) ;
|
ui.stackedWidget->removeWidget(it->second.dialog) ;
|
||||||
_lobby_infos.erase(it) ;
|
_lobby_infos.erase(it) ;
|
||||||
emit unreadCountChanged(unreadCount());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unsubscribe the chat lobby
|
// Unsubscribe the chat lobby
|
||||||
|
@ -852,10 +898,7 @@ void ChatLobbyWidget::updateCurrentLobby()
|
||||||
int iPrivacyLevel= item->parent()->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt();
|
int iPrivacyLevel= item->parent()->data(COLUMN_DATA, ROLE_PRIVACYLEVEL).toInt();
|
||||||
QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
QIcon icon = (iPrivacyLevel==CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) ? QIcon(IMAGE_PUBLIC) : QIcon(IMAGE_PRIVATE);
|
||||||
_lobby_infos[id].default_icon = icon ;
|
_lobby_infos[id].default_icon = icon ;
|
||||||
_lobby_infos[id].unread_count = 0;
|
|
||||||
item->setIcon(COLUMN_NAME, icon) ;
|
item->setIcon(COLUMN_NAME, icon) ;
|
||||||
|
|
||||||
emit unreadCountChanged(unreadCount());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,19 +906,21 @@ void ChatLobbyWidget::updateCurrentLobby()
|
||||||
filterItems(ui.filterLineEdit->text());
|
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();
|
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.
|
// Don't show anything for current lobby.
|
||||||
//
|
//
|
||||||
if(current_item != NULL && current_item->data(COLUMN_DATA, ROLE_ID).toULongLong() == id)
|
if(bIsCurrentItem)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
_lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ;
|
_lobby_infos[id].default_icon = QIcon(IMAGE_MESSAGE) ;
|
||||||
++_lobby_infos[id].unread_count;
|
|
||||||
|
|
||||||
emit unreadCountChanged(unreadCount());
|
|
||||||
|
|
||||||
QTreeWidgetItem *item = getTreeWidgetItem(id) ;
|
QTreeWidgetItem *item = getTreeWidgetItem(id) ;
|
||||||
|
|
||||||
|
@ -1054,14 +1099,3 @@ int ChatLobbyWidget::getNumColVisible()
|
||||||
}
|
}
|
||||||
return iNumColVis;
|
return iNumColVis;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint ChatLobbyWidget::unreadCount()
|
|
||||||
{
|
|
||||||
uint count = 0;
|
|
||||||
|
|
||||||
for (std::map<ChatLobbyId,ChatLobbyInfoStruct>::iterator it = _lobby_infos.begin(); it != _lobby_infos.end(); ++it) {
|
|
||||||
count += it->second.unread_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
#include "ui_ChatLobbyWidget.h"
|
#include "ui_ChatLobbyWidget.h"
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
|
#include "chat/ChatLobbyUserNotify.h"
|
||||||
|
|
||||||
#define IMAGE_CHATLOBBY ":/images/chat_32.png"
|
#define IMAGE_CHATLOBBY ":/images/chat_32.png"
|
||||||
|
|
||||||
|
@ -20,7 +21,6 @@ struct ChatLobbyInfoStruct
|
||||||
QIcon default_icon ;
|
QIcon default_icon ;
|
||||||
ChatLobbyDialog *dialog ;
|
ChatLobbyDialog *dialog ;
|
||||||
time_t last_typing_event ;
|
time_t last_typing_event ;
|
||||||
uint unread_count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatLobbyWidget : public RsAutoUpdatePage
|
class ChatLobbyWidget : public RsAutoUpdatePage
|
||||||
|
@ -38,12 +38,13 @@ public:
|
||||||
virtual QString pageName() const { return tr("Chat Lobbies") ; } //MainPage
|
virtual QString pageName() const { return tr("Chat Lobbies") ; } //MainPage
|
||||||
virtual QString helpText() const { return ""; } //MainPage
|
virtual QString helpText() const { return ""; } //MainPage
|
||||||
|
|
||||||
virtual UserNotify *getUserNotify(QObject *parent);
|
virtual UserNotify *getUserNotify(QObject *parent); //MainPage
|
||||||
|
|
||||||
virtual void updateDisplay();
|
virtual void updateDisplay();
|
||||||
|
|
||||||
void setCurrentChatPage(ChatLobbyDialog *) ; // used by ChatLobbyDialog to raise.
|
void setCurrentChatPage(ChatLobbyDialog *) ; // used by ChatLobbyDialog to raise.
|
||||||
void addChatPage(ChatLobbyDialog *) ;
|
void addChatPage(ChatLobbyDialog *) ;
|
||||||
|
void showLobbyAnchor(ChatLobbyId id, QString anchor) ;
|
||||||
|
|
||||||
uint unreadCount();
|
uint unreadCount();
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ protected slots:
|
||||||
void subscribeChatLobbyAs() ;
|
void subscribeChatLobbyAs() ;
|
||||||
void updateTypingStatus(ChatLobbyId id) ;
|
void updateTypingStatus(ChatLobbyId id) ;
|
||||||
void resetLobbyTreeIcons() ;
|
void resetLobbyTreeIcons() ;
|
||||||
void updateMessageChanged(ChatLobbyId);
|
void updateMessageChanged(bool incoming, ChatLobbyId, QDateTime time, QString senderName, QString msg);
|
||||||
void updatePeerEntering(ChatLobbyId);
|
void updatePeerEntering(ChatLobbyId);
|
||||||
void updatePeerLeaving(ChatLobbyId);
|
void updatePeerLeaving(ChatLobbyId);
|
||||||
void autoSubscribeItem();
|
void autoSubscribeItem();
|
||||||
|
@ -75,11 +76,12 @@ private slots:
|
||||||
void filterColumnChanged(int);
|
void filterColumnChanged(int);
|
||||||
void filterItems(const QString &text);
|
void filterItems(const QString &text);
|
||||||
|
|
||||||
|
|
||||||
void setShowUserCountColumn(bool show);
|
void setShowUserCountColumn(bool show);
|
||||||
void setShowTopicColumn(bool show);
|
void setShowTopicColumn(bool show);
|
||||||
void setShowSubscribeColumn(bool show);
|
void setShowSubscribeColumn(bool show);
|
||||||
|
|
||||||
|
void updateNotify(ChatLobbyId id, unsigned int count) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void autoSubscribeLobby(QTreeWidgetItem *item);
|
void autoSubscribeLobby(QTreeWidgetItem *item);
|
||||||
void subscribeChatLobby(ChatLobbyId id) ;
|
void subscribeChatLobby(ChatLobbyId id) ;
|
||||||
|
@ -109,6 +111,8 @@ private:
|
||||||
QAction* showSubscribeAct;
|
QAction* showSubscribeAct;
|
||||||
int getNumColVisible();
|
int getNumColVisible();
|
||||||
|
|
||||||
|
ChatLobbyUserNotify* myChatLobbyUserNotify;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::ChatLobbyWidget ui;
|
Ui::ChatLobbyWidget ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -336,7 +336,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg)
|
||||||
name = QString::fromUtf8(msg.peer_alternate_nickname.c_str()) + " (" + QString::fromStdString(gxs_id.toStdString()) + ")" ;
|
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);
|
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.
|
// This is a trick to translate HTML into text.
|
||||||
QTextEdit editor;
|
QTextEdit editor;
|
||||||
|
|
|
@ -56,7 +56,7 @@ private slots:
|
||||||
signals:
|
signals:
|
||||||
void lobbyLeave(ChatLobbyId) ;
|
void lobbyLeave(ChatLobbyId) ;
|
||||||
void typingEventReceived(ChatLobbyId) ;
|
void typingEventReceived(ChatLobbyId) ;
|
||||||
void messageReceived(ChatLobbyId) ;
|
void messageReceived(bool incoming, ChatLobbyId lobby_id, QDateTime time, QString senderName, QString msg) ;
|
||||||
void peerJoined(ChatLobbyId) ;
|
void peerJoined(ChatLobbyId) ;
|
||||||
void peerLeft(ChatLobbyId) ;
|
void peerLeft(ChatLobbyId) ;
|
||||||
|
|
||||||
|
|
|
@ -19,23 +19,77 @@
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
#include <QTime>
|
||||||
|
#include <QMenu>
|
||||||
#include "ChatLobbyUserNotify.h"
|
#include "ChatLobbyUserNotify.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
#include "gui/ChatLobbyWidget.h"
|
||||||
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
#include "util/DateTime.h"
|
||||||
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) :
|
ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) :
|
||||||
UserNotify(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)
|
bool ChatLobbyUserNotify::hasSetting(QString *name, QString *group)
|
||||||
{
|
{
|
||||||
if (name) *name = tr("Chat Lobbies");
|
if (name) *name = _name;
|
||||||
if (group) *group = "ChatLobby";
|
if (group) *group = _group;
|
||||||
|
|
||||||
return true;
|
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()
|
QIcon ChatLobbyUserNotify::getIcon()
|
||||||
{
|
{
|
||||||
return QIcon(":/images/chat_32.png");
|
return QIcon(":/images/chat_32.png");
|
||||||
|
@ -48,17 +102,229 @@ QIcon ChatLobbyUserNotify::getMainIcon(bool hasNew)
|
||||||
|
|
||||||
unsigned int ChatLobbyUserNotify::getNewCount()
|
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()
|
void ChatLobbyUserNotify::iconClicked()
|
||||||
{
|
{
|
||||||
MainWindow::showWindow(MainWindow::ChatLobby);
|
/// Tray icon Menu ///
|
||||||
|
QMenu* trayMenu = new QMenu(MainWindow::getInstance());
|
||||||
|
std::list<ChatLobbyId> 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<ChatLobbyId>::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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyUserNotify::unreadCountChanged(unsigned int unreadCount)
|
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::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<ActionTag>();
|
||||||
|
if(!actionTag.removeALL){
|
||||||
|
MainWindow::showWindow(MainWindow::ChatLobby);
|
||||||
|
ChatLobbyWidget *chatLobbyWidget = dynamic_cast<ChatLobbyWidget*>(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<QMenu*>(action->parent());
|
||||||
|
if (lobbyMenu) lobbyMenu->removeAction(action);
|
||||||
|
|
||||||
updateIcon();
|
updateIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatLobbyUserNotify::subMenuHovered(QAction* action)
|
||||||
|
{
|
||||||
|
QMenu *lobbyMenu=dynamic_cast<QMenu*>(action->parent());
|
||||||
|
if (lobbyMenu) lobbyMenu->setToolTip(action->toolTip());
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,22 @@
|
||||||
#define CHATLOBBYUSERNOTIFY_H
|
#define CHATLOBBYUSERNOTIFY_H
|
||||||
|
|
||||||
#include "gui/common/UserNotify.h"
|
#include "gui/common/UserNotify.h"
|
||||||
|
#include <retroshare/rsmsgs.h>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
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
|
class ChatLobbyUserNotify : public UserNotify
|
||||||
{
|
{
|
||||||
|
@ -32,18 +48,46 @@ public:
|
||||||
ChatLobbyUserNotify(QObject *parent = 0);
|
ChatLobbyUserNotify(QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool hasSetting(QString *name, QString *group);
|
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:
|
signals:
|
||||||
void unreadCountChanged(uint unreadCount);
|
void countChanged(ChatLobbyId id, unsigned int count);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void subMenuClicked(QAction* action);
|
||||||
|
void subMenuHovered(QAction* action);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QIcon getIcon();
|
virtual QIcon getIcon();
|
||||||
virtual QIcon getMainIcon(bool hasNew);
|
virtual QIcon getMainIcon(bool hasNew);
|
||||||
virtual unsigned int getNewCount();
|
virtual unsigned int getNewCount();
|
||||||
|
virtual QString getTrayMessage(bool plural);
|
||||||
|
virtual QString getNotifyMessage(bool plural);
|
||||||
virtual void iconClicked();
|
virtual void iconClicked();
|
||||||
|
virtual void iconHovered();
|
||||||
|
bool checkWord(QString msg, QString word);
|
||||||
|
|
||||||
private:
|
QString _name;
|
||||||
uint mUnreadCount;
|
QString _group;
|
||||||
|
|
||||||
|
typedef std::map<QString, MsgData> msg_map;
|
||||||
|
typedef std::map<ChatLobbyId, msg_map> lobby_map;
|
||||||
|
lobby_map _listMsg;
|
||||||
|
QStringList _textToNotify;
|
||||||
|
bool _bCheckForNickName;
|
||||||
|
bool _bCountUnRead;
|
||||||
|
bool _bCountSpecificText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHATLOBBYUSERNOTIFY_H
|
#endif // CHATLOBBYUSERNOTIFY_H
|
||||||
|
|
|
@ -31,10 +31,12 @@
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
|
#include <QToolTip>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
|
|
||||||
#include "ChatWidget.h"
|
#include "ChatWidget.h"
|
||||||
#include "ui_ChatWidget.h"
|
#include "ui_ChatWidget.h"
|
||||||
|
#include "gui/MainWindow.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/RetroShareLink.h"
|
#include "gui/RetroShareLink.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
@ -44,9 +46,11 @@
|
||||||
#include "gui/common/StatusDefs.h"
|
#include "gui/common/StatusDefs.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
#include "gui/common/Emoticons.h"
|
#include "gui/common/Emoticons.h"
|
||||||
|
#include "gui/chat/ChatLobbyDialog.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "util/HandleRichText.h"
|
#include "util/HandleRichText.h"
|
||||||
#include "gui/chat/ChatUserNotify.h"
|
#include "gui/chat/ChatUserNotify.h"//For BradCast
|
||||||
|
#include "util/DateTime.h"
|
||||||
|
|
||||||
#include <retroshare/rsstatus.h>
|
#include <retroshare/rsstatus.h>
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
@ -104,6 +108,9 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||||
connect(ui->searchButton, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuSearchButton(QPoint)));
|
connect(ui->searchButton, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuSearchButton(QPoint)));
|
||||||
connect(ui->actionSearch_History, SIGNAL(triggered()), this, SLOT(searchHistory()));
|
connect(ui->actionSearch_History, SIGNAL(triggered()), this, SLOT(searchHistory()));
|
||||||
|
|
||||||
|
notify=NULL;
|
||||||
|
ui->notifyButton->setVisible(false);
|
||||||
|
|
||||||
ui->markButton->setToolTip(tr("<b>Mark this selected text</b><br><i>Ctrl+M</i>"));
|
ui->markButton->setToolTip(tr("<b>Mark this selected text</b><br><i>Ctrl+M</i>"));
|
||||||
|
|
||||||
connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendChat()));
|
connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendChat()));
|
||||||
|
@ -135,7 +142,8 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||||
ui->infoFrame->setVisible(false);
|
ui->infoFrame->setVisible(false);
|
||||||
ui->statusMessageLabel->hide();
|
ui->statusMessageLabel->hide();
|
||||||
|
|
||||||
ui->searchframe->hide();
|
ui->actionSearch_History->setChecked(Settings->getChatSearchShowBarByDefault());
|
||||||
|
searchHistory();
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
ui->chatTextEdit->setAcceptDrops(false);
|
ui->chatTextEdit->setAcceptDrops(false);
|
||||||
|
@ -156,8 +164,11 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
||||||
menu->addAction(ui->actionSearch_History);
|
menu->addAction(ui->actionSearch_History);
|
||||||
ui->pushtoolsButton->setMenu(menu);
|
ui->pushtoolsButton->setMenu(menu);
|
||||||
|
|
||||||
ui->chatTextEdit->installEventFilter(this);
|
|
||||||
ui->textBrowser->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
|
#if QT_VERSION < 0x040700
|
||||||
// embedded images are not supported before QT 4.7.0
|
// 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)
|
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) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
|
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(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("<a\\s+name\\s*=\\s*\"(.*)\"",Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||||
|
rx.setMinimal(true);
|
||||||
|
QString sel=cursor.selection().toHtml();
|
||||||
|
QStringList anchors;
|
||||||
|
int pos=0;
|
||||||
|
while ((pos = rx.indexIn(sel,pos)) != -1) {
|
||||||
|
anchors << rx.cap(1);
|
||||||
|
pos += rx.matchedLength();
|
||||||
}
|
}
|
||||||
|
if (!anchors.isEmpty()){
|
||||||
|
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())
|
||||||
|
,obj != ui->textBrowser && obj != ui->textBrowser->viewport());//, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (obj == ui->textBrowser) {
|
if (obj == ui->textBrowser) {
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
|
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
if (keyEvent) {
|
if (keyEvent) {
|
||||||
if (keyEvent->key() == Qt::Key_Delete ) {
|
if (keyEvent->key() == Qt::Key_Delete ) {
|
||||||
// Delete pressed
|
// Delete key pressed
|
||||||
if (ui->textBrowser->textCursor().selectedText().length()>0)
|
if (ui->textBrowser->textCursor().selectedText().length() > 0) {
|
||||||
|
if (chatType() == CHATTYPE_LOBBY) {
|
||||||
|
QRegExp rx("<a\\s+name\\s*=\\s*\"(.*)\"",Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||||
|
rx.setMinimal(true);
|
||||||
|
QString sel=ui->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();
|
ui->textBrowser->textCursor().deleteChar();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (keyEvent->key() == Qt::Key_M && keyEvent->modifiers() == Qt::ControlModifier)
|
if (keyEvent->key() == Qt::Key_M && keyEvent->modifiers() == Qt::ControlModifier)
|
||||||
{
|
{
|
||||||
on_markButton_clicked(!ui->markButton->isChecked());
|
on_markButton_clicked(!ui->markButton->isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event->type() == QEvent::ToolTip) {
|
||||||
|
QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event);
|
||||||
|
QTextCursor cursor = ui->textBrowser->cursorForPosition(helpEvent->pos());
|
||||||
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
|
QString toolTipText = "";
|
||||||
|
if (!cursor.selectedText().isEmpty()){
|
||||||
|
QRegExp rx("<a\\s+name\\s*=\\s*\"(.*)\"",Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||||
|
rx.setMinimal(true);
|
||||||
|
QString sel=cursor.selection().toHtml();
|
||||||
|
QStringList anchors;
|
||||||
|
int pos=0;
|
||||||
|
while ((pos = rx.indexIn(sel,pos)) != -1) {
|
||||||
|
anchors << rx.cap(1);
|
||||||
|
pos += rx.matchedLength();
|
||||||
|
}
|
||||||
|
if (!anchors.isEmpty()){
|
||||||
|
toolTipText = anchors.at(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!toolTipText.isEmpty()){
|
||||||
|
QToolTip::showText(helpEvent->globalPos(), toolTipText);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
QToolTip::hideText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (obj == ui->chatTextEdit) {
|
} else if (obj == ui->chatTextEdit) {
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
|
|
||||||
|
@ -691,6 +788,35 @@ void ChatWidget::focusDialog()
|
||||||
ui->chatTextEdit->setFocus();
|
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)
|
void ChatWidget::setWelcomeMessage(QString &text)
|
||||||
{
|
{
|
||||||
ui->textBrowser->setText(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 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("<a name=\"%1_%2\"/>").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->textCursor().setBlockFormat(QTextBlockFormat ());
|
||||||
ui->textBrowser->append(formatMsg);
|
ui->textBrowser->append(formatMsg);
|
||||||
|
|
||||||
|
@ -1074,13 +1204,13 @@ bool ChatWidget::findText(const QString& qsStringToFind, bool bBackWard, bool bF
|
||||||
qtcCurrent=qtcHighLight;
|
qtcCurrent=qtcHighLight;
|
||||||
if (bMoveToCursor || bForceMove) ui->textBrowser->setTextCursor(qtcHighLight);
|
if (bMoveToCursor || bForceMove) ui->textBrowser->setTextCursor(qtcHighLight);
|
||||||
|
|
||||||
}//if (bFirstFound && (qtcHighLight.position()>qtcCurrent.position()))
|
}
|
||||||
|
|
||||||
|
|
||||||
if (uiFoundCount<UINT_MAX)
|
if (uiFoundCount<UINT_MAX)
|
||||||
uiFoundCount+=1;
|
uiFoundCount+=1;
|
||||||
}//if(!qtcHighLight.isNull())
|
}
|
||||||
}//while(!qtcHighLight.isNull() && !qtcHighLight.atEnd())
|
}
|
||||||
|
|
||||||
if (bFound)
|
if (bFound)
|
||||||
{
|
{
|
||||||
|
@ -1218,6 +1348,9 @@ void ChatWidget::clearChatHistory()
|
||||||
ui->textBrowser->clear();
|
ui->textBrowser->clear();
|
||||||
on_searchButton_clicked(false);
|
on_searchButton_clicked(false);
|
||||||
ui->markButton->setChecked(false);
|
ui->markButton->setChecked(false);
|
||||||
|
if (chatType() == CHATTYPE_LOBBY) {
|
||||||
|
if (notify) notify->chatLobbyCleared(chatId.toLobbyId(),"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::deleteChatHistory()
|
void ChatWidget::deleteChatHistory()
|
||||||
|
@ -1434,7 +1567,7 @@ void ChatWidget::updateTitle()
|
||||||
ui->titleLabel->setText(RsHtml::plainText(name) + "@" + RsHtml::plainText(title));
|
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;
|
QString status_text;
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,12 @@
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
|
#include <QToolButton>
|
||||||
#include "gui/common/HashBox.h"
|
#include "gui/common/HashBox.h"
|
||||||
#include "gui/common/RsButtonOnText.h"
|
#include "gui/common/RsButtonOnText.h"
|
||||||
#include "ChatStyle.h"
|
#include "ChatStyle.h"
|
||||||
#include "gui/style/RSStyle.h"
|
#include "gui/style/RSStyle.h"
|
||||||
|
#include "ChatLobbyUserNotify.h"
|
||||||
|
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
#include <retroshare/rsfiles.h>
|
#include <retroshare/rsfiles.h>
|
||||||
|
@ -84,6 +86,9 @@ public:
|
||||||
bool isTyping() { return typing; }
|
bool isTyping() { return typing; }
|
||||||
|
|
||||||
void focusDialog();
|
void focusDialog();
|
||||||
|
QToolButton* getNotifyButton();
|
||||||
|
void setNotify(ChatLobbyUserNotify* clun);
|
||||||
|
void scrollToAnchor(QString anchor);
|
||||||
void addToParent(QWidget *newParent);
|
void addToParent(QWidget *newParent);
|
||||||
void removeFromParent(QWidget *oldParent);
|
void removeFromParent(QWidget *oldParent);
|
||||||
|
|
||||||
|
@ -162,6 +167,8 @@ private slots:
|
||||||
void toogle_MoveToCursor();
|
void toogle_MoveToCursor();
|
||||||
void toogle_SeachWithoutLimit();
|
void toogle_SeachWithoutLimit();
|
||||||
|
|
||||||
|
void on_notifyButton_clicked();
|
||||||
|
|
||||||
void on_markButton_clicked(bool bValue);
|
void on_markButton_clicked(bool bValue);
|
||||||
|
|
||||||
void chooseColor();
|
void chooseColor();
|
||||||
|
@ -237,6 +244,7 @@ private:
|
||||||
QCompleter *completer;
|
QCompleter *completer;
|
||||||
|
|
||||||
QList<ChatWidgetHolder*> mChatWidgetHolder;
|
QList<ChatWidgetHolder*> mChatWidgetHolder;
|
||||||
|
ChatLobbyUserNotify* notify;
|
||||||
|
|
||||||
Ui::ChatWidget *ui;
|
Ui::ChatWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="4">
|
<item row="0" column="5">
|
||||||
<widget class="QToolButton" name="searchButton">
|
<widget class="QToolButton" name="searchButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
@ -159,7 +159,68 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QToolButton" name="notifyButton">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>28</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/chat_red24.png</normaloff>:/images/chat_red24.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="3">
|
||||||
|
<widget class="QToolButton" name="searchAfter">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>14</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>14</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/arrow-right.png</normaloff>:/images/arrow-right.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="autoRaise">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="LineEditClear" name="leSearch"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
<widget class="QToolButton" name="searchBefore">
|
<widget class="QToolButton" name="searchBefore">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -185,7 +246,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="1">
|
||||||
<widget class="QToolButton" name="markButton">
|
<widget class="QToolButton" name="markButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
@ -226,35 +287,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="LineEditClear" name="leSearch"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QToolButton" name="searchAfter">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>14</width>
|
|
||||||
<height>28</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>14</width>
|
|
||||||
<height>28</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::NoFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/arrow-right.png</normaloff>:/images/arrow-right.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="autoRaise">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -116,6 +116,7 @@ void UserNotify::createIcons(QMenu *notifyMenu)
|
||||||
if (mNotifyIcon == NULL) {
|
if (mNotifyIcon == NULL) {
|
||||||
mNotifyIcon = notifyMenu->addAction(getIcon(), "", this, SLOT(trayIconClicked()));
|
mNotifyIcon = notifyMenu->addAction(getIcon(), "", this, SLOT(trayIconClicked()));
|
||||||
mNotifyIcon->setVisible(false);
|
mNotifyIcon->setVisible(false);
|
||||||
|
connect(mNotifyIcon, SIGNAL(hovered()), this, SLOT(trayIconHovered()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DELETE_OBJECT(mNotifyIcon);
|
DELETE_OBJECT(mNotifyIcon);
|
||||||
|
@ -212,11 +213,16 @@ QString UserNotify::getNotifyMessage(bool plural)
|
||||||
|
|
||||||
void UserNotify::trayIconClicked(QSystemTrayIcon::ActivationReason e)
|
void UserNotify::trayIconClicked(QSystemTrayIcon::ActivationReason e)
|
||||||
{
|
{
|
||||||
if (e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {
|
if (e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick || e == QSystemTrayIcon::Context) {
|
||||||
iconClicked();
|
iconClicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserNotify::trayIconHovered()
|
||||||
|
{
|
||||||
|
iconHovered();
|
||||||
|
}
|
||||||
|
|
||||||
void UserNotify::blink(bool on)
|
void UserNotify::blink(bool on)
|
||||||
{
|
{
|
||||||
if (mTrayIcon) {
|
if (mTrayIcon) {
|
||||||
|
|
|
@ -40,6 +40,8 @@ public:
|
||||||
|
|
||||||
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem);
|
void initialize(QToolBar *mainToolBar, QAction *mainAction, QListWidgetItem *listItem);
|
||||||
void createIcons(QMenu *notifyMenu);
|
void createIcons(QMenu *notifyMenu);
|
||||||
|
QSystemTrayIcon* getTrayIcon(){ return mTrayIcon;}
|
||||||
|
QAction* getNotifyIcon(){ return mNotifyIcon;}
|
||||||
|
|
||||||
virtual bool hasSetting(QString */*name*/, QString */*group*/) { return false; }
|
virtual bool hasSetting(QString */*name*/, QString */*group*/) { return false; }
|
||||||
bool notifyEnabled();
|
bool notifyEnabled();
|
||||||
|
@ -55,6 +57,7 @@ public slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void trayIconClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
void trayIconClicked(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
||||||
|
void trayIconHovered();
|
||||||
void blink(bool on);
|
void blink(bool on);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -70,6 +73,7 @@ private:
|
||||||
virtual QString getNotifyMessage(bool plural);
|
virtual QString getNotifyMessage(bool plural);
|
||||||
|
|
||||||
virtual void iconClicked() {}
|
virtual void iconClicked() {}
|
||||||
|
virtual void iconHovered() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QToolButton *mMainToolButton;
|
QToolButton *mMainToolButton;
|
||||||
|
|
|
@ -131,6 +131,7 @@ ChatPage::save(QString &/*errmsg*/)
|
||||||
|
|
||||||
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
|
Settings->setChatSendMessageWithCtrlReturn(ui.sendMessageWithCtrlReturn->isChecked());
|
||||||
|
|
||||||
|
Settings->setChatSearchShowBarByDefault(ui.cbSearch_ShowBar->isChecked());
|
||||||
Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value());
|
Settings->setChatSearchCharToStartSearch(ui.sbSearch_CharToStart->value());
|
||||||
Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked());
|
Settings->setChatSearchCaseSensitively(ui.cbSearch_CaseSensitively->isChecked());
|
||||||
Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked());
|
Settings->setChatSearchWholeWords(ui.cbSearch_WholeWords->isChecked());
|
||||||
|
@ -233,6 +234,7 @@ ChatPage::load()
|
||||||
|
|
||||||
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
|
ui.sendMessageWithCtrlReturn->setChecked(Settings->getChatSendMessageWithCtrlReturn());
|
||||||
|
|
||||||
|
ui.cbSearch_ShowBar->setChecked(Settings->getChatSearchShowBarByDefault());
|
||||||
ui.sbSearch_CharToStart->setValue(Settings->getChatSearchCharToStartSearch());
|
ui.sbSearch_CharToStart->setValue(Settings->getChatSearchCharToStartSearch());
|
||||||
ui.cbSearch_CaseSensitively->setChecked(Settings->getChatSearchCaseSensitively());
|
ui.cbSearch_CaseSensitively->setChecked(Settings->getChatSearchCaseSensitively());
|
||||||
ui.cbSearch_WholeWords->setChecked(Settings->getChatSearchWholeWords());
|
ui.cbSearch_WholeWords->setChecked(Settings->getChatSearchWholeWords());
|
||||||
|
|
|
@ -314,6 +314,13 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cbSearch_ShowBar">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show Bar by default</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="hlSearch_CharToStart">
|
<layout class="QHBoxLayout" name="hlSearch_CharToStart">
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -43,6 +43,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||||
connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster()));
|
connect(ui.toasterButton, 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))) ;
|
||||||
|
|
||||||
ui.notify_Blogs->hide();
|
ui.notify_Blogs->hide();
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||||
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
|
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
|
||||||
QList<UserNotify*>::const_iterator it;
|
QList<UserNotify*>::const_iterator it;
|
||||||
row = 0;
|
row = 0;
|
||||||
|
mChatLobbyUserNotify = 0;
|
||||||
for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) {
|
for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) {
|
||||||
UserNotify *userNotify = *it;
|
UserNotify *userNotify = *it;
|
||||||
|
|
||||||
|
@ -96,6 +98,9 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags)
|
||||||
ui.notifyLayout->addWidget(blinkCheckBox, row++, 2);
|
ui.notifyLayout->addWidget(blinkCheckBox, row++, 2);
|
||||||
|
|
||||||
mUserNotifySettingList.push_back(UserNotifySetting(userNotify, enabledCheckBox, combinedCheckBox, blinkCheckBox));
|
mUserNotifySettingList.push_back(UserNotifySetting(userNotify, enabledCheckBox, combinedCheckBox, blinkCheckBox));
|
||||||
|
|
||||||
|
//To get ChatLobbyUserNotify Settings
|
||||||
|
if (!mChatLobbyUserNotify) mChatLobbyUserNotify = dynamic_cast<ChatLobbyUserNotify*>(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hide platform specific features */
|
/* Hide platform specific features */
|
||||||
|
@ -205,6 +210,12 @@ NotifyPage::save(QString &/*errmsg*/)
|
||||||
|
|
||||||
Settings->setToasterMargin(QPoint(ui.spinBoxToasterXMargin->value(), ui.spinBoxToasterYMargin->value()));
|
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();
|
load();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -282,6 +293,15 @@ void NotifyPage::load()
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyToggled();
|
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()
|
void NotifyPage::notifyToggled()
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#include <retroshare-gui/configpage.h>
|
#include <retroshare-gui/configpage.h>
|
||||||
#include "ui_NotifyPage.h"
|
#include "ui_NotifyPage.h"
|
||||||
|
|
||||||
|
#include "gui/chat/ChatLobbyUserNotify.h"
|
||||||
|
|
||||||
class UserNotify;
|
class UserNotify;
|
||||||
class FeedNotify;
|
class FeedNotify;
|
||||||
|
|
||||||
|
@ -79,6 +81,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
uint getNewsFlags();
|
uint getNewsFlags();
|
||||||
uint getNotifyFlags();
|
uint getNotifyFlags();
|
||||||
|
ChatLobbyUserNotify* mChatLobbyUserNotify;
|
||||||
|
|
||||||
QList<FeedNotifySetting> mFeedNotifySettingList;
|
QList<FeedNotifySetting> mFeedNotifySettingList;
|
||||||
QList<UserNotifySetting> mUserNotifySettingList;
|
QList<UserNotifySetting> mUserNotifySettingList;
|
||||||
|
|
|
@ -10,9 +10,17 @@
|
||||||
<height>512</height>
|
<height>512</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tabFeed">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Feed</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="notify_ForumNewMsg">
|
<widget class="QGroupBox" name="notify_ForumNewMsg">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -115,18 +123,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="trayNotifyGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Systray Icon</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="notifyLayout"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="messageGroupBox">
|
<widget class="QGroupBox" name="messageGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -157,9 +153,12 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</widget>
|
||||||
<item>
|
<widget class="QWidget" name="tabToasters">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<attribute name="title">
|
||||||
|
<string>Toasters</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButtonDisableAll">
|
<widget class="QPushButton" name="pushButtonDisableAll">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -345,6 +344,38 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tabSystray">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Systray</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="trayNotifyGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Systray Icon</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="notifyLayout"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -385,6 +416,52 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tabChatLobbies">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Chat Lobbies</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chatLobbies_CountUnRead">
|
||||||
|
<property name="text">
|
||||||
|
<string>Count all unread messages</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chatLobbies_CheckNickName">
|
||||||
|
<property name="text">
|
||||||
|
<string>Count occurences of my current nickname</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chatLobbies_CountFollowingText">
|
||||||
|
<property name="text">
|
||||||
|
<string>Count occurences of any of the following texts (separate by newlines):</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="chatLobbies_TextToNotify"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -496,6 +496,16 @@ void RshareSettings::setChatSendMessageWithCtrlReturn(bool bValue)
|
||||||
setValueToGroup("Chat", "SendMessageWithCtrlReturn", 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)
|
void RshareSettings::setChatSearchCharToStartSearch(int iValue)
|
||||||
{
|
{
|
||||||
setValueToGroup("Chat", "SearchCharToStartSearch", iValue);
|
setValueToGroup("Chat", "SearchCharToStartSearch", iValue);
|
||||||
|
|
|
@ -202,6 +202,9 @@ public:
|
||||||
bool getChatSendMessageWithCtrlReturn();
|
bool getChatSendMessageWithCtrlReturn();
|
||||||
void setChatSendMessageWithCtrlReturn(bool bValue);
|
void setChatSendMessageWithCtrlReturn(bool bValue);
|
||||||
|
|
||||||
|
bool getChatSearchShowBarByDefault();
|
||||||
|
void setChatSearchShowBarByDefault(bool bValue);
|
||||||
|
|
||||||
void setChatSearchCharToStartSearch(int iValue);
|
void setChatSearchCharToStartSearch(int iValue);
|
||||||
int getChatSearchCharToStartSearch();
|
int getChatSearchCharToStartSearch();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue