diff options
| author | Arno <arno@disconnect.de> | 2018-07-30 20:36:59 +0200 | 
|---|---|---|
| committer | Arno <arno@disconnect.de> | 2018-07-30 20:36:59 +0200 | 
| commit | 598cb833aec9a404271a99eac6f7d360e62ce5c4 (patch) | |
| tree | 91956bc278444c0e44d8760e72ee7e4fac51448a | |
| parent | fa1f377ff5ce22f399b167e4e4b97b1a0f0ae5f9 (diff) | |
| download | ShemovCleaner-598cb833aec9a404271a99eac6f7d360e62ce5c4.tar.gz ShemovCleaner-598cb833aec9a404271a99eac6f7d360e62ce5c4.tar.bz2 ShemovCleaner-598cb833aec9a404271a99eac6f7d360e62ce5c4.zip  | |
Give some indication that we're copying
Add a new label to the statusBar: When it's green the FileCopier is
idle, when working, show the count.
| -rw-r--r-- | filecopier.cpp | 2 | ||||
| -rw-r--r-- | filecopier.h | 1 | ||||
| -rw-r--r-- | filewidget.h | 2 | ||||
| -rw-r--r-- | shemovcleaner.cpp | 28 | ||||
| -rw-r--r-- | shemovcleaner.h | 2 | 
5 files changed, 35 insertions, 0 deletions
diff --git a/filecopier.cpp b/filecopier.cpp index 6256be1..dd3f679 100644 --- a/filecopier.cpp +++ b/filecopier.cpp @@ -24,6 +24,8 @@ void FileCopier::run(){          mJobs.remove(source);          mAddJobMutex.unlock();          QString msg = QString(tr("Copy: %1 (%2/%3)")).arg(source).arg(QString::number(mCopied + 1)).arg(QString::number(mTotal)); +        QString cmsg = QString("%1/%2").arg(QString::number(mCopied + 1)).arg(QString::number(mTotal)); +        emit copying(true, cmsg);          emit message(msg);          QFile sFile(source);          if(sFile.copy(dest)){ diff --git a/filecopier.h b/filecopier.h index 12aa3ac..ed988f1 100644 --- a/filecopier.h +++ b/filecopier.h @@ -15,6 +15,7 @@ class FileCopier : public QThread {      signals:          void message(const QString &msg); +        void copying(bool copying, const QString &msg);      private:          QHash<QString, QString> mJobs; diff --git a/filewidget.h b/filewidget.h index 0b11d0e..f9b5af3 100644 --- a/filewidget.h +++ b/filewidget.h @@ -27,6 +27,7 @@ class CachedFileData;  class QStandardItem;  class QComboBox;  class SearchDialog; +class FileCopier;  class FileWidget : public QWidget {      Q_OBJECT @@ -40,6 +41,7 @@ class FileWidget : public QWidget {          QTreeView *fileView() { return mFileView; }          QMenuBar *menuBar() { return mMenuBar; }          QToolBar *toolBar() { return mToolBar; } +        FileCopier *fileCopier() { return mFileCopier; }          const QString currentDir() const { return mDir->text(); }          void setProgressBar(QProgressBar *progressBar) { mProgressBar = progressBar; }          virtual ~FileWidget(); diff --git a/shemovcleaner.cpp b/shemovcleaner.cpp index 65153d8..fa21934 100644 --- a/shemovcleaner.cpp +++ b/shemovcleaner.cpp @@ -20,6 +20,7 @@  #include "shemovcleaner.h"  #include "torrentwidget.h"  #include "filewidget.h" +#include "filecopier.h"  #include "torrentdisplay.h"  #include "configurationwidget.h"  #include "filewidget.h" @@ -65,6 +66,8 @@ ShemovCleaner::ShemovCleaner(QWidget *parent, Qt::WindowFlags f) : QMainWindow(p      connect(mFileTab, &FileWidget::freeSpaceChanged, this, &ShemovCleaner::updateFreeSpace);      connect(mTab, &QTabWidget::currentChanged, this, &ShemovCleaner::tabChanged);      connect(this, &ShemovCleaner::configurationChanged, mFileTab, &FileWidget::readSettings); +    connect(mFileTab->fileCopier(), &FileCopier::copying, this, &ShemovCleaner::updateCopying); +    connect(mFileTab->fileCopier(), &FileCopier::finished, [=] { updateCopying(false, QString());} );      QMenu *helpMenu = new QMenu(tr("&Help"));      QAction *aboutThisA = new QAction(tr("About ShemovCleaner..."), this); @@ -127,6 +130,22 @@ void ShemovCleaner::updateFreeSpace(const QString &path){      mFree->setPixmap(QPixmap::fromImage(img));  } +void ShemovCleaner::updateCopying(bool inProgress, const QString &count){ +    QImage img(mCopying->size(), QImage::Format_ARGB32); +    if(inProgress){ +        img.fill(Qt::red); +        QPainter p(&img); +        QFont f(qApp->font()); +        f.setBold(true); +        p.setFont(f); +        p.setPen(Qt::blue); +        p.drawText(mCopying->rect(), Qt::AlignCenter, count); +    }else{ +        img.fill(Qt::green); +    } +    mCopying->setPixmap(QPixmap::fromImage(img)); +} +  void ShemovCleaner::setSelectionCount(const QString &msg){      mSelected->setText(msg);  } @@ -184,12 +203,21 @@ void ShemovCleaner::createStatusBar(){      f.setBold(true);      QFontMetrics fm(f);      mFree->setMaximumHeight(fm.height() + 6); +    mCopying = new QLabel; +    mCopying->setFrameStyle(QFrame::Panel | QFrame::Sunken); +    mCopying->setMinimumWidth(fm.maxWidth() + 6); +    mCopying->setMaximumWidth(fm.maxWidth() + 6); +    mCopying->setMaximumHeight(fm.height() + 6); +    mCopying->setMinimumHeight(fm.height() + 6); +    statusBar()->addPermanentWidget(new QLabel(tr("C:"))); +    statusBar()->addPermanentWidget(mCopying);      statusBar()->addPermanentWidget(l1);      statusBar()->addPermanentWidget(mSelected);      statusBar()->addPermanentWidget(l2);      statusBar()->addPermanentWidget(mDuration);      statusBar()->addPermanentWidget(mDrive);      statusBar()->addPermanentWidget(mFree); +    updateCopying(false, QString());  }  void ShemovCleaner::createGlobalActions(){ diff --git a/shemovcleaner.h b/shemovcleaner.h index 802f442..47a763a 100644 --- a/shemovcleaner.h +++ b/shemovcleaner.h @@ -21,6 +21,7 @@ class ShemovCleaner : public QMainWindow {          void setSelectionCount(const QString &msg);          void setDuration(const QString &msg);          void updateFreeSpace(const QString &path); +        void updateCopying(bool inProgress, const QString &count);          void configure();          void tabChanged(int idx);          void aboutThisProgram(); @@ -42,6 +43,7 @@ class ShemovCleaner : public QMainWindow {          QLabel *mDuration;          QLabel *mDrive;          QLabel *mFree; +        QLabel *mCopying;          QTabWidget *mTab;          TorrentWidget *mTorrentTab;          FileWidget *mFileTab;  | 
