mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 04:54:29 -04:00
bookmarks and image optiones are now stored in the library for each comic
This commit is contained in:
@ -1,8 +1,13 @@
|
||||
6.8 (No p<>blica)
|
||||
Corregido bug que causaba un cierre inesperado despu<70>s de cambiar el modo de sincronizaci<63>n vertical (flow)
|
||||
Corregido bug que causaba que la toolbar en el visor no se pudiese ocultar/mostrar sin un c<>mic abierto
|
||||
Mejorada la gesti<74>n de errores al abrir c<>mics
|
||||
Corregidos algunos bugs relacionados con la apertura de c<>mics
|
||||
|
||||
6.7 (No p<>blica)
|
||||
A<EFBFBD>adidos nuevos campos en la base de datos para almacenar informaci<63>n adicional sobre c<>mics: rating, p<>gina actual, bookmarks y configuraci<63>n de imagen
|
||||
A<EFBFBD>adida comunicaci<63>n entre YACReaderLibrary y YACReader para poder almacenar el progreso de los c<>mics e informaci<63>n adicional
|
||||
|
||||
|
||||
6.6 (No p<>blica)
|
||||
Modificado YACReader para que abra los archivos comprimidos usando 7z.dll (.so, .dylib)
|
||||
YACReader abre ahora los c<>mics por la <20>ltima p<>gina le<6C>da.
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <QList>
|
||||
#define NUM_BOOKMARKS 250
|
||||
|
||||
Bookmarks::Bookmarks()
|
||||
@ -38,33 +38,33 @@ void Bookmarks::setBookmark(int index,const QImage & page)
|
||||
|
||||
void Bookmarks::removeBookmark(int index)
|
||||
{
|
||||
bookmarks.remove(index);
|
||||
bookmarks.remove(index);
|
||||
}
|
||||
|
||||
QList<int> Bookmarks::getBookmarkPages() const
|
||||
{
|
||||
return bookmarks.keys();
|
||||
return bookmarks.keys();
|
||||
}
|
||||
|
||||
QImage Bookmarks::getBookmarkPixmap(int page) const
|
||||
{
|
||||
return bookmarks.value(page);
|
||||
return bookmarks.value(page);
|
||||
}
|
||||
|
||||
QImage Bookmarks::getLastPagePixmap() const
|
||||
{
|
||||
return lastPage;
|
||||
return lastPage;
|
||||
}
|
||||
|
||||
int Bookmarks::getLastPage() const
|
||||
{
|
||||
return lastPageIndex;
|
||||
return lastPageIndex;
|
||||
}
|
||||
|
||||
|
||||
bool Bookmarks::isBookmark(int page)
|
||||
{
|
||||
return bookmarks.contains(page);
|
||||
return bookmarks.contains(page);
|
||||
}
|
||||
|
||||
bool Bookmarks::imageLoaded(int page)
|
||||
@ -84,14 +84,27 @@ void Bookmarks::newComic(const QString & path)
|
||||
for(int i=0;i<latestBookmarks.count();i++)
|
||||
bookmarks.insert(latestBookmarks.at(i),QImage());
|
||||
added = b.added;
|
||||
|
||||
}
|
||||
|
||||
void Bookmarks::clear()
|
||||
{
|
||||
bookmarks.clear();
|
||||
latestBookmarks.clear();
|
||||
lastPageIndex=0;
|
||||
lastPage = QImage();
|
||||
lastPageIndex=0;
|
||||
lastPage = QImage();
|
||||
}
|
||||
|
||||
bool Bookmarks::load(const QList<int> & bookmarkIndexes, int lastPage)
|
||||
{
|
||||
lastPageIndex = lastPage;
|
||||
foreach(int b, bookmarkIndexes)
|
||||
if(b != -1)
|
||||
{
|
||||
latestBookmarks.push_back(b);
|
||||
bookmarks.insert(b,QImage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Bookmarks::save()
|
||||
|
@ -71,6 +71,7 @@ class Bookmarks : public QObject
|
||||
void newComic(const QString & path);
|
||||
void clear();
|
||||
void save();
|
||||
bool load(const QList<int> & bookmarkIndexes, int lastPage);
|
||||
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "bookmarks.h" //TODO desacoplar la dependencia con bookmarks
|
||||
#include "qnaturalsorting.h"
|
||||
#include "compressed_archive.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp"
|
||||
#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp"
|
||||
@ -212,7 +213,29 @@ bool FileComic::load(const QString & path, int atPage)
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool FileComic::load(const QString & path, const ComicDB & comic)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
|
||||
if(fi.exists())
|
||||
{
|
||||
QList<int> bookmarkIndexes;
|
||||
bookmarkIndexes << comic.info.bookmark1 << comic.info.bookmark2 << comic.info.bookmark3;
|
||||
if(bm->load(bookmarkIndexes,comic.info.currentPage-1))
|
||||
emit bookmarksUpdated();
|
||||
_firstPage = comic.info.currentPage-1;
|
||||
_path = QDir::cleanPath(path);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
@ -546,16 +569,48 @@ PDFComic::~PDFComic()
|
||||
}
|
||||
|
||||
bool PDFComic::load(const QString & path, int atPage)
|
||||
{
|
||||
_path = path;
|
||||
if(atPage == -1)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
|
||||
if(fi.exists())
|
||||
{
|
||||
bm->newComic(_path);
|
||||
emit bookmarksUpdated();
|
||||
_path = path;
|
||||
if(atPage == -1)
|
||||
{
|
||||
bm->newComic(_path);
|
||||
emit bookmarksUpdated();
|
||||
}
|
||||
_firstPage = atPage;
|
||||
//emit bookmarksLoaded(*bm);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool PDFComic::load(const QString & path, const ComicDB & comic)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
|
||||
if(fi.exists())
|
||||
{
|
||||
QList<int> bookmarkIndexes;
|
||||
bookmarkIndexes << comic.info.bookmark1 << comic.info.bookmark2 << comic.info.bookmark3;
|
||||
if(bm->load(bookmarkIndexes,comic.info.currentPage-1))
|
||||
emit bookmarksUpdated();
|
||||
_firstPage = comic.info.currentPage-1;
|
||||
_path = QDir::cleanPath(path);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
_firstPage = atPage;
|
||||
//emit bookmarksLoaded(*bm);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PDFComic::process()
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "poppler-qt4.h"
|
||||
|
||||
class ComicDB;
|
||||
|
||||
class Comic : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -43,6 +45,7 @@
|
||||
void setup();
|
||||
//Load pages from file
|
||||
virtual bool load(const QString & path, int atPage = -1) = 0;
|
||||
virtual bool load(const QString & path, const ComicDB & comic){return false;};
|
||||
|
||||
/*void loadFromFile(const QString & pathFile);
|
||||
void loadFromDir(const QString & pathDir);
|
||||
@ -95,6 +98,7 @@
|
||||
~FileComic();
|
||||
void fileExtracted(int index, const QByteArray & rawData);
|
||||
virtual bool load(const QString & path, int atPage = -1);
|
||||
virtual bool load(const QString & path, const ComicDB & comic);
|
||||
void crcError(int index);
|
||||
void unknownError(int index);
|
||||
public slots:
|
||||
@ -132,6 +136,7 @@
|
||||
~PDFComic();
|
||||
|
||||
virtual bool load(const QString & path, int atPage = -1);
|
||||
virtual bool load(const QString & path, const ComicDB & comic);
|
||||
public slots:
|
||||
void process();
|
||||
};
|
||||
|
@ -23,33 +23,33 @@
|
||||
class MacToolBarSeparator : public QWidget
|
||||
{
|
||||
public:
|
||||
MacToolBarSeparator(QWidget * parent =0)
|
||||
MacToolBarSeparator(QWidget * parent =0)
|
||||
:QWidget(parent)
|
||||
{
|
||||
setFixedWidth(2);
|
||||
setFixedWidth(2);
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
QPainter painter(this);
|
||||
void paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
QPainter painter(this);
|
||||
|
||||
QLinearGradient lG(0,0,0,height());
|
||||
QLinearGradient lG(0,0,0,height());
|
||||
|
||||
lG.setColorAt(0,QColor(128,128,128,0));
|
||||
lG.setColorAt(0.5,QColor(128,128,128,255));
|
||||
lG.setColorAt(1,QColor(128,128,128,0));
|
||||
lG.setColorAt(0,QColor(128,128,128,0));
|
||||
lG.setColorAt(0.5,QColor(128,128,128,255));
|
||||
lG.setColorAt(1,QColor(128,128,128,0));
|
||||
|
||||
painter.fillRect(0,0,1,height(),lG);
|
||||
painter.fillRect(0,0,1,height(),lG);
|
||||
|
||||
QLinearGradient lG2(1,0,1,height());
|
||||
QLinearGradient lG2(1,0,1,height());
|
||||
|
||||
lG2.setColorAt(0,QColor(220,220,220,0));
|
||||
lG2.setColorAt(0.5,QColor(220,220,220,255));
|
||||
lG2.setColorAt(1,QColor(220,220,220,0));
|
||||
lG2.setColorAt(0,QColor(220,220,220,0));
|
||||
lG2.setColorAt(0.5,QColor(220,220,220,255));
|
||||
lG2.setColorAt(1,QColor(220,220,220,0));
|
||||
|
||||
painter.fillRect(1,0,1,height(),lG2);
|
||||
}
|
||||
painter.fillRect(1,0,1,height(),lG2);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -142,7 +142,7 @@ void MainWindowViewer::setupUI()
|
||||
connect(optionsDialog,SIGNAL(accepted()),viewer,SLOT(updateOptions()));
|
||||
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
||||
connect(optionsDialog, SIGNAL(optionsChanged()),this,SLOT(reloadOptions()));
|
||||
connect(optionsDialog,SIGNAL(changedImageOptions()),viewer,SLOT(updateImageOptions()));
|
||||
connect(optionsDialog,SIGNAL(changedFilters(int,int,int)),viewer,SLOT(updateFilters(int,int,int)));
|
||||
|
||||
optionsDialog->restoreOptions(settings);
|
||||
shortcutsDialog = new ShortcutsDialog(this);
|
||||
@ -152,40 +152,7 @@ void MainWindowViewer::setupUI()
|
||||
|
||||
setWindowTitle("YACReader");
|
||||
|
||||
if(QCoreApplication::argc() == 2) //only path...
|
||||
{
|
||||
isClient = false;
|
||||
//TODO: new method open(QString)
|
||||
QString pathFile = QCoreApplication::arguments().at(1);
|
||||
QFileInfo fi(pathFile);
|
||||
currentDirectory = fi.absoluteDir().path();
|
||||
getSiblingComics(fi.absolutePath(),fi.fileName());
|
||||
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
enableActions();
|
||||
viewer->open(pathFile);
|
||||
}
|
||||
else if(QCoreApplication::argc() == 5)
|
||||
{
|
||||
isClient = true;
|
||||
QString pathFile = QCoreApplication::arguments().at(1);
|
||||
currentDirectory = pathFile;
|
||||
quint64 comicId = QCoreApplication::arguments().at(2).toULongLong();
|
||||
libraryId = QCoreApplication::arguments().at(3).toULongLong();
|
||||
int page = QCoreApplication::arguments().at(4).toULongLong();
|
||||
|
||||
enableActions();
|
||||
|
||||
//TODO request data to the server
|
||||
|
||||
currentComicDB.id = comicId;
|
||||
YACReaderLocalClient client;
|
||||
|
||||
if(client.requestComicInfo(libraryId,currentComicDB,siblingComics))
|
||||
open(pathFile+currentComicDB.path,currentComicDB,siblingComics);
|
||||
else
|
||||
{/*error*/}
|
||||
}
|
||||
openFromArgv();
|
||||
|
||||
versionChecker = new HttpVersionChecker();
|
||||
|
||||
@ -193,9 +160,9 @@ void MainWindowViewer::setupUI()
|
||||
this,SLOT(newVersion()));
|
||||
|
||||
QTimer * tT = new QTimer;
|
||||
|
||||
tT->setSingleShot(true);
|
||||
connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
|
||||
|
||||
tT->setSingleShot(true);
|
||||
connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
|
||||
//versionChecker->get(); //TOD<4F>
|
||||
tT->start(100);
|
||||
|
||||
@ -220,6 +187,43 @@ void MainWindowViewer::setupUI()
|
||||
hideToolBars();
|
||||
}
|
||||
|
||||
void MainWindowViewer::openFromArgv()
|
||||
{
|
||||
if(QCoreApplication::argc() == 2) //only path...
|
||||
{
|
||||
isClient = false;
|
||||
//TODO: new method open(QString)
|
||||
QString pathFile = QCoreApplication::arguments().at(1);
|
||||
QFileInfo fi(pathFile);
|
||||
currentDirectory = fi.absoluteDir().path();
|
||||
getSiblingComics(fi.absolutePath(),fi.fileName());
|
||||
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
enableActions();
|
||||
viewer->open(pathFile);
|
||||
}
|
||||
else if(QCoreApplication::argc() == 4)
|
||||
{
|
||||
isClient = true;
|
||||
QString pathFile = QCoreApplication::arguments().at(1);
|
||||
currentDirectory = pathFile;
|
||||
quint64 comicId = QCoreApplication::arguments().at(2).toULongLong();
|
||||
libraryId = QCoreApplication::arguments().at(3).toULongLong();
|
||||
|
||||
enableActions();
|
||||
|
||||
currentComicDB.id = comicId;
|
||||
YACReaderLocalClient client;
|
||||
|
||||
if(client.requestComicInfo(libraryId,currentComicDB,siblingComics))
|
||||
open(pathFile+currentComicDB.path,currentComicDB,siblingComics);
|
||||
else
|
||||
{/*error*/}
|
||||
|
||||
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowViewer::createActions()
|
||||
{
|
||||
openAction = new QAction(tr("&Open"),this);
|
||||
@ -273,7 +277,7 @@ void MainWindowViewer::createActions()
|
||||
//adjustWidth->setCheckable(true);
|
||||
adjustHeight->setDisabled(true);
|
||||
adjustHeight->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustHeight->setToolTip(tr("Fit image to height"));
|
||||
adjustHeight->setToolTip(tr("Fit image to height"));
|
||||
//adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
||||
connect(adjustHeight, SIGNAL(triggered()),this,SLOT(fitToHeight()));
|
||||
|
||||
@ -282,7 +286,7 @@ void MainWindowViewer::createActions()
|
||||
//adjustWidth->setCheckable(true);
|
||||
adjustWidth->setDisabled(true);
|
||||
adjustWidth->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustWidth->setToolTip(tr("Fit image to width"));
|
||||
adjustWidth->setToolTip(tr("Fit image to width"));
|
||||
//adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
||||
connect(adjustWidth, SIGNAL(triggered()),this,SLOT(fitToWidth()));
|
||||
|
||||
@ -435,7 +439,7 @@ void MainWindowViewer::createToolBars()
|
||||
//#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
#else
|
||||
comicToolBar->addSeparator();
|
||||
#endif
|
||||
@ -481,7 +485,7 @@ void MainWindowViewer::createToolBars()
|
||||
comicToolBar->addAction(adjustToFullSizeAction);
|
||||
comicToolBar->addAction(leftRotationAction);
|
||||
comicToolBar->addAction(rightRotationAction);
|
||||
comicToolBar->addAction(doublePageAction);
|
||||
comicToolBar->addAction(doublePageAction);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
@ -508,7 +512,7 @@ void MainWindowViewer::createToolBars()
|
||||
comicToolBar->addAction(showInfo);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
#else
|
||||
comicToolBar->addWidget(new QToolBarStretch());
|
||||
#endif
|
||||
@ -538,7 +542,7 @@ void MainWindowViewer::createToolBars()
|
||||
viewer->addAction(adjustToFullSizeAction);
|
||||
viewer->addAction(leftRotationAction);
|
||||
viewer->addAction(rightRotationAction);
|
||||
viewer->addAction(doublePageAction);
|
||||
viewer->addAction(doublePageAction);
|
||||
separator = new QAction("",this);
|
||||
separator->setSeparator(true);
|
||||
viewer->addAction(separator);
|
||||
@ -598,10 +602,12 @@ void MainWindowViewer::open(QString path, ComicDB & comic, QList<ComicDB> & sibl
|
||||
else
|
||||
setWindowTitle("YACReader - " + fi.fileName());
|
||||
|
||||
viewer->open(path,comic.info.currentPage-1);
|
||||
viewer->open(path,comic);
|
||||
enableActions();
|
||||
int index = siblings.indexOf(comic);
|
||||
|
||||
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
|
||||
|
||||
if(index>0)
|
||||
openPreviousComicAction->setDisabled(false);
|
||||
else
|
||||
@ -680,7 +686,7 @@ void MainWindowViewer::enableActions()
|
||||
leftRotationAction->setDisabled(false);
|
||||
rightRotationAction->setDisabled(false);
|
||||
showMagnifyingGlass->setDisabled(false);
|
||||
doublePageAction->setDisabled(false);
|
||||
doublePageAction->setDisabled(false);
|
||||
adjustToFullSizeAction->setDisabled(false);
|
||||
//setBookmark->setDisabled(false);
|
||||
showBookmarks->setDisabled(false);
|
||||
@ -690,23 +696,23 @@ void MainWindowViewer::enableActions()
|
||||
}
|
||||
void MainWindowViewer::disableActions()
|
||||
{
|
||||
saveImageAction->setDisabled(true);
|
||||
prevAction->setDisabled(true);
|
||||
nextAction->setDisabled(true);
|
||||
saveImageAction->setDisabled(true);
|
||||
prevAction->setDisabled(true);
|
||||
nextAction->setDisabled(true);
|
||||
adjustHeight->setDisabled(true);
|
||||
adjustWidth->setDisabled(true);
|
||||
goToPage->setDisabled(true);
|
||||
adjustWidth->setDisabled(true);
|
||||
goToPage->setDisabled(true);
|
||||
//alwaysOnTopAction->setDisabled(true);
|
||||
leftRotationAction->setDisabled(true);
|
||||
rightRotationAction->setDisabled(true);
|
||||
showMagnifyingGlass->setDisabled(true);
|
||||
doublePageAction->setDisabled(true);
|
||||
leftRotationAction->setDisabled(true);
|
||||
rightRotationAction->setDisabled(true);
|
||||
showMagnifyingGlass->setDisabled(true);
|
||||
doublePageAction->setDisabled(true);
|
||||
adjustToFullSizeAction->setDisabled(true);
|
||||
setBookmark->setDisabled(true);
|
||||
showBookmarks->setDisabled(true);
|
||||
showInfo->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
openPreviousComicAction->setDisabled(true);
|
||||
openNextComicAction->setDisabled(true);
|
||||
setBookmark->setDisabled(true);
|
||||
showBookmarks->setDisabled(true);
|
||||
showInfo->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
openPreviousComicAction->setDisabled(true);
|
||||
openNextComicAction->setDisabled(true);
|
||||
showDictionaryAction->setDisabled(true);
|
||||
showFlowAction->setDisabled(true);
|
||||
}
|
||||
@ -840,20 +846,10 @@ void MainWindowViewer::newVersion()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindowViewer::closeEvent ( QCloseEvent * event )
|
||||
{
|
||||
YACReaderLocalClient client;
|
||||
if(isClient)
|
||||
{
|
||||
currentComicDB.info.currentPage = viewer->getCurrentPageNumber()+1;
|
||||
currentComicDB.info.hasBeenOpened = true;
|
||||
//viewer->getBookmarks();
|
||||
client.sendComicInfo(libraryId,currentComicDB);
|
||||
}
|
||||
sendComic();
|
||||
|
||||
viewer->save();
|
||||
Configuration & conf = Configuration::getConfiguration();
|
||||
@ -869,20 +865,16 @@ void MainWindowViewer::closeEvent ( QCloseEvent * event )
|
||||
|
||||
void MainWindowViewer::openPreviousComic()
|
||||
{
|
||||
YACReaderLocalClient client;
|
||||
if(!siblingComics.isEmpty() && isClient)
|
||||
{
|
||||
|
||||
currentComicDB.info.currentPage = viewer->getCurrentPageNumber()+1;
|
||||
currentComicDB.info.hasBeenOpened = true;
|
||||
//viewer->getBookmarks();
|
||||
client.sendComicInfo(libraryId,currentComicDB);
|
||||
sendComic();
|
||||
|
||||
int currentIndex = siblingComics.indexOf(currentComicDB);
|
||||
if (currentIndex == -1)
|
||||
return;
|
||||
if(currentIndex-1 >= 0 && currentIndex-1 < siblingComics.count())
|
||||
{
|
||||
siblingComics[currentIndex] = currentComicDB; //updated
|
||||
currentComicDB = siblingComics.at(currentIndex-1);
|
||||
open(currentDirectory+currentComicDB.path,currentComicDB,siblingComics);
|
||||
}
|
||||
@ -900,19 +892,16 @@ void MainWindowViewer::openPreviousComic()
|
||||
|
||||
void MainWindowViewer::openNextComic()
|
||||
{
|
||||
YACReaderLocalClient client;
|
||||
if(!siblingComics.isEmpty() && isClient)
|
||||
{
|
||||
currentComicDB.info.currentPage = viewer->getCurrentPageNumber()+1;
|
||||
currentComicDB.info.hasBeenOpened = true;
|
||||
//viewer->getBookmarks();
|
||||
client.sendComicInfo(libraryId,currentComicDB);
|
||||
sendComic();
|
||||
|
||||
int currentIndex = siblingComics.indexOf(currentComicDB);
|
||||
if (currentIndex == -1)
|
||||
return;
|
||||
if(currentIndex+1 > 0 && currentIndex+1 < siblingComics.count())
|
||||
{
|
||||
siblingComics[currentIndex] = currentComicDB; //updated
|
||||
currentComicDB = siblingComics.at(currentIndex+1);
|
||||
open(currentDirectory+currentComicDB.path,currentComicDB,siblingComics);
|
||||
}
|
||||
@ -938,27 +927,27 @@ void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
|
||||
qSort(list.begin(),list.end(),naturalSortLessThanCI);
|
||||
//std::sort(list.begin(),list.end(),naturalSortLessThanCI);
|
||||
int index = list.indexOf(currentComic);
|
||||
if(index == -1) //comic not found
|
||||
{
|
||||
QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt");
|
||||
if(!f.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Saving error log file...."),tr("There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder."));
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream txtS(&f);
|
||||
txtS << "METHOD : MainWindowViewer::getSiblingComics" << '\n';
|
||||
txtS << "ERROR : current comic not found in its own path" << '\n';
|
||||
txtS << path << '\n';
|
||||
txtS << currentComic << '\n';
|
||||
txtS << "Comic list count : " + list.count() << '\n';
|
||||
foreach(QString s, list){
|
||||
txtS << s << '\n';
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
if(index == -1) //comic not found
|
||||
{
|
||||
QFile f(QCoreApplication::applicationDirPath()+"/errorLog.txt");
|
||||
if(!f.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Saving error log file...."),tr("There was a problem saving YACReader error log file. Please, check if you have enough permissions in the YACReader root folder."));
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextStream txtS(&f);
|
||||
txtS << "METHOD : MainWindowViewer::getSiblingComics" << '\n';
|
||||
txtS << "ERROR : current comic not found in its own path" << '\n';
|
||||
txtS << path << '\n';
|
||||
txtS << currentComic << '\n';
|
||||
txtS << "Comic list count : " + list.count() << '\n';
|
||||
foreach(QString s, list){
|
||||
txtS << s << '\n';
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
}
|
||||
|
||||
previousComicPath = nextComicPath = "";
|
||||
if(index>0)
|
||||
@ -981,37 +970,37 @@ void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
|
||||
void MainWindowViewer::dropEvent(QDropEvent *event)
|
||||
{
|
||||
QList<QUrl> urlList;
|
||||
QString fName;
|
||||
QFileInfo info;
|
||||
QString fName;
|
||||
QFileInfo info;
|
||||
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
urlList = event->mimeData()->urls();
|
||||
|
||||
if ( urlList.size() > 0)
|
||||
{
|
||||
fName = urlList[0].toLocalFile(); // convert first QUrl to local path
|
||||
info.setFile( fName ); // information about file
|
||||
if (info.isFile())
|
||||
if (event->mimeData()->hasUrls())
|
||||
{
|
||||
urlList = event->mimeData()->urls();
|
||||
|
||||
if ( urlList.size() > 0)
|
||||
{
|
||||
fName = urlList[0].toLocalFile(); // convert first QUrl to local path
|
||||
info.setFile( fName ); // information about file
|
||||
if (info.isFile())
|
||||
openComicFromPath(fName); // if is file, setText
|
||||
else
|
||||
if(info.isDir())
|
||||
openFolderFromPath(fName);
|
||||
|
||||
isClient = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
void MainWindowViewer::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
// accept just text/uri-list mime format
|
||||
if (event->mimeData()->hasFormat("text/uri-list"))
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
// accept just text/uri-list mime format
|
||||
if (event->mimeData()->hasFormat("text/uri-list"))
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
isClient = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowViewer::alwaysOnTopSwitch()
|
||||
@ -1034,3 +1023,13 @@ void MainWindowViewer::adjustToFullSizeSwitch()
|
||||
Configuration::getConfiguration().setAdjustToFullSize(!Configuration::getConfiguration().getAdjustToFullSize());
|
||||
viewer->updatePage();
|
||||
}
|
||||
|
||||
void MainWindowViewer::sendComic()
|
||||
{
|
||||
YACReaderLocalClient * client = new YACReaderLocalClient;
|
||||
currentComicDB.info.hasBeenOpened = true;
|
||||
viewer->updateComic(currentComicDB);
|
||||
client->sendComicInfo(libraryId,currentComicDB);
|
||||
connect(client,SIGNAL(finished()),client,SLOT(deleteLater()));
|
||||
//delete client;
|
||||
}
|
@ -106,6 +106,7 @@ class YACReaderSliderAction;
|
||||
QString nextComicPath;
|
||||
//! M<>todo que inicializa el interfaz.
|
||||
void setupUI();
|
||||
void openFromArgv();
|
||||
void createActions();
|
||||
void createToolBars();
|
||||
void getSiblingComics(QString path,QString currentComic);
|
||||
@ -127,9 +128,10 @@ signals:
|
||||
void closed();
|
||||
protected:
|
||||
virtual void closeEvent ( QCloseEvent * event );
|
||||
void sendComic();
|
||||
public:
|
||||
MainWindowViewer();
|
||||
~MainWindowViewer();
|
||||
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
@ -244,21 +244,24 @@ void OptionsDialog::brightnessChanged(int value)
|
||||
{
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
settings.setValue(BRIGHTNESS,value);
|
||||
emit(changedImageOptions());
|
||||
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
||||
//emit(changedImageOptions());
|
||||
}
|
||||
|
||||
void OptionsDialog::contrastChanged(int value)
|
||||
{
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
settings.setValue(CONTRAST,value);
|
||||
emit(changedImageOptions());
|
||||
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
||||
///emit(changedImageOptions());
|
||||
}
|
||||
|
||||
void OptionsDialog::gammaChanged(int value)
|
||||
{
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
settings.setValue(GAMMA,value);
|
||||
emit(changedImageOptions());
|
||||
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
||||
//emit(changedImageOptions());
|
||||
}
|
||||
|
||||
void OptionsDialog::resetImageConfig()
|
||||
@ -270,7 +273,8 @@ void OptionsDialog::resetImageConfig()
|
||||
settings.setValue(BRIGHTNESS,0);
|
||||
settings.setValue(CONTRAST,100);
|
||||
settings.setValue(GAMMA,100);
|
||||
emit(changedImageOptions());
|
||||
emit changedFilters(brightnessS->getValue(), contrastS->getValue(), gammaS->getValue());
|
||||
//emit(changedImageOptions());
|
||||
}
|
||||
|
||||
void OptionsDialog::show()
|
||||
@ -280,4 +284,21 @@ void OptionsDialog::show()
|
||||
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
||||
QDialog::show();
|
||||
delete s;
|
||||
}
|
||||
|
||||
void OptionsDialog::setFilters(int brightness, int contrast, int gamma)
|
||||
{
|
||||
if(brightness != -1)
|
||||
brightnessS->setValue(brightness);
|
||||
else
|
||||
brightnessS->setValue(0);
|
||||
if(contrast != -1)
|
||||
contrastS->setValue(contrast);
|
||||
else
|
||||
contrastS->setValue(100);
|
||||
if(gamma != -1)
|
||||
gammaS->setValue(gamma);
|
||||
else
|
||||
gammaS->setValue(100);
|
||||
|
||||
}
|
@ -56,10 +56,12 @@ Q_OBJECT
|
||||
void gammaChanged(int value);
|
||||
void resetImageConfig();
|
||||
void show();
|
||||
void setFilters(int brightness, int contrast, int gamma);
|
||||
|
||||
signals:
|
||||
void changedOptions();
|
||||
void changedImageOptions();
|
||||
void changedFilters(int brightness, int contrast, int gamma);
|
||||
void fitToWidthRatioChanged(float ratio);
|
||||
|
||||
};
|
||||
|
@ -10,125 +10,126 @@
|
||||
#define NL 2
|
||||
#define NR 2
|
||||
|
||||
#include "comic_db.h"
|
||||
#include "yacreader_global.h"
|
||||
|
||||
template<class T>
|
||||
inline const T& kClamp( const T& x, const T& low, const T& high )
|
||||
{
|
||||
if ( x < low ) return low;
|
||||
else if ( high < x ) return high;
|
||||
else return x;
|
||||
if ( x < low ) return low;
|
||||
else if ( high < x ) return high;
|
||||
else return x;
|
||||
}
|
||||
|
||||
inline
|
||||
int changeBrightness( int value, int brightness )
|
||||
{
|
||||
return kClamp( value + brightness * 255 / 100, 0, 255 );
|
||||
}
|
||||
{
|
||||
return kClamp( value + brightness * 255 / 100, 0, 255 );
|
||||
}
|
||||
|
||||
inline
|
||||
int changeContrast( int value, int contrast )
|
||||
{
|
||||
return kClamp((( value - 127 ) * contrast / 100 ) + 127, 0, 255 );
|
||||
}
|
||||
{
|
||||
return kClamp((( value - 127 ) * contrast / 100 ) + 127, 0, 255 );
|
||||
}
|
||||
|
||||
inline
|
||||
int changeGamma( int value, int gamma )
|
||||
{
|
||||
return kClamp( int( pow( value / 255.0, 100.0 / gamma ) * 255 ), 0, 255 );
|
||||
}
|
||||
{
|
||||
return kClamp( int( pow( value / 255.0, 100.0 / gamma ) * 255 ), 0, 255 );
|
||||
}
|
||||
|
||||
inline
|
||||
int changeUsingTable( int value, const int table[] )
|
||||
{
|
||||
return table[ value ];
|
||||
}
|
||||
{
|
||||
return table[ value ];
|
||||
}
|
||||
|
||||
template< int operation( int, int ) >
|
||||
static
|
||||
QImage changeImage( const QImage& image, int value )
|
||||
{
|
||||
QImage im = image;
|
||||
im.detach();
|
||||
if( im.numColors() == 0 ) /* truecolor */
|
||||
{
|
||||
if( im.format() != QImage::Format_RGB32 ) /* just in case */
|
||||
im = im.convertToFormat( QImage::Format_RGB32 );
|
||||
int table[ 256 ];
|
||||
for( int i = 0;
|
||||
i < 256;
|
||||
++i )
|
||||
table[ i ] = operation( i, value );
|
||||
if( im.hasAlphaChannel() )
|
||||
{
|
||||
for( int y = 0;
|
||||
y < im.height();
|
||||
++y )
|
||||
{
|
||||
QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
|
||||
for( int x = 0;
|
||||
x < im.width();
|
||||
++x )
|
||||
line[ x ] = qRgba( changeUsingTable( qRed( line[ x ] ), table ),
|
||||
changeUsingTable( qGreen( line[ x ] ), table ),
|
||||
changeUsingTable( qBlue( line[ x ] ), table ),
|
||||
changeUsingTable( qAlpha( line[ x ] ), table ));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int y = 0;
|
||||
y < im.height();
|
||||
++y )
|
||||
{
|
||||
QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
|
||||
for( int x = 0;
|
||||
x < im.width();
|
||||
++x )
|
||||
line[ x ] = qRgb( changeUsingTable( qRed( line[ x ] ), table ),
|
||||
changeUsingTable( qGreen( line[ x ] ), table ),
|
||||
changeUsingTable( qBlue( line[ x ] ), table ));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QVector<QRgb> colors = im.colorTable();
|
||||
for( int i = 0;
|
||||
i < im.numColors();
|
||||
++i )
|
||||
colors[ i ] = qRgb( operation( qRed( colors[ i ] ), value ),
|
||||
operation( qGreen( colors[ i ] ), value ),
|
||||
operation( qBlue( colors[ i ] ), value ));
|
||||
}
|
||||
return im;
|
||||
}
|
||||
{
|
||||
QImage im = image;
|
||||
im.detach();
|
||||
if( im.numColors() == 0 ) /* truecolor */
|
||||
{
|
||||
if( im.format() != QImage::Format_RGB32 ) /* just in case */
|
||||
im = im.convertToFormat( QImage::Format_RGB32 );
|
||||
int table[ 256 ];
|
||||
for( int i = 0;
|
||||
i < 256;
|
||||
++i )
|
||||
table[ i ] = operation( i, value );
|
||||
if( im.hasAlphaChannel() )
|
||||
{
|
||||
for( int y = 0;
|
||||
y < im.height();
|
||||
++y )
|
||||
{
|
||||
QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
|
||||
for( int x = 0;
|
||||
x < im.width();
|
||||
++x )
|
||||
line[ x ] = qRgba( changeUsingTable( qRed( line[ x ] ), table ),
|
||||
changeUsingTable( qGreen( line[ x ] ), table ),
|
||||
changeUsingTable( qBlue( line[ x ] ), table ),
|
||||
changeUsingTable( qAlpha( line[ x ] ), table ));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int y = 0;
|
||||
y < im.height();
|
||||
++y )
|
||||
{
|
||||
QRgb* line = reinterpret_cast< QRgb* >( im.scanLine( y ));
|
||||
for( int x = 0;
|
||||
x < im.width();
|
||||
++x )
|
||||
line[ x ] = qRgb( changeUsingTable( qRed( line[ x ] ), table ),
|
||||
changeUsingTable( qGreen( line[ x ] ), table ),
|
||||
changeUsingTable( qBlue( line[ x ] ), table ));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QVector<QRgb> colors = im.colorTable();
|
||||
for( int i = 0;
|
||||
i < im.numColors();
|
||||
++i )
|
||||
colors[ i ] = qRgb( operation( qRed( colors[ i ] ), value ),
|
||||
operation( qGreen( colors[ i ] ), value ),
|
||||
operation( qBlue( colors[ i ] ), value ));
|
||||
}
|
||||
return im;
|
||||
}
|
||||
|
||||
|
||||
// brightness is multiplied by 100 in order to avoid floating point numbers
|
||||
QImage changeBrightness( const QImage& image, int brightness )
|
||||
{
|
||||
if( brightness == 0 ) // no change
|
||||
return image;
|
||||
return changeImage< changeBrightness >( image, brightness );
|
||||
}
|
||||
{
|
||||
if( brightness == 0 ) // no change
|
||||
return image;
|
||||
return changeImage< changeBrightness >( image, brightness );
|
||||
}
|
||||
|
||||
|
||||
// contrast is multiplied by 100 in order to avoid floating point numbers
|
||||
QImage changeContrast( const QImage& image, int contrast )
|
||||
{
|
||||
if( contrast == 100 ) // no change
|
||||
return image;
|
||||
return changeImage< changeContrast >( image, contrast );
|
||||
}
|
||||
{
|
||||
if( contrast == 100 ) // no change
|
||||
return image;
|
||||
return changeImage< changeContrast >( image, contrast );
|
||||
}
|
||||
|
||||
// gamma is multiplied by 100 in order to avoid floating point numbers
|
||||
QImage changeGamma( const QImage& image, int gamma )
|
||||
{
|
||||
if( gamma == 100 ) // no change
|
||||
return image;
|
||||
return changeImage< changeGamma >( image, gamma );
|
||||
}
|
||||
{
|
||||
if( gamma == 100 ) // no change
|
||||
return image;
|
||||
return changeImage< changeGamma >( image, gamma );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -223,9 +224,9 @@ QImage MedianNoiseReductionFilter::setFilter(const QImage & image)
|
||||
// BrightnessFilter
|
||||
//-----------------------------------------------------------------------------
|
||||
BrightnessFilter::BrightnessFilter(int l)
|
||||
:level(l)
|
||||
:ImageFilter()
|
||||
{
|
||||
|
||||
level = l;
|
||||
}
|
||||
|
||||
QImage BrightnessFilter::setFilter(const QImage & image)
|
||||
@ -240,17 +241,24 @@ QImage BrightnessFilter::setFilter(const QImage & image)
|
||||
}
|
||||
}
|
||||
return result;*/
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
return changeBrightness(image,settings.value(BRIGHTNESS,0).toInt());
|
||||
if(level ==-1)
|
||||
{
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
return changeBrightness(image,settings.value(BRIGHTNESS,0).toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
return changeBrightness(image,level);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ContrastFilter
|
||||
//-----------------------------------------------------------------------------
|
||||
ContrastFilter::ContrastFilter(int l)
|
||||
:level(l)
|
||||
:ImageFilter()
|
||||
{
|
||||
|
||||
level = l;
|
||||
}
|
||||
|
||||
QImage ContrastFilter::setFilter(const QImage & image)
|
||||
@ -311,21 +319,36 @@ QImage ContrastFilter::setFilter(const QImage & image)
|
||||
}
|
||||
|
||||
return result;*/
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
return changeContrast(image,settings.value(CONTRAST,100).toInt());
|
||||
if(level ==-1)
|
||||
{
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
return changeContrast(image,settings.value(CONTRAST,100).toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
return changeContrast(image,level);
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// ContrastFilter
|
||||
//-----------------------------------------------------------------------------
|
||||
GammaFilter::GammaFilter(int l)
|
||||
:level(l)
|
||||
:ImageFilter()
|
||||
{
|
||||
level = l;
|
||||
}
|
||||
|
||||
QImage GammaFilter::setFilter(const QImage & image)
|
||||
{
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
return changeGamma(image,settings.value(GAMMA,100).toInt());
|
||||
if(level ==-1)
|
||||
{
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
return changeGamma(image,settings.value(GAMMA,100).toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
return changeGamma(image,level);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -585,6 +608,40 @@ void Render::update()
|
||||
// Comic interface
|
||||
//-----------------------------------------------------------------------------
|
||||
void Render::load(const QString & path, int atPage)
|
||||
{
|
||||
createComic(path);
|
||||
loadComic(path,atPage);
|
||||
startLoad();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Render::load(const QString & path, const ComicDB & comicDB)
|
||||
{
|
||||
//TODO prepare filters
|
||||
for(int i = 0; i < filters.count(); i++)
|
||||
{
|
||||
if(typeid(*filters[i]) == typeid(BrightnessFilter))
|
||||
if(comicDB.info.brightness == -1)
|
||||
filters[i]->setLevel(0);
|
||||
else
|
||||
filters[i]->setLevel(comicDB.info.brightness);
|
||||
if(typeid(*filters[i]) == typeid(ContrastFilter))
|
||||
if(comicDB.info.contrast == -1)
|
||||
filters[i]->setLevel(100);
|
||||
else
|
||||
filters[i]->setLevel(comicDB.info.contrast);
|
||||
if(typeid(*filters[i]) == typeid(GammaFilter))
|
||||
if(comicDB.info.gamma == -1)
|
||||
filters[i]->setLevel(100);
|
||||
else
|
||||
filters[i]->setLevel(comicDB.info.gamma);
|
||||
}
|
||||
createComic(path);
|
||||
loadComic(path,comicDB);
|
||||
startLoad();
|
||||
}
|
||||
|
||||
void Render::createComic(const QString & path)
|
||||
{
|
||||
if(comic!=0)
|
||||
{
|
||||
@ -622,6 +679,22 @@ void Render::load(const QString & path, int atPage)
|
||||
connect(comic,SIGNAL(isLast()),this,SIGNAL(isLast()));
|
||||
connect(comic,SIGNAL(isCover()),this,SIGNAL(isCover()));
|
||||
|
||||
pagesReady.clear();
|
||||
}
|
||||
void Render::loadComic(const QString & path,const ComicDB & comicDB)
|
||||
{
|
||||
//if(typeid(*comic) != typeid(FolderComic))
|
||||
comic->load(path,comicDB);
|
||||
//else
|
||||
{/*TODO error*/}
|
||||
}
|
||||
void Render::loadComic(const QString & path, int atPage)
|
||||
{
|
||||
comic->load(path,atPage);
|
||||
}
|
||||
|
||||
void Render::startLoad()
|
||||
{
|
||||
QThread * thread = NULL;
|
||||
|
||||
thread = new QThread();
|
||||
@ -631,18 +704,12 @@ void Render::load(const QString & path, int atPage)
|
||||
connect(thread, SIGNAL(started()), comic, SLOT(process()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
pagesReady.clear();
|
||||
|
||||
comic->load(path,atPage); //garantiza que se va a intentar abrir el c<>mic
|
||||
|
||||
if(thread != NULL)
|
||||
thread->start();
|
||||
|
||||
invalidate();
|
||||
loadedComic = true;
|
||||
update();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Render::renderAt(int page)
|
||||
@ -797,7 +864,7 @@ void Render::goTo(int index)
|
||||
void Render::rotateRight()
|
||||
{
|
||||
imageRotation = (imageRotation+90) % 360;
|
||||
reload();
|
||||
reload();
|
||||
}
|
||||
void Render::rotateLeft()
|
||||
{
|
||||
@ -1002,4 +1069,19 @@ void Render::reload()
|
||||
invalidate();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void Render::updateFilters(int brightness, int contrast, int gamma)
|
||||
{
|
||||
for(int i = 0; i < filters.count(); i++)
|
||||
{
|
||||
if(typeid(*filters[i]) == typeid(BrightnessFilter))
|
||||
filters[i]->setLevel(brightness);
|
||||
if(typeid(*filters[i]) == typeid(ContrastFilter))
|
||||
filters[i]->setLevel(contrast);
|
||||
if(typeid(*filters[i]) == typeid(GammaFilter))
|
||||
filters[i]->setLevel(gamma);
|
||||
}
|
||||
|
||||
reload();
|
||||
}
|
@ -15,54 +15,53 @@
|
||||
#include <QThread>
|
||||
|
||||
class Comic;
|
||||
class ComicDB;
|
||||
class Render;
|
||||
|
||||
class ImageFilter {
|
||||
public:
|
||||
ImageFilter(){};
|
||||
virtual QImage setFilter(const QImage & image) = 0;
|
||||
ImageFilter(){};
|
||||
virtual QImage setFilter(const QImage & image) = 0;
|
||||
inline int getLevel() {return level;};
|
||||
inline void setLevel(int l) {level = l;};
|
||||
protected:
|
||||
int level;
|
||||
};
|
||||
|
||||
class MeanNoiseReductionFilter : public ImageFilter {
|
||||
public:
|
||||
enum NeighborghoodSize{SMALL=9, LARGE=25 };
|
||||
MeanNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
enum NeighborghoodSize{SMALL=9, LARGE=25 };
|
||||
MeanNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
private:
|
||||
enum NeighborghoodSize neighborghoodSize;
|
||||
enum NeighborghoodSize neighborghoodSize;
|
||||
};
|
||||
|
||||
class MedianNoiseReductionFilter : public ImageFilter {
|
||||
public:
|
||||
enum NeighborghoodSize{SMALL=9, LARGE=25 };
|
||||
MedianNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
enum NeighborghoodSize{SMALL=9, LARGE=25 };
|
||||
MedianNoiseReductionFilter(enum NeighborghoodSize ns = SMALL);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
private:
|
||||
enum NeighborghoodSize neighborghoodSize;
|
||||
enum NeighborghoodSize neighborghoodSize;
|
||||
};
|
||||
|
||||
class BrightnessFilter : public ImageFilter {
|
||||
public:
|
||||
BrightnessFilter(int l=150);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
private:
|
||||
int level;
|
||||
BrightnessFilter(int l=-1);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
};
|
||||
|
||||
class ContrastFilter : public ImageFilter {
|
||||
public:
|
||||
ContrastFilter(int l=150);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
private:
|
||||
int level;
|
||||
ContrastFilter(int l=-1);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
};
|
||||
|
||||
class GammaFilter : public ImageFilter {
|
||||
public:
|
||||
GammaFilter(int l=150);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
private:
|
||||
int level;
|
||||
GammaFilter(int l=-1);
|
||||
virtual QImage setFilter(const QImage & image);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -74,16 +73,16 @@ class PageRender : public QThread
|
||||
Q_OBJECT
|
||||
public:
|
||||
PageRender();
|
||||
PageRender(Render * render,int numPage, const QByteArray & rawData, QImage * page,unsigned int degrees=0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
|
||||
PageRender(Render * render,int numPage, const QByteArray & rawData, QImage * page,unsigned int degrees=0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
|
||||
int getNumPage(){return numPage;};
|
||||
void setData(const QByteArray & rawData){data = rawData;};
|
||||
void setPage(QImage * p){page = p;};
|
||||
void setPage(QImage * p){page = p;};
|
||||
void setRotation(unsigned int d){degrees = d;};
|
||||
void setFilters(QVector<ImageFilter *> f){filters = f;};
|
||||
private:
|
||||
int numPage;
|
||||
QByteArray data;
|
||||
QImage * page;
|
||||
QImage * page;
|
||||
unsigned int degrees;
|
||||
QVector<ImageFilter *> filters;
|
||||
void run();
|
||||
@ -100,12 +99,12 @@ class DoublePageRender : public PageRender
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DoublePageRender(Render * render, int firstPage, const QByteArray & firstPageData,const QByteArray & secondPageData, QImage * page,unsigned int degrees=0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
|
||||
DoublePageRender(Render * render, int firstPage, const QByteArray & firstPageData,const QByteArray & secondPageData, QImage * page,unsigned int degrees=0, QVector<ImageFilter *> filters = QVector<ImageFilter *>());
|
||||
private:
|
||||
int numPage;
|
||||
QByteArray data;
|
||||
QByteArray data2;
|
||||
QImage * page;
|
||||
QImage * page;
|
||||
unsigned int degrees;
|
||||
QVector<ImageFilter *> filters;
|
||||
void run();
|
||||
@ -136,7 +135,12 @@ public slots:
|
||||
//--comic interface
|
||||
void nextPage();
|
||||
void previousPage();
|
||||
void load(const QString & path, const ComicDB & comic);
|
||||
void load(const QString & path, int atPage);
|
||||
void createComic(const QString & path);
|
||||
void loadComic(const QString & path,const ComicDB & comic);
|
||||
void loadComic(const QString & path, int atPage);
|
||||
void startLoad();
|
||||
void rotateRight();
|
||||
void rotateLeft();
|
||||
unsigned int getIndex();
|
||||
@ -152,6 +156,7 @@ public slots:
|
||||
void save();
|
||||
void reset();
|
||||
void reload();
|
||||
void updateFilters(int brightness, int contrast, int gamma);
|
||||
Bookmarks * getBookmarks();
|
||||
//sets the firt page to render
|
||||
void renderAt(int page);
|
||||
@ -183,7 +188,7 @@ private:
|
||||
int numLeftPages;
|
||||
int numRightPages;
|
||||
QList<PageRender *> pageRenders;
|
||||
QList<QImage *> buffer;
|
||||
QList<QImage *> buffer;
|
||||
void loadAll();
|
||||
void updateRightPages();
|
||||
void updateLeftPages();
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "onstart_flow_selection_dialog.h"
|
||||
#include "page_label_widget.h"
|
||||
#include "notifications_label_widget.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
#include <QFile>
|
||||
#define STEPS 22
|
||||
|
||||
@ -174,18 +174,19 @@ void Viewer::createConnections()
|
||||
connect(render,SIGNAL(bookmarksUpdated()),this,SLOT(setBookmarks()));
|
||||
}
|
||||
|
||||
void Viewer::open(QString pathFile, int atPage)
|
||||
//Deprecated
|
||||
void Viewer::prepareForOpening()
|
||||
{
|
||||
if(render->hasLoadedComic())
|
||||
save();
|
||||
//bd->setBookmarks(*bm);
|
||||
|
||||
goToFlow->reset();
|
||||
render->load(pathFile, atPage);
|
||||
|
||||
//render->update();
|
||||
|
||||
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
|
||||
|
||||
|
||||
if(Configuration::getConfiguration().getShowInformation() && !information)
|
||||
{
|
||||
QTimer * timer = new QTimer();
|
||||
@ -195,8 +196,18 @@ void Viewer::open(QString pathFile, int atPage)
|
||||
}
|
||||
|
||||
informationLabel->setText("...");
|
||||
}
|
||||
|
||||
|
||||
void Viewer::open(QString pathFile, int atPage)
|
||||
{
|
||||
prepareForOpening();
|
||||
render->load(pathFile, atPage);
|
||||
}
|
||||
|
||||
void Viewer::open(QString pathFile, const ComicDB & comic)
|
||||
{
|
||||
prepareForOpening();
|
||||
render->load(pathFile, comic);
|
||||
}
|
||||
|
||||
void Viewer::showMessageErrorOpening()
|
||||
@ -638,35 +649,35 @@ void Viewer::rotateRight()
|
||||
//TODO
|
||||
void Viewer::setBookmark(bool set)
|
||||
{
|
||||
render->setBookmark();
|
||||
if(set) //add bookmark
|
||||
{
|
||||
render->setBookmark();
|
||||
}
|
||||
else //remove bookmark
|
||||
{
|
||||
if(set) //add bookmark
|
||||
{
|
||||
render->setBookmark();
|
||||
}
|
||||
else //remove bookmark
|
||||
{
|
||||
render->removeBookmark();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::save ()
|
||||
{
|
||||
if(render->hasLoadedComic())
|
||||
if(render->hasLoadedComic())
|
||||
render->save();
|
||||
}
|
||||
|
||||
void Viewer::doublePageSwitch()
|
||||
{
|
||||
doublePage = !doublePage;
|
||||
render->doublePageSwitch();
|
||||
doublePage = !doublePage;
|
||||
render->doublePageSwitch();
|
||||
Configuration::getConfiguration().setDoublePage(doublePage);
|
||||
}
|
||||
|
||||
void Viewer::resetContent()
|
||||
{
|
||||
configureContent(tr("Press 'O' to open comic."));
|
||||
configureContent(tr("Press 'O' to open comic."));
|
||||
goToFlow->reset();
|
||||
emit reset();
|
||||
emit reset();
|
||||
}
|
||||
|
||||
void Viewer::setLoadingMessage()
|
||||
@ -693,12 +704,12 @@ void Viewer::setPageUnavailableMessage()
|
||||
|
||||
void Viewer::configureContent(QString msg)
|
||||
{
|
||||
content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||
content->setScaledContents(true);
|
||||
content->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||
content->setText(msg);
|
||||
content->setFont(QFont("courier new", 12));
|
||||
content->adjustSize();
|
||||
content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||
content->setScaledContents(true);
|
||||
content->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
|
||||
content->setText(msg);
|
||||
content->setFont(QFont("courier new", 12));
|
||||
content->adjustSize();
|
||||
setFocus(Qt::ShortcutFocusReason);
|
||||
//emit showingText();
|
||||
}
|
||||
@ -802,11 +813,17 @@ void Viewer::updateConfig(QSettings * settings)
|
||||
|
||||
}
|
||||
|
||||
//deprecated
|
||||
void Viewer::updateImageOptions()
|
||||
{
|
||||
render->reload();
|
||||
}
|
||||
|
||||
void Viewer::updateFilters(int brightness, int contrast,int gamma)
|
||||
{
|
||||
render->updateFilters(brightness,contrast,gamma);
|
||||
}
|
||||
|
||||
void Viewer::setBookmarks()
|
||||
{
|
||||
bd->setBookmarks(*render->getBookmarks());
|
||||
@ -833,4 +850,35 @@ unsigned int Viewer::getIndex()
|
||||
int Viewer::getCurrentPageNumber()
|
||||
{
|
||||
return render->getIndex();
|
||||
}
|
||||
|
||||
void Viewer::updateComic(ComicDB & comic)
|
||||
{
|
||||
//set currentPage
|
||||
comic.info.currentPage = render->getIndex()+1;
|
||||
//set bookmarks
|
||||
Bookmarks * boomarks = render->getBookmarks();
|
||||
QList<int> boomarksList = boomarks->getBookmarkPages();
|
||||
int numBookmarks = boomarksList.size();
|
||||
if(numBookmarks > 0)
|
||||
comic.info.bookmark1 = boomarksList[0];
|
||||
if(numBookmarks > 1)
|
||||
comic.info.bookmark2 = boomarksList[1];
|
||||
if(numBookmarks > 2)
|
||||
comic.info.bookmark3 = boomarksList[2];
|
||||
//set filters
|
||||
//TODO: avoid use settings for this...
|
||||
QSettings settings(QCoreApplication::applicationDirPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
int brightness = settings.value(BRIGHTNESS,0).toInt();
|
||||
int contrast = settings.value(CONTRAST,100).toInt();
|
||||
int gamma = settings.value(GAMMA,100).toInt();
|
||||
|
||||
if(brightness != 0 || comic.info.brightness!=-1)
|
||||
comic.info.brightness = brightness;
|
||||
if(contrast != 100 || comic.info.contrast!=-1)
|
||||
comic.info.contrast = contrast;
|
||||
if(gamma != 100 || comic.info.gamma!=-1)
|
||||
comic.info.gamma = gamma;
|
||||
|
||||
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
#include <QPropertyAnimation>
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
class ComicDB;
|
||||
class Comic;
|
||||
class MagnifyingGlass;
|
||||
class GoToFlow;
|
||||
@ -35,7 +35,9 @@ class NotificationsLabelWidget;
|
||||
public:
|
||||
bool fullscreen; //TODO, change by the right use of windowState();
|
||||
public slots:
|
||||
void prepareForOpening();
|
||||
void open(QString pathFile, int atPage = -1);
|
||||
void open(QString pathFile, const ComicDB & comic);
|
||||
void prev();
|
||||
void next();
|
||||
void showGoToDialog();
|
||||
@ -80,7 +82,9 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
void showMessageErrorOpening();
|
||||
void showMessageErrorOpening(QString);
|
||||
void setBookmarks();
|
||||
//deprecated
|
||||
void updateImageOptions();
|
||||
void updateFilters(int brightness, int contrast,int gamma);
|
||||
void showIsCoverMessage();
|
||||
void showIsLastMessage();
|
||||
int getCurrentPageNumber();
|
||||
@ -142,6 +146,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
const BookmarksDialog * getBookmarksDialog(){return bd;}
|
||||
//returns the current index starting in 1 [1,nPages]
|
||||
unsigned int getIndex();
|
||||
void updateComic(ComicDB & comic);
|
||||
signals:
|
||||
void backgroundChanges();
|
||||
void pageAvailable(bool);
|
||||
|
@ -5,14 +5,14 @@
|
||||
#include <QLocalSocket>
|
||||
|
||||
YACReaderLocalClient::YACReaderLocalClient(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent)
|
||||
{
|
||||
localSocket = new QLocalSocket(this);
|
||||
localSocket = new QLocalSocket(this);
|
||||
|
||||
//connect(localSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));
|
||||
//connect(localSocket, SIGNAL(readyRead()), this, SLOT(readMessage()));
|
||||
|
||||
/*connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
|
||||
this, SLOT(displayError(QLocalSocket::LocalSocketError)));*/
|
||||
/*connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
|
||||
this, SLOT(displayError(QLocalSocket::LocalSocketError)));*/
|
||||
}
|
||||
|
||||
//información de comic recibida...
|
||||
@ -101,10 +101,15 @@ bool YACReaderLocalClient::sendComicInfo(quint64 libraryId, ComicDB & comic)
|
||||
tries++;
|
||||
}
|
||||
if(tries == 100 && written != block.size())
|
||||
{
|
||||
emit finished();
|
||||
return false;
|
||||
}
|
||||
emit finished();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
emit finished();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
explicit YACReaderLocalClient(QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
void finished();
|
||||
public slots:
|
||||
void readMessage();
|
||||
bool requestComicInfo(quint64 libraryId, ComicDB & comic,QList<ComicDB> & siblings);
|
||||
|
@ -170,14 +170,14 @@ void DBHelper::removeFromDB(Folder * folder, QSqlDatabase & db)
|
||||
{
|
||||
QSqlQuery query(db);
|
||||
query.prepare("DELETE FROM folder WHERE id = :id");
|
||||
query.bindValue(":id", folder->id);
|
||||
query.bindValue(":id", folder->id);
|
||||
query.exec();
|
||||
}
|
||||
void DBHelper::removeFromDB(ComicDB * comic, QSqlDatabase & db)
|
||||
{
|
||||
QSqlQuery query(db);
|
||||
query.prepare("DELETE FROM comic WHERE id = :id");
|
||||
query.bindValue(":id", comic->id);
|
||||
query.bindValue(":id", comic->id);
|
||||
query.exec();
|
||||
}
|
||||
|
||||
@ -314,9 +314,9 @@ qulonglong DBHelper::insert(Folder * folder, QSqlDatabase & db)
|
||||
{
|
||||
QSqlQuery query(db);
|
||||
query.prepare("INSERT INTO folder (parentId, name, path) "
|
||||
"VALUES (:parentId, :name, :path)");
|
||||
query.bindValue(":parentId", folder->parentId);
|
||||
query.bindValue(":name", folder->name);
|
||||
"VALUES (:parentId, :name, :path)");
|
||||
query.bindValue(":parentId", folder->parentId);
|
||||
query.bindValue(":name", folder->name);
|
||||
query.bindValue(":path", folder->path);
|
||||
query.exec();
|
||||
return query.lastInsertId().toULongLong();
|
||||
@ -340,10 +340,10 @@ qulonglong DBHelper::insert(ComicDB * comic, QSqlDatabase & db)
|
||||
|
||||
QSqlQuery query(db);
|
||||
query.prepare("INSERT INTO comic (parentId, comicInfoId, fileName, path) "
|
||||
"VALUES (:parentId,:comicInfoId,:name, :path)");
|
||||
query.bindValue(":parentId", comic->parentId);
|
||||
"VALUES (:parentId,:comicInfoId,:name, :path)");
|
||||
query.bindValue(":parentId", comic->parentId);
|
||||
query.bindValue(":comicInfoId", comic->info.id);
|
||||
query.bindValue(":name", comic->name);
|
||||
query.bindValue(":name", comic->name);
|
||||
query.bindValue(":path", comic->path);
|
||||
query.exec();
|
||||
return query.lastInsertId().toULongLong();
|
||||
|
@ -1012,17 +1012,15 @@ void LibraryWindow::openComic()
|
||||
quint64 comicId = comic.id;
|
||||
//TODO generate IDS for libraries...
|
||||
quint64 libraryId = selectedLibrary->currentIndex();
|
||||
int page = *(comic.info.numPages) / 2;
|
||||
|
||||
|
||||
// %1 %2 %3 NO-->%4 %5 %6 %7 %8 %9 %10
|
||||
//Invoke YACReader comicPath comicId libraryId NO-->currentPage bookmark1 bookmark2 bookmark3 brightness contrast gamma
|
||||
#ifdef Q_OS_MAC
|
||||
|
||||
QProcess::startDetached("open", QStringList() << "-n" << QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app") << "--args" << path << comicId << libraryId << page);//,QStringList() << path);
|
||||
#else
|
||||
|
||||
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\" \"%2\" \"%3\" \"%4\"").arg(path).arg(comicId).arg(libraryId).arg(page),QStringList());
|
||||
QProcess::startDetached("open", QStringList() << "-n" << QDir::cleanPath(QCoreApplication::applicationDirPath()+"/../../../YACReader.app") << "--args" << path << comicId << libraryId /*<< page << bookmark1 << bookmark2 << bookmark3 << brightness << contrast << gamma*/);//,QStringList() << path);
|
||||
#else
|
||||
/* \"%4\" \"%5\" \"%6\" \"%7\" \"%8\" \"%9\" \"%10\" */
|
||||
QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath())+QString("/YACReader \"%1\" \"%2\" \"%3\"").arg(path).arg(comicId).arg(libraryId)/*.arg(page).arg(bookmark1).arg(bookmark2).arg(bookmark3).arg(brightness).arg(contrast).arg(gamma)*/,QStringList());
|
||||
#endif
|
||||
//Comic is readed
|
||||
//setCurrentComicReaded();
|
||||
setCurrentComicOpened();
|
||||
}
|
||||
}
|
||||
|
@ -9,26 +9,26 @@
|
||||
#include "comic_db.h"
|
||||
|
||||
YACReaderLocalServer::YACReaderLocalServer(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent)
|
||||
{
|
||||
localServer = new QLocalServer(this);
|
||||
if (!localServer->listen(YACREADERLIBRARY_GUID)) {
|
||||
//error...........
|
||||
}
|
||||
localServer = new QLocalServer(this);
|
||||
if (!localServer->listen(YACREADERLIBRARY_GUID)) {
|
||||
//error...........
|
||||
}
|
||||
|
||||
connect(localServer, SIGNAL(newConnection()), this, SLOT(sendResponse()));
|
||||
connect(localServer, SIGNAL(newConnection()), this, SLOT(sendResponse()));
|
||||
}
|
||||
|
||||
bool YACReaderLocalServer::isListening()
|
||||
{
|
||||
return localServer->isListening();
|
||||
return localServer->isListening();
|
||||
}
|
||||
|
||||
void YACReaderLocalServer::sendResponse()
|
||||
{
|
||||
QLocalSocket *clientConnection = localServer->nextPendingConnection();
|
||||
connect(clientConnection, SIGNAL(disconnected()),
|
||||
clientConnection, SLOT(deleteLater()));
|
||||
connect(clientConnection, SIGNAL(disconnected()),
|
||||
clientConnection, SLOT(deleteLater()));
|
||||
|
||||
quint64 libraryId;
|
||||
ComicDB comic;
|
||||
|
Reference in New Issue
Block a user