mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-01 02:36:23 -04:00
Merge branch 'master' into gxs_mail_experiments
This commit is contained in:
commit
5159e326c7
335 changed files with 12307 additions and 24670 deletions
|
@ -63,7 +63,7 @@ void ChatDialog::closeEvent(QCloseEvent *event)
|
|||
emit dialogClose(this);
|
||||
}
|
||||
|
||||
void ChatDialog::init(ChatId id, const QString &title)
|
||||
void ChatDialog::init(const ChatId &id, const QString &title)
|
||||
{
|
||||
mChatId = id;
|
||||
ChatWidget *cw = getChatWidget();
|
||||
|
@ -102,14 +102,14 @@ void ChatDialog::init(ChatId id, const QString &title)
|
|||
if (chatflags & RS_CHAT_OPEN) {
|
||||
if (id.isLobbyId()) {
|
||||
ChatLobbyDialog* cld = new ChatLobbyDialog(id.toLobbyId());
|
||||
cld->init();
|
||||
cld->init(ChatId(), "");
|
||||
cd = cld;
|
||||
}
|
||||
else if(id.isDistantChatId())
|
||||
{
|
||||
PopupDistantChatDialog* pdcd = new PopupDistantChatDialog(id.toDistantChatId());
|
||||
|
||||
pdcd->init(id.toDistantChatId());
|
||||
pdcd->init(id, "");
|
||||
cd = pdcd;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -84,7 +84,7 @@ protected:
|
|||
virtual QString getPeerName(const ChatId &sslid) const ; // can be overloaded for chat dialogs that have specific peers
|
||||
virtual QString getOwnName() const;
|
||||
|
||||
virtual void init(ChatId id, const QString &title);
|
||||
virtual void init(const ChatId &id, const QString &title);
|
||||
virtual void addChatMsg(const ChatMessage& msg) = 0;
|
||||
|
||||
ChatId mChatId;
|
||||
|
|
|
@ -304,7 +304,7 @@ void ChatLobbyDialog::showInPeopleTab()
|
|||
idDialog->navigate(nickname);
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::init()
|
||||
void ChatLobbyDialog::init(const ChatId &/*id*/, const QString &/*title*/)
|
||||
{
|
||||
ChatLobbyInfo linfo ;
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
|||
virtual ~ChatLobbyDialog();
|
||||
|
||||
void processSettings(bool load);
|
||||
virtual void init();
|
||||
virtual void init(const ChatId &id, const QString &title);
|
||||
virtual bool canClose();
|
||||
virtual void addChatMsg(const ChatMessage &msg);
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "gui/common/FilesDefs.h"
|
||||
#include "gui/common/Emoticons.h"
|
||||
#include "gui/chat/ChatLobbyDialog.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/HandleRichText.h"
|
||||
#include "gui/chat/ChatUserNotify.h"//For BradCast
|
||||
|
@ -65,6 +66,8 @@
|
|||
|
||||
#define FMM 2.5//fontMetricsMultiplicator
|
||||
|
||||
#define PERSONID "PersonId:"
|
||||
|
||||
/*****
|
||||
* #define CHAT_DEBUG 1
|
||||
*****/
|
||||
|
@ -76,7 +79,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
|||
|
||||
int iconHeight = FMM*QFontMetricsF(font()).height() ;
|
||||
QSize iconSize = QSize(iconHeight,iconHeight);
|
||||
QSize buttonSize = QSize(iconSize + QSize(FMM,FMM));
|
||||
QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM));
|
||||
|
||||
newMessages = false;
|
||||
typing = false;
|
||||
|
@ -258,7 +261,7 @@ void ChatWidget::addChatBarWidget(QWidget *w)
|
|||
{
|
||||
int iconHeight = FMM*QFontMetricsF(font()).height() ;
|
||||
QSize iconSize = QSize(iconHeight,iconHeight);
|
||||
QSize buttonSize = QSize(iconSize + QSize(FMM,FMM));
|
||||
QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM));
|
||||
w->setFixedSize(buttonSize);
|
||||
ui->pluginButtonFrame->layout()->addWidget(w) ;
|
||||
}
|
||||
|
@ -578,6 +581,9 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||
if (ui->textBrowser->checkImage(helpEvent->pos(), imageStr)) {
|
||||
toolTipText = imageStr;
|
||||
}
|
||||
} else if (toolTipText.startsWith(PERSONID)){
|
||||
toolTipText = toolTipText.replace(PERSONID, tr("Person id: ") );
|
||||
toolTipText = toolTipText.append(tr("\nDouble click on it to add his name on text writer.") );
|
||||
}
|
||||
}
|
||||
if (!toolTipText.isEmpty()){
|
||||
|
@ -655,6 +661,39 @@ bool ChatWidget::eventFilter(QObject *obj, QEvent *event)
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (obj == ui->textBrowser->viewport()) {
|
||||
if (event->type() == QEvent::MouseButtonDblClick) {
|
||||
|
||||
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
QTextCursor cursor = ui->textBrowser->cursorForPosition(mouseEvent->pos());
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
if (!cursor.selectedText().isEmpty()){
|
||||
QRegExp rx("<a name=\"(.*)\"",Qt::CaseSensitive, 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()){
|
||||
if (anchors.at(0).startsWith(PERSONID)){
|
||||
RsGxsId mId = RsGxsId(QString(anchors.at(0)).replace(PERSONID,"").toStdString());
|
||||
if(!mId.isNull()) {
|
||||
RsIdentityDetails details;
|
||||
if (rsIdentity->getIdDetails(mId, details)){
|
||||
QString text = QString("@").append(GxsIdDetails::getName(details)).append(" ");
|
||||
ui->chatTextEdit->textCursor().insertText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (event->type() == QEvent::WindowActivate) {
|
||||
if (isVisible() && (window() == NULL || window()->isActiveWindow())) {
|
||||
|
@ -954,9 +993,13 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx
|
|||
formatMsg.replace(QString("<a name=\"time\">"),QString("<a name=\"%1\">").arg(timeStamp));
|
||||
//replace Name anchors with GXS Id
|
||||
QString strGxsId = "";
|
||||
if (!gxsId.isNull())
|
||||
if (!gxsId.isNull()) {
|
||||
strGxsId = QString::fromStdString(gxsId.toStdString());
|
||||
formatMsg.replace(QString("<a name=\"name\">"),QString("<a name=\"Person Id: %1\">").arg(strGxsId));
|
||||
formatMsg.replace(QString("<a name=\"name\">")
|
||||
,QString("<a name=\"").append(PERSONID).append("%1\">").arg(strGxsId) );
|
||||
} else {
|
||||
formatMsg.replace(QString("<a name=\"name\">"),"");
|
||||
}
|
||||
|
||||
QTextCursor textCursor = QTextCursor(ui->textBrowser->textCursor());
|
||||
textCursor.movePosition(QTextCursor::End);
|
||||
|
|
|
@ -46,7 +46,7 @@ protected:
|
|||
/** Default destructor */
|
||||
virtual ~PopupChatDialog();
|
||||
|
||||
virtual void init(const ChatId &chat_id, const QString &title);
|
||||
virtual void init(const ChatId &chat_id, const QString &title);
|
||||
virtual void showDialog(uint chatflags);
|
||||
virtual ChatWidget *getChatWidget();
|
||||
virtual bool hasPeerStatus() { return true; }
|
||||
|
|
|
@ -63,9 +63,12 @@ PopupDistantChatDialog::PopupDistantChatDialog(const DistantChatPeerId& tunnel_i
|
|||
updateDisplay() ;
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::init(const DistantChatPeerId &peer_id)
|
||||
void PopupDistantChatDialog::init(const ChatId &chat_id, const QString &/*title*/)
|
||||
{
|
||||
_tunnel_id = peer_id;
|
||||
if (!chat_id.isDistantChatId())
|
||||
return;
|
||||
|
||||
_tunnel_id = chat_id.toDistantChatId();
|
||||
DistantChatPeerInfo tinfo;
|
||||
|
||||
if(!rsMsgs->getDistantChatStatus(_tunnel_id,tinfo))
|
||||
|
@ -74,15 +77,15 @@ void PopupDistantChatDialog::init(const DistantChatPeerId &peer_id)
|
|||
RsIdentityDetails iddetails ;
|
||||
|
||||
if(rsIdentity->getIdDetails(tinfo.to_id,iddetails))
|
||||
PopupChatDialog::init(ChatId(peer_id), QString::fromUtf8(iddetails.mNickname.c_str())) ;
|
||||
PopupChatDialog::init(chat_id, QString::fromUtf8(iddetails.mNickname.c_str())) ;
|
||||
else
|
||||
PopupChatDialog::init(ChatId(peer_id), QString::fromStdString(tinfo.to_id.toStdString())) ;
|
||||
PopupChatDialog::init(chat_id, QString::fromStdString(tinfo.to_id.toStdString())) ;
|
||||
|
||||
// Do not use setOwnId, because we don't want the user to change the GXS avatar from the chat window
|
||||
// it will not be transmitted.
|
||||
|
||||
ui.ownAvatarWidget->setOwnId() ; // sets the flag
|
||||
ui.ownAvatarWidget->setId(ChatId(peer_id)) ; // sets the actual Id
|
||||
ui.ownAvatarWidget->setId(chat_id) ; // sets the actual Id
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::updateDisplay()
|
||||
|
|
|
@ -38,7 +38,7 @@ class PopupDistantChatDialog: public PopupChatDialog
|
|||
/** Default destructor */
|
||||
virtual ~PopupDistantChatDialog();
|
||||
|
||||
virtual void init(const DistantChatPeerId& peer_id);
|
||||
virtual void init(const ChatId& chat_id, const QString &title);
|
||||
virtual void closeEvent(QCloseEvent *e) ;
|
||||
|
||||
virtual QString getPeerName(const ChatId &id) const ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue