Merged luisangelsm/yacreader into default

This commit is contained in:
Felix Kauselmann
2015-08-20 12:28:47 +02:00
parent 3a6b2d9b98
commit 23c33cef61
64 changed files with 1758 additions and 877 deletions

View File

@ -1,164 +0,0 @@
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
INCLUDEPATH += .
INCLUDEPATH += $$PWD/../common \
$$PWD/../custom_widgets
CONFIG(legacy_gl_widget) {
INCLUDEPATH += ../common/gl_legacy \
} else {
INCLUDEPATH += ../common/gl \
}
win32 {
LIBS += -L$$PWD/../dependencies/poppler/lib -loleaut32 -lole32
LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT
!CONFIG(no_opengl) {
QMAKE_CXXFLAGS_RELEASE += /GL
}
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
}
unix:!macx{
INCLUDEPATH += /usr/include/poppler/qt5
LIBS += -L/usr/lib -lpoppler-qt5
!CONFIG(no_opengl) {
LIBS += -lGLU
}
}
macx{
#INCLUDEPATH += "/Volumes/Mac OS X Lion/usr/X11/include"
#isEqual(QT_MAJOR_VERSION, 5) {
#INCLUDEPATH += /usr/local/include/poppler/qt5
#LIBS += -L/usr/local/lib -lpoppler-qt5
#}
#else {
#INCLUDEPATH += /usr/local/include/poppler/qt4
#LIBS += -L/usr/local/lib -lpoppler-qt4
#}
CONFIG += objective_c
QT += macextras gui-private
LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
OBJECTIVE_SOURCES += $$PWD/../common/pdf_comic.mm
HEADERS += $$PWD/../common/pdf_comic.h
}
QT += network widgets core
!CONFIG(no_opengl) {
QT += opengl
}
#CONFIG += release
CONFIG -= flat
QT += multimedia
# Input
HEADERS += $$PWD/../common/comic.h \
$$PWD/configuration.h \
$$PWD/goto_dialog.h \
$$PWD/magnifying_glass.h \
$$PWD/main_window_viewer.h \
$$PWD/viewer.h \
$$PWD/goto_flow.h \
$$PWD/options_dialog.h \
$$PWD/../common/bookmarks.h \
$$PWD/bookmarks_dialog.h \
$$PWD/render.h \
$$PWD/shortcuts_dialog.h \
$$PWD/translator.h \
$$PWD/goto_flow_widget.h \
$$PWD/page_label_widget.h \
$$PWD/goto_flow_toolbar.h \
$$PWD/goto_flow_decorationbar.h \
$$PWD/width_slider.h \
$$PWD/notifications_label_widget.h \
$$PWD/../common/pictureflow.h \
$$PWD/../common/custom_widgets.h \
$$PWD/../common/check_new_version.h \
$$PWD/../common/qnaturalsorting.h \
$$PWD/../common/yacreader_global.h \
$$PWD/../common/onstart_flow_selection_dialog.h \
$$PWD/../common/comic_db.h \
$$PWD/../common/folder.h \
$$PWD/../common/library_item.h \
$$PWD/yacreader_local_client.h \
$$PWD/../common/http_worker.h \
$$PWD/../common/exit_check.h \
$$PWD/../common/scroll_management.h
!CONFIG(no_opengl) {
CONFIG(legacy_gl_widget) {
message("using legacy YACReaderFlowGL (QGLWidget) header")
HEADERS += ../common/gl_legacy/yacreader_flow_gl.h
} else {
HEADERS += ../common/gl/yacreader_flow_gl.h
}
HEADERS += $$PWD/goto_flow_gl.h
}
SOURCES += $$PWD/../common/comic.cpp \
$$PWD/configuration.cpp \
$$PWD/goto_dialog.cpp \
$$PWD/magnifying_glass.cpp \
$$PWD/main_window_viewer.cpp \
$$PWD/viewer.cpp \
$$PWD/goto_flow.cpp \
$$PWD/options_dialog.cpp \
$$PWD/../common/bookmarks.cpp \
$$PWD/bookmarks_dialog.cpp \
$$PWD/render.cpp \
$$PWD/shortcuts_dialog.cpp \
$$PWD/translator.cpp \
$$PWD/goto_flow_widget.cpp \
$$PWD/page_label_widget.cpp \
$$PWD/goto_flow_toolbar.cpp \
$$PWD/goto_flow_decorationbar.cpp \
$$PWD/width_slider.cpp \
$$PWD/notifications_label_widget.cpp \
$$PWD/../common/pictureflow.cpp \
$$PWD/../common/custom_widgets.cpp \
$$PWD/../common/check_new_version.cpp \
$$PWD/../common/qnaturalsorting.cpp \
$$PWD/../common/onstart_flow_selection_dialog.cpp \
$$PWD/../common/comic_db.cpp \
$$PWD/../common/folder.cpp \
$$PWD/../common/library_item.cpp \
$$PWD/yacreader_local_client.cpp \
$$PWD/../common/http_worker.cpp \
$$PWD/../common/yacreader_global.cpp \
$$PWD/../common/exit_check.cpp \
$$PWD/../common/scroll_management.cpp
!CONFIG(no_opengl) {
CONFIG(legacy_gl_widget) {
message("using legacy YACReaderFlowGL (QGLWidget) source code")
SOURCES += ../common/gl_legacy/yacreader_flow_gl.cpp
} else {
SOURCES += ../common/gl/yacreader_flow_gl.cpp
}
SOURCES += $$PWD/goto_flow_gl.cpp
}
include($$PWD/../custom_widgets/custom_widgets_yacreader.pri)
include($$PWD/../compressed_archive/wrapper.pri)
include($$PWD/../shortcuts_management/shortcuts_management.pri)
RESOURCES += $$PWD/yacreader_images.qrc \
$$PWD/yacreader_files.qrc
win32:RESOURCES += $$PWD/yacreader_images_win.qrc
unix:!macx:RESOURCES += $$PWD/yacreader_images_win.qrc
macx:RESOURCES += $$PWD/yacreader_images_osx.qrc

View File

@ -8,41 +8,51 @@ DEPENDPATH += . \
DEFINES += NOMINMAX YACREADER
CONFIG(no_opengl) {
DEFINES += NO_OPENGL
#load default build flags
include (../config.pri)
unix:!macx{
QMAKE_CXXFLAGS += -std=c++11
}
unix:!macx{
QMAKE_CXXFLAGS += -std=c++11
CONFIG(force_angle) {
Release:DESTDIR = ../release_angle
Debug:DESTDIR = ../debug_angle
} else {
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
}
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
SOURCES += main.cpp
INCLUDEPATH += ../common \
../custom_widgets
CONFIG(legacy_gl_widget) {
!CONFIG(no_opengl):CONFIG(legacy_gl_widget) {
INCLUDEPATH += ../common/gl_legacy \
} else {
INCLUDEPATH += ../common/gl \
}
#there are going to be two builds for windows, OpenGL based and ANGLE based
win32 {
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32
CONFIG(force_angle) {
message("using ANGLE")
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32
#linking extra libs are necesary for a successful compilation, a better approach should be
#to remove any OpenGL (desktop) dependencies
#the OpenGL stuff should be migrated to OpenGL ES
DEFINES += FORCE_ANGLE
} else {
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32
}
LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5
LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT
!CONFIG(no_opengl) {
QMAKE_CXXFLAGS_RELEASE += /GL
}
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
}
unix:!macx{
@ -118,7 +128,8 @@ HEADERS += ../common/comic.h \
yacreader_local_client.h \
../common/http_worker.h \
../common/exit_check.h \
../common/scroll_management.h
../common/scroll_management.h \
../common/opengl_checker.h
!CONFIG(no_opengl) {
CONFIG(legacy_gl_widget) {
@ -161,7 +172,8 @@ SOURCES += ../common/comic.cpp \
../common/http_worker.cpp \
../common/yacreader_global.cpp \
../common/exit_check.cpp \
../common/scroll_management.cpp
../common/scroll_management.cpp \
../common/opengl_checker.cpp
!CONFIG(no_opengl) {
CONFIG(legacy_gl_widget) {
@ -174,7 +186,13 @@ SOURCES += ../common/comic.cpp \
}
include(../custom_widgets/custom_widgets_yacreader.pri)
CONFIG(7zip){
include(../compressed_archive/wrapper.pri)
} else:CONFIG(unarr){
include(../compressed_archive/unarr/unarr-wrapper.pri)
} else {
error(No compression backend specified. Did you mess with the build system?)
}
include(../shortcuts_management/shortcuts_management.pri)
RESOURCES += yacreader_images.qrc \
@ -202,24 +220,6 @@ TRANSLATIONS = yacreader_es.ts \
yacreader_de.ts \
yacreader_source.ts
win32 {
!exists (../compressed_archive/lib7zip) {
error(You\'ll need 7zip source code to compile YACReader. \
Please check the compressed_archive folder for further instructions.)
}
}
unix {
exists (../compressed_archive/libp7zip) {
message(Found p7zip source code...)
system(patch -d ../compressed_archive -N -p0 -i libp7zip.patch)
} else {
error(You\'ll need 7zip source code to compile YACReader. \
Please check the compressed_archive folder for further instructions.)
}
}
unix:!macx {
#set install prefix if it's empty
isEmpty(PREFIX) {

View File

@ -59,6 +59,7 @@ class YACReaderApplication: public QApplication
int main(int argc, char * argv[])
{
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
@ -78,9 +79,13 @@ int main(int argc, char * argv[])
QApplication app(argc, argv);
#endif
#ifdef FORCE_ANGLE
app.setAttribute(Qt::AA_UseOpenGLES);
#endif
app.setApplicationName("YACReader");
app.setOrganizationName("YACReader");
qApp->setAttribute(Qt::AA_UseHighDpiPixmaps);
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
//simple command line parser
//will be replaced by QCommandLineParser in the future
QStringList optlist;

View File

@ -354,7 +354,7 @@ void MainWindowViewer::createActions()
setBookmarkAction->setCheckable(true);
setBookmarkAction->setData(SET_BOOKMARK_ACTION_Y);
setBookmarkAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_BOOKMARK_ACTION_Y));
connect(setBookmarkAction,SIGNAL(triggered (bool)),viewer,SLOT(setBookmarkAction(bool)));
connect(setBookmarkAction,SIGNAL(triggered (bool)),viewer,SLOT(setBookmark(bool)));
connect(viewer,SIGNAL(pageAvailable(bool)),setBookmarkAction,SLOT(setEnabled(bool)));
connect(viewer,SIGNAL(pageIsBookmark(bool)),setBookmarkAction,SLOT(setChecked(bool)));
@ -578,7 +578,7 @@ void MainWindowViewer::createToolBars()
#ifdef Q_OS_MAC
comicToolBar->addStretch();
#else
comicToolBar->addWidget(new QToolBarStretch());
comicToolBar->addWidget(new YACReaderToolBarStretch());
#endif
@ -671,7 +671,11 @@ void MainWindowViewer::reloadOptions()
void MainWindowViewer::open()
{
QFileDialog openDialog;
#ifndef use_unarr
QString pathFile = openDialog.getOpenFileName(this,tr("Open Comic"),currentDirectory,tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.7z *.cb7 *.arj *.cbt)");
#else
QString pathFile = openDialog.getOpenFileName(this,tr("Open Comic"),currentDirectory,tr("Comic files") + "(*.cbr *.cbz *.rar *.zip *.tar *.pdf *.cbt)");
#endif
if (!pathFile.isEmpty())
{
openComicFromPath(pathFile);
@ -1315,7 +1319,11 @@ void MainWindowViewer::getSiblingComics(QString path,QString currentComic)
{
QDir d(path);
d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
#ifndef use_unarr
d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.7z" << "*.cb7" << "*.arj" << "*.cbt");
#else
d.setNameFilters(QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.cbt");
#endif
d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
QStringList list = d.entryList();
qSort(list.begin(),list.end(),naturalSortLessThanCI);

View File

@ -431,9 +431,9 @@ Render::~Render()
delete pr;
}
}
//Este m<EFBFBD>todo se encarga de forzar el renderizado de las p<EFBFBD>ginas.
//Actualiza el buffer seg<EFBFBD>n es necesario.
//si la pagina actual no est<EFBFBD> renderizada, se lanza un hilo que la renderize (double or single page mode) y se emite una se<EFBFBD>al que indica que se est<EFBFBD> renderizando.
//Este método se encarga de forzar el renderizado de las páginas.
//Actualiza el buffer según es necesario.
//si la pagina actual no está renderizada, se lanza un hilo que la renderize (double or single page mode) y se emite una señal que indica que se está renderizando.
void Render::render()
{
updateBuffer();
@ -446,30 +446,30 @@ void Render::render()
pageRenders[currentPageBufferedIndex] = new PageRender(this,currentIndex,comic->getRawData()->at(currentIndex),buffer[currentPageBufferedIndex],imageRotation,filters);
}
else
//las p<EFBFBD>ginas no est<EFBFBD>n listas, y se est<EFBFBD>n cargando en el c<EFBFBD>mic
emit processingPage(); //para evitar confusiones esta se<EFBFBD>al deber<EFBFBD>a llamarse de otra forma
//las páginas no están listas, y se están cargando en el cómic
emit processingPage(); //para evitar confusiones esta señal debería llamarse de otra forma
//si se ha creado un hilo para renderizar la p<EFBFBD>gina actual, se arranca
//si se ha creado un hilo para renderizar la página actual, se arranca
if(pageRenders[currentPageBufferedIndex]!=0)
{
//se conecta la se<EFBFBD>al pageReady del hilo, con el SLOT prepareAvailablePage
//se conecta la señal pageReady del hilo, con el SLOT prepareAvailablePage
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
//se emite la se<EFBFBD>al de procesando, debido a que los hilos se arrancan aqu<EFBFBD>
//se emite la señal de procesando, debido a que los hilos se arrancan aquí
if(filters.size()>0)
emit processingPage();
pageRenders[currentPageBufferedIndex]->start();
pageRenders[currentPageBufferedIndex]->setPriority(QThread::TimeCriticalPriority);
}
else
//en qu<EFBFBD> caso ser<EFBFBD>a necesario hacer esto??? //TODO: IMPORTANTE, puede que no sea necesario.
//en qué caso sería necesario hacer esto??? //TODO: IMPORTANTE, puede que no sea necesario.
emit processingPage();
}
else
//no hay ninguna p<EFBFBD>gina lista para ser renderizada, es necesario esperar.
//no hay ninguna página lista para ser renderizada, es necesario esperar.
emit processingPage();
}
else
// la p<EFBFBD>gina actual est<EFBFBD> lista
// la página actual está lista
{
//emit currentPageReady();
//make prepareAvailablePage the only function that emits currentPageReady()
@ -768,7 +768,7 @@ void Render::createComic(const QString & path)
comic = FactoryComic::newComic(path);
if(comic == NULL)//archivo no encontrado o no v<EFBFBD>lido
if(comic == NULL)//archivo no encontrado o no válido
{
emit errorOpening();
reset();
@ -788,7 +788,6 @@ void Render::createComic(const QString & path)
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()));
@ -814,6 +813,9 @@ void Render::startLoad()
comic->moveToThread(thread);
connect(comic, SIGNAL(errorOpening()), thread, SLOT(quit()));
connect(comic, SIGNAL(errorOpening(QString)), thread, SLOT(quit()));
connect(comic, SIGNAL(imagesLoaded()), thread, SLOT(quit()));
connect(thread, SIGNAL(started()), comic, SLOT(process()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
@ -836,13 +838,13 @@ void Render::reset()
loadedComic = false;
invalidate();
}
//si se solicita la siguiente p<EFBFBD>gina, se calcula cu<EFBFBD>l debe ser en funci<EFBFBD>n de si se lee en modo a doble p<EFBFBD>gina o no.
//la p<EFBFBD>gina s<EFBFBD>lo se renderiza, si realmente ha cambiado.
//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.
void Render::nextPage()
{
int nextPage; //indica cu<EFBFBD>l ser<EFBFBD> la pr<EFBFBD>xima p<EFBFBD>gina
int nextPage; //indica cuál será la próxima página
nextPage = comic->nextPage();
//se fuerza renderizado si la p<EFBFBD>gina ha cambiado
//se fuerza renderizado si la página ha cambiado
if(currentIndex != nextPage)
{
previousIndex = currentIndex;
@ -880,14 +882,14 @@ void Render::nextDoublePage()
}
}
//si se solicita la p<EFBFBD>gina anterior, se calcula cu<EFBFBD>l debe ser en funci<EFBFBD>n de si se lee en modo a doble p<EFBFBD>gina o no.
//la p<EFBFBD>gina s<EFBFBD>lo se renderiza, si realmente ha cambiado.
//si se solicita la página anterior, 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.
void Render::previousPage()
{
int previousPage; //indica cu<EFBFBD>l ser<EFBFBD> la pr<EFBFBD>xima p<EFBFBD>gina
int previousPage; //indica cuál será la próxima página
previousPage = comic->previousPage();
//se fuerza renderizado si la p<EFBFBD>gina ha cambiado
//se fuerza renderizado si la página ha cambiado
if(currentIndex != previousPage)
{
previousIndex = currentIndex;
@ -903,7 +905,7 @@ void Render::previousPage()
void Render::previousDoublePage()
{
int previousPage; //indica cu<EFBFBD>l ser<EFBFBD> la pr<EFBFBD>xima p<EFBFBD>gina
int previousPage; //indica cuál será la próxima página
previousPage = qMax(currentIndex-2,0);
if(currentIndex != previousPage)
{
@ -965,7 +967,7 @@ void Render::pageRawDataReady(int page)
}
}
//s<EFBFBD>lo se renderiza la p<EFBFBD>gina, si ha habido un cambio de p<EFBFBD>gina
//sólo se renderiza la página, si ha habido un cambio de página
void Render::goTo(int index)
{
@ -993,9 +995,9 @@ void Render::rotateLeft()
reload();
}
//Actualiza el buffer, a<EFBFBD>adiendo las im<EFBFBD>genes (vac<EFBFBD>as) necesarias para su posterior renderizado y
//eliminado aquellas que ya no sean necesarias. Tambi<EFBFBD>n libera los hilos (no estoy seguro de que sea responsabilidad suya)
//Calcula el n<EFBFBD>mero de nuevas p<EFBFBD>ginas que hay que buferear y si debe hacerlo por la izquierda o la derecha (seg<EFBFBD>n sea el sentido de la lectura)
//Actualiza el buffer, añadiendo las imágenes (vacías) necesarias para su posterior renderizado y
//eliminado aquellas que ya no sean necesarias. También libera los hilos (no estoy seguro de que sea responsabilidad suya)
//Calcula el número de nuevas páginas que hay que buferear y si debe hacerlo por la izquierda o la derecha (según sea el sentido de la lectura)
void Render::updateBuffer()
{
QMutexLocker locker(&mutex);
@ -1081,8 +1083,8 @@ void Render::fillBuffer()
}
//M<EFBFBD>todo que debe ser llamado cada vez que la estructura del buffer se vuelve inconsistente con el modo de lectura actual.
//se terminan todos los hilos en ejecuci<EFBFBD>n y se libera la memoria (de hilos e im<EFBFBD>genes)
//Método que debe ser llamado cada vez que la estructura del buffer se vuelve inconsistente con el modo de lectura actual.
//se terminan todos los hilos en ejecución y se libera la memoria (de hilos e imágenes)
void Render::invalidate()
{
for(int i=0;i<pageRenders.size();i++)

View File

@ -18,6 +18,8 @@
#include "comic_db.h"
#include "shortcuts_manager.h"
#include "opengl_checker.h"
#include <QFile>
@ -72,10 +74,15 @@ shouldOpenPrevious(false)
//CONFIG GOTO_FLOW--------------------------------------------------------
#ifndef NO_OPENGL
if(!settings->contains(USE_OPEN_GL))
{
OpenGLChecker openGLChecker;
bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion();
if(openGLAvailable && !settings->contains(USE_OPEN_GL))
settings->setValue(USE_OPEN_GL,2);
}
else
if(!openGLAvailable)
settings->setValue(USE_OPEN_GL,0);
if((settings->value(USE_OPEN_GL).toBool() == true))
goToFlow = new GoToFlowGL(this,Configuration::getConfiguration().getFlowType());