diff --git a/libretroshare/src/rsiface/rsiface.h b/libretroshare/src/rsiface/rsiface.h index e7fc4d1f1..3ad209363 100644 --- a/libretroshare/src/rsiface/rsiface.h +++ b/libretroshare/src/rsiface/rsiface.h @@ -205,6 +205,7 @@ class NotifyBase virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; } virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& files) { (void)files; } virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; } + virtual void notifyOwnAvatarChanged() {} }; const int NOTIFY_LIST_NEIGHBOURS = 1; diff --git a/retroshare-gui/src/gui/PeersDialog.cpp b/retroshare-gui/src/gui/PeersDialog.cpp index de5678a9e..72ec9a947 100644 --- a/retroshare-gui/src/gui/PeersDialog.cpp +++ b/retroshare-gui/src/gui/PeersDialog.cpp @@ -92,6 +92,8 @@ PeersDialog::PeersDialog(QWidget *parent) /* Create RshareSettings object */ _settings = new RshareSettings(); + last_status_send_time = 0 ; + connect( ui.peertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( peertreeWidgetCostumPopupMenu( QPoint ) ) ); connect( ui.peertreeWidget, SIGNAL( itemDoubleClicked ( QTreeWidgetItem *, int)), this, SLOT(chatfriend())); @@ -686,6 +688,34 @@ void PeersDialog::configurefriend() ConfCertDialog::show(getPeerRsCertId(getCurrentPeer())); } +void PeersDialog::resetStatusBar() +{ + std::cerr << "PeersDialog: reseting status bar." << std::endl ; + + ui.statusStringLabel->setText(QString("")) ; +} + +void PeersDialog::updateStatusTyping() +{ + if(time(NULL) - last_status_send_time > 5) // limit 'peer is typing' packets to at most every 10 sec + { + std::cerr << "PeersDialog: sending group chat typing info." << std::endl ; + + rsMsgs->sendGroupChatStatusString(rsiface->getConfig().ownName + " is typing..."); + last_status_send_time = time(NULL) ; + } +} +// Called by libretroshare through notifyQt to display the peer's status +// +void PeersDialog::updateStatusString(const QString& status_string) +{ + std::cerr << "PeersDialog: received group chat typing info. updating gui." << std::endl ; + + ui.statusStringLabel->setText(status_string) ; // displays info for 5 secs. + + QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ; +} + void PeersDialog::updatePeersAvatar(const QString& peer_id) { std::cerr << "PeersDialog: Got notified of new avatar for peer " << peer_id.toStdString() << std::endl ; @@ -704,6 +734,8 @@ void PeersDialog::updatePeerStatusString(const QString& peer_id,const QString& s else { std::cerr << "Updating public chat msg from peer " << rsPeers->getPeerName(peer_id.toStdString()) << ": " << status_string.toStdString() << std::endl ; + + updateStatusString(status_string) ; } } @@ -825,6 +857,8 @@ void PeersDialog::checkChat() } else { + updateStatusTyping() ; + //std::cerr << "No found in :" << txt << ":"; //std::cerr << std::endl; } @@ -1261,6 +1295,9 @@ void PeersDialog::updateAvatar() pix.loadFromData(data,size,"PNG") ; ui.avatartoolButton->setIcon(pix); // writes image into ba in PNG format + for(std::map::const_iterator it(chatDialogs.begin());it!=chatDialogs.end();++it) + it->second->updateAvatar() ; + delete[] data ; } @@ -1283,7 +1320,8 @@ void PeersDialog::getAvatar() rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()),ba.size()) ; // last char 0 included. - updateAvatar() ; + // I suppressed this because it gets called already by rsMsgs->setOwnAvatarData() through a Qt notification signal + //updateAvatar() ; } } diff --git a/retroshare-gui/src/gui/PeersDialog.h b/retroshare-gui/src/gui/PeersDialog.h index e280b1515..7738ab446 100644 --- a/retroshare-gui/src/gui/PeersDialog.h +++ b/retroshare-gui/src/gui/PeersDialog.h @@ -62,6 +62,8 @@ public slots: void insertChat(); void setChatInfo(QString info, QColor color=QApplication::palette().color(QPalette::WindowText)); + void resetStatusBar() ; + void smileyWidgetgroupchat(); void addSmileys(); @@ -69,14 +71,19 @@ public slots: void on_actionClearChat_triggered(); void displayInfoChatMenu(const QPoint& pos); + // called by notifyQt when another peer is typing (in group chant and private chat) void updatePeerStatusString(const QString& peer_id,const QString& status_string,bool is_private_chat) ; - void updatePeersAvatar(const QString& peer_id); + void updatePeersAvatar(const QString& peer_id); + void updateAvatar(); // called by notifyQt to update the avatar when it gets changed by another component private slots: /** Create the context popup menu and it's submenus */ void peertreeWidgetCostumPopupMenu( QPoint point ); + + void updateStatusString(const QString& statusString) ; // called when a peer is typing in group chat + void updateStatusTyping() ; // called each time a key is hit //void updatePeerStatusString(const QString& peer_id,const QString& chat_status) ; @@ -109,7 +116,6 @@ private slots: void underline(); void changeAvatarClicked(); - void updateAvatar(); void getAvatar(); void on_actionAdd_Friend_activated(); @@ -151,6 +157,7 @@ private: QColor _currentColor; bool _underline; + time_t last_status_send_time ; QHash smileys; diff --git a/retroshare-gui/src/gui/PeersDialog.ui b/retroshare-gui/src/gui/PeersDialog.ui index 6a12e24b9..6a9f43662 100644 --- a/retroshare-gui/src/gui/PeersDialog.ui +++ b/retroshare-gui/src/gui/PeersDialog.ui @@ -816,23 +816,8 @@ p, li { white-space: pre-wrap; } Live Chat - - - 0 - - - 0 - - - 0 - - - 2 - - - 2 - - + + @@ -855,153 +840,29 @@ background: white;} - - - + + + + + + + + + + Qt::Horizontal - 321 - 20 + 88 + 21 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Italic - - - - - - - :/images/edit-italic.png:/images/edit-italic.png - - - true - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - Underline - - - - - - - :/images/edit-underline.png:/images/edit-underline.png - - - true - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - Bold - - - - - - - :/images/edit-bold.png:/images/edit-bold.png - - - true - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - Text Color - - - - - - - - - - - 24 - 24 - - - - - 24 - 24 - - - - Font - - - - - - - + @@ -1030,7 +891,138 @@ background: white;} - + + + + + 24 + 24 + + + + + 24 + 24 + + + + Bold + + + + + + + :/images/edit-bold.png:/images/edit-bold.png + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Underline + + + + + + + :/images/edit-underline.png:/images/edit-underline.png + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Italic + + + + + + + :/images/edit-italic.png:/images/edit-italic.png + + + true + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Font + + + + + + + + + + + 24 + 24 + + + + + 24 + 24 + + + + Text Color + + + + + + + @@ -1051,7 +1043,7 @@ background: white;} - + @@ -1083,7 +1075,7 @@ background: white;} - + @@ -1108,10 +1100,6 @@ background: white;} - msgText - - lineEdit - diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.h b/retroshare-gui/src/gui/chat/PopupChatDialog.h index ef8a3fc32..971b0fbfb 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.h +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.h @@ -58,6 +58,7 @@ public: void loadEmoticons(); void loadEmoticons2(); + void updateAvatar(); QString loadEmptyStyle(); @@ -107,7 +108,6 @@ private slots: private: void colorChanged(const QColor &c); - void updateAvatar(); void addAttachment(std::string); QAction *actionTextBold; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index d67230fce..9d75598ea 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -146,6 +146,7 @@ int main(int argc, char *argv[]) QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(peerHasNewAvatar(const QString&)),w->peersDialog,SLOT(updatePeersAvatar(const QString&))); + QObject::connect(notify,SIGNAL(ownAvatarChanged()),w->peersDialog,SLOT(updateAvatar())); QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)),w->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(ConfCertDialog::instance(),SIGNAL(configChanged()),w->networkDialog,SLOT(insertConnect())) ; diff --git a/retroshare-gui/src/rsiface/notifyqt.cpp b/retroshare-gui/src/rsiface/notifyqt.cpp index dd79b85dd..85dff1a43 100644 --- a/retroshare-gui/src/rsiface/notifyqt.cpp +++ b/retroshare-gui/src/rsiface/notifyqt.cpp @@ -39,6 +39,12 @@ void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) return; } +void NotifyQt::notifyOwnAvatarChanged() +{ + std::cerr << "Notifyqt:: notified that own avatar changed" << std::endl ; + emit ownAvatarChanged() ; +} + void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id) { std::cerr << "notifyQt: notification of new avatar." << std::endl ; diff --git a/retroshare-gui/src/rsiface/notifyqt.h b/retroshare-gui/src/rsiface/notifyqt.h index 01371d141..fc918a925 100644 --- a/retroshare-gui/src/rsiface/notifyqt.h +++ b/retroshare-gui/src/rsiface/notifyqt.h @@ -38,6 +38,7 @@ class NotifyQt: public QObject, public NotifyBase virtual void notifyHashingInfo(std::string fileinfo); virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_files); virtual void notifyPeerHasNewAvatar(std::string peer_id) ; + virtual void notifyOwnAvatarChanged() ; signals: // It's beneficial to send info to the GUI using signals, because signals are thread-safe @@ -56,6 +57,7 @@ class NotifyQt: public QObject, public NotifyBase void peerCustomStateStringChanged(const QString&,const QString&) const ; void gotTurtleSearchResult(qulonglong search_id,FileDetail file) const ; void peerHasNewAvatar(const QString& peer_id) const ; + void ownAvatarChanged() const ; public slots: diff --git a/retroshare-gui/src/rsiface/rsiface.h b/retroshare-gui/src/rsiface/rsiface.h index e7fc4d1f1..3ad209363 100644 --- a/retroshare-gui/src/rsiface/rsiface.h +++ b/retroshare-gui/src/rsiface/rsiface.h @@ -205,6 +205,7 @@ class NotifyBase virtual void notifyHashingInfo(std::string fileinfo) { (void)fileinfo; return ; } virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& files) { (void)files; } virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; } + virtual void notifyOwnAvatarChanged() {} }; const int NOTIFY_LIST_NEIGHBOURS = 1;