forked from ermaotech/CppTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.cpp
61 lines (57 loc) · 1.62 KB
/
MainWindow.cpp
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
/***********************************************************************
*
*文件名 : MainWindow.cpp
*摘要 :
*
*
*创建人: ErMao
*创建时间 :2018/3/10
*
*
*历史版本
*
*序号 修改日期 版本号 修改人 摘要
*01 2018/3/10 V1.0.0 ErMao 创建
**********************************************************************/
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "FileOperation.h"
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_ChooseDir_pushButton_clicked()
{
QString ChooseDir = QFileDialog::getExistingDirectory(this);
ui->Files_lineEdit->setText(ChooseDir);
}
void MainWindow::on_Start_pushButton_clicked()
{
QString dir = ui->Files_lineEdit->text();
QString suffix = ui->Suffix_lineEdit->text();
if (dir.isEmpty() || suffix.isEmpty()) {
QMessageBox mb(QMessageBox::Warning, tr("警告"), "目录或后缀不能为空");
mb.exec();
}else {
FileOperation fo(dir.toStdString(), suffix.toStdString());
fo.RenameFile();
if (fo.error_code() == -1) {
QMessageBox mb(QMessageBox::Warning, tr("警告"), fo.err_msg().c_str());
mb.exec();
}
else {
QString str = "共有"+QString::number(fo.Count()) +"个文件名后缀被修改";
QMessageBox mb(QMessageBox::Information, tr("提示"), str);
mb.exec();
}
}
}