- fixed the update of avatars in the various chat dialogs

- added a "peer is typing" function to the group chat.


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1706 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-09-30 22:30:57 +00:00
parent 10aef0b027
commit 97400a74ef
9 changed files with 209 additions and 165 deletions

View File

@ -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<TurtleFileInfo>& files) { (void)files; }
virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; }
virtual void notifyOwnAvatarChanged() {}
};
const int NOTIFY_LIST_NEIGHBOURS = 1;

View File

@ -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 <return> 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<std::string, PopupChatDialog *>::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() ;
}
}

View File

@ -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,15 +71,20 @@ 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) ;
/** Export friend in Friends Dialog */
@ -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<QString, QString> smileys;

View File

@ -816,23 +816,8 @@ p, li { white-space: pre-wrap; }
<attribute name="title">
<string>Live Chat</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTextBrowser" name="msgText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -855,153 +840,29 @@ background: white;}</string>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout">
<item row="0" column="0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="statusStringLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>321</width>
<height>20</height>
<width>88</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="textitalicChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Italic</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit-italic.png</normaloff>:/images/edit-italic.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="textunderlineChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Underline</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit-underline.png</normaloff>:/images/edit-underline.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="textboldChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Bold</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit-bold.png</normaloff>:/images/edit-bold.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QPushButton" name="colorChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Text Color</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="fontsButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Font</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<item>
<widget class="QPushButton" name="emoticonBtn">
<property name="minimumSize">
<size>
@ -1030,7 +891,138 @@ background: white;}</string>
</property>
</widget>
</item>
<item row="0" column="7">
<item>
<widget class="QPushButton" name="textboldChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Bold</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit-bold.png</normaloff>:/images/edit-bold.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="textunderlineChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Underline</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit-underline.png</normaloff>:/images/edit-underline.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="textitalicChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Italic</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit-italic.png</normaloff>:/images/edit-italic.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fontsButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Font</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="colorChatButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Text Color</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="menuButton">
<property name="minimumSize">
<size>
@ -1051,7 +1043,7 @@ background: white;}</string>
</item>
</layout>
</item>
<item row="2" column="0">
<item>
<widget class="QTextEdit" name="lineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -1083,7 +1075,7 @@ background: white;}</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item>
<layout class="QGridLayout">
<item row="0" column="0">
<spacer>
@ -1108,10 +1100,6 @@ background: white;}</string>
</layout>
</item>
</layout>
<zorder>msgText</zorder>
<zorder></zorder>
<zorder>lineEdit</zorder>
<zorder></zorder>
</widget>
</widget>
</item>

View File

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

View File

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

View File

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

View File

@ -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<TurtleFileInfo>& 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:

View File

@ -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<TurtleFileInfo>& files) { (void)files; }
virtual void notifyPeerHasNewAvatar(std::string peer_id) { (void)peer_id; }
virtual void notifyOwnAvatarChanged() {}
};
const int NOTIFY_LIST_NEIGHBOURS = 1;