mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-02 10:35:15 -05:00
commit
c844d37ada
@ -671,7 +671,7 @@ void ChatLobbyDialog::displayLobbyEvent(int event_type, const RsGxsId& gxs_id, c
|
|||||||
|
|
||||||
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(),
|
ui.chatWidget->addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(),
|
||||||
QDateTime::currentDateTime(),
|
QDateTime::currentDateTime(),
|
||||||
tr("%1 changed his name to: %2").arg(name).arg(newname),
|
tr("%1 changed his name to: %2").arg(RsHtml::plainText(name)).arg(RsHtml::plainText(newname)),
|
||||||
ChatWidget::MSGTYPE_SYSTEM);
|
ChatWidget::MSGTYPE_SYSTEM);
|
||||||
|
|
||||||
// TODO if a user was muted and changed his name, update mute list, but only, when the muted peer, dont change his name to a other peer in your chat lobby
|
// TODO if a user was muted and changed his name, update mute list, but only, when the muted peer, dont change his name to a other peer in your chat lobby
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
#include <util/HandleRichText.h>
|
||||||
|
|
||||||
ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) :
|
ChatLobbyUserNotify::ChatLobbyUserNotify(QObject *parent) :
|
||||||
UserNotify(parent)
|
UserNotify(parent)
|
||||||
@ -257,9 +258,8 @@ void ChatLobbyUserNotify::chatLobbyNewMessage(ChatLobbyId lobby_id, QDateTime ti
|
|||||||
|
|
||||||
if ((bGetNickName || bFoundTextToNotify || _bCountUnRead)){
|
if ((bGetNickName || bFoundTextToNotify || _bCountUnRead)){
|
||||||
QString strAnchor = time.toString(Qt::ISODate);
|
QString strAnchor = time.toString(Qt::ISODate);
|
||||||
strAnchor.append("_").append(senderName);
|
|
||||||
MsgData msgData;
|
MsgData msgData;
|
||||||
msgData.text=msg;
|
msgData.text=RsHtml::plainText(senderName) + ": " + msg;
|
||||||
msgData.unread=!(bGetNickName || bFoundTextToNotify);
|
msgData.unread=!(bGetNickName || bFoundTextToNotify);
|
||||||
|
|
||||||
_listMsg[lobby_id][strAnchor]=msgData;
|
_listMsg[lobby_id][strAnchor]=msgData;
|
||||||
|
@ -448,7 +448,7 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatType() == CHATTYPE_LOBBY) {
|
if (notify && chatType() == CHATTYPE_LOBBY) {
|
||||||
if ((event->type() == QEvent::KeyPress)
|
if ((event->type() == QEvent::KeyPress)
|
||||||
|| (event->type() == QEvent::MouseMove)
|
|| (event->type() == QEvent::MouseMove)
|
||||||
|| (event->type() == QEvent::Enter)
|
|| (event->type() == QEvent::Enter)
|
||||||
@ -460,9 +460,11 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
QPoint bottom_right(ui->textBrowser->viewport()->width() - 1, ui->textBrowser->viewport()->height() - 1);
|
QPoint bottom_right(ui->textBrowser->viewport()->width() - 1, ui->textBrowser->viewport()->height() - 1);
|
||||||
int end_pos = ui->textBrowser->cursorForPosition(bottom_right).position();
|
int end_pos = ui->textBrowser->cursorForPosition(bottom_right).position();
|
||||||
cursor.setPosition(end_pos, QTextCursor::KeepAnchor);
|
cursor.setPosition(end_pos, QTextCursor::KeepAnchor);
|
||||||
|
if ((cursor.position() != lastUpdateCursorPos || cursor.selectionEnd() != lastUpdateCursorEnd) &&
|
||||||
if (!cursor.selectedText().isEmpty()){
|
!cursor.selectedText().isEmpty()) {
|
||||||
QRegExp rx("<a\\s+name\\s*=\\s*\"(.*)\"",Qt::CaseInsensitive, QRegExp::RegExp2);
|
lastUpdateCursorPos = cursor.position();
|
||||||
|
lastUpdateCursorEnd = cursor.selectionEnd();
|
||||||
|
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
QString sel=cursor.selection().toHtml();
|
QString sel=cursor.selection().toHtml();
|
||||||
QStringList anchors;
|
QStringList anchors;
|
||||||
@ -473,13 +475,9 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
}
|
}
|
||||||
if (!anchors.isEmpty()){
|
if (!anchors.isEmpty()){
|
||||||
for (QStringList::iterator it=anchors.begin();it!=anchors.end();++it) {
|
for (QStringList::iterator it=anchors.begin();it!=anchors.end();++it) {
|
||||||
QByteArray bytArray=it->toUtf8();
|
notify->chatLobbyCleared(chatId.toLobbyId(), *it);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,11 +488,11 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
|
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
|
||||||
if (keyEvent) {
|
if (keyEvent) {
|
||||||
if (keyEvent->key() == Qt::Key_Delete ) {
|
if (notify && keyEvent->key() == Qt::Key_Delete) {
|
||||||
// Delete key pressed
|
// Delete key pressed
|
||||||
if (ui->textBrowser->textCursor().selectedText().length() > 0) {
|
if (ui->textBrowser->textCursor().selectedText().length() > 0) {
|
||||||
if (chatType() == CHATTYPE_LOBBY) {
|
if (chatType() == CHATTYPE_LOBBY) {
|
||||||
QRegExp rx("<a\\s+name\\s*=\\s*\"(.*)\"",Qt::CaseInsensitive, QRegExp::RegExp2);
|
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
QString sel=ui->textBrowser->textCursor().selection().toHtml();
|
QString sel=ui->textBrowser->textCursor().selection().toHtml();
|
||||||
QStringList anchors;
|
QStringList anchors;
|
||||||
@ -505,9 +503,7 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (QStringList::iterator it=anchors.begin();it!=anchors.end();++it) {
|
for (QStringList::iterator it=anchors.begin();it!=anchors.end();++it) {
|
||||||
QByteArray bytArray=it->toUtf8();
|
notify->chatLobbyCleared(chatId.toLobbyId(), *it);
|
||||||
std::string stdString=std::string(bytArray.begin(),bytArray.end());
|
|
||||||
if (notify) notify->chatLobbyCleared(chatId.toLobbyId(), QString::fromUtf8(stdString.c_str()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -529,7 +525,7 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||||||
cursor.select(QTextCursor::WordUnderCursor);
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
QString toolTipText = "";
|
QString toolTipText = "";
|
||||||
if (!cursor.selectedText().isEmpty()){
|
if (!cursor.selectedText().isEmpty()){
|
||||||
QRegExp rx("<a\\s+name\\s*=\\s*\"(.*)\"",Qt::CaseInsensitive, QRegExp::RegExp2);
|
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, QRegExp::RegExp2);
|
||||||
rx.setMinimal(true);
|
rx.setMinimal(true);
|
||||||
QString sel=cursor.selection().toHtml();
|
QString sel=cursor.selection().toHtml();
|
||||||
QStringList anchors;
|
QStringList anchors;
|
||||||
@ -902,7 +898,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const QDateTime
|
|||||||
QString formatMsg = chatStyle.formatMessage(type, name, dtTimestamp, formattedMessage, formatFlag);
|
QString formatMsg = chatStyle.formatMessage(type, name, dtTimestamp, formattedMessage, formatFlag);
|
||||||
QString timeStamp = dtTimestamp.toString(Qt::ISODate);
|
QString timeStamp = dtTimestamp.toString(Qt::ISODate);
|
||||||
|
|
||||||
formatMsg.prepend(QString("<a name=\"%1_%2\"/>").arg(timeStamp).arg(name));
|
formatMsg.prepend(QString("<a name=\"%1\"/>").arg(timeStamp));
|
||||||
//To call this anchor do: ui->textBrowser->scrollToAnchor(QString("%1_%2").arg(timeStamp).arg(name));
|
//To call this anchor do: ui->textBrowser->scrollToAnchor(QString("%1_%2").arg(timeStamp).arg(name));
|
||||||
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
||||||
textCursor.movePosition(QTextCursor::End);
|
textCursor.movePosition(QTextCursor::End);
|
||||||
|
@ -238,6 +238,9 @@ private:
|
|||||||
|
|
||||||
QTextCursor qtcMark;
|
QTextCursor qtcMark;
|
||||||
|
|
||||||
|
int lastUpdateCursorPos;
|
||||||
|
int lastUpdateCursorEnd;
|
||||||
|
|
||||||
TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies.
|
TransferRequestFlags mDefaultExtraFileFlags ; // flags for extra files shared in this chat. Will be 0 by default, but might be ANONYMOUS for chat lobbies.
|
||||||
QDate lastMsgDate ;
|
QDate lastMsgDate ;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user