#include #include #include #include "progressdialog.h" ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ mLabel = new QLabel; mProgress = new QProgressBar; QPushButton *cancelBtn = new QPushButton(tr("Cancel")); connect(cancelBtn, SIGNAL(clicked()), this, SIGNAL(cancelled())); QHBoxLayout *btnLayout = new QHBoxLayout; btnLayout->addStretch(); btnLayout->addWidget(cancelBtn); btnLayout->addStretch(); QVBoxLayout *mainLayout = new QVBoxLayout; 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); }