diff options
author | Arno <arno@disconnect.de> | 2016-12-06 11:34:41 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2016-12-06 11:34:41 +0100 |
commit | a68cf88e69c65014f2e528aa26db42b4808c3b64 (patch) | |
tree | 430cfe8249357f38ede3e83fae4959b1a9f62fe4 | |
parent | 0e02ad100b0e96c77b6030853bd88a6d4706a776 (diff) | |
download | ShemovCleaner-a68cf88e69c65014f2e528aa26db42b4808c3b64.tar.gz ShemovCleaner-a68cf88e69c65014f2e528aa26db42b4808c3b64.tar.bz2 ShemovCleaner-a68cf88e69c65014f2e528aa26db42b4808c3b64.zip |
Add destination to ProgressDialog
Elide the text if necessary. Only show the destination directory.
-rw-r--r-- | filecopier.cpp | 2 | ||||
-rw-r--r-- | filecopier.h | 2 | ||||
-rw-r--r-- | filewidget.cpp | 10 | ||||
-rw-r--r-- | filewidget.h | 2 | ||||
-rw-r--r-- | progressdialog.cpp | 18 | ||||
-rw-r--r-- | progressdialog.h | 5 |
6 files changed, 23 insertions, 16 deletions
diff --git a/filecopier.cpp b/filecopier.cpp index 3475b74..e652339 100644 --- a/filecopier.cpp +++ b/filecopier.cpp @@ -36,7 +36,7 @@ void FileCopier::run(){ emit success(false, source); goto cleanup; } - emit newFile(source, sFile.size()); + emit newFile(source, dest, sFile.size()); int read = 0; qint64 total = 0; while(!sFile.atEnd()){ diff --git a/filecopier.h b/filecopier.h index 8ffdd4d..96702a3 100644 --- a/filecopier.h +++ b/filecopier.h @@ -15,7 +15,7 @@ class FileCopier : public QThread { void cancel(); signals: - void newFile(const QString &source, qint64 size); + void newFile(const QString &source, const QString & dest, qint64 size); void success(bool s, QString source); void bytesRead(qint64 bytes); diff --git a/filewidget.cpp b/filewidget.cpp index 6905c53..a539f82 100644 --- a/filewidget.cpp +++ b/filewidget.cpp @@ -45,7 +45,7 @@ FileWidget::FileWidget(QWidget *parent) : QWidget(parent), mCopyToMenu(0), mCopyToMapper(0) { mFileCopier = new FileCopier(this); mCopyProgress = new ProgressDialog; - connect(mFileCopier, SIGNAL(newFile(QString,qint64)), this, SLOT(setupProgress(QString,qint64))); + connect(mFileCopier, SIGNAL(newFile(QString,QString,qint64)), this, SLOT(setupProgress(QString,QString,qint64))); connect(mFileCopier, SIGNAL(bytesRead(qint64)), this, SLOT(setCopyProgress(qint64))); connect(mFileCopier, SIGNAL(finished()), this, SLOT(hideCopyProgress())); connect(mFileCopier, SIGNAL(success(bool,QString)), this, SLOT(copySuccess(bool,QString))); @@ -511,12 +511,14 @@ void FileWidget::addAsOrigin(){ mOrignDlg->show(); } -void FileWidget::setupProgress(QString file, qint64 size){ +void FileWidget::setupProgress(QString file, QString dest, qint64 size){ mCopyProgress->setMaximum(size / 1024 / 1024); mCopyProgress->setValue(0); QFileInfo fi(file); - QString progressLabel = QString(tr("Copying %1")).arg(fi.fileName()); - mCopyProgress->setLabelText(progressLabel); + QString srcLabel = QString(tr("Copying %1")).arg(fi.fileName()); + QFileInfo fi2(dest); + QString dstLabel = QString(tr("to %2")).arg(QDir::toNativeSeparators(fi2.absolutePath())); + mCopyProgress->setLabelText(srcLabel, dstLabel); } void FileWidget::setCopyProgress(qint64 bytes){ diff --git a/filewidget.h b/filewidget.h index 6d427ff..62d0630 100644 --- a/filewidget.h +++ b/filewidget.h @@ -65,7 +65,7 @@ class FileWidget : public QWidget { void paste(); void selectFirst(); void addAsOrigin(); - void setupProgress(QString file, qint64 size); + void setupProgress(QString file, QString dest, qint64 size); void setCopyProgress(qint64 bytes); void copyFiles(QString destDir); void hideCopyProgress(); diff --git a/progressdialog.cpp b/progressdialog.cpp index f354a07..2f51857 100644 --- a/progressdialog.cpp +++ b/progressdialog.cpp @@ -5,7 +5,8 @@ #include "progressdialog.h" ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ - mLabel = new QLabel; + mSrc = new QLabel; + mDst = new QLabel; mProgress = new QProgressBar; QPushButton *cancelBtn = new QPushButton(tr("Cancel")); connect(cancelBtn, SIGNAL(clicked()), this, SIGNAL(cancelled())); @@ -14,7 +15,8 @@ ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(par btnLayout->addWidget(cancelBtn); btnLayout->addStretch(); QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(mLabel); + mainLayout->addWidget(mSrc); + mainLayout->addWidget(mDst); mainLayout->addWidget(mProgress); mainLayout->addLayout(btnLayout); setMaximumWidth(400); @@ -22,11 +24,13 @@ ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(par setLayout(mainLayout); } -void ProgressDialog::setLabelText(const QString &text){ - QFontMetrics fm(mLabel->font()); - int width = mLabel->width() - 4; - QString fixed = fm.elidedText(text, Qt::ElideRight, width); - mLabel->setText(fixed); +void ProgressDialog::setLabelText(const QString &src, const QString &dst){ + QFontMetrics fm(mSrc->font()); + int width = mSrc->width() - 4; + QString srcElided = fm.elidedText(src, Qt::ElideRight, width); + mSrc->setText(srcElided); + QString dstElided = fm.elidedText(dst, Qt::ElideRight, width); + mDst->setText(dstElided); } void ProgressDialog::setValue(int val){ diff --git a/progressdialog.h b/progressdialog.h index d41a515..35ede38 100644 --- a/progressdialog.h +++ b/progressdialog.h @@ -9,7 +9,7 @@ class ProgressDialog : public QDialog { Q_OBJECT public: ProgressDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); - void setLabelText(const QString &text); + void setLabelText(const QString &src, const QString &dst); void setMaximum(int max) { mProgress->setMaximum(max); } public slots: @@ -19,7 +19,8 @@ class ProgressDialog : public QDialog { void cancelled(); private: - QLabel *mLabel; + QLabel *mSrc; + QLabel *mDst; QProgressBar *mProgress; }; |