simplification of the chat interface to libretroshare using a single unified class for chat IDs. Used a common chat widget for all chats including broadcast. Opens the way to having plugins send/recv chat messages. Patch from Electron.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7800 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-12-29 21:41:05 +00:00
parent 535fe875e4
commit 13d7866171
53 changed files with 1180 additions and 2280 deletions

View file

@ -25,13 +25,12 @@
#include <retroshare/rsmsgs.h>
ChatLobbyToaster::ChatLobbyToaster(const RsPeerId &peerId, const QString &name, const QString &message) : QWidget(NULL)
ChatLobbyToaster::ChatLobbyToaster(const ChatLobbyId &lobby_id, const QString &name, const QString &message):
QWidget(NULL), mLobbyId(lobby_id)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
this->peerId = peerId;
connect(ui.toasterButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
@ -44,21 +43,17 @@ ChatLobbyToaster::ChatLobbyToaster(const RsPeerId &peerId, const QString &name,
std::list<ChatLobbyInfo> linfos;
rsMsgs->getChatLobbyList(linfos);
ChatLobbyId lobbyId;
if (rsMsgs->isLobbyId(peerId, lobbyId)) {
for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) {
if ((*it).lobby_id == lobbyId) {
lobbyName += "@" + RsHtml::plainText(it->lobby_name);
break;
}
}
}
for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) {
if ((*it).lobby_id == mLobbyId) {
lobbyName += "@" + RsHtml::plainText(it->lobby_name);
break;
}
}
ui.toasterLabel->setText(lobbyName);
}
void ChatLobbyToaster::chatButtonSlot()
{
ChatDialog::chatFriend(peerId);
ChatDialog::chatFriend(ChatId(mLobbyId));
hide();
}

View file

@ -24,6 +24,8 @@
#include "ui_ChatLobbyToaster.h"
#include "retroshare/rsmsgs.h"
/**
* Shows a toaster when a chat is incoming.
*
@ -34,13 +36,13 @@ class ChatLobbyToaster : public QWidget
Q_OBJECT
public:
ChatLobbyToaster(const RsPeerId &peerId, const QString &name, const QString &message);
ChatLobbyToaster(const ChatLobbyId &lobby_id, const QString &name, const QString &message);
private slots:
void chatButtonSlot();
private:
RsPeerId peerId;
ChatLobbyId mLobbyId;
/** Qt Designer generated object */
Ui::ChatLobbyToaster ui;

View file

@ -25,25 +25,23 @@
#include <retroshare/rspeers.h>
ChatToaster::ChatToaster(const RsPeerId &peerId, const QString &message) : QWidget(NULL)
ChatToaster::ChatToaster(const RsPeerId &peer_id, const QString &message) : QWidget(NULL), mPeerId(peer_id)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
this->peerId = peerId;
connect(ui.toasterButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
connect(ui.closeButton, SIGNAL(clicked()), SLOT(hide()));
/* set informations */
ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
ui.toasterLabel->setText(QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
ui.toasterLabel->setText(QString::fromUtf8(rsPeers->getPeerName(mPeerId).c_str()));
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatarWidget->setId(peerId);
ui.avatarWidget->setId(mPeerId);
}
void ChatToaster::chatButtonSlot()
{
ChatDialog::chatFriend(peerId);
ChatDialog::chatFriend(ChatId(mPeerId));
hide();
}

View file

@ -34,13 +34,13 @@ class ChatToaster : public QWidget
Q_OBJECT
public:
ChatToaster(const RsPeerId &peerId, const QString &message);
ChatToaster(const RsPeerId &peer_id, const QString &message);
private slots:
void chatButtonSlot();
private:
RsPeerId peerId;
RsPeerId mPeerId;
/** Qt Designer generated object */
Ui::ChatToaster ui;

View file

@ -41,6 +41,6 @@ OnlineToaster::OnlineToaster(const RsPeerId &peerId) : QWidget(NULL)
void OnlineToaster::chatButtonSlot()
{
ChatDialog::chatFriend(peerId);
ChatDialog::chatFriend(ChatId(peerId));
hide();
}