mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-09-20 12:54:52 -04:00
moved hashing status info from notify to rsEvents
This commit is contained in:
parent
da0732b5ad
commit
2edb3afc81
6 changed files with 90 additions and 89 deletions
|
@ -259,7 +259,7 @@ void HashBox::checkAttachmentReady()
|
|||
emit fileHashingFinished(hashedFiles);
|
||||
|
||||
auto ev = std::make_shared<RsSharedDirectoriesEvent>();
|
||||
ev->mEventCode = RsSharedDirectoriesEventCode::DIRECTORY_SWEEP_ENDED;
|
||||
ev->mEventCode = RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED;
|
||||
if(rsEvents)
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
|
|
|
@ -109,15 +109,15 @@ NotifyQt::NotifyQt() : cDialog(NULL)
|
|||
qRegisterMetaType<RsGxsId>("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<TurtleGxsInfo>& /*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<TurtleGxsInfo>& /*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,6 +564,14 @@ void NotifyQt::notifyListChange(int list, int type)
|
|||
#endif
|
||||
emit filesPostModChanged(false) ; /* Local */
|
||||
break;
|
||||
case NOTIFY_LIST_CONFIG:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received config changed" << std::endl ;
|
||||
#endif
|
||||
emit configChanged() ;
|
||||
break ;
|
||||
|
||||
#ifdef REMOVE
|
||||
case NOTIFY_LIST_SEARCHLIST:
|
||||
break;
|
||||
case NOTIFY_LIST_CHANNELLIST:
|
||||
|
@ -574,14 +582,7 @@ void NotifyQt::notifyListChange(int list, int type)
|
|||
#endif
|
||||
emit transfersChanged() ;
|
||||
break;
|
||||
case NOTIFY_LIST_CONFIG:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received config changed" << std::endl ;
|
||||
#endif
|
||||
emit configChanged() ;
|
||||
break ;
|
||||
|
||||
#ifdef REMOVE
|
||||
case NOTIFY_LIST_FORUMLIST_LOCKED:
|
||||
#ifdef NOTIFY_DEBUG
|
||||
std::cerr << "received forum msg changed" << std::endl ;
|
||||
|
|
|
@ -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<TurtleFileInfo>& found_files);
|
||||
#endif
|
||||
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& found_groups);
|
||||
//#ifdef TO_REMOVE
|
||||
// virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list<TurtleFileInfo>& found_files);
|
||||
//#endif
|
||||
// virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& 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();
|
||||
|
||||
|
|
|
@ -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,64 +70,25 @@ void HashingStatus::handleEvent_main_thread(std::shared_ptr<const RsEvent> 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::SAVING_FILE_INDEX:
|
||||
info = tr("Saving file index...");
|
||||
break;
|
||||
}
|
||||
|
||||
// GUI calls should only happen in the GUI thread, which is achieved by postToObject().
|
||||
|
||||
updateHashingInfo(info);
|
||||
}
|
||||
|
||||
HashingStatus::~HashingStatus()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
delete(movie);
|
||||
}
|
||||
|
||||
void HashingStatus::updateHashingInfo(const QString& s)
|
||||
{
|
||||
if (s.isEmpty())
|
||||
case RsSharedDirectoriesEventCode::HASHING_PROCESS_RESUMED:
|
||||
statusHashing->setText(mLastText); // fallthrough
|
||||
case RsSharedDirectoriesEventCode::HASHING_PROCESS_STARTED:
|
||||
{
|
||||
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() ;
|
||||
|
||||
hashloader->setMovie(movie) ;
|
||||
movie->start() ;
|
||||
|
||||
statusHashing->setVisible(!_compactMode) ;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
void HashingStatus::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
rsFiles->togglePauseHashingProcess() ;
|
||||
|
||||
if(rsFiles->hashingProcessPaused())
|
||||
case RsSharedDirectoriesEventCode::HASHING_PROCESS_PAUSED:
|
||||
{
|
||||
movie->stop() ;
|
||||
hashloader->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":/images/resume.png")) ;
|
||||
|
@ -135,10 +97,49 @@ void HashingStatus::mousePressEvent(QMouseEvent *)
|
|||
statusHashing->setText(QObject::tr("[Hashing is paused]"));
|
||||
setToolTip(QObject::tr("Click to resume the hashing process"));
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
case RsSharedDirectoriesEventCode::HASHING_PROCESS_FINISHED:
|
||||
{
|
||||
hashloader->setMovie(movie) ;
|
||||
statusHashing->setText(mLastText);
|
||||
movie->start() ;
|
||||
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:
|
||||
{
|
||||
statusHashing->setText(tr("Saving file index..."));
|
||||
}
|
||||
break;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
HashingStatus::~HashingStatus()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
delete(movie);
|
||||
}
|
||||
|
||||
void HashingStatus::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
rsFiles->togglePauseHashingProcess() ;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ public:
|
|||
void mousePressEvent(QMouseEvent *);
|
||||
|
||||
private:
|
||||
void updateHashingInfo(const QString& s);
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
ElidedLabel *statusHashing;
|
||||
|
|
|
@ -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())) ;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue