mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-13 17:13:06 -04:00
Changed some internals in the chat dialog handling (private chat and lobby).
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4855 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
44ff9fe4f7
commit
2aa1ede192
7 changed files with 62 additions and 8 deletions
|
@ -21,6 +21,7 @@
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
|
||||||
#include "ChatDialog.h"
|
#include "ChatDialog.h"
|
||||||
#include "gui/common/PeerDefs.h"
|
#include "gui/common/PeerDefs.h"
|
||||||
|
@ -40,6 +41,7 @@ static std::map<std::string, ChatDialog*> chatDialogs;
|
||||||
ChatDialog::ChatDialog(QWidget *parent, Qt::WFlags flags) :
|
ChatDialog::ChatDialog(QWidget *parent, Qt::WFlags flags) :
|
||||||
QWidget(parent, flags)
|
QWidget(parent, flags)
|
||||||
{
|
{
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatDialog::~ChatDialog()
|
ChatDialog::~ChatDialog()
|
||||||
|
@ -50,6 +52,15 @@ ChatDialog::~ChatDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatDialog::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
if (!canClose()) {
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emit dialogClose(this);
|
||||||
|
}
|
||||||
|
|
||||||
void ChatDialog::init(const std::string &peerId, const QString &title)
|
void ChatDialog::init(const std::string &peerId, const QString &title)
|
||||||
{
|
{
|
||||||
this->peerId = peerId;
|
this->peerId = peerId;
|
||||||
|
|
|
@ -41,7 +41,6 @@ public:
|
||||||
static void closeChat(const std::string &peerId);
|
static void closeChat(const std::string &peerId);
|
||||||
static void chatChanged(int list, int type);
|
static void chatChanged(int list, int type);
|
||||||
|
|
||||||
virtual bool canClose() { return true; }
|
|
||||||
virtual void showDialog(uint chatflags) {}
|
virtual void showDialog(uint chatflags) {}
|
||||||
|
|
||||||
virtual ChatWidget *getChatWidget() = 0;
|
virtual ChatWidget *getChatWidget() = 0;
|
||||||
|
@ -66,6 +65,7 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void infoChanged(ChatDialog *dialog);
|
void infoChanged(ChatDialog *dialog);
|
||||||
void newMessage(ChatDialog *dialog);
|
void newMessage(ChatDialog *dialog);
|
||||||
|
void dialogClose(ChatDialog *dialog);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void chatInfoChanged(ChatWidget*);
|
void chatInfoChanged(ChatWidget*);
|
||||||
|
@ -75,6 +75,9 @@ protected:
|
||||||
explicit ChatDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
explicit ChatDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||||
virtual ~ChatDialog();
|
virtual ~ChatDialog();
|
||||||
|
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
virtual bool canClose() { return true; }
|
||||||
|
|
||||||
virtual void init(const std::string &peerId, const QString &title);
|
virtual void init(const std::string &peerId, const QString &title);
|
||||||
virtual void onChatChanged(int list, int type) {}
|
virtual void onChatChanged(int list, int type) {}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class ChatLobbyDialog: public ChatDialog
|
||||||
public:
|
public:
|
||||||
void displayLobbyEvent(int event_type, const QString& nickname, const QString& str);
|
void displayLobbyEvent(int event_type, const QString& nickname, const QString& str);
|
||||||
|
|
||||||
virtual bool canClose();
|
|
||||||
virtual void showDialog(uint chatflags);
|
virtual void showDialog(uint chatflags);
|
||||||
virtual ChatWidget *getChatWidget();
|
virtual ChatWidget *getChatWidget();
|
||||||
virtual bool hasPeerStatus() { return false; }
|
virtual bool hasPeerStatus() { return false; }
|
||||||
|
@ -53,6 +52,7 @@ protected:
|
||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
|
|
||||||
virtual void init(const std::string &peerId, const QString &title);
|
virtual void init(const std::string &peerId, const QString &title);
|
||||||
|
virtual bool canClose();
|
||||||
virtual void addIncomingChatMsg(const ChatInfo& info);
|
virtual void addIncomingChatMsg(const ChatInfo& info);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
|
@ -50,6 +50,7 @@ void ChatTabWidget::addDialog(ChatDialog *dialog)
|
||||||
dialog->addToParent(this);
|
dialog->addToParent(this);
|
||||||
|
|
||||||
QObject::connect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
QObject::connect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
||||||
|
QObject::connect(dialog, SIGNAL(dialogClose(ChatDialog*)), this, SLOT(dialogClose(ChatDialog*)));
|
||||||
|
|
||||||
tabInfoChanged(dialog);
|
tabInfoChanged(dialog);
|
||||||
}
|
}
|
||||||
|
@ -57,11 +58,13 @@ void ChatTabWidget::addDialog(ChatDialog *dialog)
|
||||||
void ChatTabWidget::removeDialog(ChatDialog *dialog)
|
void ChatTabWidget::removeDialog(ChatDialog *dialog)
|
||||||
{
|
{
|
||||||
QObject::disconnect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
QObject::disconnect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
||||||
|
QObject::disconnect(dialog, SIGNAL(dialogClose(ChatDialog*)), this, SLOT(dialogClose(ChatDialog*)));
|
||||||
|
|
||||||
int tab = indexOf(dialog);
|
int tab = indexOf(dialog);
|
||||||
if (tab >= 0) {
|
if (tab >= 0) {
|
||||||
dialog->removeFromParent(this);
|
dialog->removeFromParent(this);
|
||||||
removeTab(tab);
|
removeTab(tab);
|
||||||
|
emit tabClosed(dialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +73,7 @@ void ChatTabWidget::tabClose(int tab)
|
||||||
ChatDialog *dialog = dynamic_cast<ChatDialog*>(widget(tab));
|
ChatDialog *dialog = dynamic_cast<ChatDialog*>(widget(tab));
|
||||||
|
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
if (dialog->canClose()) {
|
dialog->close();
|
||||||
removeDialog(dialog);
|
|
||||||
emit tabClosed(dialog);
|
|
||||||
dialog->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +104,11 @@ void ChatTabWidget::tabInfoChanged(ChatDialog *dialog)
|
||||||
emit infoChanged();
|
emit infoChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatTabWidget::dialogClose(ChatDialog *dialog)
|
||||||
|
{
|
||||||
|
removeDialog(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon)
|
void ChatTabWidget::getInfo(bool &isTyping, bool &hasNewMessage, QIcon *icon)
|
||||||
{
|
{
|
||||||
isTyping = false;
|
isTyping = false;
|
||||||
|
|
|
@ -53,6 +53,7 @@ private slots:
|
||||||
void tabClose(int tab);
|
void tabClose(int tab);
|
||||||
void tabChanged(int tab);
|
void tabChanged(int tab);
|
||||||
void tabInfoChanged(ChatDialog *dialog);
|
void tabInfoChanged(ChatDialog *dialog);
|
||||||
|
void dialogClose(ChatDialog *dialog);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ChatTabWidget *ui;
|
Ui::ChatTabWidget *ui;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QCloseEvent>
|
||||||
|
|
||||||
#include "PopupChatWindow.h"
|
#include "PopupChatWindow.h"
|
||||||
#include "ChatDialog.h"
|
#include "ChatDialog.h"
|
||||||
|
@ -137,6 +138,27 @@ void PopupChatWindow::showEvent(QShowEvent */*event*/)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupChatWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
if (tabbedWindow) {
|
||||||
|
for (int index = ui.tabWidget->count() - 1; index >= 0; --index) {
|
||||||
|
ChatDialog *dialog = dynamic_cast<ChatDialog*>(ui.tabWidget->widget(0));
|
||||||
|
if (dialog == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dialog->close()) {
|
||||||
|
event->ignore();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (chatDialog && !chatDialog->close()) {
|
||||||
|
event->ignore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ChatDialog *PopupChatWindow::getCurrentDialog()
|
ChatDialog *PopupChatWindow::getCurrentDialog()
|
||||||
{
|
{
|
||||||
if (tabbedWindow) {
|
if (tabbedWindow) {
|
||||||
|
@ -160,6 +182,8 @@ void PopupChatWindow::addDialog(ChatDialog *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(dialogClose(ChatDialog*)), this, SLOT(dialogClose(ChatDialog*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
QObject::connect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
||||||
|
@ -178,6 +202,8 @@ void PopupChatWindow::removeDialog(ChatDialog *dialog)
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
QObject::disconnect(dialog, SIGNAL(dialogClose(ChatDialog*)), this, SLOT(dialogClose(ChatDialog*)));
|
||||||
|
|
||||||
if (chatDialog == dialog) {
|
if (chatDialog == dialog) {
|
||||||
saveSettings();
|
saveSettings();
|
||||||
dialog->removeFromParent(this);
|
dialog->removeFromParent(this);
|
||||||
|
@ -280,6 +306,13 @@ void PopupChatWindow::tabClosed(ChatDialog *dialog)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupChatWindow::dialogClose(ChatDialog *dialog)
|
||||||
|
{
|
||||||
|
if (!tabbedWindow) {
|
||||||
|
removeDialog(dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PopupChatWindow::tabChanged(ChatDialog *dialog)
|
void PopupChatWindow::tabChanged(ChatDialog *dialog)
|
||||||
{
|
{
|
||||||
calculateStyle(dialog);
|
calculateStyle(dialog);
|
||||||
|
|
|
@ -49,7 +49,8 @@ protected:
|
||||||
/** Default destructor */
|
/** Default destructor */
|
||||||
~PopupChatWindow();
|
~PopupChatWindow();
|
||||||
|
|
||||||
virtual void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event);
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void getAvatar();
|
void getAvatar();
|
||||||
|
@ -57,6 +58,7 @@ private slots:
|
||||||
void tabInfoChanged(ChatDialog *dialog);
|
void tabInfoChanged(ChatDialog *dialog);
|
||||||
void tabNewMessage(ChatDialog *dialog);
|
void tabNewMessage(ChatDialog *dialog);
|
||||||
void tabClosed(ChatDialog *dialog);
|
void tabClosed(ChatDialog *dialog);
|
||||||
|
void dialogClose(ChatDialog *dialog);
|
||||||
void dockTab();
|
void dockTab();
|
||||||
void undockTab();
|
void undockTab();
|
||||||
void setStyle();
|
void setStyle();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue