Repository navigation
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
86 lines (68 loc) · 2.04 KB
/
Copy pathmainwindow.cpp
File metadata and controls
86 lines (68 loc) · 2.04 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "utils.h"
#include <QFileDialog>
#include "worker.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setFixedSize(800, 300);
setWindowTitle("Contrast Tool");
Worker *w = new Worker;
w->moveToThread(&workerThread);
connect(this, &MainWindow::operate, w, &Worker::doWork);
connect(w, &Worker::workFinished, this, &MainWindow::workFinished);
connect(w, &Worker::workProgress, this, &MainWindow::workProgress);
workerThread.start();
ui->label_5->hide();
}
MainWindow::~MainWindow()
{
workerThread.quit();
workerThread.wait();
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString dir = QFileDialog::getExistingDirectory();
ui->lineEdit->setText(dir);
}
void MainWindow::on_pushButton_2_clicked()
{
QString dir = QFileDialog::getExistingDirectory();
ui->lineEdit_2->setText(dir);
}
void MainWindow::on_pushButton_3_clicked()
{
QString dir = QFileDialog::getExistingDirectory();
ui->lineEdit_3->setText(dir);
}
void MainWindow::on_pushButton_4_clicked()
{
QString sourcePath = ui->lineEdit->text();
QString newPath = ui->lineEdit_2->text();
QString targetPath = ui->lineEdit_3->text();
operate(sourcePath, newPath, targetPath);
ui->pushButton->setEnabled(false);
ui->pushButton_2->setEnabled(false);
ui->pushButton_3->setEnabled(false);
ui->pushButton_4->setEnabled(false);
ui->label_5->hide();
}
void MainWindow::workProgress(qint64 bytesRead, qint64 totalBytes)
{
ui->progressBar->setMaximum(totalBytes);
ui->progressBar->setValue(bytesRead);
}
void MainWindow::workFinished()
{
ui->label_5->show();
ui->pushButton->setEnabled(true);
ui->pushButton_2->setEnabled(true);
ui->pushButton_3->setEnabled(true);
ui->pushButton_4->setEnabled(true);
ui->progressBar->setMaximum(1);
ui->progressBar->setValue(1);
}