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 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 ; }
//

View File

@ -34,6 +34,7 @@
#include <retroshare/rsiface.h>
#include <retroshare/rsnotify.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsplugin.h>
static std::map<std::string, ChatDialog*> 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;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;
cd->init(peerId, PeerDefs::nameWithLocation(sslDetails));
}

View File

@ -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;

View File

@ -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();

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)
{
if (list == NOTIFY_LIST_PRIVATE_OUTGOING_CHAT) {

View File

@ -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);