mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 23:25:32 -04:00
Chat lobby:
- added new notifier to p3ChatService GUI: - list all public and private chat lobbies - added subscribe/unsubscribe - added new basic widget ChatTabWidget and use it in PopupChatWindow and ChatLobbyDialog - added a tabbed dialog for every subscribed chat lobby git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4782 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fc949ce5d0
commit
6c626e180f
21 changed files with 934 additions and 420 deletions
|
@ -45,41 +45,56 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "ChatLobbyDialog.h"
|
||||
#include "gui/ChatLobbyWidget.h"
|
||||
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog::ChatLobbyDialog(const std::string& dialog_id,const ChatLobbyId& lid, const QString &name, QWidget *parent, Qt::WFlags flags)
|
||||
: PopupChatDialog(dialog_id,name,parent,flags),lobby_id(lid)
|
||||
ChatLobbyDialog::ChatLobbyDialog(const std::string& dialog_id, const ChatLobbyId& lid, const QString &name, QWidget *parent, Qt::WFlags flags)
|
||||
: PopupChatDialog(dialog_id, name, parent, flags), lobby_id(lid)
|
||||
{
|
||||
// remove the avatar widget. Replace it with a friends list.
|
||||
|
||||
ui.avatarWidget->hide() ;
|
||||
PopupChatDialog::updateStatus(QString::fromStdString(getPeerId()),RS_STATUS_ONLINE) ;
|
||||
ui.avatarWidget->hide();
|
||||
ui.ownAvatarWidget->hide();
|
||||
PopupChatDialog::updateStatus(QString::fromStdString(getPeerId()),RS_STATUS_ONLINE);
|
||||
|
||||
QObject::connect(this,SIGNAL(close()),this,SLOT(closeAndAsk())) ;
|
||||
// hide history buttons
|
||||
ui.actionClearOfflineMessages->setVisible(false);
|
||||
ui.actionDelete_Chat_History->setVisible(false);
|
||||
ui.actionMessageHistory->setVisible(false);
|
||||
|
||||
ui.avatarframe->layout()->addWidget(new QLabel(tr("Participants:"))) ;
|
||||
friendsListWidget = new QListWidget ;
|
||||
ui.avatarframe->layout()->addWidget(friendsListWidget) ;
|
||||
ui.avatarframe->layout()->addItem(new QSpacerItem(12, 335, QSizePolicy::Minimum, QSizePolicy::Expanding)) ;
|
||||
ui.avatarFrameButton->setToolTip(tr("Hide participants"));
|
||||
|
||||
ui.avatarframe->layout()->addWidget(new QLabel(tr("Participants:")));
|
||||
friendsListWidget = new QListWidget;
|
||||
ui.avatarframe->layout()->addWidget(friendsListWidget);
|
||||
ui.avatarframe->layout()->addItem(new QSpacerItem(12, 335, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
ChatLobbyDialog::~ChatLobbyDialog()
|
||||
{
|
||||
// announce leaving of lobby
|
||||
|
||||
// check that the lobby still exists.
|
||||
ChatLobbyId lid ;
|
||||
if(!rsMsgs->isLobbyId(getPeerId(),lid))
|
||||
return ;
|
||||
|
||||
if(QMessageBox::Yes == QMessageBox::question(NULL,tr("Unsubscribe to lobby?"),tr("Do you want to unsubscribe to this chat lobby?"),QMessageBox::Yes | QMessageBox::No))
|
||||
rsMsgs->unsubscribeChatLobby(lobby_id) ;
|
||||
// check that the lobby still exists.
|
||||
ChatLobbyId lid;
|
||||
if (rsMsgs->isLobbyId(getPeerId(),lid)) {
|
||||
rsMsgs->unsubscribeChatLobby(lobby_id);
|
||||
}
|
||||
}
|
||||
|
||||
bool ChatLobbyDialog::addToParent()
|
||||
{
|
||||
ChatTabWidget *tabWidget = ChatLobbyWidget::getTabWidget();
|
||||
if (tabWidget) {
|
||||
tabWidget->addDialog(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::setNickName(const QString& nick)
|
||||
{
|
||||
rsMsgs->setNickNameForChatLobby(lobby_id,nick.toUtf8().constData()) ;
|
||||
rsMsgs->setNickNameForChatLobby(lobby_id, nick.toUtf8().constData());
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
||||
|
@ -87,7 +102,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
|||
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
||||
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
||||
QString message = QString::fromStdWString(info.msg);
|
||||
QString name = QString::fromUtf8(info.peer_nickname.c_str()) ;
|
||||
QString name = QString::fromUtf8(info.peer_nickname.c_str());
|
||||
|
||||
addChatMsg(true, name, sendTime, recvTime, message, TYPE_NORMAL);
|
||||
|
||||
|
@ -96,42 +111,44 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
|||
static time_t last = 0 ;
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
if(now > last)
|
||||
{
|
||||
last = now ;
|
||||
updateFriendsList() ;
|
||||
if (now > last) {
|
||||
last = now;
|
||||
updateFriendsList();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::updateFriendsList()
|
||||
{
|
||||
friendsListWidget->clear() ;
|
||||
friendsListWidget->clear();
|
||||
|
||||
std::list<ChatLobbyInfo> linfos ;
|
||||
std::list<ChatLobbyInfo> linfos;
|
||||
rsMsgs->getChatLobbyList(linfos);
|
||||
|
||||
std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());
|
||||
for(;it!=linfos.end() && (*it).lobby_id != lobby_id;++it) ;
|
||||
for (; it!=linfos.end() && (*it).lobby_id != lobby_id; ++it);
|
||||
|
||||
if(it!=linfos.end())
|
||||
for(std::set<std::string>::const_iterator it2( (*it).nick_names.begin());it2!=(*it).nick_names.end();++it2)
|
||||
friendsListWidget->addItem(QString::fromUtf8((*it2).c_str())) ;
|
||||
if (it != linfos.end()) {
|
||||
for (std::set<std::string>::const_iterator it2((*it).nick_names.begin()); it2 != (*it).nick_names.end(); ++it2) {
|
||||
friendsListWidget->addItem(QString::fromUtf8((*it2).c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLobbyDialog::displayLobbyEvent(int event_type,const QString& nickname,const QString& str)
|
||||
void ChatLobbyDialog::displayLobbyEvent(int event_type, const QString& nickname, const QString& str)
|
||||
{
|
||||
switch(event_type)
|
||||
{
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_LEFT: addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), str + tr(" has left the lobby."), TYPE_NORMAL);
|
||||
break ;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_JOINED:
|
||||
addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), str + tr(" joined the lobby."), TYPE_NORMAL);
|
||||
break ;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
||||
updateStatusString(nickname,str) ;
|
||||
break ;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_LEFT:
|
||||
addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 has left the lobby.").arg(str), TYPE_NORMAL);
|
||||
break;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_JOINED:
|
||||
addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the lobby.").arg(str), TYPE_NORMAL);
|
||||
break;
|
||||
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
||||
updateStatusString(nickname,str);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "ChatLobbyDialog::displayLobbyEvent() Unhandled lobby event type " << event_type << std::endl;
|
||||
std::cerr << "ChatLobbyDialog::displayLobbyEvent() Unhandled lobby event type " << event_type << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,3 +157,17 @@ QString ChatLobbyDialog::makeStatusString(const QString& peer_id, const QString&
|
|||
return QString::fromUtf8(peer_id.toStdString().c_str()) + " " + tr(status_string.toAscii());
|
||||
}
|
||||
|
||||
bool ChatLobbyDialog::canClose()
|
||||
{
|
||||
// check that the lobby still exists.
|
||||
ChatLobbyId lid;
|
||||
if (!rsMsgs->isLobbyId(getPeerId(),lid)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (QMessageBox::Yes == QMessageBox::question(NULL, tr("Unsubscribe to lobby?"), tr("Do you want to unsubscribe to this chat lobby?"), QMessageBox::Yes | QMessageBox::No)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -41,34 +41,41 @@ class ChatLobbyDialog: public PopupChatDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
void displayLobbyEvent(int event_type,const QString& nickname,const QString& str) ;
|
||||
public:
|
||||
void displayLobbyEvent(int event_type,const QString& nickname,const QString& str) ;
|
||||
|
||||
protected:
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog(const std::string& id,const ChatLobbyId& lid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
// The following methods are differentfrom those of the parent:
|
||||
//
|
||||
virtual bool hasPeerStatus() { return false; }
|
||||
virtual bool canClose();
|
||||
|
||||
/** Default destructor */
|
||||
virtual ~ChatLobbyDialog();
|
||||
protected:
|
||||
/** Default constructor */
|
||||
ChatLobbyDialog(const std::string& id,const ChatLobbyId& lid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
// virtual void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType);
|
||||
// virtual void sendChat();
|
||||
/** Default destructor */
|
||||
virtual ~ChatLobbyDialog();
|
||||
|
||||
friend class PopupChatDialog ;
|
||||
// virtual void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType);
|
||||
// virtual void sendChat();
|
||||
|
||||
// The following methods are differentfrom those of the parent:
|
||||
//
|
||||
virtual void addIncomingChatMsg(const ChatInfo& info) ; //
|
||||
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
||||
friend class PopupChatDialog ;
|
||||
|
||||
protected slots:
|
||||
void setNickName(const QString&) ;
|
||||
// The following methods are differentfrom those of the parent:
|
||||
//
|
||||
virtual bool addToParent();
|
||||
virtual bool isChatLobby() { return true; }
|
||||
virtual void addIncomingChatMsg(const ChatInfo& info) ; //
|
||||
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
||||
|
||||
private:
|
||||
void updateFriendsList() ;
|
||||
protected slots:
|
||||
void setNickName(const QString&) ;
|
||||
|
||||
ChatLobbyId lobby_id ;
|
||||
QListWidget *friendsListWidget ;
|
||||
private:
|
||||
void updateFriendsList() ;
|
||||
|
||||
ChatLobbyId lobby_id ;
|
||||
QListWidget *friendsListWidget ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
116
retroshare-gui/src/gui/chat/ChatTabWidget.cpp
Normal file
116
retroshare-gui/src/gui/chat/ChatTabWidget.cpp
Normal file
|
@ -0,0 +1,116 @@
|
|||
#include "ChatTabWidget.h"
|
||||
#include "ui_ChatTabWidget.h"
|
||||
#include "PopupChatDialog.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
|
||||
#define IMAGE_WINDOW ":/images/rstray3.png"
|
||||
#define IMAGE_TYPING ":/images/typing.png"
|
||||
#define IMAGE_CHAT ":/images/chat.png"
|
||||
|
||||
ChatTabWidget::ChatTabWidget(QWidget *parent) :
|
||||
QTabWidget(parent),
|
||||
ui(new Ui::ChatTabWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClose(int)));
|
||||
connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
||||
}
|
||||
|
||||
ChatTabWidget::~ChatTabWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ChatTabWidget::addDialog(PopupChatDialog *dialog)
|
||||
{
|
||||
addTab(dialog, dialog->getTitle());
|
||||
|
||||
QObject::connect(dialog, SIGNAL(infoChanged(PopupChatDialog*)), this, SLOT(tabInfoChanged(PopupChatDialog*)));
|
||||
|
||||
tabInfoChanged(dialog);
|
||||
}
|
||||
|
||||
void ChatTabWidget::removeDialog(PopupChatDialog *dialog)
|
||||
{
|
||||
QObject::disconnect(dialog, SIGNAL(infoChanged(PopupChatDialog*)), this, SLOT(tabInfoChanged(PopupChatDialog*)));
|
||||
|
||||
int tab = indexOf(dialog);
|
||||
if (tab >= 0) {
|
||||
removeTab(tab);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTabWidget::tabClose(int tab)
|
||||
{
|
||||
PopupChatDialog *dialog = dynamic_cast<PopupChatDialog*>(widget(tab));
|
||||
|
||||
if (dialog) {
|
||||
if (dialog->canClose()) {
|
||||
dialog->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTabWidget::tabChanged(int tab)
|
||||
{
|
||||
PopupChatDialog *dialog = dynamic_cast<PopupChatDialog*>(widget(tab));
|
||||
|
||||
if (dialog) {
|
||||
dialog->activate();
|
||||
emit tabChanged(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatTabWidget::tabInfoChanged(PopupChatDialog *dialog)
|
||||
{
|
||||
int tab = indexOf(dialog);
|
||||
if (tab >= 0) {
|
||||
if (dialog->isTyping()) {
|
||||
setTabIcon(tab, QIcon(IMAGE_TYPING));
|
||||
} else if (dialog->hasNewMessages()) {
|
||||
setTabIcon(tab, QIcon(IMAGE_CHAT));
|
||||
} else if (dialog->hasPeerStatus()) {
|
||||
setTabIcon(tab, QIcon(StatusDefs::imageIM(dialog->getPeerStatus())));
|
||||
} else {
|
||||
setTabIcon(tab, QIcon());
|
||||
}
|
||||
}
|
||||
|
||||
emit infoChanged();
|
||||
}
|
||||
|
||||
void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon)
|
||||
{
|
||||
isTyping = false;
|
||||
hasNewMessage = false;
|
||||
|
||||
PopupChatDialog *pcd;
|
||||
int tabCount = count();
|
||||
for (int i = 0; i < tabCount; i++) {
|
||||
pcd = dynamic_cast<PopupChatDialog*>(widget(i));
|
||||
if (pcd) {
|
||||
if (pcd->isTyping()) {
|
||||
isTyping = true;
|
||||
}
|
||||
if (pcd->hasNewMessages()) {
|
||||
hasNewMessage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (icon) {
|
||||
if (isTyping) {
|
||||
*icon = QIcon(IMAGE_TYPING);
|
||||
} else if (hasNewMessage) {
|
||||
*icon = QIcon(IMAGE_CHAT);
|
||||
} else {
|
||||
pcd = dynamic_cast<PopupChatDialog*>(currentWidget());
|
||||
if (pcd && pcd->hasPeerStatus()) {
|
||||
*icon = QIcon(StatusDefs::imageIM(pcd->getPeerStatus()));
|
||||
} else {
|
||||
*icon = QIcon();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
38
retroshare-gui/src/gui/chat/ChatTabWidget.h
Normal file
38
retroshare-gui/src/gui/chat/ChatTabWidget.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef CHATTABWIDGET_H
|
||||
#define CHATTABWIDGET_H
|
||||
|
||||
#include <QTabWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ChatTabWidget;
|
||||
}
|
||||
|
||||
class PopupChatDialog;
|
||||
|
||||
class ChatTabWidget : public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChatTabWidget(QWidget *parent = 0);
|
||||
~ChatTabWidget();
|
||||
|
||||
void addDialog(PopupChatDialog *dialog);
|
||||
void removeDialog(PopupChatDialog *dialog);
|
||||
|
||||
void getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon);
|
||||
|
||||
signals:
|
||||
void tabChanged(PopupChatDialog *dialog);
|
||||
void infoChanged();
|
||||
|
||||
private slots:
|
||||
void tabClose(int tab);
|
||||
void tabChanged(int tab);
|
||||
void tabInfoChanged(PopupChatDialog *dialog);
|
||||
|
||||
private:
|
||||
Ui::ChatTabWidget *ui;
|
||||
};
|
||||
|
||||
#endif // CHATTABWIDGET_H
|
22
retroshare-gui/src/gui/chat/ChatTabWidget.ui
Normal file
22
retroshare-gui/src/gui/chat/ChatTabWidget.ui
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ChatTabWidget</class>
|
||||
<widget class="QTabWidget" name="ChatTabWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -91,7 +91,6 @@ void playsound()
|
|||
PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWidget *parent, Qt::WFlags flags)
|
||||
: QWidget(parent, flags), dialogId(id), dialogName(name),
|
||||
lastChatTime(0), lastChatName("")
|
||||
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
@ -155,7 +154,7 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
|||
ui.hashBox->setDropWidget(this);
|
||||
ui.hashBox->setAutoHide(true);
|
||||
|
||||
QMenu * toolmenu = new QMenu();
|
||||
QMenu *toolmenu = new QMenu();
|
||||
toolmenu->addAction(ui.actionClear_Chat_History);
|
||||
toolmenu->addAction(ui.actionDelete_Chat_History);
|
||||
toolmenu->addAction(ui.actionSave_Chat_History);
|
||||
|
@ -164,63 +163,63 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
|||
//toolmenu->addAction(ui.action_Disable_Emoticons);
|
||||
ui.pushtoolsButton->setMenu(toolmenu);
|
||||
|
||||
mCurrentColor.setNamedColor(PeerSettings->getPrivateChatColor(dialogId));
|
||||
mCurrentFont.fromString(PeerSettings->getPrivateChatFont(dialogId));
|
||||
|
||||
colorChanged(mCurrentColor);
|
||||
fontChanged(mCurrentFont);
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
// load style
|
||||
PeerSettings->getStyle(dialogId, "PopupChatDialog", style);
|
||||
|
||||
// initialize first status
|
||||
StatusInfo peerStatusInfo;
|
||||
// No check of return value. Non existing status info is handled as offline.
|
||||
rsStatus->getStatus(dialogId, peerStatusInfo);
|
||||
updateStatus(QString::fromStdString(dialogId), peerStatusInfo.status);
|
||||
|
||||
// initialize first custom state string
|
||||
QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(dialogId).c_str());
|
||||
updatePeersCustomStateString(QString::fromStdString(dialogId), customStateString);
|
||||
|
||||
if (rsHistory->getEnable(false)) {
|
||||
// get chat messages from history
|
||||
std::list<HistoryMsg> historyMsgs;
|
||||
int messageCount = Settings->getPrivateChatHistoryCount();
|
||||
if (messageCount > 0) {
|
||||
rsHistory->getMessages(dialogId, historyMsgs, messageCount);
|
||||
|
||||
std::list<HistoryMsg>::iterator historyIt;
|
||||
for (historyIt = historyMsgs.begin(); historyIt != historyMsgs.end(); historyIt++) {
|
||||
addChatMsg(historyIt->incoming, QString::fromUtf8(historyIt->peerName.c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), TYPE_HISTORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ui.chattextEdit->installEventFilter(this);
|
||||
|
||||
// add offline chat messages
|
||||
onPrivateChatChanged(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_ADD);
|
||||
|
||||
#ifdef RS_RELEASE_VERSION
|
||||
ui.attachPictureButton->setVisible(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PopupChatDialog::init()
|
||||
{
|
||||
if (!isChatLobby()) {
|
||||
mCurrentColor.setNamedColor(PeerSettings->getPrivateChatColor(dialogId));
|
||||
mCurrentFont.fromString(PeerSettings->getPrivateChatFont(dialogId));
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
// load style
|
||||
PeerSettings->getStyle(dialogId, "PopupChatDialog", style);
|
||||
|
||||
// initialize first status
|
||||
StatusInfo peerStatusInfo;
|
||||
// No check of return value. Non existing status info is handled as offline.
|
||||
rsStatus->getStatus(dialogId, peerStatusInfo);
|
||||
updateStatus(QString::fromStdString(dialogId), peerStatusInfo.status);
|
||||
|
||||
// initialize first custom state string
|
||||
QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(dialogId).c_str());
|
||||
updatePeersCustomStateString(QString::fromStdString(dialogId), customStateString);
|
||||
|
||||
if (rsHistory->getEnable(false)) {
|
||||
// get chat messages from history
|
||||
std::list<HistoryMsg> historyMsgs;
|
||||
int messageCount = Settings->getPrivateChatHistoryCount();
|
||||
if (messageCount > 0) {
|
||||
rsHistory->getMessages(dialogId, historyMsgs, messageCount);
|
||||
|
||||
std::list<HistoryMsg>::iterator historyIt;
|
||||
for (historyIt = historyMsgs.begin(); historyIt != historyMsgs.end(); historyIt++) {
|
||||
addChatMsg(historyIt->incoming, QString::fromUtf8(historyIt->peerName.c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), TYPE_HISTORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
// add offline chat messages
|
||||
onPrivateChatChanged(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_ADD);
|
||||
}
|
||||
|
||||
colorChanged(mCurrentColor);
|
||||
fontChanged(mCurrentFont);
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
PopupChatDialog::~PopupChatDialog()
|
||||
{
|
||||
// save settings
|
||||
processSettings(false);
|
||||
|
||||
PopupChatWindow *window = WINDOW(this);
|
||||
if (window) {
|
||||
window->removeDialog(this);
|
||||
window->calculateTitle(NULL);
|
||||
}
|
||||
emit dialogClose(this);
|
||||
|
||||
std::map<std::string, PopupChatDialog *>::iterator it;
|
||||
if (chatDialogs.end() != (it = chatDialogs.find(dialogId))) {
|
||||
|
@ -260,37 +259,38 @@ void PopupChatDialog::processSettings(bool bLoad)
|
|||
|
||||
/*static*/ PopupChatDialog *PopupChatDialog::getPrivateChat(const std::string &id, uint chatflags)
|
||||
{
|
||||
/* see if it exists already */
|
||||
/* see if it already exists */
|
||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||
|
||||
if (popupchatdialog == NULL) {
|
||||
ChatLobbyId lobby_id;
|
||||
if (rsMsgs->isLobbyId(id, lobby_id)) {
|
||||
chatflags = RS_CHAT_OPEN; // use own flags
|
||||
}
|
||||
|
||||
if (chatflags & RS_CHAT_OPEN) {
|
||||
RsPeerDetails sslDetails;
|
||||
ChatLobbyId lobby_id ;
|
||||
|
||||
if (rsPeers->getPeerDetails(id, sslDetails))
|
||||
{
|
||||
if (rsPeers->getPeerDetails(id, sslDetails)) {
|
||||
popupchatdialog = new PopupChatDialog(id, PeerDefs::nameWithLocation(sslDetails));
|
||||
popupchatdialog->init();
|
||||
chatDialogs[id] = popupchatdialog;
|
||||
|
||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||
window->addDialog(popupchatdialog);
|
||||
popupchatdialog->addToParent();
|
||||
} else if (lobby_id) {
|
||||
std::list<ChatLobbyInfo> linfos;
|
||||
rsMsgs->getChatLobbyList(linfos);
|
||||
|
||||
for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) {
|
||||
if ((*it).lobby_id == lobby_id) {
|
||||
popupchatdialog = new ChatLobbyDialog(id, lobby_id, QString::fromUtf8((*it).lobby_name.c_str()));
|
||||
popupchatdialog->init();
|
||||
chatDialogs[id] = popupchatdialog;
|
||||
|
||||
popupchatdialog->addToParent();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (rsMsgs->isLobbyId(id, lobby_id))
|
||||
{
|
||||
std::list<ChatLobbyInfo> linfos;
|
||||
rsMsgs->getChatLobbyList(linfos) ;
|
||||
|
||||
for(std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());it!=linfos.end();++it)
|
||||
if( (*it).lobby_id == lobby_id)
|
||||
{
|
||||
popupchatdialog = new ChatLobbyDialog(id,lobby_id,QString::fromUtf8((*it).lobby_name.c_str()));
|
||||
chatDialogs[id] = popupchatdialog;
|
||||
|
||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||
window->addDialog(popupchatdialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,27 +357,38 @@ void PopupChatDialog::processSettings(bool bLoad)
|
|||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::closeChat(const std::string& id)
|
||||
bool PopupChatDialog::addToParent()
|
||||
{
|
||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||
if (window) {
|
||||
window->addDialog(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(popupchatdialog != NULL)
|
||||
popupchatdialog->hide() ;
|
||||
return false;
|
||||
}
|
||||
|
||||
void PopupChatDialog::chatFriend(const std::string &id)
|
||||
/*static*/ void PopupChatDialog::closeChat(const std::string& id)
|
||||
{
|
||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||
|
||||
if (popupchatdialog) {
|
||||
delete(popupchatdialog);
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void PopupChatDialog::chatFriend(const std::string &id)
|
||||
{
|
||||
if (id.empty()){
|
||||
return;
|
||||
}
|
||||
std::cerr<<" popup dialog chat friend 1"<<std::endl;
|
||||
|
||||
ChatLobbyId lid ;
|
||||
if(rsMsgs->isLobbyId(id,lid))
|
||||
{
|
||||
getPrivateChat(id, RS_CHAT_OPEN | RS_CHAT_FOCUS);
|
||||
return ;
|
||||
}
|
||||
ChatLobbyId lid ;
|
||||
if(rsMsgs->isLobbyId(id, lid)) {
|
||||
getPrivateChat(id, RS_CHAT_OPEN | RS_CHAT_FOCUS);
|
||||
return;
|
||||
}
|
||||
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(id, detail))
|
||||
|
@ -447,17 +458,14 @@ void PopupChatDialog::contextMenu( QPoint /*point*/ )
|
|||
delete(contextMnu);
|
||||
}
|
||||
|
||||
void PopupChatDialog::resetStatusBar()
|
||||
void PopupChatDialog::resetStatusBar()
|
||||
{
|
||||
ui.statusLabel->clear();
|
||||
ui.typingpixmapLabel->clear();
|
||||
|
||||
typing = false;
|
||||
|
||||
PopupChatWindow *window = WINDOW(this);
|
||||
if (window) {
|
||||
window->calculateTitle(this);
|
||||
}
|
||||
emit infoChanged(this);
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateStatusTyping()
|
||||
|
@ -477,21 +485,19 @@ QString PopupChatDialog::makeStatusString(const QString& peer_id,const QString&
|
|||
{
|
||||
return QString::fromUtf8(rsPeers->getPeerName(peer_id.toStdString()).c_str()) + " " + tr(status_string.toAscii());
|
||||
}
|
||||
|
||||
// Called by libretroshare through notifyQt to display the peer's status
|
||||
//
|
||||
void PopupChatDialog::updateStatusString(const QString& peer_id, const QString& status_string)
|
||||
{
|
||||
QString status = makeStatusString(peer_id,status_string) ;
|
||||
QString status = makeStatusString(peer_id, status_string) ;
|
||||
ui.statusLabel->setText(status); // displays info for 5 secs.
|
||||
ui.typingpixmapLabel->setPixmap(QPixmap(":images/typing.png") );
|
||||
|
||||
if (status_string == "is typing...") {
|
||||
typing = true;
|
||||
|
||||
PopupChatWindow *window = WINDOW(this);
|
||||
if (window) {
|
||||
window->calculateTitle(this);
|
||||
}
|
||||
emit infoChanged(this);
|
||||
}
|
||||
|
||||
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
|
||||
|
@ -504,17 +510,26 @@ void PopupChatDialog::resizeEvent(QResizeEvent */*event*/)
|
|||
scrollbar->setValue(scrollbar->maximum());
|
||||
}
|
||||
|
||||
void PopupChatDialog::showEvent(QShowEvent */*event*/)
|
||||
{
|
||||
newMessages = false;
|
||||
emit infoChanged(this);
|
||||
focusDialog();
|
||||
}
|
||||
|
||||
void PopupChatDialog::activate()
|
||||
{
|
||||
PopupChatWindow *window = WINDOW(this);
|
||||
if (window) {
|
||||
if (window->isActiveWindow()) {
|
||||
newMessages = false;
|
||||
window->calculateTitle(this);
|
||||
emit infoChanged(this);
|
||||
focusDialog();
|
||||
}
|
||||
} else {
|
||||
newMessages = false;
|
||||
emit infoChanged(this);
|
||||
focusDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -524,56 +539,60 @@ void PopupChatDialog::onPrivateChatChanged(int list, int type)
|
|||
switch (type) {
|
||||
case NOTIFY_TYPE_ADD:
|
||||
{
|
||||
std::list<ChatInfo> savedOfflineChatNew;
|
||||
if (!isChatLobby()) {
|
||||
std::list<ChatInfo> savedOfflineChatNew;
|
||||
|
||||
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
||||
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
||||
|
||||
std::list<ChatInfo> offlineChat;
|
||||
if (rsMsgs->getPrivateChatQueueCount(false) && rsMsgs->getPrivateChatQueue(false, dialogId, offlineChat)) {
|
||||
ui.actionClearOfflineMessages->setEnabled(true);
|
||||
std::list<ChatInfo> offlineChat;
|
||||
if (rsMsgs->getPrivateChatQueueCount(false) && rsMsgs->getPrivateChatQueue(false, dialogId, offlineChat)) {
|
||||
ui.actionClearOfflineMessages->setEnabled(true);
|
||||
|
||||
std::list<ChatInfo>::iterator it;
|
||||
for(it = offlineChat.begin(); it != offlineChat.end(); it++) {
|
||||
/* are they public? */
|
||||
if ((it->chatflags & RS_CHAT_PRIVATE) == 0) {
|
||||
/* this should not happen */
|
||||
continue;
|
||||
std::list<ChatInfo>::iterator it;
|
||||
for(it = offlineChat.begin(); it != offlineChat.end(); it++) {
|
||||
/* are they public? */
|
||||
if ((it->chatflags & RS_CHAT_PRIVATE) == 0) {
|
||||
/* this should not happen */
|
||||
continue;
|
||||
}
|
||||
|
||||
savedOfflineChatNew.push_back(*it);
|
||||
|
||||
if (std::find(savedOfflineChat.begin(), savedOfflineChat.end(), *it) != savedOfflineChat.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
||||
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
||||
QString message = QString::fromStdWString(it->msg);
|
||||
|
||||
addChatMsg(false, name, sendTime, recvTime, message, TYPE_OFFLINE);
|
||||
}
|
||||
|
||||
savedOfflineChatNew.push_back(*it);
|
||||
|
||||
if (std::find(savedOfflineChat.begin(), savedOfflineChat.end(), *it) != savedOfflineChat.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
||||
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
||||
QString message = QString::fromStdWString(it->msg);
|
||||
|
||||
addChatMsg(false, name, sendTime, recvTime, message, TYPE_OFFLINE);
|
||||
}
|
||||
}
|
||||
|
||||
savedOfflineChat = savedOfflineChatNew;
|
||||
savedOfflineChat = savedOfflineChatNew;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NOTIFY_TYPE_DEL:
|
||||
{
|
||||
if (manualDelete == false) {
|
||||
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
||||
if (!isChatLobby()) {
|
||||
if (manualDelete == false) {
|
||||
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
||||
|
||||
// now show saved offline chat messages as sent
|
||||
std::list<ChatInfo>::iterator it;
|
||||
for(it = savedOfflineChat.begin(); it != savedOfflineChat.end(); ++it) {
|
||||
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
||||
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
||||
QString message = QString::fromStdWString(it->msg);
|
||||
// now show saved offline chat messages as sent
|
||||
std::list<ChatInfo>::iterator it;
|
||||
for(it = savedOfflineChat.begin(); it != savedOfflineChat.end(); ++it) {
|
||||
QDateTime sendTime = QDateTime::fromTime_t(it->sendTime);
|
||||
QDateTime recvTime = QDateTime::fromTime_t(it->recvTime);
|
||||
QString message = QString::fromStdWString(it->msg);
|
||||
|
||||
addChatMsg(false, name, sendTime, recvTime, message, TYPE_NORMAL);
|
||||
addChatMsg(false, name, sendTime, recvTime, message, TYPE_NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
savedOfflineChat.clear();
|
||||
savedOfflineChat.clear();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -619,18 +638,14 @@ void PopupChatDialog::insertChatMsgs()
|
|||
|
||||
playsound();
|
||||
|
||||
PopupChatWindow *window = WINDOW(this);
|
||||
if (window) {
|
||||
window->alertDialog(this);
|
||||
}
|
||||
emit newMessage(this);
|
||||
|
||||
PopupChatWindow *window = WINDOW(this);
|
||||
if (isVisible() == false || (window && window->isActiveWindow() == false)) {
|
||||
newMessages = true;
|
||||
|
||||
if (window) {
|
||||
window->calculateTitle(this);
|
||||
}
|
||||
}
|
||||
|
||||
emit infoChanged(this);
|
||||
}
|
||||
|
||||
void PopupChatDialog::addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType)
|
||||
|
@ -962,7 +977,7 @@ void PopupChatDialog::clearOfflineMessages()
|
|||
|
||||
void PopupChatDialog::updateStatus_slot(const QString &peer_id, int status)
|
||||
{
|
||||
updateStatus(peer_id,status) ;
|
||||
updateStatus(peer_id, status);
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
|
@ -1004,10 +1019,7 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
|||
|
||||
peerStatus = status;
|
||||
|
||||
PopupChatWindow *window = WINDOW(this);
|
||||
if (window) {
|
||||
window->calculateTitle(this);
|
||||
}
|
||||
emit infoChanged(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
static void closeChat(const std::string &id);
|
||||
static void privateChatChanged(int list, int type);
|
||||
|
||||
void init();
|
||||
|
||||
void updateStatusString(const QString& peer_id, const QString& statusString);
|
||||
std::string getPeerId() { return dialogId; }
|
||||
QString getTitle() { return dialogName; }
|
||||
|
@ -61,6 +63,16 @@ public:
|
|||
const RSStyle &getStyle();
|
||||
virtual void updateStatus(const QString &peer_id, int status);
|
||||
|
||||
// derived in ChatLobbyDialog.
|
||||
//
|
||||
virtual bool hasPeerStatus() { return true; }
|
||||
virtual bool canClose() { return true; }
|
||||
|
||||
signals:
|
||||
void dialogClose(PopupChatDialog *dialog);
|
||||
void infoChanged(PopupChatDialog *dialog);
|
||||
void newMessage(PopupChatDialog *dialog);
|
||||
|
||||
public slots:
|
||||
void updateStatus_slot(const QString &peer_id, int status);
|
||||
|
||||
|
@ -71,16 +83,19 @@ protected:
|
|||
~PopupChatDialog();
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *ev);
|
||||
|
||||
void insertChatMsgs();
|
||||
void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType);
|
||||
|
||||
// derived in ChatLobbyDialog.
|
||||
//
|
||||
virtual void addIncomingChatMsg(const ChatInfo& info) ;
|
||||
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
||||
// derived in ChatLobbyDialog.
|
||||
//
|
||||
virtual bool addToParent();
|
||||
virtual bool isChatLobby() { return false; } // TODO: spilt into a good base class
|
||||
virtual void addIncomingChatMsg(const ChatInfo& info);
|
||||
virtual QString makeStatusString(const QString& peer_id, const QString& status_string) const;
|
||||
|
||||
private slots:
|
||||
void pasteLink() ;
|
||||
|
@ -150,7 +165,7 @@ private:
|
|||
RSStyle style;
|
||||
|
||||
protected:
|
||||
virtual bool sendPrivateChat(const std::wstring& msg) ; // can be derived to send chat to e.g. a chat lobby
|
||||
virtual bool sendPrivateChat(const std::wstring& msg) ; // can be derived to send chat to e.g. a chat lobby
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::PopupChatDialog ui;
|
||||
|
|
|
@ -88,8 +88,7 @@ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WFlags flags)
|
|||
connect(ui.actionUndockTab, SIGNAL(triggered()), this, SLOT(undockTab()));
|
||||
connect(ui.actionSetOnTop, SIGNAL(toggled(bool)), this, SLOT(setOnTop()));
|
||||
|
||||
connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
|
||||
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabCurrentChanged(int)));
|
||||
connect(ui.tabWidget, SIGNAL(tabChanged(PopupChatDialog*)), this, SLOT(tabChanged(PopupChatDialog*)));
|
||||
|
||||
if (tabbedWindow) {
|
||||
/* signal toggled is called */
|
||||
|
@ -159,7 +158,7 @@ void PopupChatWindow::changeEvent(QEvent *event)
|
|||
void PopupChatWindow::addDialog(PopupChatDialog *dialog)
|
||||
{
|
||||
if (tabbedWindow) {
|
||||
ui.tabWidget->addTab(dialog, dialog->getTitle());
|
||||
ui.tabWidget->addDialog(dialog);
|
||||
} else {
|
||||
ui.horizontalLayout->addWidget(dialog);
|
||||
ui.horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
@ -170,15 +169,20 @@ void PopupChatWindow::addDialog(PopupChatDialog *dialog)
|
|||
/* signal toggled is called */
|
||||
ui.actionSetOnTop->setChecked(PeerSettings->getPrivateChatOnTop(peerId));
|
||||
}
|
||||
|
||||
QObject::connect(dialog, SIGNAL(infoChanged(PopupChatDialog*)), this, SLOT(tabInfoChanged(PopupChatDialog*)));
|
||||
QObject::connect(dialog, SIGNAL(newMessage(PopupChatDialog*)), this, SLOT(tabNewMessage(PopupChatDialog*)));
|
||||
QObject::connect(dialog, SIGNAL(dialogClose(PopupChatDialog*)), this, SLOT(dialogClose(PopupChatDialog*)));
|
||||
}
|
||||
|
||||
void PopupChatWindow::removeDialog(PopupChatDialog *dialog)
|
||||
{
|
||||
QObject::disconnect(dialog, SIGNAL(infoChanged(PopupChatDialog*)), this, SLOT(tabInfoChanged(PopupChatDialog*)));
|
||||
QObject::disconnect(dialog, SIGNAL(newMessage(PopupChatDialog*)), this, SLOT(tabNewMessage(PopupChatDialog*)));
|
||||
QObject::disconnect(dialog, SIGNAL(dialogClose(PopupChatDialog*)), this, SLOT(dialogClose(PopupChatDialog*)));
|
||||
|
||||
if (tabbedWindow) {
|
||||
int tab = ui.tabWidget->indexOf(dialog);
|
||||
if (tab >= 0) {
|
||||
ui.tabWidget->removeTab(tab);
|
||||
}
|
||||
ui.tabWidget->removeDialog(dialog);
|
||||
|
||||
if (ui.tabWidget->count() == 0) {
|
||||
deleteLater();
|
||||
|
@ -220,39 +224,13 @@ void PopupChatWindow::alertDialog(PopupChatDialog */*dialog*/)
|
|||
|
||||
void PopupChatWindow::calculateTitle(PopupChatDialog *dialog)
|
||||
{
|
||||
if (dialog) {
|
||||
if (ui.tabWidget->isVisible()) {
|
||||
int tab = ui.tabWidget->indexOf(dialog);
|
||||
if (tab >= 0) {
|
||||
if (dialog->isTyping()) {
|
||||
ui.tabWidget->setTabIcon(tab, QIcon(IMAGE_TYPING));
|
||||
} else if (dialog->hasNewMessages()) {
|
||||
ui.tabWidget->setTabIcon(tab, QIcon(IMAGE_CHAT));
|
||||
} else {
|
||||
ui.tabWidget->setTabIcon(tab, QIcon(StatusDefs::imageIM(dialog->getPeerStatus())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool hasNewMessages = false;
|
||||
PopupChatDialog *pcd;
|
||||
|
||||
/* is typing */
|
||||
bool isTyping = false;
|
||||
if (ui.tabWidget->isVisible()) {
|
||||
int tabCount = ui.tabWidget->count();
|
||||
for (int i = 0; i < tabCount; i++) {
|
||||
pcd = dynamic_cast<PopupChatDialog*>(ui.tabWidget->widget(i));
|
||||
if (pcd) {
|
||||
if (pcd->isTyping()) {
|
||||
isTyping = true;
|
||||
}
|
||||
if (pcd->hasNewMessages()) {
|
||||
hasNewMessages = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ui.tabWidget->getInfo(isTyping, hasNewMessages, NULL);
|
||||
} else {
|
||||
if (dialog) {
|
||||
isTyping = dialog->isTyping();
|
||||
|
@ -272,7 +250,7 @@ void PopupChatWindow::calculateTitle(PopupChatDialog *dialog)
|
|||
} else if (hasNewMessages) {
|
||||
icon = QIcon(IMAGE_CHAT);
|
||||
} else {
|
||||
if (pcd) {
|
||||
if (pcd && pcd->hasPeerStatus()) {
|
||||
icon = QIcon(StatusDefs::imageIM(pcd->getPeerStatus()));
|
||||
} else {
|
||||
icon = QIcon(IMAGE_WINDOW);
|
||||
|
@ -291,31 +269,32 @@ void PopupChatWindow::calculateTitle(PopupChatDialog *dialog)
|
|||
void PopupChatWindow::getAvatar()
|
||||
{
|
||||
QByteArray ba;
|
||||
if (misc::getOpenAvatarPicture(this, ba))
|
||||
{
|
||||
if (misc::getOpenAvatarPicture(this, ba)) {
|
||||
std::cerr << "Avatar image size = " << ba.size() << std::endl ;
|
||||
|
||||
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()), ba.size()); // last char 0 included.
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatWindow::tabCloseRequested(int tab)
|
||||
void PopupChatWindow::dialogClose(PopupChatDialog *dialog)
|
||||
{
|
||||
QWidget *widget = ui.tabWidget->widget(tab);
|
||||
|
||||
if (widget) {
|
||||
widget->deleteLater();
|
||||
}
|
||||
removeDialog(dialog);
|
||||
}
|
||||
|
||||
void PopupChatWindow::tabCurrentChanged(int tab)
|
||||
void PopupChatWindow::tabChanged(PopupChatDialog *dialog)
|
||||
{
|
||||
PopupChatDialog *pcd = dynamic_cast<PopupChatDialog*>(ui.tabWidget->widget(tab));
|
||||
calculateStyle(dialog);
|
||||
calculateTitle(dialog);
|
||||
}
|
||||
|
||||
if (pcd) {
|
||||
pcd->activate();
|
||||
calculateStyle(pcd);
|
||||
}
|
||||
void PopupChatWindow::tabInfoChanged(PopupChatDialog *dialog)
|
||||
{
|
||||
calculateTitle(dialog);
|
||||
}
|
||||
|
||||
void PopupChatWindow::tabNewMessage(PopupChatDialog *dialog)
|
||||
{
|
||||
alertDialog(dialog);
|
||||
}
|
||||
|
||||
void PopupChatWindow::dockTab()
|
||||
|
|
|
@ -54,8 +54,10 @@ protected:
|
|||
|
||||
private slots:
|
||||
void getAvatar();
|
||||
void tabCloseRequested(int tab);
|
||||
void tabCurrentChanged(int tab);
|
||||
void tabChanged(PopupChatDialog *dialog);
|
||||
void tabInfoChanged(PopupChatDialog *dialog);
|
||||
void tabNewMessage(PopupChatDialog *dialog);
|
||||
void dialogClose(PopupChatDialog *dialog);
|
||||
void dockTab();
|
||||
void undockTab();
|
||||
void setStyle();
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<widget class="ChatTabWidget" name="tabWidget">
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -147,6 +147,14 @@
|
|||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ChatTabWidget</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header location="global">gui/chat/ChatTabWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue