diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 5b36e3b2b..9073f01d0 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -112,6 +112,23 @@ #define RS_RELEASE_VERSION 1 +// This static function is a callback passed to the file hashing thread. As it is called +// from a separate thread without locks, it should not perturbate the interface. That's why +// I'm only using show()/hide() and setText() instead of add/remove widgets. +// +static QLabel *hash_info_label = NULL ; +static void displayHashingInfo(const std::string& s) +{ + if(hash_info_label != NULL) + if(s == "") + hash_info_label->hide() ; + else + { + hash_info_label->show() ; + hash_info_label->setText(QString::fromStdString(s)) ; + } +} + /** Constructor */ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) : RWindow("MainWindow", parent, flags) @@ -309,8 +326,12 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) #endif peerstatus = new PeerStatus(); statusBar()->addWidget(peerstatus); - statusBar()->addPermanentWidget(statusRates = new QLabel(tr("Down: 0.00 (kB/s) | Up: 0.00 (kB/s) "))); + hash_info_label = new QLabel("") ; + statusBar()->addPermanentWidget(hash_info_label); + hash_info_label->hide() ; + + statusBar()->addPermanentWidget(statusRates = new QLabel(tr("Down: 0.00 (kB/s) | Up: 0.00 (kB/s) "))); //servicegrp->actions()[0]->setChecked(true); @@ -365,6 +386,10 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags) timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); timer->start(5113); + // Here we're setting the callback responsible for displaying what's happening to + // file hashing. + // + rsFiles->setFileHashingCallback(displayHashingInfo) ; } void MainWindow::updateStatus() @@ -386,7 +411,6 @@ void MainWindow::updateStatus() } - /** Creates a new action associated with a config page. */ QAction* MainWindow::createPageAction(QIcon img, QString text, QActionGroup *group) { diff --git a/retroshare-gui/src/rsiface/rsfiles.h b/retroshare-gui/src/rsiface/rsfiles.h index 3f8575035..5ea3e6851 100644 --- a/retroshare-gui/src/rsiface/rsfiles.h +++ b/retroshare-gui/src/rsiface/rsfiles.h @@ -139,6 +139,9 @@ virtual int SearchBoolExp(Expression * exp, std::list &results) = 0; virtual bool ConvertSharedFilePath(std::string path, std::string &fullpath) = 0; virtual void ForceDirectoryCheck() = 0; virtual bool InDirectoryCheck() = 0; +virtual void setFileHashingCallback( void(*cb)(const std::string&)) = 0; + + /*** * Directory Control