fixed typing message missing

This commit is contained in:
csoler 2025-08-27 17:37:45 +02:00
parent 42f0bd41ae
commit 96fddc9066
6 changed files with 123 additions and 108 deletions

View file

@ -338,12 +338,7 @@ void ChatDialog::setPeerStatus(RsStatusValue status)
// convert to virtual peer id // convert to virtual peer id
// this is only required for private and distant chat, // this is only required for private and distant chat,
// because lobby and broadcast does not have a status // because lobby and broadcast does not have a status
RsPeerId vpid; cw->updateStatus(mChatId, status);
if(mChatId.isPeerId())
vpid = mChatId.toPeerId();
if(mChatId.isDistantChatId())
vpid = RsPeerId(mChatId.toDistantChatId());
cw->updateStatus(QString::fromStdString(vpid.toStdString()), status);
} }
} }
RsStatusValue ChatDialog::getPeerStatus() RsStatusValue ChatDialog::getPeerStatus()

View file

@ -176,7 +176,8 @@ ChatWidget::ChatWidget(QWidget *parent)
//connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int))); //connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
mEventHandlerId = 0; mEventHandlerId_friends = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e) rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{ {
RsQThreadUtils::postToObject([=](){ RsQThreadUtils::postToObject([=](){
@ -187,7 +188,7 @@ ChatWidget::ChatWidget(QWidget *parent)
switch(fe->mEventCode) switch(fe->mEventCode)
{ {
case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(QString::fromStdString(fe->mSslId.toStdString()),fe->mStatus); case RsFriendListEventCode::NODE_STATUS_CHANGED: updateStatus(ChatId(fe->mSslId),fe->mStatus);
break; break;
case RsFriendListEventCode::NODE_STATE_STRING_CHANGED: updatePeersCustomStateString(ChatId(fe->mSslId),QString::fromUtf8(fe->mStateString.c_str())); case RsFriendListEventCode::NODE_STATE_STRING_CHANGED: updatePeersCustomStateString(ChatId(fe->mSslId),QString::fromUtf8(fe->mStateString.c_str()));
@ -198,7 +199,7 @@ ChatWidget::ChatWidget(QWidget *parent)
} }
}, this ); }, this );
},mEventHandlerId,RsEventType::FRIEND_LIST); },mEventHandlerId_friends,RsEventType::FRIEND_LIST);
//connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&))); //connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));
connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts())); connect(NotifyQt::getInstance(), SIGNAL(chatFontChanged()), this, SLOT(resetFonts()));
@ -282,7 +283,7 @@ ChatWidget::ChatWidget(QWidget *parent)
ChatWidget::~ChatWidget() ChatWidget::~ChatWidget()
{ {
processSettings(false); processSettings(false);
rsEvents->unregisterEventsHandler(mEventHandlerId); rsEvents->unregisterEventsHandler(mEventHandlerId_friends);
/* Cleanup plugin functions */ /* Cleanup plugin functions */
foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) { foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) {
@ -397,7 +398,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title)
StatusInfo peerStatusInfo; StatusInfo peerStatusInfo;
// No check of return value. Non existing status info is handled as offline. // No check of return value. Non existing status info is handled as offline.
rsStatus->getStatus(chatId.toPeerId(), peerStatusInfo); rsStatus->getStatus(chatId.toPeerId(), peerStatusInfo);
updateStatus(QString::fromStdString(chatId.toPeerId().toStdString()), peerStatusInfo.status); updateStatus(chatId, peerStatusInfo.status);
// initialize first custom state string // initialize first custom state string
QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(chatId.toPeerId()).c_str()); QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(chatId.toPeerId()).c_str());
@ -1820,110 +1821,106 @@ void ChatWidget::setCurrentFileName(const QString &fileName)
setWindowModified(false); setWindowModified(false);
} }
void ChatWidget::updateStatus(const QString &peer_id, RsStatusValue status) void ChatWidget::updateStatus(const ChatId& cid, RsStatusValue status)
{ {
if (! (chatType() == CHATTYPE_PRIVATE || chatType() == CHATTYPE_DISTANT)) if (! (chatType() == CHATTYPE_PRIVATE || chatType() == CHATTYPE_DISTANT))
{ {
// updateTitle is used // updateTitle is used
return; return;
} }
// make virtual peer id from gxs id in case of distant chat // // make virtual peer id from gxs id in case of distant chat
RsPeerId vpid; // RsPeerId vpid;
// if(chatId.isDistantChatId())
// vpid = RsPeerId(chatId.toDistantChatId());
// else
// vpid = chatId.toPeerId();
/* set font size for status */
if (!(cid == chatId))
return;
// the peers status has changed
QString tooltip_info ;
QString peerName ;
if(chatId.isDistantChatId()) if(chatId.isDistantChatId())
vpid = RsPeerId(chatId.toDistantChatId());
else
vpid = chatId.toPeerId();
/* set font size for status */
if (peer_id.toStdString() == vpid.toStdString())
{ {
// the peers status has changed DistantChatPeerInfo dcpinfo ;
RsIdentityDetails details ;
QString tooltip_info ; if(rsMsgs->getDistantChatStatus(chatId.toDistantChatId(),dcpinfo))
QString peerName ; {
if(rsIdentity->getIdDetails(dcpinfo.to_id,details))
peerName = QString::fromUtf8( details.mNickname.c_str() ) ;
else
peerName = QString::fromStdString(dcpinfo.to_id.toStdString()) ;
if(chatId.isDistantChatId()) tooltip_info = QString("Identity Id: ")+QString::fromStdString(dcpinfo.to_id.toStdString());
{ }
DistantChatPeerInfo dcpinfo ; else
RsIdentityDetails details ; {
peerName = QString::fromStdString(chatId.toDistantChatId().toStdString()) ;
if(rsMsgs->getDistantChatStatus(chatId.toDistantChatId(),dcpinfo)) tooltip_info = QString("Identity Id: unknown (bug?)");
{ }
if(rsIdentity->getIdDetails(dcpinfo.to_id,details)) }
peerName = QString::fromUtf8( details.mNickname.c_str() ) ; else
else {
peerName = QString::fromStdString(dcpinfo.to_id.toStdString()) ; peerName = QString::fromUtf8(rsPeers->getPeerName(chatId.toPeerId()).c_str());
tooltip_info = QString("Peer Id: ") + QString::fromStdString(chatId.toPeerId().toStdString());
tooltip_info = QString("Identity Id: ")+QString::fromStdString(dcpinfo.to_id.toStdString());
}
else
{
peerName = QString::fromStdString(chatId.toDistantChatId().toStdString()) ;
tooltip_info = QString("Identity Id: unknown (bug?)");
}
}
else
{
peerName = QString::fromUtf8(rsPeers->getPeerName(chatId.toPeerId()).c_str());
tooltip_info = QString("Peer Id: ") + QString::fromStdString(chatId.toPeerId().toStdString());
}
// is scrollbar at the end?
QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar();
bool atEnd = (scrollbar->value() == scrollbar->maximum());
switch (status) {
default:
case RsStatusValue::RS_STATUS_OFFLINE:
ui->info_Frame->setVisible(true);
ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online."));
break;
case RsStatusValue::RS_STATUS_INACTIVE:
ui->info_Frame->setVisible(true);
ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply"));
break;
case RsStatusValue::RS_STATUS_ONLINE:
ui->info_Frame->setVisible(false);
break;
case RsStatusValue::RS_STATUS_AWAY:
ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply"));
ui->info_Frame->setVisible(true);
break;
case RsStatusValue::RS_STATUS_BUSY:
ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply"));
ui->info_Frame->setVisible(true);
break;
}
ui->titleLabel->setText(peerName);
ui->titleLabel->setToolTip(tooltip_info);
#warning inconsistent conversion here
ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name((RsStatusValue)status)));
peerStatus = status;
if (atEnd) {
// scroll to the end
scrollbar->setValue(scrollbar->maximum());
}
emit infoChanged(this);
emit statusChanged(status);
// Notify all ChatWidgetHolder
foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) {
chatWidgetHolder->updateStatus(status);
}
return;
} }
// ignore status change // is scrollbar at the end?
QScrollBar *scrollbar = ui->textBrowser->verticalScrollBar();
bool atEnd = (scrollbar->value() == scrollbar->maximum());
switch (status) {
default:
case RsStatusValue::RS_STATUS_OFFLINE:
ui->info_Frame->setVisible(true);
ui->infoLabel->setText(peerName + " " + tr("appears to be Offline.") +"\n" + tr("Messages you send will be delivered after Friend is again Online."));
break;
case RsStatusValue::RS_STATUS_INACTIVE:
ui->info_Frame->setVisible(true);
ui->infoLabel->setText(peerName + " " + tr("is Idle and may not reply"));
break;
case RsStatusValue::RS_STATUS_ONLINE:
ui->info_Frame->setVisible(false);
break;
case RsStatusValue::RS_STATUS_AWAY:
ui->infoLabel->setText(peerName + " " + tr("is Away and may not reply"));
ui->info_Frame->setVisible(true);
break;
case RsStatusValue::RS_STATUS_BUSY:
ui->infoLabel->setText(peerName + " " + tr("is Busy and may not reply"));
ui->info_Frame->setVisible(true);
break;
}
ui->titleLabel->setText(peerName);
ui->titleLabel->setToolTip(tooltip_info);
#warning inconsistent conversion here
ui->statusLabel->setText(QString("(%1)").arg(StatusDefs::name((RsStatusValue)status)));
peerStatus = status;
if (atEnd) {
// scroll to the end
scrollbar->setValue(scrollbar->maximum());
}
emit infoChanged(this);
emit statusChanged(status);
// Notify all ChatWidgetHolder
foreach (ChatWidgetHolder *chatWidgetHolder, mChatWidgetHolder) {
chatWidgetHolder->updateStatus(status);
}
} }
void ChatWidget::updateTitle() void ChatWidget::updateTitle()

View file

@ -131,7 +131,7 @@ public:
const QList<ChatWidgetHolder*> &chatWidgetHolderList() { return mChatWidgetHolder; } const QList<ChatWidgetHolder*> &chatWidgetHolderList() { return mChatWidgetHolder; }
public slots: public slots:
void updateStatus(const QString &peer_id, RsStatusValue status); void updateStatus(const ChatId &cid, RsStatusValue status);
void setUseCMark(const bool bUseCMark); void setUseCMark(const bool bUseCMark);
void updateCMPreview(); void updateCMPreview();
@ -274,7 +274,8 @@ private:
Ui::ChatWidget *ui; Ui::ChatWidget *ui;
RsEventsHandlerId_t mEventHandlerId ; // RsEventsHandlerId_t mEventHandlerId_chat ;
RsEventsHandlerId_t mEventHandlerId_friends ;
}; };
#endif // CHATWIDGET_H #endif // CHATWIDGET_H

View file

@ -28,6 +28,7 @@
#include "gui/settings/RsharePeerSettings.h" #include "gui/settings/RsharePeerSettings.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "util/DateTime.h" #include "util/DateTime.h"
#include "util/qtthreadsutils.h"
#include <retroshare/rspeers.h> #include <retroshare/rspeers.h>
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
@ -51,6 +52,25 @@ PopupChatDialog::PopupChatDialog(QWidget *parent, Qt::WindowFlags flags)
connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool))); connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool)));
connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages())); connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages()));
//connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusChanged(ChatId,QString))); //connect(NotifyQt::getInstance(), SIGNAL(chatStatusChanged(ChatId,QString)), this, SLOT(chatStatusChanged(ChatId,QString)));
mEventHandlerId_chat =0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> e)
{
RsQThreadUtils::postToObject([=]()
{
auto fe = dynamic_cast<const RsChatServiceEvent*>(e.get()); if(!fe) return;
switch(fe->mEventCode)
{
case RsChatServiceEventCode::CHAT_STATUS_CHANGED: chatStatusChanged(fe->mCid,QString::fromUtf8(fe->mStr.c_str())); break;
default:
break;
}
}
, this );
}, mEventHandlerId_chat, RsEventType::CHAT_SERVICE );
} }
void PopupChatDialog::init(const ChatId &chat_id, const QString &title) void PopupChatDialog::init(const ChatId &chat_id, const QString &title)

View file

@ -65,6 +65,8 @@ protected:
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::PopupChatDialog ui; Ui::PopupChatDialog ui;
RsEventsHandlerId_t mEventHandlerId_chat;
}; };
#endif #endif

View file

@ -85,7 +85,7 @@
</action> </action>
<action name="actionDockTab"> <action name="actionDockTab">
<property name="icon"> <property name="icon">
<iconset resource="../images.qrc"> <iconset>
<normaloff>:/images/tab-dock.png</normaloff>:/images/tab-dock.png</iconset> <normaloff>:/images/tab-dock.png</normaloff>:/images/tab-dock.png</iconset>
</property> </property>
<property name="text"> <property name="text">
@ -97,7 +97,7 @@
</action> </action>
<action name="actionUndockTab"> <action name="actionUndockTab">
<property name="icon"> <property name="icon">
<iconset resource="../images.qrc"> <iconset>
<normaloff>:/images/tab-undock.png</normaloff>:/images/tab-undock.png</iconset> <normaloff>:/images/tab-undock.png</normaloff>:/images/tab-undock.png</iconset>
</property> </property>
<property name="text"> <property name="text">