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
This commit is contained in:
csoler 2012-02-25 12:17:36 +00:00
parent 63cd9d65f2
commit 96fd780502
6 changed files with 32 additions and 4 deletions

View File

@ -48,6 +48,7 @@ class ftServer ;
class ConfigPage ; class ConfigPage ;
class RsPQIService ; class RsPQIService ;
class RsAutoUpdatePage ; class RsAutoUpdatePage ;
class PopupChatDialog ;
// Used for the status of plugins. // 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 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 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 ; } virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */ ) const { return NULL ; }
// //

View File

@ -34,6 +34,7 @@
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <retroshare/rsnotify.h> #include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsplugin.h>
static std::map<std::string, ChatDialog*> chatDialogs; static std::map<std::string, ChatDialog*> chatDialogs;
@ -110,7 +111,14 @@ void ChatDialog::init(const std::string &peerId, const QString &title)
} else { } else {
RsPeerDetails sslDetails; RsPeerDetails sslDetails;
if (rsPeers->getPeerDetails(peerId, sslDetails)) { if (rsPeers->getPeerDetails(peerId, sslDetails)) {
cd = new PopupChatDialog();
for(int i=0;i<rsPlugins->nbPlugins();++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; chatDialogs[peerId] = cd;
cd->init(peerId, PeerDefs::nameWithLocation(sslDetails)); cd->init(peerId, PeerDefs::nameWithLocation(sslDetails));
} }

View File

@ -123,6 +123,11 @@ ChatWidget::~ChatWidget()
delete ui; delete ui;
} }
void ChatWidget::addChatButton(QPushButton *button)
{
ui->chatButtonLayout->addWidget(button) ;
}
void ChatWidget::init(const std::string &peerId, const QString &title) void ChatWidget::init(const std::string &peerId, const QString &title)
{ {
this->peerId = peerId; this->peerId = peerId;

View File

@ -33,6 +33,7 @@
class QAction; class QAction;
class QTextEdit; class QTextEdit;
class QPushButton;
namespace Ui { namespace Ui {
class ChatWidget; class ChatWidget;
@ -71,6 +72,8 @@ public:
bool setStyle(); bool setStyle();
const RSStyle *getStyle() { return &style; } const RSStyle *getStyle() { return &style; }
void addChatButton(QPushButton *button) ;
private slots: private slots:
void clearChatHistory(); void clearChatHistory();
void deleteChatHistory(); void deleteChatHistory();
@ -85,6 +88,8 @@ protected:
virtual void showEvent(QShowEvent *event); virtual void showEvent(QShowEvent *event);
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
void updateTitle(); void updateTitle();
virtual void updateStatus(const QString &peer_id, int status);
void resetStatusBar() ;
private slots: private slots:
void pasteLink(); void pasteLink();
@ -95,8 +100,6 @@ private slots:
void smileyWidget(); void smileyWidget();
void addSmiley(); void addSmiley();
void resetStatusBar() ;
void addExtraFile(); void addExtraFile();
void addExtraPicture(); void addExtraPicture();
void on_closeInfoFrameButton_clicked(); void on_closeInfoFrameButton_clicked();
@ -108,7 +111,6 @@ private slots:
void sendChat(); void sendChat();
void updateStatus(const QString &peer_id, int status);
void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ; void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ;
bool fileSave(); bool fileSave();

View File

@ -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) void PopupChatDialog::onChatChanged(int list, int type)
{ {
if (list == NOTIFY_LIST_PRIVATE_OUTGOING_CHAT) { if (list == NOTIFY_LIST_PRIVATE_OUTGOING_CHAT) {

View File

@ -52,6 +52,9 @@ protected:
void processSettings(bool load); void processSettings(bool load);
// used by plugins
void addButton(QPushButton *button) ;
protected: protected:
virtual void addIncomingChatMsg(const ChatInfo& info); virtual void addIncomingChatMsg(const ChatInfo& info);
virtual void onChatChanged(int list, int type); virtual void onChatChanged(int list, int type);