-
Notifications
You must be signed in to change notification settings - Fork 0
/
kfilesaver.cpp
25 lines (21 loc) · 1005 Bytes
/
kfilesaver.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
#include "kfilesaver.h"
#include <QPushButton>
KFileSaver::KFileSaver(const QFileInfoList &fileInfoList, const QString &destDirPath, QWidget *parent) :
QObject(parent),
m_thread(new KFileSaveThread(fileInfoList, destDirPath, this)),
m_waitingMessageBox(new QMessageBox(QMessageBox::NoIcon, tr("导出中"), tr("正在导出,请稍后"), QMessageBox::Cancel, parent))
{
// 绑定信号,实现终止导出
connect(m_waitingMessageBox, &QMessageBox::buttonClicked, this, [&]() {
if (m_thread->isRunning())
m_thread->exit();
});
// 绑定信号,实现保存结束之后关闭提示框
connect(m_thread, &KFileSaveThread::finished, this, [&]() {
m_waitingMessageBox->close();
QMessageBox *successMessageBox = new QMessageBox(QMessageBox::NoIcon, tr("完成"), tr("导出成功"), QMessageBox::Ok, parent);
successMessageBox->exec();
});
m_thread->start();
m_waitingMessageBox->exec();
}