From ed729385f809e3b5a043664f4ad6f74f400baac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 15 Dec 2013 19:57:33 +0100 Subject: [PATCH] added errors check to Comic --- YACReader/main_window_viewer.cpp | 24 ++++++++++++++++++++++-- YACReader/main_window_viewer.h | 1 + YACReader/viewer.cpp | 6 ++++-- common/comic.cpp | 15 ++++++++++++--- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 67d79cec..2c60d399 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -122,7 +122,7 @@ void MainWindowViewer::setupUI() setUnifiedTitleAndToolBarOnMac(true); viewer = new Viewer(this); - connect(viewer,SIGNAL(reset()),this,SLOT(disableActions())); + connect(viewer,SIGNAL(reset()),this,SLOT(processReset())); //detected end of comic connect(viewer,SIGNAL(openNextComic()),this,SLOT(openNextComic())); //detected start of comic @@ -888,8 +888,28 @@ void MainWindowViewer::checkNewVersion() tT->start(100); conf.setLastVersionCheck(current); - } + } } + +void MainWindowViewer::processReset() +{ + if(isClient) + { + if(siblingComics.count()>1) + { + bool openNextB = openNextComicAction->isEnabled(); + bool openPrevB = openPreviousComicAction->isEnabled(); + disableActions(); + openNextComicAction->setEnabled(openNextB); + openPreviousComicAction->setEnabled(openPrevB); + } + else + disableActions(); + } + else + disableActions(); +} + void MainWindowViewer::changeFit() { Configuration & conf = Configuration::getConfiguration(); diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index b6082c6b..6b33c434 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -50,6 +50,7 @@ class YACReaderSliderAction; void fitToWidth(); void fitToHeight(); void checkNewVersion(); + void processReset(); /*void viewComic(); void prev(); void next(); diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 7be5af6c..01ef3089 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -213,12 +213,14 @@ void Viewer::open(QString pathFile, const ComicDB & comic) void Viewer::showMessageErrorOpening() { - QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")); + QMessageBox::critical(this,tr("Not found"),tr("Comic not found")); + resetContent(); } void Viewer::showMessageErrorOpening(QString message) { - QMessageBox::critical(NULL,tr("Error opening"),message); + QMessageBox::critical(this,tr("Error opening comic"),message); + resetContent(); } void Viewer::next() diff --git a/common/comic.cpp b/common/comic.cpp index f5119943..fb73bbcc 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -414,7 +414,16 @@ void FileComic::process() { CompressedArchive archive(_path); if(!archive.toolsLoaded()) + { + emit errorOpening(tr("7z not found")); return; + } + + if(!archive.isValid()) + { + emit errorOpening(tr("Format not supported")); + return; + } //se filtran para obtener sólo los formatos soportados _order = archive.getFileNames(); _fileNames = filter(_order); @@ -665,11 +674,11 @@ void PDFComic::renderPage(int page) Poppler::Page* pdfpage = pdfComic->page(page); if (pdfpage) { - QImage img = pdfpage->renderToImage(150,150); - delete pdfpage; + QImage img = pdfpage->renderToImage(150,150); + delete pdfpage; QByteArray ba; QBuffer buf(&ba); - img.save(&buf, "jpg"); + img.save(&buf, "jpg"); _pages[page] = ba; emit imageLoaded(page); emit imageLoaded(page,_pages[page]);