From a68cf88e69c65014f2e528aa26db42b4808c3b64 Mon Sep 17 00:00:00 2001 From: Arno Date: Tue, 6 Dec 2016 11:34:41 +0100 Subject: Add destination to ProgressDialog Elide the text if necessary. Only show the destination directory. --- progressdialog.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'progressdialog.cpp') 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){ -- cgit v1.2.3-70-g09d2