From 96fd780502f5126e96642560a69da20c8117333b Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 25 Feb 2012 12:17:36 +0000 Subject: [PATCH] added ability for plugins to return their own PopupChatDialog class git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4988 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/retroshare/rsplugin.h | 5 +++++ retroshare-gui/src/gui/chat/ChatDialog.cpp | 10 +++++++++- retroshare-gui/src/gui/chat/ChatWidget.cpp | 5 +++++ retroshare-gui/src/gui/chat/ChatWidget.h | 8 +++++--- retroshare-gui/src/gui/chat/PopupChatDialog.cpp | 5 +++++ retroshare-gui/src/gui/chat/PopupChatDialog.h | 3 +++ 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/retroshare/rsplugin.h b/libretroshare/src/retroshare/rsplugin.h index 25e50869b..4f017f15b 100644 --- a/libretroshare/src/retroshare/rsplugin.h +++ b/libretroshare/src/retroshare/rsplugin.h @@ -48,6 +48,7 @@ class ftServer ; class ConfigPage ; class RsPQIService ; class RsAutoUpdatePage ; +class PopupChatDialog ; // Used for the status of plugins. // @@ -114,6 +115,10 @@ class RsPlugin virtual RsAutoUpdatePage *qt_transfers_tab() const { return NULL ; } // Tab to add in transfers, after turtle statistics. virtual std::string qt_transfers_tab_name()const { return "Tab" ; } // Tab name + // Any derived class of PopupChatDialog to be used for chat. + // + virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const { return NULL ; } + virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */ ) const { return NULL ; } // diff --git a/retroshare-gui/src/gui/chat/ChatDialog.cpp b/retroshare-gui/src/gui/chat/ChatDialog.cpp index 4a1a63ba4..336edee0c 100644 --- a/retroshare-gui/src/gui/chat/ChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatDialog.cpp @@ -34,6 +34,7 @@ #include #include #include +#include static std::map chatDialogs; @@ -110,7 +111,14 @@ void ChatDialog::init(const std::string &peerId, const QString &title) } else { RsPeerDetails sslDetails; if (rsPeers->getPeerDetails(peerId, sslDetails)) { - cd = new PopupChatDialog(); + + for(int i=0;inbPlugins();++i) + if(rsPlugins->plugin(i) != NULL && (cd = rsPlugins->plugin(i)->qt_allocate_new_popup_chat_dialog()) != NULL) + break ; + + if(cd == NULL) + cd = new PopupChatDialog(); + chatDialogs[peerId] = cd; cd->init(peerId, PeerDefs::nameWithLocation(sslDetails)); } diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 847e0345c..a800083bc 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -123,6 +123,11 @@ ChatWidget::~ChatWidget() delete ui; } +void ChatWidget::addChatButton(QPushButton *button) +{ + ui->chatButtonLayout->addWidget(button) ; +} + void ChatWidget::init(const std::string &peerId, const QString &title) { this->peerId = peerId; diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index 60c878279..00266a6f4 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -33,6 +33,7 @@ class QAction; class QTextEdit; +class QPushButton; namespace Ui { class ChatWidget; @@ -71,6 +72,8 @@ public: bool setStyle(); const RSStyle *getStyle() { return &style; } + void addChatButton(QPushButton *button) ; + private slots: void clearChatHistory(); void deleteChatHistory(); @@ -85,6 +88,8 @@ protected: virtual void showEvent(QShowEvent *event); virtual void resizeEvent(QResizeEvent *event); void updateTitle(); + virtual void updateStatus(const QString &peer_id, int status); + void resetStatusBar() ; private slots: void pasteLink(); @@ -95,8 +100,6 @@ private slots: void smileyWidget(); void addSmiley(); - void resetStatusBar() ; - void addExtraFile(); void addExtraPicture(); void on_closeInfoFrameButton_clicked(); @@ -108,7 +111,6 @@ private slots: void sendChat(); - void updateStatus(const QString &peer_id, int status); void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ; bool fileSave(); diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index a9ea81a86..928c6a4b8 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -133,6 +133,11 @@ void PopupChatDialog::addIncomingChatMsg(const ChatInfo& info) } } +void PopupChatDialog::addButton(QPushButton *button) +{ + getChatWidget()->addChatButton(button) ; +} + void PopupChatDialog::onChatChanged(int list, int type) { if (list == NOTIFY_LIST_PRIVATE_OUTGOING_CHAT) { diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index a68a8fef8..aac29b534 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -52,6 +52,9 @@ protected: void processSettings(bool load); + // used by plugins + void addButton(QPushButton *button) ; + protected: virtual void addIncomingChatMsg(const ChatInfo& info); virtual void onChatChanged(int list, int type);