moved hashing status info from notify to rsEvents

This commit is contained in:
csoler 2025-06-07 15:50:24 +02:00
parent da0732b5ad
commit 2edb3afc81
6 changed files with 90 additions and 89 deletions

View file

@ -259,7 +259,7 @@ void HashBox::checkAttachmentReady()
emit fileHashingFinished(hashedFiles); emit fileHashingFinished(hashedFiles);
auto ev = std::make_shared<RsSharedDirectoriesEvent>(); auto ev = std::make_shared<RsSharedDirectoriesEvent>();
ev->mEventCode = RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED; ev->mEventCode = RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED;
if(rsEvents) if(rsEvents)
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
} }

View file

@ -109,15 +109,15 @@ NotifyQt::NotifyQt() : cDialog(NULL)
qRegisterMetaType<RsGxsId>("RsGxsId"); qRegisterMetaType<RsGxsId>("RsGxsId");
} }
void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) //void NotifyQt::notifyErrorMsg(int list, int type, std::string msg)
{ //{
{ // {
QMutexLocker m(&_mutex) ; // QMutexLocker m(&_mutex) ;
if(!_enabled) // if(!_enabled)
return ; // return ;
} // }
emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; // emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ;
} //}
void NotifyQt::notifyChatMessage(const ChatMessage &msg) void NotifyQt::notifyChatMessage(const ChatMessage &msg)
{ {
@ -477,10 +477,10 @@ void NotifyQt::notifyChatCleared(const ChatId& chat_id)
emit chatCleared(chat_id); emit chatCleared(chat_id);
} }
void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list<TurtleGxsInfo>& /*found_groups*/) //void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list<TurtleGxsInfo>& /*found_groups*/)
{ //{
std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; // std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl;
} //}
#ifdef TO_REMOVE #ifdef TO_REMOVE
// Mai 2023: distant turtle search now uses RsEvents. // Mai 2023: distant turtle search now uses RsEvents.
@ -564,16 +564,6 @@ void NotifyQt::notifyListChange(int list, int type)
#endif #endif
emit filesPostModChanged(false) ; /* Local */ emit filesPostModChanged(false) ; /* Local */
break; break;
case NOTIFY_LIST_SEARCHLIST:
break;
case NOTIFY_LIST_CHANNELLIST:
break;
case NOTIFY_LIST_TRANSFERLIST:
#ifdef NOTIFY_DEBUG
std::cerr << "received transfer changed" << std::endl ;
#endif
emit transfersChanged() ;
break;
case NOTIFY_LIST_CONFIG: case NOTIFY_LIST_CONFIG:
#ifdef NOTIFY_DEBUG #ifdef NOTIFY_DEBUG
std::cerr << "received config changed" << std::endl ; std::cerr << "received config changed" << std::endl ;
@ -582,6 +572,17 @@ void NotifyQt::notifyListChange(int list, int type)
break ; break ;
#ifdef REMOVE #ifdef REMOVE
case NOTIFY_LIST_SEARCHLIST:
break;
case NOTIFY_LIST_CHANNELLIST:
break;
case NOTIFY_LIST_TRANSFERLIST:
#ifdef NOTIFY_DEBUG
std::cerr << "received transfer changed" << std::endl ;
#endif
emit transfersChanged() ;
break;
case NOTIFY_LIST_FORUMLIST_LOCKED: case NOTIFY_LIST_FORUMLIST_LOCKED:
#ifdef NOTIFY_DEBUG #ifdef NOTIFY_DEBUG
std::cerr << "received forum msg changed" << std::endl ; std::cerr << "received forum msg changed" << std::endl ;

View file

@ -62,15 +62,15 @@ class NotifyQt: public QObject, public NotifyClient
virtual void notifyListPreChange(int list, int type); virtual void notifyListPreChange(int list, int type);
virtual void notifyListChange(int list, int type); virtual void notifyListChange(int list, int type);
virtual void notifyErrorMsg(int list, int sev, std::string msg); // virtual void notifyErrorMsg(int list, int sev, std::string msg);
virtual void notifyChatMessage(const ChatMessage& /* msg */); virtual void notifyChatMessage(const ChatMessage& /* msg */);
virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string); virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string);
virtual void notifyChatCleared(const ChatId &chat_id); virtual void notifyChatCleared(const ChatId &chat_id);
virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
#ifdef TO_REMOVE //#ifdef TO_REMOVE
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 */) ;
@ -107,7 +107,7 @@ class NotifyQt: public QObject, public NotifyClient
void hashingInfoChanged(const QString&) const ; void hashingInfoChanged(const QString&) const ;
void filesPreModChanged(bool) const ; void filesPreModChanged(bool) const ;
void filesPostModChanged(bool) const ; void filesPostModChanged(bool) const ;
void transfersChanged() const ; // void transfersChanged() const ;
void friendsChanged() const ; void friendsChanged() const ;
void lobbyListChanged() const ; void lobbyListChanged() const ;
void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ;
@ -130,7 +130,7 @@ class NotifyQt: public QObject, public NotifyClient
void discInfoChanged() const ; void discInfoChanged() const ;
void historyChanged(uint msgId, int type); void historyChanged(uint msgId, int type);
void chatLobbyInviteReceived() ; void chatLobbyInviteReceived() ;
void deferredSignatureHandlingRequested() ; // void deferredSignatureHandlingRequested() ;
void chatLobbyTimeShift(int time_shift) ; void chatLobbyTimeShift(int time_shift) ;
void connectionWithoutCert(); void connectionWithoutCert();

View file

@ -27,6 +27,7 @@
#include "hashingstatus.h" #include "hashingstatus.h"
#include "gui/common/ElidedLabel.h" #include "gui/common/ElidedLabel.h"
#include "util/qtthreadsutils.h" #include "util/qtthreadsutils.h"
#include "util/misc.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "gui/common/FilesDefs.h" #include "gui/common/FilesDefs.h"
@ -69,27 +70,66 @@ void HashingStatus::handleEvent_main_thread(std::shared_ptr<const RsEvent> event
if(!fe) if(!fe)
return; return;
QString info; std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << std::endl;
switch (fe->mEventCode) switch (fe->mEventCode)
{ {
default: default:
case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP:
info = tr("Examining shared files..."); case RsSharedDirectoriesEventCode::HASHING_PROCESS_RESUMED:
break; statusHashing->setText(mLastText); // fallthrough
case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED: case RsSharedDirectoriesEventCode::HASHING_PROCESS_STARTED:
break; {
case RsSharedDirectoriesEventCode::HASHING_FILE: hashloader->show() ;
info = tr("Hashing file") + " " + QString::fromUtf8(fe->mMessage.c_str()); hashloader->setMovie(movie) ;
break; movie->start() ;
statusHashing->setVisible(!_compactMode) ;
}
break;
case RsSharedDirectoriesEventCode::HASHING_PROCESS_PAUSED:
{
movie->stop() ;
hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ;
mLastText = statusHashing->text();
statusHashing->setText(QObject::tr("[Hashing is paused]"));
setToolTip(QObject::tr("Click to resume the hashing process"));
}
break;
case RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED:
{
movie->stop() ;
statusHashing->setText(QString());
statusHashing->hide() ;
setToolTip(QString());
hashloader->hide() ;
}
break;
case RsSharedDirectoriesEventCode::HASHING_FILE:
{
QString msg = QString::number((unsigned long int)fe->mHashCounter+1) + "/" + QString::number((unsigned long int)fe->mTotalFilesToHash);
msg += " (" + misc::friendlyUnit(fe->mTotalHashedSize) + " - "
+ QString::number(int(fe->mTotalHashedSize/double(fe->mTotalSizeToHash)*100.0)) + "%"
+ ((fe->mHashingSpeed>0)?("," + QString::number((double)fe->mHashingSpeed,'f',2) + " MB/s)"):(QString()))
+ " : " + QString::fromUtf8(fe->mFilePath.c_str()) ;
statusHashing->setText(tr("Hashing file") + " " + msg);
setToolTip(msg + "\n"+QObject::tr("Click to pause the hashing process"));
}
break;
case RsSharedDirectoriesEventCode::SAVING_FILE_INDEX: case RsSharedDirectoriesEventCode::SAVING_FILE_INDEX:
info = tr("Saving file index..."); {
break; statusHashing->setText(tr("Saving file index..."));
} }
break;
// GUI calls should only happen in the GUI thread, which is achieved by postToObject(). };
updateHashingInfo(info);
} }
HashingStatus::~HashingStatus() HashingStatus::~HashingStatus()
@ -98,47 +138,8 @@ HashingStatus::~HashingStatus()
delete(movie); delete(movie);
} }
void HashingStatus::updateHashingInfo(const QString& s)
{
if (s.isEmpty())
{
statusHashing->hide() ;
hashloader->hide() ;
setToolTip(QString());
movie->stop() ;
} else {
setToolTip(s + "\n"+QObject::tr("Click to pause the hashing process"));
if (_compactMode) {
statusHashing->hide() ;
} else {
statusHashing->setText(s) ;
statusHashing->show() ;
}
hashloader->show() ;
movie->start() ;
}
}
void HashingStatus::mousePressEvent(QMouseEvent *) void HashingStatus::mousePressEvent(QMouseEvent *)
{ {
rsFiles->togglePauseHashingProcess() ; rsFiles->togglePauseHashingProcess() ;
if(rsFiles->hashingProcessPaused())
{
movie->stop() ;
hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ;
mLastText = statusHashing->text();
statusHashing->setText(QObject::tr("[Hashing is paused]"));
setToolTip(QObject::tr("Click to resume the hashing process"));
}
else
{
hashloader->setMovie(movie) ;
statusHashing->setText(mLastText);
movie->start() ;
}
} }

View file

@ -39,7 +39,6 @@ public:
void mousePressEvent(QMouseEvent *); void mousePressEvent(QMouseEvent *);
private: private:
void updateHashingInfo(const QString& s);
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event); void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
ElidedLabel *statusHashing; ElidedLabel *statusHashing;

View file

@ -725,11 +725,11 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
#ifdef DEBUG #ifdef DEBUG
std::cerr << "connecting signals and slots" << std::endl ; std::cerr << "connecting signals and slots" << std::endl ;
#endif #endif
QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; // QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;
QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool)) ,Qt::QueuedConnection ) ;
QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; // QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ;
QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) ));
QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ;