mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Copy and move to import are now cancelable
This commit is contained in:
parent
b246ccea13
commit
6a057dffd0
@ -3,6 +3,8 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <QsLog.h>
|
||||||
|
|
||||||
ComicFilesManager::ComicFilesManager(QObject *parent) :
|
ComicFilesManager::ComicFilesManager(QObject *parent) :
|
||||||
QObject(parent), canceled(false)
|
QObject(parent), canceled(false)
|
||||||
{
|
{
|
||||||
@ -27,6 +29,16 @@ void ComicFilesManager::process()
|
|||||||
int i=0;
|
int i=0;
|
||||||
bool successProcesingFiles = false;
|
bool successProcesingFiles = false;
|
||||||
foreach (QString source, comics) {
|
foreach (QString source, comics) {
|
||||||
|
|
||||||
|
if(canceled)
|
||||||
|
{
|
||||||
|
if(successProcesingFiles)
|
||||||
|
emit success();
|
||||||
|
emit finished();
|
||||||
|
|
||||||
|
return; //TODO rollback?
|
||||||
|
}
|
||||||
|
|
||||||
QFileInfo info(source);
|
QFileInfo info(source);
|
||||||
if(QFile::copy(source, QDir::cleanPath(folder+'/'+info.fileName())))
|
if(QFile::copy(source, QDir::cleanPath(folder+'/'+info.fileName())))
|
||||||
{
|
{
|
||||||
@ -46,5 +58,6 @@ void ComicFilesManager::process()
|
|||||||
|
|
||||||
void ComicFilesManager::cancel()
|
void ComicFilesManager::cancel()
|
||||||
{
|
{
|
||||||
|
QLOG_DEBUG() << "Operation canceled";
|
||||||
|
canceled = true;
|
||||||
}
|
}
|
||||||
|
@ -1335,6 +1335,8 @@ void LibraryWindow::processComicFiles(ComicFilesManager * comicFilesManager, QPr
|
|||||||
|
|
||||||
comicFilesManager->moveToThread(thread);
|
comicFilesManager->moveToThread(thread);
|
||||||
|
|
||||||
|
connect(progressDialog, SIGNAL(canceled()), comicFilesManager, SLOT(cancel()), Qt::DirectConnection);
|
||||||
|
|
||||||
connect(thread, SIGNAL(started()), comicFilesManager, SLOT(process()));
|
connect(thread, SIGNAL(started()), comicFilesManager, SLOT(process()));
|
||||||
connect(comicFilesManager, SIGNAL(success()), this, SLOT(updateCopyMoveFolderDestination()));
|
connect(comicFilesManager, SIGNAL(success()), this, SLOT(updateCopyMoveFolderDestination()));
|
||||||
connect(comicFilesManager, SIGNAL(finished()), thread, SLOT(quit()));
|
connect(comicFilesManager, SIGNAL(finished()), thread, SLOT(quit()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user