From 2edb3afc8152745d0103e3feecd77284de818224 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 7 Jun 2025 15:50:24 +0200 Subject: [PATCH] moved hashing status info from notify to rsEvents --- retroshare-gui/src/gui/common/HashBox.cpp | 2 +- retroshare-gui/src/gui/notifyqt.cpp | 47 ++++---- retroshare-gui/src/gui/notifyqt.h | 14 +-- .../src/gui/statusbar/hashingstatus.cpp | 111 +++++++++--------- .../src/gui/statusbar/hashingstatus.h | 1 - retroshare-gui/src/main.cpp | 4 +- 6 files changed, 90 insertions(+), 89 deletions(-) diff --git a/retroshare-gui/src/gui/common/HashBox.cpp b/retroshare-gui/src/gui/common/HashBox.cpp index 0a96068e5..44f2ebeb7 100644 --- a/retroshare-gui/src/gui/common/HashBox.cpp +++ b/retroshare-gui/src/gui/common/HashBox.cpp @@ -259,7 +259,7 @@ void HashBox::checkAttachmentReady() emit fileHashingFinished(hashedFiles); auto ev = std::make_shared(); - ev->mEventCode = RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED; + ev->mEventCode = RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED; if(rsEvents) rsEvents->postEvent(ev); } diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index d2dee5ac4..67a61ff7a 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -109,15 +109,15 @@ NotifyQt::NotifyQt() : cDialog(NULL) qRegisterMetaType("RsGxsId"); } -void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) -{ - { - QMutexLocker m(&_mutex) ; - if(!_enabled) - return ; - } - emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; -} +//void NotifyQt::notifyErrorMsg(int list, int type, std::string msg) +//{ +// { +// QMutexLocker m(&_mutex) ; +// if(!_enabled) +// return ; +// } +// emit errorOccurred(list,type,QString::fromUtf8(msg.c_str())) ; +//} void NotifyQt::notifyChatMessage(const ChatMessage &msg) { @@ -477,10 +477,10 @@ void NotifyQt::notifyChatCleared(const ChatId& chat_id) emit chatCleared(chat_id); } -void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list& /*found_groups*/) -{ - std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; -} +//void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list& /*found_groups*/) +//{ +// std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl; +//} #ifdef TO_REMOVE // Mai 2023: distant turtle search now uses RsEvents. @@ -564,16 +564,6 @@ void NotifyQt::notifyListChange(int list, int type) #endif emit filesPostModChanged(false) ; /* Local */ 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: #ifdef NOTIFY_DEBUG std::cerr << "received config changed" << std::endl ; @@ -582,6 +572,17 @@ void NotifyQt::notifyListChange(int list, int type) break ; #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: #ifdef NOTIFY_DEBUG std::cerr << "received forum msg changed" << std::endl ; diff --git a/retroshare-gui/src/gui/notifyqt.h b/retroshare-gui/src/gui/notifyqt.h index 5782ef5b7..3ee7180d3 100644 --- a/retroshare-gui/src/gui/notifyqt.h +++ b/retroshare-gui/src/gui/notifyqt.h @@ -62,15 +62,15 @@ class NotifyQt: public QObject, public NotifyClient virtual void notifyListPreChange(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 notifyChatStatus(const ChatId &chat_id,const std::string& status_string); virtual void notifyChatCleared(const ChatId &chat_id); virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string); -#ifdef TO_REMOVE - virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); -#endif - virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); +//#ifdef TO_REMOVE +// virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list& found_files); +//#endif +// virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list& found_groups); virtual void notifyPeerHasNewAvatar(std::string peer_id) ; virtual void notifyOwnAvatarChanged() ; 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 filesPreModChanged(bool) const ; void filesPostModChanged(bool) const ; - void transfersChanged() const ; +// void transfersChanged() const ; void friendsChanged() const ; void lobbyListChanged() const ; void chatLobbyEvent(qulonglong,int,const RsGxsId&,const QString&) ; @@ -130,7 +130,7 @@ class NotifyQt: public QObject, public NotifyClient void discInfoChanged() const ; void historyChanged(uint msgId, int type); void chatLobbyInviteReceived() ; - void deferredSignatureHandlingRequested() ; +// void deferredSignatureHandlingRequested() ; void chatLobbyTimeShift(int time_shift) ; void connectionWithoutCert(); diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp index fc57bb286..283c92028 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.cpp @@ -27,6 +27,7 @@ #include "hashingstatus.h" #include "gui/common/ElidedLabel.h" #include "util/qtthreadsutils.h" +#include "util/misc.h" #include "gui/notifyqt.h" #include "gui/common/FilesDefs.h" @@ -69,27 +70,66 @@ void HashingStatus::handleEvent_main_thread(std::shared_ptr event if(!fe) return; - QString info; + std::cerr << "HashStatusEventHandler: received event " << (void*)fe->mEventCode << std::endl; switch (fe->mEventCode) { default: - case RsSharedDirectoriesEventCode::STARTING_DIRECTORY_SWEEP: - info = tr("Examining shared files..."); - break; - case RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED: - break; - case RsSharedDirectoriesEventCode::HASHING_FILE: - info = tr("Hashing file") + " " + QString::fromUtf8(fe->mMessage.c_str()); - break; + + case RsSharedDirectoriesEventCode::HASHING_PROCESS_RESUMED: + statusHashing->setText(mLastText); // fallthrough + case RsSharedDirectoriesEventCode::HASHING_PROCESS_STARTED: + { + hashloader->show() ; + hashloader->setMovie(movie) ; + 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: - 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() @@ -98,47 +138,8 @@ HashingStatus::~HashingStatus() 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 *) { 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() ; - } } + diff --git a/retroshare-gui/src/gui/statusbar/hashingstatus.h b/retroshare-gui/src/gui/statusbar/hashingstatus.h index 8f09120a1..180206088 100644 --- a/retroshare-gui/src/gui/statusbar/hashingstatus.h +++ b/retroshare-gui/src/gui/statusbar/hashingstatus.h @@ -39,7 +39,6 @@ public: void mousePressEvent(QMouseEvent *); private: - void updateHashingInfo(const QString& s); void handleEvent_main_thread(std::shared_ptr event); ElidedLabel *statusHashing; diff --git a/retroshare-gui/src/main.cpp b/retroshare-gui/src/main.cpp index 228f24067..c349df404 100644 --- a/retroshare-gui/src/main.cpp +++ b/retroshare-gui/src/main.cpp @@ -725,11 +725,11 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO); #ifdef DEBUG std::cerr << "connecting signals and slots" << std::endl ; #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(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; 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(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ;