Ubuntu12.04.4_lts
2023-08-01 961efe36f62f7eba688d504ec0cdf3e1daa4dd74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//----------------------------------------------------------------------------------------------
#include "filecopydialog.h"
#include "ui_filecopydialog.h"
#include <QTimer>
#include <QTextCodec>
//----------------------------------------------------------------------------------------------
 
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();
}
//----------------------------------------------------------------------------------------------