mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-06 14:03:54 -04:00
Added the peers custom state string to NotifyBase::notifyCustomState and to the signal NotifyQt::notifyCustomState.
Changed the display of the peers custom state string in PopupChatDialog from QTimer to signal. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3429 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
80764a1ff7
commit
48acd856af
@ -201,7 +201,7 @@ class NotifyBase
|
||||
virtual void notifyErrorMsg(int list, int sev, std::string msg) { (void) list; (void) sev; (void) msg; return; }
|
||||
virtual void notifyChat() { return; }
|
||||
virtual void notifyChatStatus(const std::string& /* peer_id */, const std::string& /* status_string */ ,bool /* is_private */) {}
|
||||
virtual void notifyCustomState(const std::string& /* peer_id */) {}
|
||||
virtual void notifyCustomState(const std::string& /* peer_id */, const std::string& /* status_string */) {}
|
||||
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; }
|
||||
|
@ -375,7 +375,7 @@ void p3ChatService::receiveChatQueue()
|
||||
if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE){
|
||||
|
||||
receiveStateString(cs->PeerId(),cs->status_string) ; // store it
|
||||
rsicontrol->getNotify().notifyCustomState(cs->PeerId()) ;
|
||||
rsicontrol->getNotify().notifyCustomState(cs->PeerId(), cs->status_string) ;
|
||||
}else
|
||||
if(cs->flags & RS_CHAT_FLAG_CUSTOM_STATE_AVAILABLE){
|
||||
|
||||
|
@ -1049,18 +1049,6 @@ void PeersDialog::updateStatusString(const QString& peer_id, const QString& stat
|
||||
QTimer::singleShot(5000,this,SLOT(resetStatusBar())) ;
|
||||
}
|
||||
|
||||
void PeersDialog::updatePeersCustomStateString(const QString& peer_id)
|
||||
{
|
||||
#ifdef JUST_AN_EXAMPLE
|
||||
// This is an example of how to retrieve the custom string.
|
||||
//
|
||||
std::cerr << "PeersDialog: Got notified that state string changed for peer " << peer_id.toStdString() << std::endl ;
|
||||
std::cerr << "New state string for this peer is : " << rsMsgs->getCustomStateString(peer_id.toStdString()) << std::endl ;
|
||||
|
||||
QMessageBox::information(NULL,"Notification",peer_id+" has new custom string: " + QString::fromStdString(rsMsgs->getCustomStateString(peer_id.toStdString()))) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
void PeersDialog::updatePeersAvatar(const QString& peer_id)
|
||||
{
|
||||
#ifdef PEERS_DEBUG
|
||||
|
@ -90,7 +90,6 @@ public slots:
|
||||
// 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 updatePeersCustomStateString(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
|
||||
|
||||
|
@ -133,6 +133,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
|
||||
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
|
||||
|
||||
std::cerr << "Connecting custom context menu" << std::endl;
|
||||
ui.chattextEdit->setContextMenuPolicy(Qt::CustomContextMenu) ;
|
||||
@ -183,9 +184,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
|
||||
updateAvatar() ;
|
||||
updatePeerAvatar(id) ;
|
||||
updateStatusMessage();
|
||||
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
@ -199,6 +198,10 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
if (rsStatus->getOwnStatus(ownStatusInfo)) {
|
||||
updateStatus(QString::fromStdString(ownStatusInfo.id), ownStatusInfo.status);
|
||||
}
|
||||
|
||||
// initialize first custom state string
|
||||
QString customStateString = QString::fromStdString(rsMsgs->getCustomStateString(dialogId));
|
||||
updatePeersCustomStateString(QString::fromStdString(dialogId), customStateString);
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
@ -1315,39 +1318,18 @@ void PopupChatDialog::updateStatus(const QString &peer_id, int status)
|
||||
// ignore status change
|
||||
}
|
||||
|
||||
void PopupChatDialog::updateStatusMessage()
|
||||
void PopupChatDialog::updatePeersCustomStateString(const QString& peer_id, const QString& status_string)
|
||||
{
|
||||
if (!rsPeers)
|
||||
return;
|
||||
std::string stdPeerId = peer_id.toStdString();
|
||||
|
||||
|
||||
if(!RsAutoUpdatePage::eventsLocked()) {
|
||||
RsPeerDetails details;
|
||||
if (!rsPeers->getPeerDetails(dialogId, details))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString sCustomString;
|
||||
if (details.state & RS_PEER_STATE_CONNECTED) {
|
||||
sCustomString = QString::fromStdString(rsMsgs->getCustomStateString(details.id));
|
||||
}
|
||||
|
||||
if (sCustomString.isEmpty())
|
||||
{
|
||||
if (stdPeerId == dialogId) {
|
||||
// the peers status string has changed
|
||||
if (status_string.isEmpty()) {
|
||||
ui.statusmessagelabel->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ui.statusmessagelabel->show();
|
||||
ui.statusmessagelabel->setText(sCustomString);
|
||||
ui.statusmessagelabel->setText(status_string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* slow Tick */
|
||||
int msec_rate = 10129;
|
||||
|
||||
QTimer::singleShot( msec_rate, this, SLOT(updateStatusMessage( void ) ));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
|
||||
void updateChat();
|
||||
void updatePeerAvatar(const std::string&);
|
||||
|
||||
|
||||
public slots:
|
||||
/** Overloaded QWidget.show */
|
||||
void show();
|
||||
@ -53,10 +53,10 @@ public slots:
|
||||
void flash();
|
||||
void pasteLink() ;
|
||||
void contextMenu(QPoint) ;
|
||||
|
||||
|
||||
void smileyWidget();
|
||||
void addSmiley();
|
||||
|
||||
|
||||
void changeStyle();
|
||||
void fileHashingFinished(AttachFileItem* file);
|
||||
|
||||
@ -86,7 +86,6 @@ protected:
|
||||
void loadEmoticons2();
|
||||
|
||||
void updateAvatar();
|
||||
void updateStatusMessage();
|
||||
|
||||
|
||||
QString loadEmptyStyle();
|
||||
@ -98,17 +97,18 @@ private slots:
|
||||
void showAvatarFrame(bool show);
|
||||
void on_closeInfoFrameButton_clicked();
|
||||
|
||||
void setColor();
|
||||
void setColor();
|
||||
void getFont();
|
||||
void setFont();
|
||||
|
||||
void checkChat();
|
||||
void sendChat();
|
||||
|
||||
void updatePeersCustomStateString(const QString& peer_id, const QString& status_string) ;
|
||||
void getAvatar();
|
||||
|
||||
|
||||
void on_actionClear_Chat_triggered();
|
||||
|
||||
|
||||
bool fileSave();
|
||||
bool fileSaveAs();
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
@ -120,24 +120,24 @@ private:
|
||||
void addAttachment(std::string,int flag);
|
||||
void processSettings(bool bLoad);
|
||||
|
||||
QAction *actionTextBold;
|
||||
QAction *actionTextUnderline;
|
||||
QAction *actionTextItalic;
|
||||
QAction *pasteLinkAct ;
|
||||
|
||||
QAction *actionTextBold;
|
||||
QAction *actionTextUnderline;
|
||||
QAction *actionTextItalic;
|
||||
QAction *pasteLinkAct ;
|
||||
|
||||
std::string dialogId, dialogName;
|
||||
unsigned int lastChatTime;
|
||||
std::string lastChatName;
|
||||
|
||||
|
||||
time_t last_status_send_time ;
|
||||
QHash<QString, QString> smileys;
|
||||
QColor mCurrentColor;
|
||||
QFont mCurrentFont;
|
||||
|
||||
|
||||
QString styleHtm;
|
||||
QString emptyStyle;
|
||||
QStringList history;
|
||||
QString wholeChat;
|
||||
QString wholeChat;
|
||||
QString fileName;
|
||||
|
||||
bool m_bInsertOnVisible;
|
||||
@ -145,7 +145,6 @@ private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::PopupChatDialog ui;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -114,12 +114,12 @@ void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id)
|
||||
emit peerHasNewAvatar(QString::fromStdString(peer_id)) ;
|
||||
}
|
||||
|
||||
void NotifyQt::notifyCustomState(const std::string& peer_id)
|
||||
void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string)
|
||||
{
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "notifyQt: Received custom status string notification" << std::endl ;
|
||||
#endif
|
||||
emit peerHasNewCustomStateString(QString::fromStdString(peer_id)) ;
|
||||
emit peerHasNewCustomStateString(QString::fromStdString(peer_id), QString::fromStdString(status_string)) ;
|
||||
}
|
||||
|
||||
void NotifyQt::notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private)
|
||||
|
@ -33,7 +33,7 @@ class NotifyQt: public QObject, public NotifyBase
|
||||
virtual void notifyListChange(int list, int type);
|
||||
virtual void notifyErrorMsg(int list, int sev, std::string msg);
|
||||
virtual void notifyChatStatus(const std::string& peer_id,const std::string& status_string,bool is_private);
|
||||
virtual void notifyCustomState(const std::string& peer_id);
|
||||
virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
|
||||
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) ;
|
||||
@ -63,7 +63,7 @@ class NotifyQt: public QObject, public NotifyBase
|
||||
void configChanged() const ;
|
||||
void logInfoChanged(const QString&) const ;
|
||||
void chatStatusChanged(const QString&,const QString&,bool) const ;
|
||||
void peerHasNewCustomStateString(const QString&) const ;
|
||||
void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ;
|
||||
void gotTurtleSearchResult(qulonglong search_id,FileDetail file) const ;
|
||||
void peerHasNewAvatar(const QString& peer_id) const ;
|
||||
void ownAvatarChanged() const ;
|
||||
|
@ -190,7 +190,6 @@ int main(int argc, char *argv[])
|
||||
QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection);
|
||||
|
||||
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->peersDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
|
||||
QObject::connect(notify,SIGNAL(peerHasNewCustomStateString(const QString&)),w->peersDialog,SLOT(updatePeersCustomStateString(const QString&)));
|
||||
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(ownStatusMessageChanged()),w->peersDialog,SLOT(loadmypersonalstatus()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user