mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-16 09:03:51 -05: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
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue