mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
corregido bug al intentar abrir un c?mic en un path no existente
- ahora se muestra un error al usuario. - y se restaura el estado inicial.
This commit is contained in:
parent
7df6e4d7f7
commit
86914fd634
@ -31,22 +31,33 @@ void Comic::setup()
|
||||
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(updateBookmarkImage(int)));
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::load(const QString & path)
|
||||
bool Comic::load(const QString & path)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
bm->newComic(path);
|
||||
emit bookmarksLoaded(*bm);
|
||||
if(fi.isFile())
|
||||
{
|
||||
loadFromFile(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fi.isDir())
|
||||
QFileInfo fi(path);
|
||||
if(fi.exists())
|
||||
{
|
||||
loadFromDir(path);
|
||||
bm->newComic(path);
|
||||
emit bookmarksLoaded(*bm);
|
||||
|
||||
if(fi.isFile())
|
||||
{
|
||||
loadFromFile(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fi.isDir())
|
||||
{
|
||||
loadFromDir(path);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found"));
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::loadFromFile(const QString & pathFile)
|
||||
|
@ -33,7 +33,7 @@
|
||||
Comic(const QString pathFile);
|
||||
void setup();
|
||||
//Load pages from file
|
||||
void load(const QString & path);
|
||||
bool load(const QString & path);
|
||||
void loadFromFile(const QString & pathFile);
|
||||
void loadFromDir(const QString & pathDir);
|
||||
int nextPage();
|
||||
|
@ -403,6 +403,7 @@ void Render::load(const QString & path)
|
||||
previousIndex = currentIndex = 0;
|
||||
|
||||
connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening()));
|
||||
connect(comic,SIGNAL(errorOpening()),this,SLOT(reset()));
|
||||
connect(comic,SIGNAL(imageLoaded(int)),this,SIGNAL(imageLoaded(int)));
|
||||
connect(comic,SIGNAL(imageLoaded(int)),this,SLOT(pageRawDataReady(int)));
|
||||
//connect(comic,SIGNAL(pageChanged(int)),this,SIGNAL(pageChanged(int)));
|
||||
@ -412,9 +413,19 @@ void Render::load(const QString & path)
|
||||
connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)));
|
||||
connect(comic,SIGNAL(bookmarksLoaded(const Bookmarks &)),this,SIGNAL(bookmarksLoaded(const Bookmarks &)));
|
||||
pagesReady.clear();
|
||||
comic->load(path);
|
||||
if(comic->load(path)) //garantiza que se va a intentar abrir el cómic
|
||||
{
|
||||
invalidate();
|
||||
loadedComic = true;
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Render::reset()
|
||||
{
|
||||
loadedComic = false;
|
||||
invalidate();
|
||||
loadedComic = true; //TODO reset if an error occurs while opening
|
||||
}
|
||||
//si se solicita la siguiente página, se calcula cuál debe ser en función de si se lee en modo a doble página o no.
|
||||
//la página sólo se renderiza, si realmente ha cambiado.
|
||||
|
@ -138,6 +138,7 @@ public slots:
|
||||
void setBookmark();
|
||||
void removeBookmark();
|
||||
void save();
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void currentPageReady();
|
||||
|
@ -130,7 +130,7 @@ void Viewer::open(QString pathFile)
|
||||
|
||||
goToFlow->reset();
|
||||
render->load(pathFile);
|
||||
render->update();
|
||||
//render->update();
|
||||
|
||||
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user