//---------------------------------------------------------------------------------------------- #include "filecopydialog.h" #include "ui_filecopydialog.h" #include #include //---------------------------------------------------------------------------------------------- FileCopyDialog::FileCopyDialog(QWidget *parent) : QDialog(parent), ui(new Ui::FileCopyDialog) { value = 0; timer = new QTimer(this); ui->setupUi(this); ui->label->setText(tr("等待U盘转存完成...")); } //---------------------------------------------------------------------------------------------- FileCopyDialog::~FileCopyDialog() { delete ui; } //---------------------------------------------------------------------------------------------- void FileCopyDialog::valueAdd() { value++; } void FileCopyDialog::updateProgress() { ui->progressBar->setValue(value); if(value >= ui->progressBar->maximum()) { ui->pushButton->setEnabled(false); QTimer::singleShot(1000, this, SLOT(accept())); } } //---------------------------------------------------------------------------------------------- void FileCopyDialog::CopyFiles(const QStringList &fromDir, const QString &toDir, bool coverFileIfExist) { ui->progressBar->setMinimum(0); ui->progressBar->setMaximum(100); ui->progressBar->setValue(0); connect(timer,SIGNAL(timeout()),this, SLOT(valueAdd())); connect(timer,SIGNAL(timeout()),this, SLOT(updateProgress())); timer->start(10); FileManage FM; //connect(&FM, SIGNAL(progressValue(int)), this, SLOT(updateProgress(int))); FM.copyDirectoryFiles(fromDir, toDir, coverFileIfExist); this->exec(); } void FileCopyDialog::updateTimeSetProgress() { ui->progressBar->setValue(value); if(value >= ui->progressBar->maximum()) { QTimer::singleShot(1000, this, SLOT(accept())); } } //---------------------------------------------------------------------------------------------- void FileCopyDialog::on_pushButton_released() { this->reject(); } //----------------------------------------------------------------------------------------------