moved ownAvatarChanged() and ownStatusChanged() to rsEvents

This commit is contained in:
csoler 2025-07-10 15:39:10 +02:00
parent 4b9d060c81
commit 9b881a6214
6 changed files with 38 additions and 17 deletions

View file

@ -95,8 +95,8 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
ui.avatar->setOwnId(); ui.avatar->setOwnId();
connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage())); connect(ui.messagelineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(savestatusmessage()));
connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage()));
//connect(NotifyQt::getInstance(), SIGNAL(ownStatusMessageChanged()), this, SLOT(loadmystatusmessage()));
//connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int))); //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(updateOwnStatus(QString,int)));
mEventHandlerId = 0; mEventHandlerId = 0;
@ -105,10 +105,17 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WindowFlags flags)
RsQThreadUtils::postToObject([=](){ RsQThreadUtils::postToObject([=](){
auto fe = dynamic_cast<const RsFriendListEvent*>(e.get()); auto fe = dynamic_cast<const RsFriendListEvent*>(e.get());
if(!fe || fe->mEventCode != RsFriendListEventCode::NODE_STATUS_CHANGED) if(!fe) return;
return;
updateOwnStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); switch(fe->mEventCode)
{
case RsFriendListEventCode::NODE_STATUS_CHANGED: updateOwnStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus);
break;
case RsFriendListEventCode::OWN_STATUS_CHANGED: loadmystatusmessage();
break;
default:
break;
}
}, this ); }, this );
},mEventHandlerId,RsEventType::FRIEND_LIST); },mEventHandlerId,RsEventType::FRIEND_LIST);

View file

@ -49,8 +49,8 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarW
setFrameType(NO_FRAME); setFrameType(NO_FRAME);
/* connect signals */ /* connect signals */
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&))); //connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar())); //connect(NotifyQt::getInstance(), SIGNAL(ownAvatarChanged()), this, SLOT(updateOwnAvatar()));
mEventHandlerId = 0; mEventHandlerId = 0;
@ -61,7 +61,19 @@ AvatarWidget::AvatarWidget(QWidget *parent) : QLabel(parent), ui(new Ui::AvatarW
const RsFriendListEvent *e = dynamic_cast<const RsFriendListEvent*>(event.get()); const RsFriendListEvent *e = dynamic_cast<const RsFriendListEvent*>(event.get());
if(!e) if(!e)
return; return;
updateStatus(QString::fromStdString(e->mSslId.toStdString()),e->mStatus);
switch(e->mEventCode)
{
case RsFriendListEventCode::OWN_AVATAR_CHANGED:
case RsFriendListEventCode::NODE_AVATAR_CHANGED: updateAvatar(QString::fromStdString(e->mSslId.toStdString()));
break;
case RsFriendListEventCode::OWN_STATUS_CHANGED:
case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(QString::fromStdString(e->mSslId.toStdString()),e->mStatus);
default:
break;
}
}, this ); }, this );
}, mEventHandlerId, RsEventType::FRIEND_LIST ); }, mEventHandlerId, RsEventType::FRIEND_LIST );

View file

@ -203,7 +203,7 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST ); rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_peer, RsEventType::FRIEND_LIST );
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY ); rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) { handleEvent(e); }, mEventHandlerId_gssp, RsEventType::GOSSIP_DISCOVERY );
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay())); // connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(QString)), this, SLOT(forceUpdateDisplay()));
// connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay())); // connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(QString,int)), this, SLOT(forceUpdateDisplay()));
mModel = new RsFriendListModel(ui->peerTreeWidget); mModel = new RsFriendListModel(ui->peerTreeWidget);

View file

@ -133,6 +133,7 @@ void NotifyQt::notifyChatMessage(const ChatMessage &msg)
emit chatMessageReceived(msg); emit chatMessageReceived(msg);
} }
#ifdef TO_REMOVE
void NotifyQt::notifyOwnAvatarChanged() void NotifyQt::notifyOwnAvatarChanged()
{ {
{ {
@ -146,6 +147,7 @@ void NotifyQt::notifyOwnAvatarChanged()
#endif #endif
emit ownAvatarChanged() ; emit ownAvatarChanged() ;
} }
#endif
class SignatureEventData class SignatureEventData
{ {
@ -365,7 +367,6 @@ void NotifyQt::notifyPeerStatusChangedSummary()
emit peerStatusChangedSummary(); emit peerStatusChangedSummary();
} }
#endif
void NotifyQt::notifyOwnStatusMessageChanged() void NotifyQt::notifyOwnStatusMessageChanged()
{ {
@ -393,6 +394,7 @@ void NotifyQt::notifyPeerHasNewAvatar(std::string peer_id)
#endif #endif
emit peerHasNewAvatar(QString::fromStdString(peer_id)) ; emit peerHasNewAvatar(QString::fromStdString(peer_id)) ;
} }
#endif
void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string) void NotifyQt::notifyCustomState(const std::string& peer_id, const std::string& status_string)
{ {

View file

@ -71,12 +71,12 @@ class NotifyQt: public QObject, public NotifyClient
// virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list<TurtleFileInfo>& found_files); // virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list<TurtleFileInfo>& found_files);
//#endif //#endif
// virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& found_groups); // virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& found_groups);
virtual void notifyPeerHasNewAvatar(std::string peer_id) ; // virtual void notifyPeerHasNewAvatar(std::string peer_id) ;
virtual void notifyOwnAvatarChanged() ; // virtual void notifyOwnAvatarChanged() ;
// virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ; // virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ;
// virtual void notifyChatLobbyTimeShift(int time_shift) ; // virtual void notifyChatLobbyTimeShift(int time_shift) ;
virtual void notifyOwnStatusMessageChanged() ; // virtual void notifyOwnStatusMessageChanged() ;
// virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ; // virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ;
/* peer has changed the state */ /* peer has changed the state */
// virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state); // virtual void notifyPeerStatusChanged(const std::string& peer_id, uint32_t state);
@ -117,9 +117,9 @@ class NotifyQt: public QObject, public NotifyClient
void chatStatusChanged(const ChatId&,const QString&) const ; void chatStatusChanged(const ChatId&,const QString&) const ;
void chatCleared(const ChatId&) const ; void chatCleared(const ChatId&) const ;
void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ; void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ;
void peerHasNewAvatar(const QString& peer_id) const ; // void peerHasNewAvatar(const QString& peer_id) const ;
void ownAvatarChanged() const ; // void ownAvatarChanged() const ;
void ownStatusMessageChanged() const ; // void ownStatusMessageChanged() const ;
void errorOccurred(int,int,const QString&) const ; void errorOccurred(int,int,const QString&) const ;
void diskFull(int,int) const ; void diskFull(int,int) const ;
// void peerStatusChanged(const QString& /* peer_id */, int /* status */); // void peerStatusChanged(const QString& /* peer_id */, int /* status */);

View file

@ -734,7 +734,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
// QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; // QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ;
QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool)));
QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); // QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus()));
// QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ; // QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ;
QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ;