diff options
author | Arno <arno@disconnect.de> | 2016-12-06 11:18:07 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2016-12-06 11:18:07 +0100 |
commit | 0e02ad100b0e96c77b6030853bd88a6d4706a776 (patch) | |
tree | c5fe9bf96cb848795e5c760b8b775ed81070ed9b | |
parent | 0432c09d7889009beb9557e0546d0c4f240bb37e (diff) | |
download | ShemovCleaner-0e02ad100b0e96c77b6030853bd88a6d4706a776.tar.gz ShemovCleaner-0e02ad100b0e96c77b6030853bd88a6d4706a776.tar.bz2 ShemovCleaner-0e02ad100b0e96c77b6030853bd88a6d4706a776.zip |
Prettify ProgressDialog
Make it fixed width, show only the filename from the source instead of
the full path and elide text if necessary.
-rw-r--r-- | filewidget.cpp | 3 | ||||
-rw-r--r-- | progressdialog.cpp | 9 | ||||
-rw-r--r-- | progressdialog.h | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/filewidget.cpp b/filewidget.cpp index 409c551..6905c53 100644 --- a/filewidget.cpp +++ b/filewidget.cpp @@ -514,7 +514,8 @@ void FileWidget::addAsOrigin(){ void FileWidget::setupProgress(QString file, qint64 size){ mCopyProgress->setMaximum(size / 1024 / 1024); mCopyProgress->setValue(0); - QString progressLabel = QString(tr("Copying %1")).arg(file); + QFileInfo fi(file); + QString progressLabel = QString(tr("Copying %1")).arg(fi.fileName()); mCopyProgress->setLabelText(progressLabel); } diff --git a/progressdialog.cpp b/progressdialog.cpp index 778a3b4..f354a07 100644 --- a/progressdialog.cpp +++ b/progressdialog.cpp @@ -17,9 +17,18 @@ ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(par mainLayout->addWidget(mLabel); mainLayout->addWidget(mProgress); mainLayout->addLayout(btnLayout); + setMaximumWidth(400); + setMinimumWidth(400); 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::setValue(int val){ mProgress->setValue(val); } diff --git a/progressdialog.h b/progressdialog.h index 6aee406..d41a515 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) { mLabel->setText(text); } + void setLabelText(const QString &text); void setMaximum(int max) { mProgress->setMaximum(max); } public slots: |