mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 13:04:28 -04:00
Corregido bug relativo a bookmarks y los c?mics en pdf o carpetas
Cambiado de uso de QPixmap por QImage en las partes que estan fuera de GUI Cambiadas las llamadas a enableAction para asegurar que se producen siempre antes que disableAction en caso de error al abrir. Corregida la gesti?n de errores de apertura al usar FactoryComic
This commit is contained in:
@ -13,12 +13,12 @@ Bookmarks::Bookmarks()
|
||||
{
|
||||
list.load();
|
||||
}
|
||||
void Bookmarks::setLastPage(int index,const QPixmap & page)
|
||||
void Bookmarks::setLastPage(int index,const QImage & page)
|
||||
{
|
||||
lastPageIndex = index;
|
||||
lastPage = page;
|
||||
}
|
||||
void Bookmarks::setBookmark(int index,const QPixmap & page)
|
||||
void Bookmarks::setBookmark(int index,const QImage & page)
|
||||
{
|
||||
if(!bookmarks.contains(index))
|
||||
{
|
||||
@ -46,12 +46,12 @@ QList<int> Bookmarks::getBookmarkPages() const
|
||||
return bookmarks.keys();
|
||||
}
|
||||
|
||||
QPixmap Bookmarks::getBookmarkPixmap(int page) const
|
||||
QImage Bookmarks::getBookmarkPixmap(int page) const
|
||||
{
|
||||
return bookmarks.value(page);
|
||||
}
|
||||
|
||||
QPixmap Bookmarks::getLastPagePixmap() const
|
||||
QImage Bookmarks::getLastPagePixmap() const
|
||||
{
|
||||
return lastPage;
|
||||
}
|
||||
@ -82,7 +82,7 @@ void Bookmarks::newComic(const QString & path)
|
||||
lastPageIndex = b.lastPage;
|
||||
latestBookmarks = b.bookmarks;
|
||||
for(int i=0;i<latestBookmarks.count();i++)
|
||||
bookmarks.insert(latestBookmarks.at(i),QPixmap());
|
||||
bookmarks.insert(latestBookmarks.at(i),QImage());
|
||||
added = b.added;
|
||||
|
||||
}
|
||||
@ -91,7 +91,7 @@ void Bookmarks::clear()
|
||||
bookmarks.clear();
|
||||
latestBookmarks.clear();
|
||||
lastPageIndex=0;
|
||||
lastPage = QPixmap();
|
||||
lastPage = QImage();
|
||||
}
|
||||
|
||||
void Bookmarks::save()
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QDateTime>
|
||||
@ -49,22 +49,22 @@ class Bookmarks : public QObject
|
||||
protected:
|
||||
QString comicPath;
|
||||
//bookmarks setted by the user
|
||||
QMap<int,QPixmap> bookmarks;
|
||||
QMap<int,QImage> bookmarks;
|
||||
QList<int> latestBookmarks;
|
||||
//last page readed
|
||||
int lastPageIndex;
|
||||
QPixmap lastPage;
|
||||
QImage lastPage;
|
||||
BookmarksList list;
|
||||
QDateTime added;
|
||||
|
||||
public:
|
||||
Bookmarks();
|
||||
void setLastPage(int index,const QPixmap & page);
|
||||
void setBookmark(int index,const QPixmap & page);
|
||||
void setLastPage(int index,const QImage & page);
|
||||
void setBookmark(int index,const QImage & page);
|
||||
void removeBookmark(int index);
|
||||
QList<int> getBookmarkPages() const;
|
||||
QPixmap getBookmarkPixmap(int page) const;
|
||||
QPixmap getLastPagePixmap() const;
|
||||
QImage getBookmarkPixmap(int page) const;
|
||||
QImage getLastPagePixmap() const;
|
||||
int getLastPage() const;
|
||||
bool isBookmark(int page);
|
||||
bool imageLoaded(int page);
|
||||
|
@ -85,7 +85,7 @@ void BookmarksDialog::setBookmarks(const Bookmarks & bm)
|
||||
lastPage = bm.getLastPage();
|
||||
if (lastPage > 0)
|
||||
{
|
||||
QPixmap p = bm.getLastPagePixmap();
|
||||
QPixmap p = QPixmap::fromImage(bm.getLastPagePixmap());
|
||||
if(p.isNull())
|
||||
{
|
||||
images.at(0)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||
@ -109,7 +109,7 @@ void BookmarksDialog::setBookmarks(const Bookmarks & bm)
|
||||
for(int i=0;i<s;i++)
|
||||
{
|
||||
pages.at(i+1)->setText(QString::number(l.at(i)+1));
|
||||
QPixmap p = bm.getBookmarkPixmap(l.at(i));
|
||||
QPixmap p = QPixmap::fromImage(bm.getBookmarkPixmap(l.at(i)));
|
||||
if(p.isNull())
|
||||
{
|
||||
images.at(i+1)->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||
|
@ -92,21 +92,23 @@ void Comic::loadFinished()
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::setBookmark()
|
||||
{
|
||||
QPixmap p;
|
||||
QImage p;
|
||||
p.loadFromData(_pages[_index]);
|
||||
bm->setBookmark(_index,p);
|
||||
emit bookmarksLoaded(*bm);
|
||||
//emit bookmarksLoaded(*bm);
|
||||
emit bookmarksUpdated();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::removeBookmark()
|
||||
{
|
||||
bm->removeBookmark(_index);
|
||||
emit bookmarksLoaded(*bm);
|
||||
//emit bookmarksLoaded(*bm);
|
||||
emit bookmarksUpdated();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Comic::saveBookmarks()
|
||||
{
|
||||
QPixmap p;
|
||||
QImage p;
|
||||
p.loadFromData(_pages[_index]);
|
||||
bm->setLastPage(_index,p);
|
||||
bm->save();
|
||||
@ -121,17 +123,20 @@ void Comic::updateBookmarkImage(int index)
|
||||
{
|
||||
if(bm->isBookmark(index))
|
||||
{
|
||||
QPixmap p;
|
||||
p.loadFromData(_pages[_index]);
|
||||
QImage p;
|
||||
p.loadFromData(_pages[index]);
|
||||
bm->setBookmark(index,p);
|
||||
emit bookmarksLoaded(*bm);
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
|
||||
}
|
||||
if(bm->getLastPage() == index)
|
||||
{
|
||||
QPixmap p;
|
||||
p.loadFromData(_pages[_index]);
|
||||
QImage p;
|
||||
p.loadFromData(_pages[index]);
|
||||
bm->setLastPage(index,p);
|
||||
emit bookmarksLoaded(*bm);
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
}
|
||||
|
||||
}
|
||||
@ -183,7 +188,8 @@ bool FileComic::load(const QString & path)
|
||||
if(fi.exists())
|
||||
{
|
||||
bm->newComic(path);
|
||||
emit bookmarksLoaded(*bm);
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
|
||||
_path = QDir::cleanPath(path);
|
||||
//load files size
|
||||
@ -322,6 +328,9 @@ FolderComic::~FolderComic()
|
||||
bool FolderComic::load(const QString & path)
|
||||
{
|
||||
_path = path;
|
||||
bm->newComic(_path);
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -363,8 +372,6 @@ void FolderComic::process()
|
||||
}
|
||||
}
|
||||
emit imagesLoaded();
|
||||
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -391,6 +398,9 @@ PDFComic::~PDFComic()
|
||||
bool PDFComic::load(const QString & path)
|
||||
{
|
||||
_path = path;
|
||||
bm->newComic(_path);
|
||||
emit bookmarksUpdated();
|
||||
//emit bookmarksLoaded(*bm);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -407,6 +417,7 @@ void PDFComic::process()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//pdfComic->setRenderHint(Poppler::Document::Antialiasing, true);
|
||||
pdfComic->setRenderHint(Poppler::Document::TextAntialiasing, true);
|
||||
int nPages = pdfComic->numPages();
|
||||
@ -424,7 +435,7 @@ void PDFComic::process()
|
||||
Poppler::Page* pdfpage = pdfComic->page(i);
|
||||
if (pdfpage)
|
||||
{
|
||||
QImage img = pdfpage->renderToImage(150,150); //TODO use defaults if not using X11 (e.g. MS Win)
|
||||
QImage img = pdfpage->renderToImage(150,150);
|
||||
delete pdfpage;
|
||||
QByteArray ba;
|
||||
QBuffer buf(&ba);
|
||||
@ -438,8 +449,6 @@ void PDFComic::process()
|
||||
}
|
||||
delete pdfComic;
|
||||
emit imagesLoaded();
|
||||
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
}
|
||||
|
||||
|
||||
@ -448,15 +457,23 @@ Comic * FactoryComic::newComic(const QString & path)
|
||||
|
||||
QFileInfo fi(path);
|
||||
if(fi.exists())
|
||||
{
|
||||
if(fi.isFile())
|
||||
{
|
||||
if(fi.suffix().compare("pdf",Qt::CaseInsensitive) == 0)
|
||||
return new PDFComic();
|
||||
else
|
||||
return new FileComic();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fi.isDir())
|
||||
return new FolderComic();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
}
|
@ -27,11 +27,13 @@
|
||||
|
||||
int _cfi;
|
||||
|
||||
Bookmarks * bm;
|
||||
|
||||
|
||||
|
||||
bool _isPDF;
|
||||
public:
|
||||
Bookmarks * bm;
|
||||
|
||||
//Constructors
|
||||
Comic();
|
||||
Comic(const QString & pathFile);
|
||||
@ -71,7 +73,7 @@
|
||||
void numPages(unsigned int numPages);
|
||||
void errorOpening();
|
||||
void isBookmark(bool);
|
||||
void bookmarksLoaded(const Bookmarks &);
|
||||
void bookmarksUpdated();
|
||||
|
||||
};
|
||||
|
||||
|
@ -82,8 +82,10 @@ void MainWindowViewer::setupUI()
|
||||
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
viewer->open(pathFile);
|
||||
enableActions();
|
||||
|
||||
viewer->open(pathFile);
|
||||
|
||||
}
|
||||
|
||||
versionChecker = new HttpVersionChecker();
|
||||
@ -410,8 +412,10 @@ void MainWindowViewer::openComicFromPath(QString pathFile)
|
||||
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
viewer->open(pathFile);
|
||||
enableActions();
|
||||
|
||||
viewer->open(pathFile);
|
||||
|
||||
}
|
||||
|
||||
void MainWindowViewer::openFolder()
|
||||
@ -432,8 +436,10 @@ void MainWindowViewer::openFolderFromPath(QString pathDir)
|
||||
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
viewer->open(pathDir);
|
||||
enableActions();
|
||||
|
||||
viewer->open(pathDir);
|
||||
|
||||
}
|
||||
|
||||
void MainWindowViewer::saveImage()
|
||||
|
@ -410,10 +410,29 @@ void Render::load(const QString & path)
|
||||
//comic->moveToThread(QApplication::instance()->thread());
|
||||
comic = FactoryComic::newComic(path);
|
||||
|
||||
|
||||
if(comic == NULL)//archivo no encontrado o no v<>lido
|
||||
{
|
||||
emit errorOpening();
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
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)));
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SIGNAL(numPages(unsigned int)));
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(setNumPages(unsigned int)));
|
||||
connect(comic,SIGNAL(imageLoaded(int,QByteArray)),this,SIGNAL(imageLoaded(int,QByteArray)));
|
||||
connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)));
|
||||
connect(comic,SIGNAL(isBookmark(bool)),this,SLOT(pageIsBookmark(bool)));
|
||||
|
||||
connect(comic,SIGNAL(bookmarksUpdated()),this,SIGNAL(bookmarksUpdated()));
|
||||
|
||||
QThread * thread = NULL;
|
||||
if (typeid(*comic) != typeid(FileComic))
|
||||
{
|
||||
@ -426,20 +445,8 @@ void Render::load(const QString & path)
|
||||
|
||||
}
|
||||
|
||||
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)));
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SIGNAL(numPages(unsigned int)));
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(setNumPages(unsigned int)));
|
||||
connect(comic,SIGNAL(imageLoaded(int,QByteArray)),this,SIGNAL(imageLoaded(int,QByteArray)));
|
||||
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); //garantiza que se va a intentar abrir el c<>mic
|
||||
|
||||
if(thread != NULL)
|
||||
@ -785,3 +792,8 @@ void Render::save()
|
||||
{
|
||||
comic->saveBookmarks();
|
||||
}
|
||||
|
||||
Bookmarks * Render::getBookmarks()
|
||||
{
|
||||
return comic->bm;
|
||||
}
|
@ -139,6 +139,7 @@ public slots:
|
||||
void removeBookmark();
|
||||
void save();
|
||||
void reset();
|
||||
Bookmarks * getBookmarks();
|
||||
|
||||
signals:
|
||||
void currentPageReady();
|
||||
@ -150,7 +151,8 @@ signals:
|
||||
void numPages(unsigned int numPages);
|
||||
void errorOpening();
|
||||
void currentPageIsBookmark(bool);
|
||||
void bookmarksLoaded(const Bookmarks &);
|
||||
|
||||
void bookmarksUpdated();
|
||||
|
||||
private:
|
||||
Comic * comic;
|
||||
|
@ -137,13 +137,16 @@ void Viewer::createConnections()
|
||||
|
||||
//render
|
||||
connect(render,SIGNAL(errorOpening()),this,SLOT(resetContent()));
|
||||
connect(render,SIGNAL(errorOpening()),this,SLOT(showMessageErrorOpening()));
|
||||
connect(render,SIGNAL(numPages(unsigned int)),goToFlow,SLOT(setNumSlides(unsigned int)));
|
||||
connect(render,SIGNAL(numPages(unsigned int)),goToDialog,SLOT(setNumPages(unsigned int)));
|
||||
connect(render,SIGNAL(imageLoaded(int,QByteArray)),goToFlow,SLOT(setImageReady(int,QByteArray)));
|
||||
connect(render,SIGNAL(currentPageReady()),this,SLOT(updatePage()));
|
||||
connect(render,SIGNAL(processingPage()),this,SLOT(setLoadingMessage()));
|
||||
connect(render,SIGNAL(currentPageIsBookmark(bool)),this,SIGNAL(pageIsBookmark(bool)));
|
||||
connect(render,SIGNAL(bookmarksLoaded(const Bookmarks &)),bd,SLOT(setBookmarks(const Bookmarks &)));
|
||||
//connect(render,SIGNAL(bookmarksLoaded(Bookmarks)),this,SLOT(setBookmarks(Bookmarks)));
|
||||
|
||||
connect(render,SIGNAL(bookmarksUpdated()),this,SLOT(setBookmarks()));
|
||||
}
|
||||
|
||||
void Viewer::open(QString pathFile)
|
||||
@ -159,6 +162,11 @@ void Viewer::open(QString pathFile)
|
||||
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
|
||||
}
|
||||
|
||||
void Viewer::showMessageErrorOpening()
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found"));
|
||||
}
|
||||
|
||||
void Viewer::next()
|
||||
{
|
||||
direction = 1;
|
||||
@ -724,3 +732,8 @@ void Viewer::updateConfig(QSettings * settings)
|
||||
{
|
||||
goToFlow->updateConfig(settings);
|
||||
}
|
||||
|
||||
void Viewer::setBookmarks()
|
||||
{
|
||||
bd->setBookmarks(*render->getBookmarks());
|
||||
}
|
@ -25,6 +25,7 @@ class Render;
|
||||
class GoToDialog;
|
||||
class YACReaderTranslator;
|
||||
class GoToFlowWidget;
|
||||
class Bookmarks;
|
||||
|
||||
class Viewer : public QScrollArea
|
||||
{
|
||||
@ -73,6 +74,8 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
void updateBackgroundColor(const QColor & color);
|
||||
void updateFitToWidthRatio(float ratio);
|
||||
void updateConfig(QSettings * settings);
|
||||
void showMessageErrorOpening();
|
||||
void setBookmarks();
|
||||
|
||||
private:
|
||||
bool information;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __YACREADER_GLOBAL_H
|
||||
#define __YACREADER_GLOBAL_H
|
||||
|
||||
#define VERSION "5.5.0"
|
||||
#define VERSION "5.5.1"
|
||||
|
||||
#define PATH "PATH"
|
||||
#define MAG_GLASS_SIZE "MAG_GLASS_SIZE"
|
||||
|
@ -3,7 +3,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
YACReader - Yet Another Comic Reader - version 5.5 <br/>
|
||||
YACReader - Yet Another Comic Reader - version 5.5.1 <br/>
|
||||
by Luis Ángel San Martín Rodríguez <br/>
|
||||
e-mail: luisangelsm@gmail.com <br/>
|
||||
web site: <a href="http://www.yacreader.com">http://www.yacreader.com</a> <br/>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<body>
|
||||
<p>
|
||||
<img src=":/images/icon.png" /> <br/>
|
||||
YACReader - Yet Another Comic Reader - versión 5.5 <br/>
|
||||
YACReader - Yet Another Comic Reader - versión 5.5.1 <br/>
|
||||
por Luis Ángel San Martín Rodríguez <br/>
|
||||
e-mail: luisangelsm@gmail.com <br/>
|
||||
Página web: <a href="http://www.yacreader.com">http://www.yacreader.com</a> <br/>
|
||||
|
Reference in New Issue
Block a user