Merge ea05dbcd6678119b538bb968ff785cdaf9f40ad4 into 1d1138d0cb941845632cc4a8f74336818d63bcc4

This commit is contained in:
defnax 2025-04-16 20:47:00 +02:00 committed by GitHub
commit 502f2171cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 68 additions and 1 deletions

View File

@ -1931,7 +1931,12 @@ void ChatWidget::updatePeersCustomStateString(const QString& peer_id, const QStr
void ChatWidget::updateStatusString(const QString &statusMask, const QString &statusString, bool permanent)
{
ui->typingLabel->setText(QString(statusMask).arg(trUtf8(statusString.toUtf8()))); // displays info for 5 secs.
ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":icons/png/typing.png") );
if (statusString.contains("Connexion refused")){
ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":images/denied-32.png") );
} else {
ui->typingPixmapLabel->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":icons/png/typing.png") );
}
if (statusString == "is typing...") {
typing = true;
@ -1943,6 +1948,11 @@ void ChatWidget::updateStatusString(const QString &statusMask, const QString &st
QTimer::singleShot(5000, this, SLOT(resetStatusBar())) ;
}
void ChatWidget::updatePixmapLabel(const QPixmap &pixmap)
{
ui->typingPixmapLabel->setPixmap(pixmap);
}
void ChatWidget::setName(const QString &name)
{
this->name = name;

View File

@ -101,6 +101,7 @@ public:
void addChatMsg(bool incoming, const QString &name, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType);
void addChatMsg(bool incoming, const QString &name, const RsGxsId gxsId, const QDateTime &sendTime, const QDateTime &recvTime, const QString &message, MsgType chatType);
void updateStatusString(const QString &statusMask, const QString &statusString, bool permanent = false);
void updatePixmapLabel(const QPixmap &pixmap);
void addToolsAction(QAction *action);

View File

@ -26,7 +26,9 @@
#include <unistd.h>
#include "gui/notifyqt.h"
#include "gui/common/FilesDefs.h"
#include <retroshare/rsstatus.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsidentity.h>
@ -60,6 +62,8 @@ PopupDistantChatDialog::PopupDistantChatDialog(const DistantChatPeerId& tunnel_i
_update_timer->setInterval(1000) ;
QObject::connect(_update_timer,SIGNAL(timeout()),this,SLOT(updateDisplay())) ;
connect(NotifyQt::getInstance(), SIGNAL(distantchatStatusChanged(ChatId)), this, SLOT(updateDistantChatEvent()));
_update_timer->start() ;
getChatWidget()->addTopBarWidget(_status_label) ;
@ -118,6 +122,7 @@ void PopupDistantChatDialog::updateDisplay()
msg = tr("Remote status unknown.");
_status_label->setToolTip(msg);
getChatWidget()->updateStatusString("%1", msg, true);
getChatWidget()->updatePixmapLabel(FilesDefs::getPixmapFromQtResourcePath(":images/status_unknown.png"));
getChatWidget()->blockSending(tr( "Can't send message immediately, "
"because there is no tunnel "
"available." ));
@ -129,6 +134,7 @@ void PopupDistantChatDialog::updateDisplay()
_status_label->setToolTip( QObject::tr("Distant peer has closed the chat") );
getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true );
getChatWidget()->updatePixmapLabel(FilesDefs::getPixmapFromQtResourcePath(":images/status_unknown.png"));
getChatWidget()->blockSending(tr( "Your partner closed the conversation."));
setPeerStatus(RS_STATUS_OFFLINE) ;
@ -144,6 +150,7 @@ void PopupDistantChatDialog::updateDisplay()
_status_label->setToolTip(msg);
getChatWidget()->updateStatusString("%1", msg, true);
getChatWidget()->updatePixmapLabel(FilesDefs::getPixmapFromQtResourcePath(":images/quick_restart24.png"));
getChatWidget()->blockSending(msg);
setPeerStatus(RS_STATUS_OFFLINE);
break;
@ -158,6 +165,33 @@ void PopupDistantChatDialog::updateDisplay()
}
}
void PopupDistantChatDialog::updateDistantChatEvent()
{
if(RsAutoUpdatePage::eventsLocked())
return ;
DistantChatPeerInfo tinfo;
rsMsgs->getDistantChatStatus(_tunnel_id,tinfo) ;
switch(tinfo.status)
{
case RS_DISTANT_CHAT_STATUS_UNKNOWN:
break ;
case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED:
getChatWidget()->addChatMsg(true, tr("Chat status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("Your partner closed the conversation."), ChatWidget::MSGTYPE_SYSTEM);
break ;
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN:
break;
case RS_DISTANT_CHAT_STATUS_CAN_TALK:
getChatWidget()->addChatMsg(true, tr("Chat status"), QDateTime::currentDateTime(), QDateTime::currentDateTime()
, tr("Tunnel is secured. You can talk!"), ChatWidget::MSGTYPE_SYSTEM);
getChatWidget()->unblockSending();
break;
}
}
void PopupDistantChatDialog::closeEvent(QCloseEvent *e)
{
DistantChatPeerInfo tinfo ;

View File

@ -47,6 +47,9 @@ class PopupDistantChatDialog: public PopupChatDialog
protected slots:
void updateDisplay() ; // overloads RsAutoUpdatePage
private slots:
void updateDistantChatEvent() ;
private:
QTimer *_update_timer ;
DistantChatPeerId _tunnel_id ;

View File

@ -84,6 +84,7 @@
<file>images/closehover.png</file>
<file>images/closepressed.png</file>
<file>images/denied16.png</file>
<file>images/denied-32.png</file>
<file>images/filetype-association.png</file>
<file>images/foldermail.png</file>
<file>images/folderopen.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -461,6 +461,22 @@ void NotifyQt::notifyChatStatus(const ChatId& chat_id,const std::string& status_
std::cerr << "notifyQt: Received chat status string: " << status_string << std::endl ;
#endif
emit chatStatusChanged(chat_id, QString::fromUtf8(status_string.c_str()));
}
void NotifyQt::notifyDistantChatStatus(const ChatId& chat_id)
{
{
QMutexLocker m(&_mutex) ;
if(!_enabled)
return ;
}
#ifdef NOTIFY_DEBUG
std::cerr << "notifyQt: Received distant chat status : " << status_string << std::endl ;
#endif
emit distantchatStatusChanged(chat_id);
}
void NotifyQt::notifyChatCleared(const ChatId& chat_id)

View File

@ -65,6 +65,7 @@ class NotifyQt: public QObject, public NotifyClient
virtual void notifyErrorMsg(int list, int sev, std::string msg);
virtual void notifyChatMessage(const ChatMessage& /* msg */);
virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string);
virtual void notifyDistantChatStatus(const ChatId &chat_id);
virtual void notifyChatCleared(const ChatId &chat_id);
virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
#ifdef TO_REMOVE
@ -115,6 +116,7 @@ class NotifyQt: public QObject, public NotifyClient
void configChanged() const ;
void logInfoChanged(const QString&) const ;
void chatStatusChanged(const ChatId&,const QString&) const ;
void distantchatStatusChanged(const ChatId&) const ;
void chatCleared(const ChatId&) const ;
void peerHasNewCustomStateString(const QString& /* peer_id */, const QString& /* status_string */) const ;
void peerHasNewAvatar(const QString& peer_id) const ;