Repository navigation
Expand file tree
/
Copy pathCProgresDialog.cpp
More file actions
70 lines (58 loc) · 1.74 KB
/
Copy pathCProgresDialog.cpp
File metadata and controls
70 lines (58 loc) · 1.74 KB
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
#include <QtGui>
#include <QFileInfo>
#include <iostream>
#include "CProgresDialog.h"
CProgresDialog::CProgresDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
worker = new CThread();
t = new QTimer();
written = 0;
QObject::connect(pb_Cancel, SIGNAL(clicked()), this, SLOT(pd_close()));
connect(pb_Stop, SIGNAL(clicked()), this, SLOT(pb_Stop_clicked()));
connect(pb_Start, SIGNAL(clicked()), this, SLOT(pb_Start_clicked()));
connect(worker,SIGNAL(finished ()),this,SLOT(pd_close()));
connect(pb_Cancel,SIGNAL(clicked()),worker,SLOT( terminate()));
connect(worker,SIGNAL(actualySource(QString)),this,SLOT(setSource()));
connect( t, SIGNAL(timeout()), this, SLOT(perform()) );
connect(&toFile, SIGNAL(readyRead()),this, SLOT(perform()));
}
CProgresDialog::~CProgresDialog(){
delete worker;
}
void CProgresDialog::pb_Stop_clicked(){
pb_Stop->setEnabled(false);
pb_Start->setEnabled(true);
}
void CProgresDialog::pb_Start_clicked(){
worker->setSource(l_source->text());
worker->setDestination(l_dest->text());
worker->setType(type);
worker->start();
t->start();
pb_Stop->setEnabled(true);
pb_Start->setEnabled(false);
}
void CProgresDialog::pd_close(){
t->stop();
this->close();
}
void CProgresDialog::setSource(QString source){
l_source->setText(source);
fromFile.setFileName(source);
}
void CProgresDialog::setDestination(QString dest){
l_dest->setText(dest);
toFile.setFileName (dest);
}
void CProgresDialog::setProgresValue(qint64 w){
std::cout << "Slot prijal" << std::endl;
written += w;
pbar_progres->setValue(written / 1024);
}
void CProgresDialog::perform(){
pbar_progres->setValue(worker->progres);
l_source->setText(worker->actualySource);
l_dest->setText(worker->actualyDest);
}