diff --git a/YACReaderLibrary/comics_remover.cpp b/YACReaderLibrary/comics_remover.cpp index 30cd5f8b..d5d5676d 100644 --- a/YACReaderLibrary/comics_remover.cpp +++ b/YACReaderLibrary/comics_remover.cpp @@ -20,9 +20,9 @@ void ComicsRemover::run() QModelIndex mi = i.previous(); currentComicPath = i2.previous(); if(QFile::remove(currentComicPath)) - { emit remove(mi.row()); - } + else + emit removeError(); } emit finished(); diff --git a/YACReaderLibrary/comics_remover.h b/YACReaderLibrary/comics_remover.h index 111f09eb..5a77a84b 100644 --- a/YACReaderLibrary/comics_remover.h +++ b/YACReaderLibrary/comics_remover.h @@ -14,6 +14,7 @@ public: signals: void remove(int); + void removeError(); void finished(); private: diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index bff48460..9efe02a7 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -67,7 +67,7 @@ #endif LibraryWindow::LibraryWindow() - :QMainWindow(),fullscreen(false),fetching(false),previousFilter("") + :QMainWindow(),fullscreen(false),fetching(false),previousFilter(""),removeError(false) { setupUI(); loadLibraries(); @@ -1433,6 +1433,20 @@ void LibraryWindow::showComicVineScraper() comicVineDialog->show(); } +void LibraryWindow::setRemoveError() +{ + removeError = true; +} + +void LibraryWindow::checkRemoveError() +{ + if(removeError) + { + QMessageBox::critical(this,tr("Unable to delete"),tr("There was an issue trying to delete the selected comics. Please, check for write permissions in the selected files or containing folder.")); + } + removeError = false; +} + void LibraryWindow::asignNumbers() { QModelIndexList indexList = getSelectedComics(); @@ -1640,9 +1654,11 @@ void LibraryWindow::deleteComics() connect(remover, SIGNAL(remove(int)), dmCV, SLOT(remove(int))); connect(remover, SIGNAL(remove(int)), comicFlow, SLOT(remove(int))); + connect(remover,SIGNAL(removeError()),this,SLOT(setRemoveError())); connect(remover, SIGNAL(finished()), dmCV, SLOT(finishTransaction())); //connect(remover, SIGNAL(finished()), comicView, SLOT(hideDeleteProgress())); connect(remover, SIGNAL(finished()),this,SLOT(checkEmptyFolder())); + connect(remover, SIGNAL(finished()),this,SLOT(checkRemoveError())); connect(remover, SIGNAL(finished()), remover, SLOT(deleteLater())); //connect(remover, SIGNAL(finished()), thread, SLOT(deleteLater())); diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 19e3d69c..536cb0db 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -205,6 +205,8 @@ private: int currentFolderNavigation; QList history; + bool removeError; + protected: virtual void closeEvent ( QCloseEvent * event ); public: @@ -270,6 +272,8 @@ public: void updateComicsView(quint64 libraryId, const ComicDB & comic); void setCurrentComicOpened(); void showComicVineScraper(); + void setRemoveError(); + void checkRemoveError(); }; #endif