mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 14:42:51 -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
|
@ -224,7 +224,7 @@ const int NOTIFY_LIST_PRIVATE_OUTGOING_CHAT = 15;
|
||||||
const int NOTIFY_LIST_GROUPLIST = 16;
|
const int NOTIFY_LIST_GROUPLIST = 16;
|
||||||
const int NOTIFY_LIST_CHANNELLIST_LOCKED = 17; // use connect with Qt::QueuedConnection
|
const int NOTIFY_LIST_CHANNELLIST_LOCKED = 17; // use connect with Qt::QueuedConnection
|
||||||
const int NOTIFY_LIST_CHAT_LOBBY_INVITATION = 18;
|
const int NOTIFY_LIST_CHAT_LOBBY_INVITATION = 18;
|
||||||
const int NOTIFY_LIST_PUBLIC_CHAT_LOBBY_LIST = 19;
|
const int NOTIFY_LIST_CHAT_LOBBY_LIST = 19;
|
||||||
|
|
||||||
const int NOTIFY_TYPE_SAME = 0x01;
|
const int NOTIFY_TYPE_SAME = 0x01;
|
||||||
const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */
|
const int NOTIFY_TYPE_MOD = 0x02; /* general purpose, check all */
|
||||||
|
|
|
@ -666,7 +666,7 @@ void p3ChatService::handleRecvChatLobbyList(RsChatLobbyListItem *item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PUBLIC_CHAT_LOBBY_LIST,0) ;
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *item)
|
void p3ChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *item)
|
||||||
|
@ -1922,6 +1922,7 @@ bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PRIVATE_INCOMING_CHAT, NOTIFY_TYPE_ADD);
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_PRIVATE_INCOMING_CHAT, NOTIFY_TYPE_ADD);
|
||||||
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD);
|
||||||
|
|
||||||
// send AKN item
|
// send AKN item
|
||||||
sendLobbyStatusNewPeer(lobby_id) ;
|
sendLobbyStatusNewPeer(lobby_id) ;
|
||||||
|
@ -2009,6 +2010,8 @@ bool p3ChatService::joinPublicChatLobby(const ChatLobbyId& lobby_id)
|
||||||
for(std::list<std::string>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
for(std::list<std::string>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
||||||
invitePeerToLobby(lobby_id,*it) ;
|
invitePeerToLobby(lobby_id,*it) ;
|
||||||
|
|
||||||
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2047,11 +2050,14 @@ ChatLobbyId p3ChatService::createChatLobby(const std::string& lobby_name,const s
|
||||||
for(std::list<std::string>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
for(std::list<std::string>::const_iterator it(invited_friends.begin());it!=invited_friends.end();++it)
|
||||||
invitePeerToLobby(lobby_id,*it) ;
|
invitePeerToLobby(lobby_id,*it) ;
|
||||||
|
|
||||||
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_ADD) ;
|
||||||
|
|
||||||
return lobby_id ;
|
return lobby_id ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribeItem *item)
|
void p3ChatService::handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribeItem *item)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||||
std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.find(item->lobby_id) ;
|
std::map<ChatLobbyId,ChatLobbyEntry>::iterator it = _chat_lobbys.find(item->lobby_id) ;
|
||||||
|
|
||||||
|
@ -2074,6 +2080,9 @@ void p3ChatService::handleFriendUnsubscribeLobby(RsChatLobbyUnsubscribeItem *ite
|
||||||
it->second.participating_friends.erase(it2) ;
|
it->second.participating_friends.erase(it2) ;
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_MOD) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
||||||
|
@ -2117,6 +2126,9 @@ void p3ChatService::unsubscribeChatLobby(const ChatLobbyId& id)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CHAT_LOBBY_LIST, NOTIFY_TYPE_DEL) ;
|
||||||
|
|
||||||
// done!
|
// done!
|
||||||
}
|
}
|
||||||
bool p3ChatService::setDefaultNickNameForChatLobby(const std::string& nick)
|
bool p3ChatService::setDefaultNickNameForChatLobby(const std::string& nick)
|
||||||
|
@ -2197,5 +2209,3 @@ void p3ChatService::cleanLobbyCaches()
|
||||||
// also clean inactive lobbies.
|
// also clean inactive lobbies.
|
||||||
// [...]
|
// [...]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,7 @@ HEADERS += rshare.h \
|
||||||
gui/profile/StatusMessage.h \
|
gui/profile/StatusMessage.h \
|
||||||
gui/chat/PopupChatWindow.h \
|
gui/chat/PopupChatWindow.h \
|
||||||
gui/chat/PopupChatDialog.h \
|
gui/chat/PopupChatDialog.h \
|
||||||
|
gui/chat/ChatTabWidget.h \
|
||||||
gui/ChatLobbyWidget.h \
|
gui/ChatLobbyWidget.h \
|
||||||
gui/chat/ChatLobbyDialog.h \
|
gui/chat/ChatLobbyDialog.h \
|
||||||
gui/chat/CreateLobbyDialog.h \
|
gui/chat/CreateLobbyDialog.h \
|
||||||
|
@ -411,6 +412,7 @@ FORMS += gui/StartDialog.ui \
|
||||||
gui/channels/ShareKey.ui \
|
gui/channels/ShareKey.ui \
|
||||||
gui/chat/PopupChatWindow.ui \
|
gui/chat/PopupChatWindow.ui \
|
||||||
gui/chat/PopupChatDialog.ui \
|
gui/chat/PopupChatDialog.ui \
|
||||||
|
gui/chat/ChatTabWidget.ui \
|
||||||
gui/chat/CreateLobbyDialog.ui \
|
gui/chat/CreateLobbyDialog.ui \
|
||||||
gui/ChatLobbyWidget.ui \
|
gui/ChatLobbyWidget.ui \
|
||||||
gui/connect/ConfCertDialog.ui \
|
gui/connect/ConfCertDialog.ui \
|
||||||
|
@ -537,6 +539,7 @@ SOURCES += main.cpp \
|
||||||
gui/channels/ShareKey.cpp \
|
gui/channels/ShareKey.cpp \
|
||||||
gui/chat/PopupChatWindow.cpp \
|
gui/chat/PopupChatWindow.cpp \
|
||||||
gui/chat/PopupChatDialog.cpp \
|
gui/chat/PopupChatDialog.cpp \
|
||||||
|
gui/chat/ChatTabWidget.cpp \
|
||||||
gui/ChatLobbyWidget.cpp \
|
gui/ChatLobbyWidget.cpp \
|
||||||
gui/chat/ChatLobbyDialog.cpp \
|
gui/chat/ChatLobbyDialog.cpp \
|
||||||
gui/chat/CreateLobbyDialog.cpp \
|
gui/chat/CreateLobbyDialog.cpp \
|
||||||
|
|
|
@ -1,84 +1,321 @@
|
||||||
#include <QTableWidget>
|
#include <QTreeWidget>
|
||||||
#include <retroshare/rsmsgs.h>
|
#include <QMenu>
|
||||||
|
#include <QMessageBox>
|
||||||
#include "ChatLobbyWidget.h"
|
#include "ChatLobbyWidget.h"
|
||||||
|
#include "chat/CreateLobbyDialog.h"
|
||||||
|
#include "common/RSTreeWidgetItem.h"
|
||||||
|
#include "notifyqt.h"
|
||||||
|
#include "chat/ChatLobbyDialog.h"
|
||||||
|
|
||||||
#define COL_LOBBY_NAME 0
|
#include "retroshare/rsmsgs.h"
|
||||||
#define COL_LOBBY_ID 1
|
#include "retroshare/rspeers.h"
|
||||||
#define COL_LOBBY_TYPE 2
|
#include "retroshare/rsnotify.h"
|
||||||
#define COL_LOBBY_STATE 3
|
|
||||||
#define COL_LOBBY_COUNT 4
|
#define COLUMN_NAME 0
|
||||||
|
#define COLUMN_USER_COUNT 1
|
||||||
|
#define COLUMN_COUNT 2
|
||||||
|
|
||||||
|
#define COLUMN_DATA 0
|
||||||
|
#define ROLE_SORT Qt::UserRole
|
||||||
|
#define ROLE_ID Qt::UserRole + 1
|
||||||
|
#define ROLE_SUBSCRIBED Qt::UserRole + 2
|
||||||
|
|
||||||
|
#define TYPE_FOLDER 0
|
||||||
|
#define TYPE_LOBBY 1
|
||||||
|
|
||||||
|
#define IMAGE_CREATE ""
|
||||||
|
#define IMAGE_PUBLIC ""
|
||||||
|
#define IMAGE_PRIVATE ""
|
||||||
|
#define IMAGE_SUBSCRIBE ""
|
||||||
|
#define IMAGE_UNSUBSCRIBE ""
|
||||||
|
|
||||||
|
static ChatLobbyWidget *instance = NULL;
|
||||||
|
|
||||||
ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
|
ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WFlags flags)
|
||||||
: RsAutoUpdatePage(5000,parent)
|
: RsAutoUpdatePage(5000,parent)
|
||||||
{
|
{
|
||||||
setupUi(this) ;
|
setupUi(this);
|
||||||
|
|
||||||
QObject::connect(this,SIGNAL(cellDoubleClicked(int,int)),this,SLOT(doubleClickCell(int,int))) ;
|
if (instance == NULL) {
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
_lobby_table_TW->setColumnHidden(1,true) ;
|
QObject::connect(NotifyQt::getInstance(), SIGNAL(lobbyListChanged()), SLOT(lobbyChanged()));
|
||||||
updateDisplay() ;
|
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(chatLobbyInviteReceived()), this, SLOT(readChatLobbyInvites()));
|
||||||
|
|
||||||
|
QObject::connect(lobbyTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(lobbyTreeWidgetCostumPopupMenu()));
|
||||||
|
QObject::connect(lobbyTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int)));
|
||||||
|
QObject::connect(lobbyTabWidget, SIGNAL(infoChanged()), this, SLOT(tabInfoChanged()));
|
||||||
|
|
||||||
|
compareRole = new RSTreeWidgetItemCompareRole;
|
||||||
|
compareRole->setRole(COLUMN_NAME, ROLE_SORT);
|
||||||
|
|
||||||
|
lobbyTreeWidget->setColumnCount(COLUMN_COUNT);
|
||||||
|
lobbyTreeWidget->sortItems(COLUMN_NAME, Qt::AscendingOrder);
|
||||||
|
|
||||||
|
QTreeWidgetItem *headerItem = lobbyTreeWidget->headerItem();
|
||||||
|
headerItem->setText(COLUMN_NAME, tr("Name"));
|
||||||
|
headerItem->setText(COLUMN_USER_COUNT, tr("Count"));
|
||||||
|
headerItem->setTextAlignment(COLUMN_NAME, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
headerItem->setTextAlignment(COLUMN_USER_COUNT, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
|
||||||
|
QHeaderView *header = lobbyTreeWidget->header();
|
||||||
|
header->setResizeMode(COLUMN_NAME, QHeaderView::Interactive);
|
||||||
|
header->setResizeMode(COLUMN_USER_COUNT, QHeaderView::Stretch);
|
||||||
|
|
||||||
|
lobbyTreeWidget->setColumnWidth(COLUMN_NAME, 200);
|
||||||
|
lobbyTreeWidget->setColumnWidth(COLUMN_USER_COUNT, 50);
|
||||||
|
|
||||||
|
privateLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
|
||||||
|
privateLobbyItem->setText(COLUMN_NAME, tr("Private Lobbies"));
|
||||||
|
privateLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "1");
|
||||||
|
lobbyTreeWidget->insertTopLevelItem(0, privateLobbyItem);
|
||||||
|
|
||||||
|
publicLobbyItem = new RSTreeWidgetItem(compareRole, TYPE_FOLDER);
|
||||||
|
publicLobbyItem->setText(COLUMN_NAME, tr("Public Lobbies"));
|
||||||
|
publicLobbyItem->setData(COLUMN_NAME, ROLE_SORT, "2");
|
||||||
|
lobbyTreeWidget->insertTopLevelItem(1, publicLobbyItem);
|
||||||
|
|
||||||
|
lobbyTreeWidget->expandAll();
|
||||||
|
|
||||||
|
lobbyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatLobbyWidget::~ChatLobbyWidget()
|
ChatLobbyWidget::~ChatLobbyWidget()
|
||||||
{
|
{
|
||||||
|
if (this == instance) {
|
||||||
|
instance = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ ChatTabWidget *ChatLobbyWidget::getTabWidget()
|
||||||
|
{
|
||||||
|
return instance ? instance->lobbyTabWidget : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::lobbyTreeWidgetCostumPopupMenu()
|
||||||
|
{
|
||||||
|
QMenu contextMnu(this);
|
||||||
|
|
||||||
|
contextMnu.addAction(QIcon(IMAGE_CREATE), tr("Create chat lobby"), this, SLOT(createChatLobby()));
|
||||||
|
|
||||||
|
QTreeWidgetItem *item = lobbyTreeWidget->currentItem();
|
||||||
|
if (item && item->type() == TYPE_LOBBY) {
|
||||||
|
if (item->data(COLUMN_DATA, ROLE_SUBSCRIBED).toBool()) {
|
||||||
|
contextMnu.addAction(QIcon(IMAGE_UNSUBSCRIBE), tr("Unsubscribe"), this, SLOT(unsubscribeItem()));
|
||||||
|
} else {
|
||||||
|
contextMnu.addAction(QIcon(IMAGE_SUBSCRIBE), tr("Subscribe"), this, SLOT(subscribeItem()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
contextMnu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::lobbyChanged()
|
||||||
|
{
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void updateItem(QTreeWidgetItem *item, ChatLobbyId id, const std::string &name, int count, bool subscribed)
|
||||||
|
{
|
||||||
|
item->setText(COLUMN_NAME, QString::fromUtf8(name.c_str()));
|
||||||
|
item->setData(COLUMN_NAME, ROLE_SORT, QString::fromUtf8(name.c_str()));
|
||||||
|
|
||||||
|
item->setText(COLUMN_USER_COUNT, QString::number(count));
|
||||||
|
|
||||||
|
item->setData(COLUMN_DATA, ROLE_ID, id);
|
||||||
|
item->setData(COLUMN_DATA, ROLE_SUBSCRIBED, subscribed);
|
||||||
|
|
||||||
|
for (int column = 0; column < COLUMN_COUNT; ++column) {
|
||||||
|
item->setTextColor(column, subscribed ? QColor() : QColor(Qt::gray));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::updateDisplay()
|
void ChatLobbyWidget::updateDisplay()
|
||||||
{
|
{
|
||||||
std::cerr << "updating chat lobby display!" << std::endl;
|
std::cerr << "updating chat lobby display!" << std::endl;
|
||||||
std::vector<PublicChatLobbyRecord> public_lobbies ;
|
std::vector<PublicChatLobbyRecord> publicLobbies;
|
||||||
rsMsgs->getListOfNearbyChatLobbies(public_lobbies) ;
|
rsMsgs->getListOfNearbyChatLobbies(publicLobbies);
|
||||||
|
|
||||||
std::list<ChatLobbyInfo> linfos ;
|
std::list<ChatLobbyInfo> lobbies;
|
||||||
rsMsgs->getChatLobbyList(linfos) ;
|
rsMsgs->getChatLobbyList(lobbies);
|
||||||
|
|
||||||
std::cerr << "got " << public_lobbies.size() << " public lobbies, and " << linfos.size() << " private lobbies." << std::endl;
|
std::cerr << "got " << publicLobbies.size() << " public lobbies, and " << lobbies.size() << " private lobbies." << std::endl;
|
||||||
|
|
||||||
// now, do a nice display of public lobbies.
|
// now, do a nice display of lobbies
|
||||||
|
|
||||||
_lobby_table_TW->clear() ;
|
std::string vpid;
|
||||||
int n=0 ;
|
uint32_t i;
|
||||||
|
uint32_t size = publicLobbies.size();
|
||||||
|
std::list<ChatLobbyInfo>::const_iterator lobbyIt;
|
||||||
|
|
||||||
QList<QTreeWidgetItem*> list ;
|
// remove not existing public lobbies
|
||||||
std::string vpid ;
|
int childCount = publicLobbyItem->childCount();
|
||||||
for(uint32_t i=0;i<public_lobbies.size();++i,++n)
|
int childIndex = 0;
|
||||||
if(!rsMsgs->getVirtualPeerId(public_lobbies[i].lobby_id,vpid)) // only display unsubscribed lobbies
|
while (childIndex < childCount) {
|
||||||
{
|
QTreeWidgetItem *itemLoop = publicLobbyItem->child(childIndex);
|
||||||
std::cerr << "adding " << public_lobbies[i].lobby_name << " #" << std::hex << public_lobbies[i].lobby_id << std::dec << " public " << public_lobbies[i].total_number_of_peers << " peers." << std::endl;
|
if (itemLoop->type() == TYPE_LOBBY) {
|
||||||
|
// check for public lobby
|
||||||
QStringList strl ;
|
for (i = 0; i < size; ++i) {
|
||||||
|
if (itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == publicLobbies[i].lobby_id) {
|
||||||
strl.push_back(QString::fromUtf8(public_lobbies[i].lobby_name.c_str())) ;
|
break;
|
||||||
strl.push_back(QString::number(public_lobbies[i].lobby_id,16)) ;
|
}
|
||||||
strl.push_back(tr("Public")) ;
|
|
||||||
strl.push_back(QString::number(public_lobbies[i].total_number_of_peers)) ;
|
|
||||||
strl.push_back("") ;
|
|
||||||
|
|
||||||
list.push_back(new QTreeWidgetItem(strl)) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());it!=linfos.end();++it,++n)
|
if (i >= size) {
|
||||||
{
|
// check for private lobby with public level
|
||||||
std::cerr << "adding " << (*it).lobby_name << " #" << std::hex << (*it).lobby_id << std::dec << " private " << (*it).nick_names.size() << " peers." << std::endl;
|
for (lobbyIt = lobbies.begin(); lobbyIt != lobbies.end(); ++lobbyIt) {
|
||||||
|
if (lobbyIt->lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC &&
|
||||||
QStringList strl ;
|
itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == lobbyIt->lobby_id) {
|
||||||
strl.push_back(QString::fromUtf8((*it).lobby_name.c_str())) ;
|
break;
|
||||||
strl.push_back(QString::number((*it).lobby_id,16)) ;
|
}
|
||||||
|
|
||||||
if( (*it).lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC)
|
|
||||||
strl.push_back(tr("Public")) ;
|
|
||||||
else
|
|
||||||
strl.push_back(tr("Private")) ;
|
|
||||||
|
|
||||||
strl.push_back(QString::number((*it).nick_names.size())) ;
|
|
||||||
strl.push_back(tr("subscribed")) ;
|
|
||||||
|
|
||||||
list.push_back(new QTreeWidgetItem(strl)) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_lobby_table_TW->addTopLevelItems(list) ;
|
if (lobbyIt == lobbies.end()) {
|
||||||
|
delete(publicLobbyItem->takeChild(publicLobbyItem->indexOfChild(itemLoop)));
|
||||||
|
childCount = publicLobbyItem->childCount();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
childIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < size; ++i) {
|
||||||
|
const PublicChatLobbyRecord &lobby = publicLobbies[i];
|
||||||
|
|
||||||
|
std::cerr << "adding " << lobby.lobby_name << " #" << std::hex << lobby.lobby_id << std::dec << " public " << lobby.total_number_of_peers << " peers." << std::endl;
|
||||||
|
|
||||||
|
QTreeWidgetItem *item = NULL;
|
||||||
|
|
||||||
|
// search existing item
|
||||||
|
childCount = publicLobbyItem->childCount();
|
||||||
|
for (childIndex = 0; childIndex < childCount; childIndex++) {
|
||||||
|
QTreeWidgetItem *itemLoop = publicLobbyItem->child(childIndex);
|
||||||
|
if (itemLoop->type() == TYPE_LOBBY && itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == lobby.lobby_id) {
|
||||||
|
item = itemLoop;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item == NULL) {
|
||||||
|
item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY);
|
||||||
|
publicLobbyItem->addChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
item->setIcon(COLUMN_NAME, QIcon(IMAGE_PUBLIC));
|
||||||
|
|
||||||
|
bool subscribed = false;
|
||||||
|
if (rsMsgs->getVirtualPeerId(lobby.lobby_id, vpid)) {
|
||||||
|
subscribed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateItem(item, lobby.lobby_id, lobby.lobby_name, lobby.total_number_of_peers, subscribed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove not existing private lobbies
|
||||||
|
childCount = privateLobbyItem->childCount();
|
||||||
|
childIndex = 0;
|
||||||
|
while (childIndex < childCount) {
|
||||||
|
QTreeWidgetItem *itemLoop = privateLobbyItem->child(childIndex);
|
||||||
|
if (itemLoop->type() == TYPE_LOBBY) {
|
||||||
|
for (lobbyIt = lobbies.begin(); lobbyIt != lobbies.end(); ++lobbyIt) {
|
||||||
|
if (lobbyIt->lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PRIVATE &&
|
||||||
|
itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == lobbyIt->lobby_id) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lobbyIt == lobbies.end()) {
|
||||||
|
delete(privateLobbyItem->takeChild(privateLobbyItem->indexOfChild(itemLoop)));
|
||||||
|
childCount = privateLobbyItem->childCount();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
childIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (lobbyIt = lobbies.begin(); lobbyIt != lobbies.end(); ++lobbyIt) {
|
||||||
|
const ChatLobbyInfo &lobby = *lobbyIt;
|
||||||
|
|
||||||
|
std::cerr << "adding " << lobby.lobby_name << " #" << std::hex << lobby.lobby_id << std::dec << " private " << lobby.nick_names.size() << " peers." << std::endl;
|
||||||
|
|
||||||
|
QTreeWidgetItem *itemParent;
|
||||||
|
if (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) {
|
||||||
|
itemParent = publicLobbyItem;
|
||||||
|
} else {
|
||||||
|
itemParent = privateLobbyItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem *item = NULL;
|
||||||
|
|
||||||
|
// search existing item
|
||||||
|
childCount = itemParent->childCount();
|
||||||
|
for (childIndex = 0; childIndex < childCount; childIndex++) {
|
||||||
|
QTreeWidgetItem *itemLoop = itemParent->child(childIndex);
|
||||||
|
if (itemLoop->type() == TYPE_LOBBY && itemLoop->data(COLUMN_DATA, ROLE_ID).toULongLong() == lobby.lobby_id) {
|
||||||
|
item = itemLoop;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item == NULL) {
|
||||||
|
item = new RSTreeWidgetItem(compareRole, TYPE_LOBBY);
|
||||||
|
itemParent->addChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lobby.lobby_privacy_level == RS_CHAT_LOBBY_PRIVACY_LEVEL_PUBLIC) {
|
||||||
|
item->setIcon(COLUMN_NAME, QIcon(IMAGE_PUBLIC));
|
||||||
|
} else {
|
||||||
|
item->setIcon(COLUMN_NAME, QIcon(IMAGE_PRIVATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateItem(item, lobby.lobby_id, lobby.lobby_name, lobby.nick_names.size(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyWidget::doubleClickCell(int row,int col)
|
void ChatLobbyWidget::createChatLobby()
|
||||||
|
{
|
||||||
|
std::list<std::string> friends;
|
||||||
|
CreateLobbyDialog(friends).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::subscribeItem()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item = lobbyTreeWidget->currentItem();
|
||||||
|
if (item == NULL && item->type() != TYPE_LOBBY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||||
|
if (rsMsgs->joinPublicChatLobby(id)) {
|
||||||
|
std::string vpeer_id;
|
||||||
|
if (rsMsgs->getVirtualPeerId(id, vpeer_id)) {
|
||||||
|
PopupChatDialog::chatFriend(vpeer_id) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::unsubscribeItem()
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item = lobbyTreeWidget->currentItem();
|
||||||
|
if (item == NULL && item->type() != TYPE_LOBBY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ChatLobbyId id = item->data(COLUMN_DATA, ROLE_ID).toULongLong();
|
||||||
|
|
||||||
|
std::string vpeer_id;
|
||||||
|
if (rsMsgs->getVirtualPeerId(id, vpeer_id)) {
|
||||||
|
PopupChatDialog::closeChat(vpeer_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
rsMsgs->unsubscribeChatLobby(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||||
{
|
{
|
||||||
// Each lobby can be joined directly, by calling
|
// Each lobby can be joined directly, by calling
|
||||||
// rsMsgs->joinPublicLobby(chatLobbyId) ;
|
// rsMsgs->joinPublicLobby(chatLobbyId) ;
|
||||||
|
@ -94,4 +331,47 @@ void ChatLobbyWidget::doubleClickCell(int row,int col)
|
||||||
// rsMsgs->getVirtualPeerId(ChatLobbyId,std::string& virtual_peer_id)
|
// rsMsgs->getVirtualPeerId(ChatLobbyId,std::string& virtual_peer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& nickname, const QString& str)
|
||||||
|
{
|
||||||
|
std::cerr << "Received displayChatLobbyEvent()!" << std::endl;
|
||||||
|
|
||||||
|
std::string vpid;
|
||||||
|
if (rsMsgs->getVirtualPeerId(lobby_id, vpid)) {
|
||||||
|
if (ChatLobbyDialog *cld = dynamic_cast<ChatLobbyDialog*>(PopupChatDialog::getExistingInstance(vpid))) {
|
||||||
|
cld->displayLobbyEvent(event_type, nickname, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::readChatLobbyInvites()
|
||||||
|
{
|
||||||
|
std::list<ChatLobbyInvite> invites;
|
||||||
|
rsMsgs->getPendingChatLobbyInvites(invites);
|
||||||
|
|
||||||
|
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it) {
|
||||||
|
if (QMessageBox::Ok == QMessageBox::question(NULL, tr("Invitation to chat lobby"), QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str()) + QString(" invites you to chat lobby named ") + QString::fromUtf8((*it).lobby_name.c_str()), QMessageBox::Ok, QMessageBox::Ignore)) {
|
||||||
|
std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl;
|
||||||
|
|
||||||
|
rsMsgs->acceptLobbyInvite((*it).lobby_id);
|
||||||
|
|
||||||
|
std::string vpid;
|
||||||
|
if(rsMsgs->getVirtualPeerId((*it).lobby_id,vpid )) {
|
||||||
|
PopupChatDialog::chatFriend(vpid);
|
||||||
|
} else {
|
||||||
|
std::cerr << "No lobby known with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rsMsgs->denyLobbyInvite((*it).lobby_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::tabInfoChanged()
|
||||||
|
{
|
||||||
|
emit infoChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatLobbyWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon)
|
||||||
|
{
|
||||||
|
lobbyTabWidget->getInfo(isTyping, hasNewMessage, icon);
|
||||||
|
}
|
||||||
|
|
|
@ -3,20 +3,41 @@
|
||||||
#include "ui_ChatLobbyWidget.h"
|
#include "ui_ChatLobbyWidget.h"
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
|
|
||||||
class ChatLobbyWidget : public RsAutoUpdatePage, public Ui::ChatLobbyWidget
|
class RSTreeWidgetItemCompareRole;
|
||||||
|
class ChatTabWidget;
|
||||||
|
|
||||||
|
class ChatLobbyWidget : public RsAutoUpdatePage, Ui::ChatLobbyWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
ChatLobbyWidget(QWidget *parent = 0, Qt::WFlags flags = 0);
|
ChatLobbyWidget(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
|
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
~ChatLobbyWidget();
|
~ChatLobbyWidget();
|
||||||
|
|
||||||
virtual void updateDisplay() ;
|
virtual void updateDisplay();
|
||||||
|
void getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon);
|
||||||
|
|
||||||
protected slots:
|
static ChatTabWidget *getTabWidget();
|
||||||
void doubleClickCell(int,int);
|
|
||||||
|
signals:
|
||||||
|
void infoChanged();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void lobbyChanged();
|
||||||
|
void lobbyTreeWidgetCostumPopupMenu();
|
||||||
|
void createChatLobby();
|
||||||
|
void subscribeItem();
|
||||||
|
void unsubscribeItem();
|
||||||
|
void itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||||
|
void displayChatLobbyEvent(qulonglong lobby_id, int event_type, const QString& nickname, const QString& str);
|
||||||
|
void readChatLobbyInvites();
|
||||||
|
void tabInfoChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
RSTreeWidgetItemCompareRole *compareRole;
|
||||||
|
QTreeWidgetItem *privateLobbyItem;
|
||||||
|
QTreeWidgetItem *publicLobbyItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,47 +10,37 @@
|
||||||
<height>397</height>
|
<height>397</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeWidget" name="_lobby_table_TW">
|
<widget class="QTreeWidget" name="lobbyTreeWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<column>
|
<property name="contextMenuPolicy">
|
||||||
<property name="text">
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
</property>
|
||||||
</column>
|
<property name="editTriggers">
|
||||||
<column>
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
<property name="text">
|
|
||||||
<string>ID</string>
|
|
||||||
</property>
|
</property>
|
||||||
</column>
|
<property name="rootIsDecorated">
|
||||||
<column>
|
<bool>false</bool>
|
||||||
<property name="text">
|
|
||||||
<string>Type</string>
|
|
||||||
</property>
|
</property>
|
||||||
</column>
|
<property name="itemsExpandable">
|
||||||
<column>
|
<bool>false</bool>
|
||||||
<property name="text">
|
|
||||||
<string>Count</string>
|
|
||||||
</property>
|
</property>
|
||||||
</column>
|
<property name="expandsOnDoubleClick">
|
||||||
<column>
|
<bool>false</bool>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>S</string>
|
<property name="columnCount">
|
||||||
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="_lobby_tab_TW">
|
<widget class="ChatTabWidget" name="lobbyTabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>-1</number>
|
<number>-1</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -58,6 +48,14 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>ChatTabWidget</class>
|
||||||
|
<extends>QTabWidget</extends>
|
||||||
|
<header location="global">gui/chat/ChatTabWidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
#include "channels/CreateChannel.h"
|
#include "channels/CreateChannel.h"
|
||||||
#include "chat/PopupChatDialog.h"
|
#include "chat/PopupChatDialog.h"
|
||||||
#include "chat/ChatLobbyDialog.h"
|
|
||||||
#include "common/Emoticons.h"
|
#include "common/Emoticons.h"
|
||||||
#include "common/vmessagebox.h"
|
#include "common/vmessagebox.h"
|
||||||
#include "connect/ConfCertDialog.h"
|
#include "connect/ConfCertDialog.h"
|
||||||
|
@ -86,7 +85,9 @@ FriendsDialog::FriendsDialog(QWidget *parent)
|
||||||
ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME);
|
ui.avatar->setFrameType(AvatarWidget::STATUS_FRAME);
|
||||||
ui.avatar->setOwnId();
|
ui.avatar->setOwnId();
|
||||||
|
|
||||||
ui.peertabWidget->addTab(new ChatLobbyWidget(), tr("Chat lobbies"));
|
chatLobbyWidget = new ChatLobbyWidget();
|
||||||
|
QObject::connect(chatLobbyWidget, SIGNAL(infoChanged()), this, SLOT(lobbyInfoChanged()));
|
||||||
|
chatlobbyTabIndex = ui.peertabWidget->addTab(chatLobbyWidget, tr("Chat lobbies"));
|
||||||
ui.peertabWidget->setTabPosition(QTabWidget::North);
|
ui.peertabWidget->setTabPosition(QTabWidget::North);
|
||||||
ui.peertabWidget->addTab(new ProfileWidget(), tr("Profile"));
|
ui.peertabWidget->addTab(new ProfileWidget(), tr("Profile"));
|
||||||
NewsFeed *newsFeed = new NewsFeed();
|
NewsFeed *newsFeed = new NewsFeed();
|
||||||
|
@ -300,21 +301,6 @@ void FriendsDialog::updateStatusTyping()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendsDialog::updatePublicLobbyList()
|
|
||||||
{
|
|
||||||
std::cerr << "Updating public lobby list !!" << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FriendsDialog::displayChatLobbyEvent(qulonglong lobby_id,int event_type,const QString& nickname,const QString& str)
|
|
||||||
{
|
|
||||||
std::cerr << "Received displayChatLobbyEvent()!" << std::endl;
|
|
||||||
|
|
||||||
std::string vpid ;
|
|
||||||
if(rsMsgs->getVirtualPeerId(lobby_id,vpid))
|
|
||||||
if( ChatLobbyDialog *cld = dynamic_cast<ChatLobbyDialog*>(PopupChatDialog::getExistingInstance(vpid)))
|
|
||||||
cld->displayLobbyEvent(event_type,nickname,str) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called by libretroshare through notifyQt to display the peer's status
|
// Called by libretroshare through notifyQt to display the peer's status
|
||||||
//
|
//
|
||||||
void FriendsDialog::updateStatusString(const QString& peer_id, const QString& status_string)
|
void FriendsDialog::updateStatusString(const QString& peer_id, const QString& status_string)
|
||||||
|
@ -329,28 +315,6 @@ void FriendsDialog::updateStatusString(const QString& peer_id, const QString& st
|
||||||
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
|
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendsDialog::readChatLobbyInvites()
|
|
||||||
{
|
|
||||||
std::list<ChatLobbyInvite> invites ;
|
|
||||||
rsMsgs->getPendingChatLobbyInvites(invites) ;
|
|
||||||
|
|
||||||
for(std::list<ChatLobbyInvite>::const_iterator it(invites.begin());it!=invites.end();++it)
|
|
||||||
if(QMessageBox::Ok == QMessageBox::question(NULL,tr("Invitation to chat lobby"),QString::fromUtf8(rsPeers->getPeerName((*it).peer_id).c_str())+QString(" invites you to chat lobby named ")+QString::fromUtf8((*it).lobby_name.c_str()),QMessageBox::Ok,QMessageBox::Ignore))
|
|
||||||
{
|
|
||||||
std::cerr << "Accepting invite to lobby " << (*it).lobby_name << std::endl;
|
|
||||||
|
|
||||||
rsMsgs->acceptLobbyInvite( (*it).lobby_id ) ;
|
|
||||||
|
|
||||||
std::string vpid ;
|
|
||||||
if(rsMsgs->getVirtualPeerId( (*it).lobby_id,vpid ) )
|
|
||||||
PopupChatDialog::chatFriend(vpid) ;
|
|
||||||
else
|
|
||||||
std::cerr << "No lobby known with id 0x" << std::hex << (*it).lobby_id << std::dec << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
rsMsgs->denyLobbyInvite( (*it).lobby_id ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FriendsDialog::updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat)
|
void FriendsDialog::updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat)
|
||||||
{
|
{
|
||||||
if(is_private_chat)
|
if(is_private_chat)
|
||||||
|
@ -860,3 +824,13 @@ void FriendsDialog::newsFeedChanged(int count)
|
||||||
ui.peertabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED));
|
ui.peertabWidget->tabBar()->setTabIcon(newsFeedTabIndex, QIcon(IMAGE_NEWSFEED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FriendsDialog::lobbyInfoChanged()
|
||||||
|
{
|
||||||
|
bool isTyping;
|
||||||
|
bool hasNewMessage;
|
||||||
|
QIcon icon;
|
||||||
|
chatLobbyWidget->getInfo(isTyping, hasNewMessage, &icon);
|
||||||
|
|
||||||
|
ui.peertabWidget->setTabIcon(chatlobbyTabIndex, icon);
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ class QAction;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
class QTextCharFormat;
|
class QTextCharFormat;
|
||||||
class ChatDialog;
|
class ChatDialog;
|
||||||
|
class ChatLobbyWidget;
|
||||||
|
|
||||||
class FriendsDialog : public RsAutoUpdatePage
|
class FriendsDialog : public RsAutoUpdatePage
|
||||||
{
|
{
|
||||||
|
@ -56,10 +57,7 @@ public slots:
|
||||||
|
|
||||||
void insertChat();
|
void insertChat();
|
||||||
void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText));
|
||||||
void displayChatLobbyEvent(qulonglong,int,const QString&,const QString&) ;
|
|
||||||
void updatePublicLobbyList() ;
|
|
||||||
void resetStatusBar() ;
|
void resetStatusBar() ;
|
||||||
void readChatLobbyInvites() ;
|
|
||||||
|
|
||||||
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
||||||
|
|
||||||
|
@ -114,6 +112,8 @@ private slots:
|
||||||
|
|
||||||
void newsFeedChanged(int count);
|
void newsFeedChanged(int count);
|
||||||
|
|
||||||
|
void lobbyInfoChanged();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void notifyGroupChat(const QString&,const QString&) ;
|
void notifyGroupChat(const QString&,const QString&) ;
|
||||||
|
|
||||||
|
@ -140,6 +140,9 @@ private:
|
||||||
QColor newsFeedTabColor;
|
QColor newsFeedTabColor;
|
||||||
QString newsFeedText;
|
QString newsFeedText;
|
||||||
|
|
||||||
|
ChatLobbyWidget *chatLobbyWidget;
|
||||||
|
int chatlobbyTabIndex;
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::FriendsDialog ui;
|
Ui::FriendsDialog ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,22 +45,28 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ChatLobbyDialog.h"
|
#include "ChatLobbyDialog.h"
|
||||||
|
#include "gui/ChatLobbyWidget.h"
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
ChatLobbyDialog::ChatLobbyDialog(const std::string& dialog_id,const ChatLobbyId& lid, const QString &name, QWidget *parent, Qt::WFlags flags)
|
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)
|
: PopupChatDialog(dialog_id, name, parent, flags), lobby_id(lid)
|
||||||
{
|
{
|
||||||
// remove the avatar widget. Replace it with a friends list.
|
// remove the avatar widget. Replace it with a friends list.
|
||||||
|
ui.avatarWidget->hide();
|
||||||
|
ui.ownAvatarWidget->hide();
|
||||||
|
PopupChatDialog::updateStatus(QString::fromStdString(getPeerId()),RS_STATUS_ONLINE);
|
||||||
|
|
||||||
ui.avatarWidget->hide() ;
|
// hide history buttons
|
||||||
PopupChatDialog::updateStatus(QString::fromStdString(getPeerId()),RS_STATUS_ONLINE) ;
|
ui.actionClearOfflineMessages->setVisible(false);
|
||||||
|
ui.actionDelete_Chat_History->setVisible(false);
|
||||||
|
ui.actionMessageHistory->setVisible(false);
|
||||||
|
|
||||||
QObject::connect(this,SIGNAL(close()),this,SLOT(closeAndAsk())) ;
|
ui.avatarFrameButton->setToolTip(tr("Hide participants"));
|
||||||
|
|
||||||
ui.avatarframe->layout()->addWidget(new QLabel(tr("Participants:"))) ;
|
ui.avatarframe->layout()->addWidget(new QLabel(tr("Participants:")));
|
||||||
friendsListWidget = new QListWidget ;
|
friendsListWidget = new QListWidget;
|
||||||
ui.avatarframe->layout()->addWidget(friendsListWidget) ;
|
ui.avatarframe->layout()->addWidget(friendsListWidget);
|
||||||
ui.avatarframe->layout()->addItem(new QSpacerItem(12, 335, QSizePolicy::Minimum, QSizePolicy::Expanding)) ;
|
ui.avatarframe->layout()->addItem(new QSpacerItem(12, 335, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
|
@ -69,17 +75,26 @@ ChatLobbyDialog::~ChatLobbyDialog()
|
||||||
// announce leaving of lobby
|
// announce leaving of lobby
|
||||||
|
|
||||||
// check that the lobby still exists.
|
// check that the lobby still exists.
|
||||||
ChatLobbyId lid ;
|
ChatLobbyId lid;
|
||||||
if(!rsMsgs->isLobbyId(getPeerId(),lid))
|
if (rsMsgs->isLobbyId(getPeerId(),lid)) {
|
||||||
return ;
|
rsMsgs->unsubscribeChatLobby(lobby_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(QMessageBox::Yes == QMessageBox::question(NULL,tr("Unsubscribe to lobby?"),tr("Do you want to unsubscribe to this chat lobby?"),QMessageBox::Yes | QMessageBox::No))
|
bool ChatLobbyDialog::addToParent()
|
||||||
rsMsgs->unsubscribeChatLobby(lobby_id) ;
|
{
|
||||||
|
ChatTabWidget *tabWidget = ChatLobbyWidget::getTabWidget();
|
||||||
|
if (tabWidget) {
|
||||||
|
tabWidget->addDialog(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyDialog::setNickName(const QString& nick)
|
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)
|
void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
||||||
|
@ -87,7 +102,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
||||||
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
QDateTime sendTime = QDateTime::fromTime_t(info.sendTime);
|
||||||
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
QDateTime recvTime = QDateTime::fromTime_t(info.recvTime);
|
||||||
QString message = QString::fromStdWString(info.msg);
|
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);
|
addChatMsg(true, name, sendTime, recvTime, message, TYPE_NORMAL);
|
||||||
|
|
||||||
|
@ -96,40 +111,42 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
||||||
static time_t last = 0 ;
|
static time_t last = 0 ;
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
|
|
||||||
if(now > last)
|
if (now > last) {
|
||||||
{
|
last = now;
|
||||||
last = now ;
|
updateFriendsList();
|
||||||
updateFriendsList() ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyDialog::updateFriendsList()
|
void ChatLobbyDialog::updateFriendsList()
|
||||||
{
|
{
|
||||||
friendsListWidget->clear() ;
|
friendsListWidget->clear();
|
||||||
|
|
||||||
std::list<ChatLobbyInfo> linfos ;
|
std::list<ChatLobbyInfo> linfos;
|
||||||
rsMsgs->getChatLobbyList(linfos);
|
rsMsgs->getChatLobbyList(linfos);
|
||||||
|
|
||||||
std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());
|
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())
|
if (it != linfos.end()) {
|
||||||
for(std::set<std::string>::const_iterator it2( (*it).nick_names.begin());it2!=(*it).nick_names.end();++it2)
|
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())) ;
|
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)
|
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);
|
case RS_CHAT_LOBBY_EVENT_PEER_LEFT:
|
||||||
break ;
|
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:
|
case RS_CHAT_LOBBY_EVENT_PEER_JOINED:
|
||||||
addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), str + tr(" joined the lobby."), TYPE_NORMAL);
|
addChatMsg(true, tr("Lobby management"), QDateTime::currentDateTime(), QDateTime::currentDateTime(), tr("%1 joined the lobby.").arg(str), TYPE_NORMAL);
|
||||||
break ;
|
break;
|
||||||
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
case RS_CHAT_LOBBY_EVENT_PEER_STATUS:
|
||||||
updateStatusString(nickname,str) ;
|
updateStatusString(nickname,str);
|
||||||
break ;
|
break;
|
||||||
default:
|
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());
|
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,10 +41,15 @@ class ChatLobbyDialog: public PopupChatDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void displayLobbyEvent(int event_type,const QString& nickname,const QString& str) ;
|
void displayLobbyEvent(int event_type,const QString& nickname,const QString& str) ;
|
||||||
|
|
||||||
protected:
|
// The following methods are differentfrom those of the parent:
|
||||||
|
//
|
||||||
|
virtual bool hasPeerStatus() { return false; }
|
||||||
|
virtual bool canClose();
|
||||||
|
|
||||||
|
protected:
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
ChatLobbyDialog(const std::string& id,const ChatLobbyId& lid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
ChatLobbyDialog(const std::string& id,const ChatLobbyId& lid, const QString &name, QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
|
|
||||||
|
@ -58,13 +63,15 @@ class ChatLobbyDialog: public PopupChatDialog
|
||||||
|
|
||||||
// The following methods are differentfrom those of the parent:
|
// The following methods are differentfrom those of the parent:
|
||||||
//
|
//
|
||||||
|
virtual bool addToParent();
|
||||||
|
virtual bool isChatLobby() { return true; }
|
||||||
virtual void addIncomingChatMsg(const ChatInfo& info) ; //
|
virtual void addIncomingChatMsg(const ChatInfo& info) ; //
|
||||||
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void setNickName(const QString&) ;
|
void setNickName(const QString&) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateFriendsList() ;
|
void updateFriendsList() ;
|
||||||
|
|
||||||
ChatLobbyId lobby_id ;
|
ChatLobbyId lobby_id ;
|
||||||
|
|
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)
|
PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWidget *parent, Qt::WFlags flags)
|
||||||
: QWidget(parent, flags), dialogId(id), dialogName(name),
|
: QWidget(parent, flags), dialogId(id), dialogName(name),
|
||||||
lastChatTime(0), lastChatName("")
|
lastChatTime(0), lastChatName("")
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
@ -155,7 +154,7 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
||||||
ui.hashBox->setDropWidget(this);
|
ui.hashBox->setDropWidget(this);
|
||||||
ui.hashBox->setAutoHide(true);
|
ui.hashBox->setAutoHide(true);
|
||||||
|
|
||||||
QMenu * toolmenu = new QMenu();
|
QMenu *toolmenu = new QMenu();
|
||||||
toolmenu->addAction(ui.actionClear_Chat_History);
|
toolmenu->addAction(ui.actionClear_Chat_History);
|
||||||
toolmenu->addAction(ui.actionDelete_Chat_History);
|
toolmenu->addAction(ui.actionDelete_Chat_History);
|
||||||
toolmenu->addAction(ui.actionSave_Chat_History);
|
toolmenu->addAction(ui.actionSave_Chat_History);
|
||||||
|
@ -164,12 +163,19 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
||||||
//toolmenu->addAction(ui.action_Disable_Emoticons);
|
//toolmenu->addAction(ui.action_Disable_Emoticons);
|
||||||
ui.pushtoolsButton->setMenu(toolmenu);
|
ui.pushtoolsButton->setMenu(toolmenu);
|
||||||
|
|
||||||
|
ui.chattextEdit->installEventFilter(this);
|
||||||
|
|
||||||
|
#ifdef RS_RELEASE_VERSION
|
||||||
|
ui.attachPictureButton->setVisible(false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::init()
|
||||||
|
{
|
||||||
|
if (!isChatLobby()) {
|
||||||
mCurrentColor.setNamedColor(PeerSettings->getPrivateChatColor(dialogId));
|
mCurrentColor.setNamedColor(PeerSettings->getPrivateChatColor(dialogId));
|
||||||
mCurrentFont.fromString(PeerSettings->getPrivateChatFont(dialogId));
|
mCurrentFont.fromString(PeerSettings->getPrivateChatFont(dialogId));
|
||||||
|
|
||||||
colorChanged(mCurrentColor);
|
|
||||||
fontChanged(mCurrentFont);
|
|
||||||
|
|
||||||
// load settings
|
// load settings
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
|
|
||||||
|
@ -199,15 +205,12 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.chattextEdit->installEventFilter(this);
|
|
||||||
|
|
||||||
// add offline chat messages
|
// add offline chat messages
|
||||||
onPrivateChatChanged(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_ADD);
|
onPrivateChatChanged(NOTIFY_LIST_PRIVATE_OUTGOING_CHAT, NOTIFY_TYPE_ADD);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RS_RELEASE_VERSION
|
colorChanged(mCurrentColor);
|
||||||
ui.attachPictureButton->setVisible(false);
|
fontChanged(mCurrentFont);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
|
@ -216,11 +219,7 @@ PopupChatDialog::~PopupChatDialog()
|
||||||
// save settings
|
// save settings
|
||||||
processSettings(false);
|
processSettings(false);
|
||||||
|
|
||||||
PopupChatWindow *window = WINDOW(this);
|
emit dialogClose(this);
|
||||||
if (window) {
|
|
||||||
window->removeDialog(this);
|
|
||||||
window->calculateTitle(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string, PopupChatDialog *>::iterator it;
|
std::map<std::string, PopupChatDialog *>::iterator it;
|
||||||
if (chatDialogs.end() != (it = chatDialogs.find(dialogId))) {
|
if (chatDialogs.end() != (it = chatDialogs.find(dialogId))) {
|
||||||
|
@ -260,35 +259,36 @@ void PopupChatDialog::processSettings(bool bLoad)
|
||||||
|
|
||||||
/*static*/ PopupChatDialog *PopupChatDialog::getPrivateChat(const std::string &id, uint chatflags)
|
/*static*/ PopupChatDialog *PopupChatDialog::getPrivateChat(const std::string &id, uint chatflags)
|
||||||
{
|
{
|
||||||
/* see if it exists already */
|
/* see if it already exists */
|
||||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||||
|
|
||||||
if (popupchatdialog == NULL) {
|
if (popupchatdialog == NULL) {
|
||||||
|
ChatLobbyId lobby_id;
|
||||||
|
if (rsMsgs->isLobbyId(id, lobby_id)) {
|
||||||
|
chatflags = RS_CHAT_OPEN; // use own flags
|
||||||
|
}
|
||||||
|
|
||||||
if (chatflags & RS_CHAT_OPEN) {
|
if (chatflags & RS_CHAT_OPEN) {
|
||||||
RsPeerDetails sslDetails;
|
RsPeerDetails sslDetails;
|
||||||
ChatLobbyId lobby_id ;
|
|
||||||
|
|
||||||
if (rsPeers->getPeerDetails(id, sslDetails))
|
if (rsPeers->getPeerDetails(id, sslDetails)) {
|
||||||
{
|
|
||||||
popupchatdialog = new PopupChatDialog(id, PeerDefs::nameWithLocation(sslDetails));
|
popupchatdialog = new PopupChatDialog(id, PeerDefs::nameWithLocation(sslDetails));
|
||||||
|
popupchatdialog->init();
|
||||||
chatDialogs[id] = popupchatdialog;
|
chatDialogs[id] = popupchatdialog;
|
||||||
|
|
||||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
popupchatdialog->addToParent();
|
||||||
window->addDialog(popupchatdialog);
|
} else if (lobby_id) {
|
||||||
}
|
|
||||||
else if (rsMsgs->isLobbyId(id, lobby_id))
|
|
||||||
{
|
|
||||||
std::list<ChatLobbyInfo> linfos;
|
std::list<ChatLobbyInfo> linfos;
|
||||||
rsMsgs->getChatLobbyList(linfos) ;
|
rsMsgs->getChatLobbyList(linfos);
|
||||||
|
|
||||||
for(std::list<ChatLobbyInfo>::const_iterator it(linfos.begin());it!=linfos.end();++it)
|
for (std::list<ChatLobbyInfo>::const_iterator it(linfos.begin()); it != linfos.end(); ++it) {
|
||||||
if( (*it).lobby_id == lobby_id)
|
if ((*it).lobby_id == lobby_id) {
|
||||||
{
|
popupchatdialog = new ChatLobbyDialog(id, lobby_id, QString::fromUtf8((*it).lobby_name.c_str()));
|
||||||
popupchatdialog = new ChatLobbyDialog(id,lobby_id,QString::fromUtf8((*it).lobby_name.c_str()));
|
popupchatdialog->init();
|
||||||
chatDialogs[id] = popupchatdialog;
|
chatDialogs[id] = popupchatdialog;
|
||||||
|
|
||||||
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
popupchatdialog->addToParent();
|
||||||
window->addDialog(popupchatdialog);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,15 +357,27 @@ void PopupChatDialog::processSettings(bool bLoad)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::closeChat(const std::string& id)
|
bool PopupChatDialog::addToParent()
|
||||||
|
{
|
||||||
|
PopupChatWindow *window = PopupChatWindow::getWindow(false);
|
||||||
|
if (window) {
|
||||||
|
window->addDialog(this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*static*/ void PopupChatDialog::closeChat(const std::string& id)
|
||||||
{
|
{
|
||||||
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
PopupChatDialog *popupchatdialog = getExistingInstance(id);
|
||||||
|
|
||||||
if(popupchatdialog != NULL)
|
if (popupchatdialog) {
|
||||||
popupchatdialog->hide() ;
|
delete(popupchatdialog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::chatFriend(const std::string &id)
|
/*static*/ void PopupChatDialog::chatFriend(const std::string &id)
|
||||||
{
|
{
|
||||||
if (id.empty()){
|
if (id.empty()){
|
||||||
return;
|
return;
|
||||||
|
@ -373,10 +385,9 @@ void PopupChatDialog::chatFriend(const std::string &id)
|
||||||
std::cerr<<" popup dialog chat friend 1"<<std::endl;
|
std::cerr<<" popup dialog chat friend 1"<<std::endl;
|
||||||
|
|
||||||
ChatLobbyId lid ;
|
ChatLobbyId lid ;
|
||||||
if(rsMsgs->isLobbyId(id,lid))
|
if(rsMsgs->isLobbyId(id, lid)) {
|
||||||
{
|
|
||||||
getPrivateChat(id, RS_CHAT_OPEN | RS_CHAT_FOCUS);
|
getPrivateChat(id, RS_CHAT_OPEN | RS_CHAT_FOCUS);
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
|
@ -454,10 +465,7 @@ void PopupChatDialog::resetStatusBar()
|
||||||
|
|
||||||
typing = false;
|
typing = false;
|
||||||
|
|
||||||
PopupChatWindow *window = WINDOW(this);
|
emit infoChanged(this);
|
||||||
if (window) {
|
|
||||||
window->calculateTitle(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::updateStatusTyping()
|
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());
|
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
|
// Called by libretroshare through notifyQt to display the peer's status
|
||||||
//
|
//
|
||||||
void PopupChatDialog::updateStatusString(const QString& peer_id, const QString& status_string)
|
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.statusLabel->setText(status); // displays info for 5 secs.
|
||||||
ui.typingpixmapLabel->setPixmap(QPixmap(":images/typing.png") );
|
ui.typingpixmapLabel->setPixmap(QPixmap(":images/typing.png") );
|
||||||
|
|
||||||
if (status_string == "is typing...") {
|
if (status_string == "is typing...") {
|
||||||
typing = true;
|
typing = true;
|
||||||
|
|
||||||
PopupChatWindow *window = WINDOW(this);
|
emit infoChanged(this);
|
||||||
if (window) {
|
|
||||||
window->calculateTitle(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
|
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
|
||||||
|
@ -504,17 +510,26 @@ void PopupChatDialog::resizeEvent(QResizeEvent */*event*/)
|
||||||
scrollbar->setValue(scrollbar->maximum());
|
scrollbar->setValue(scrollbar->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupChatDialog::showEvent(QShowEvent */*event*/)
|
||||||
|
{
|
||||||
|
newMessages = false;
|
||||||
|
emit infoChanged(this);
|
||||||
|
focusDialog();
|
||||||
|
}
|
||||||
|
|
||||||
void PopupChatDialog::activate()
|
void PopupChatDialog::activate()
|
||||||
{
|
{
|
||||||
PopupChatWindow *window = WINDOW(this);
|
PopupChatWindow *window = WINDOW(this);
|
||||||
if (window) {
|
if (window) {
|
||||||
if (window->isActiveWindow()) {
|
if (window->isActiveWindow()) {
|
||||||
newMessages = false;
|
newMessages = false;
|
||||||
window->calculateTitle(this);
|
emit infoChanged(this);
|
||||||
focusDialog();
|
focusDialog();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newMessages = false;
|
newMessages = false;
|
||||||
|
emit infoChanged(this);
|
||||||
|
focusDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,6 +539,7 @@ void PopupChatDialog::onPrivateChatChanged(int list, int type)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NOTIFY_TYPE_ADD:
|
case NOTIFY_TYPE_ADD:
|
||||||
{
|
{
|
||||||
|
if (!isChatLobby()) {
|
||||||
std::list<ChatInfo> savedOfflineChatNew;
|
std::list<ChatInfo> savedOfflineChatNew;
|
||||||
|
|
||||||
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
||||||
|
@ -556,9 +572,11 @@ void PopupChatDialog::onPrivateChatChanged(int list, int type)
|
||||||
|
|
||||||
savedOfflineChat = savedOfflineChatNew;
|
savedOfflineChat = savedOfflineChatNew;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NOTIFY_TYPE_DEL:
|
case NOTIFY_TYPE_DEL:
|
||||||
{
|
{
|
||||||
|
if (!isChatLobby()) {
|
||||||
if (manualDelete == false) {
|
if (manualDelete == false) {
|
||||||
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
QString name = QString::fromUtf8(rsPeers->getPeerName(rsPeers->getOwnId()).c_str());
|
||||||
|
|
||||||
|
@ -575,6 +593,7 @@ void PopupChatDialog::onPrivateChatChanged(int list, int type)
|
||||||
|
|
||||||
savedOfflineChat.clear();
|
savedOfflineChat.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,18 +638,14 @@ void PopupChatDialog::insertChatMsgs()
|
||||||
|
|
||||||
playsound();
|
playsound();
|
||||||
|
|
||||||
PopupChatWindow *window = WINDOW(this);
|
emit newMessage(this);
|
||||||
if (window) {
|
|
||||||
window->alertDialog(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
PopupChatWindow *window = WINDOW(this);
|
||||||
if (isVisible() == false || (window && window->isActiveWindow() == false)) {
|
if (isVisible() == false || (window && window->isActiveWindow() == false)) {
|
||||||
newMessages = true;
|
newMessages = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (window) {
|
emit infoChanged(this);
|
||||||
window->calculateTitle(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatDialog::addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, enumChatType chatType)
|
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)
|
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)
|
void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||||
|
@ -1004,10 +1019,7 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||||
|
|
||||||
peerStatus = status;
|
peerStatus = status;
|
||||||
|
|
||||||
PopupChatWindow *window = WINDOW(this);
|
emit infoChanged(this);
|
||||||
if (window) {
|
|
||||||
window->calculateTitle(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ public:
|
||||||
static void closeChat(const std::string &id);
|
static void closeChat(const std::string &id);
|
||||||
static void privateChatChanged(int list, int type);
|
static void privateChatChanged(int list, int type);
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
void updateStatusString(const QString& peer_id, const QString& statusString);
|
void updateStatusString(const QString& peer_id, const QString& statusString);
|
||||||
std::string getPeerId() { return dialogId; }
|
std::string getPeerId() { return dialogId; }
|
||||||
QString getTitle() { return dialogName; }
|
QString getTitle() { return dialogName; }
|
||||||
|
@ -61,6 +63,16 @@ public:
|
||||||
const RSStyle &getStyle();
|
const RSStyle &getStyle();
|
||||||
virtual void updateStatus(const QString &peer_id, int status);
|
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:
|
public slots:
|
||||||
void updateStatus_slot(const QString &peer_id, int status);
|
void updateStatus_slot(const QString &peer_id, int status);
|
||||||
|
|
||||||
|
@ -71,6 +83,7 @@ protected:
|
||||||
~PopupChatDialog();
|
~PopupChatDialog();
|
||||||
|
|
||||||
virtual void resizeEvent(QResizeEvent *event);
|
virtual void resizeEvent(QResizeEvent *event);
|
||||||
|
virtual void showEvent(QShowEvent *event);
|
||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
|
|
||||||
|
@ -79,8 +92,10 @@ protected:
|
||||||
|
|
||||||
// derived in ChatLobbyDialog.
|
// derived in ChatLobbyDialog.
|
||||||
//
|
//
|
||||||
virtual void addIncomingChatMsg(const ChatInfo& info) ;
|
virtual bool addToParent();
|
||||||
virtual QString makeStatusString(const QString& peer_id,const QString& status_string) const ;
|
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:
|
private slots:
|
||||||
void pasteLink() ;
|
void pasteLink() ;
|
||||||
|
|
|
@ -88,8 +88,7 @@ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WFlags flags)
|
||||||
connect(ui.actionUndockTab, SIGNAL(triggered()), this, SLOT(undockTab()));
|
connect(ui.actionUndockTab, SIGNAL(triggered()), this, SLOT(undockTab()));
|
||||||
connect(ui.actionSetOnTop, SIGNAL(toggled(bool)), this, SLOT(setOnTop()));
|
connect(ui.actionSetOnTop, SIGNAL(toggled(bool)), this, SLOT(setOnTop()));
|
||||||
|
|
||||||
connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
|
connect(ui.tabWidget, SIGNAL(tabChanged(PopupChatDialog*)), this, SLOT(tabChanged(PopupChatDialog*)));
|
||||||
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabCurrentChanged(int)));
|
|
||||||
|
|
||||||
if (tabbedWindow) {
|
if (tabbedWindow) {
|
||||||
/* signal toggled is called */
|
/* signal toggled is called */
|
||||||
|
@ -159,7 +158,7 @@ void PopupChatWindow::changeEvent(QEvent *event)
|
||||||
void PopupChatWindow::addDialog(PopupChatDialog *dialog)
|
void PopupChatWindow::addDialog(PopupChatDialog *dialog)
|
||||||
{
|
{
|
||||||
if (tabbedWindow) {
|
if (tabbedWindow) {
|
||||||
ui.tabWidget->addTab(dialog, dialog->getTitle());
|
ui.tabWidget->addDialog(dialog);
|
||||||
} else {
|
} else {
|
||||||
ui.horizontalLayout->addWidget(dialog);
|
ui.horizontalLayout->addWidget(dialog);
|
||||||
ui.horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
ui.horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -170,15 +169,20 @@ void PopupChatWindow::addDialog(PopupChatDialog *dialog)
|
||||||
/* signal toggled is called */
|
/* signal toggled is called */
|
||||||
ui.actionSetOnTop->setChecked(PeerSettings->getPrivateChatOnTop(peerId));
|
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)
|
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) {
|
if (tabbedWindow) {
|
||||||
int tab = ui.tabWidget->indexOf(dialog);
|
ui.tabWidget->removeDialog(dialog);
|
||||||
if (tab >= 0) {
|
|
||||||
ui.tabWidget->removeTab(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ui.tabWidget->count() == 0) {
|
if (ui.tabWidget->count() == 0) {
|
||||||
deleteLater();
|
deleteLater();
|
||||||
|
@ -220,39 +224,13 @@ void PopupChatWindow::alertDialog(PopupChatDialog */*dialog*/)
|
||||||
|
|
||||||
void PopupChatWindow::calculateTitle(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;
|
bool hasNewMessages = false;
|
||||||
PopupChatDialog *pcd;
|
PopupChatDialog *pcd;
|
||||||
|
|
||||||
/* is typing */
|
/* is typing */
|
||||||
bool isTyping = false;
|
bool isTyping = false;
|
||||||
if (ui.tabWidget->isVisible()) {
|
if (ui.tabWidget->isVisible()) {
|
||||||
int tabCount = ui.tabWidget->count();
|
ui.tabWidget->getInfo(isTyping, hasNewMessages, NULL);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
isTyping = dialog->isTyping();
|
isTyping = dialog->isTyping();
|
||||||
|
@ -272,7 +250,7 @@ void PopupChatWindow::calculateTitle(PopupChatDialog *dialog)
|
||||||
} else if (hasNewMessages) {
|
} else if (hasNewMessages) {
|
||||||
icon = QIcon(IMAGE_CHAT);
|
icon = QIcon(IMAGE_CHAT);
|
||||||
} else {
|
} else {
|
||||||
if (pcd) {
|
if (pcd && pcd->hasPeerStatus()) {
|
||||||
icon = QIcon(StatusDefs::imageIM(pcd->getPeerStatus()));
|
icon = QIcon(StatusDefs::imageIM(pcd->getPeerStatus()));
|
||||||
} else {
|
} else {
|
||||||
icon = QIcon(IMAGE_WINDOW);
|
icon = QIcon(IMAGE_WINDOW);
|
||||||
|
@ -291,31 +269,32 @@ void PopupChatWindow::calculateTitle(PopupChatDialog *dialog)
|
||||||
void PopupChatWindow::getAvatar()
|
void PopupChatWindow::getAvatar()
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
if (misc::getOpenAvatarPicture(this, ba))
|
if (misc::getOpenAvatarPicture(this, ba)) {
|
||||||
{
|
|
||||||
std::cerr << "Avatar image size = " << ba.size() << std::endl ;
|
std::cerr << "Avatar image size = " << ba.size() << std::endl ;
|
||||||
|
|
||||||
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()), ba.size()); // last char 0 included.
|
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);
|
removeDialog(dialog);
|
||||||
|
|
||||||
if (widget) {
|
|
||||||
widget->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
void PopupChatWindow::tabInfoChanged(PopupChatDialog *dialog)
|
||||||
pcd->activate();
|
{
|
||||||
calculateStyle(pcd);
|
calculateTitle(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupChatWindow::tabNewMessage(PopupChatDialog *dialog)
|
||||||
|
{
|
||||||
|
alertDialog(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupChatWindow::dockTab()
|
void PopupChatWindow::dockTab()
|
||||||
|
|
|
@ -54,8 +54,10 @@ protected:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void getAvatar();
|
void getAvatar();
|
||||||
void tabCloseRequested(int tab);
|
void tabChanged(PopupChatDialog *dialog);
|
||||||
void tabCurrentChanged(int tab);
|
void tabInfoChanged(PopupChatDialog *dialog);
|
||||||
|
void tabNewMessage(PopupChatDialog *dialog);
|
||||||
|
void dialogClose(PopupChatDialog *dialog);
|
||||||
void dockTab();
|
void dockTab();
|
||||||
void undockTab();
|
void undockTab();
|
||||||
void setStyle();
|
void setStyle();
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="ChatTabWidget" name="tabWidget">
|
||||||
<property name="tabsClosable">
|
<property name="tabsClosable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -147,6 +147,14 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>ChatTabWidget</class>
|
||||||
|
<extends>QTabWidget</extends>
|
||||||
|
<header location="global">gui/chat/ChatTabWidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -380,9 +380,9 @@ void NotifyQt::notifyListChange(int list, int type)
|
||||||
#endif
|
#endif
|
||||||
emit privateChatChanged(list, type);
|
emit privateChatChanged(list, type);
|
||||||
break;
|
break;
|
||||||
case NOTIFY_LIST_PUBLIC_CHAT_LOBBY_LIST:
|
case NOTIFY_LIST_CHAT_LOBBY_LIST:
|
||||||
std::cerr << "received notify public chat lobby list" << std::endl;
|
std::cerr << "received notify chat lobby list" << std::endl;
|
||||||
emit publicLobbyListChanged();
|
emit lobbyListChanged();
|
||||||
|
|
||||||
case NOTIFY_LIST_GROUPLIST:
|
case NOTIFY_LIST_GROUPLIST:
|
||||||
#ifdef NOTIFY_DEBUG
|
#ifdef NOTIFY_DEBUG
|
||||||
|
|
|
@ -68,7 +68,7 @@ class NotifyQt: public QObject, public NotifyBase
|
||||||
void filesPostModChanged(bool) const ;
|
void filesPostModChanged(bool) const ;
|
||||||
void transfersChanged() const ;
|
void transfersChanged() const ;
|
||||||
void friendsChanged() const ;
|
void friendsChanged() const ;
|
||||||
void publicLobbyListChanged() const ;
|
void lobbyListChanged() const ;
|
||||||
void chatLobbyEvent(qulonglong,int,const QString&,const QString&) ;
|
void chatLobbyEvent(qulonglong,int,const QString&,const QString&) ;
|
||||||
void neighboursChanged() const ;
|
void neighboursChanged() const ;
|
||||||
void messagesChanged() const ;
|
void messagesChanged() const ;
|
||||||
|
|
|
@ -127,8 +127,6 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
/* Login Dialog */
|
/* Login Dialog */
|
||||||
/* check for existing Certificate */
|
/* check for existing Certificate */
|
||||||
std::string userName;
|
|
||||||
|
|
||||||
StartDialog *sd = NULL;
|
StartDialog *sd = NULL;
|
||||||
bool genCert = false;
|
bool genCert = false;
|
||||||
std::list<std::string> accountIds;
|
std::list<std::string> accountIds;
|
||||||
|
@ -281,9 +279,6 @@ int main(int argc, char *argv[])
|
||||||
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ;
|
||||||
QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ;
|
QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ;
|
||||||
QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ;
|
QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ;
|
||||||
QObject::connect(notify,SIGNAL(chatLobbyInviteReceived()) ,w->friendsDialog ,SLOT(readChatLobbyInvites() )) ;
|
|
||||||
QObject::connect(notify,SIGNAL(publicLobbyListChanged()) ,w->friendsDialog ,SLOT(updatePublicLobbyList() )) ;
|
|
||||||
QObject::connect(notify,SIGNAL(chatLobbyEvent(qulonglong,int,const QString&,const QString&)),w->friendsDialog,SLOT(displayChatLobbyEvent(qulonglong,int,const QString&,const QString&))) ;
|
|
||||||
QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection);
|
QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection);
|
||||||
QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection);
|
QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection);
|
||||||
QObject::connect(notify,SIGNAL(downloadCompleteCountChanged(int)) ,w ,SLOT(updateTransfers(int) ));
|
QObject::connect(notify,SIGNAL(downloadCompleteCountChanged(int)) ,w ,SLOT(updateTransfers(int) ));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue