mirror of
https://github.com/YACReader/yacreader
synced 2025-07-23 07:24:58 -04:00
Merged luisangelsm/yacreader into default
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
#include "comic.h"
|
||||
#include "comic.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QRegExp>
|
||||
@ -18,9 +18,13 @@
|
||||
const QStringList Comic::imageExtensions = QStringList() << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" << "*.webp";
|
||||
const QStringList Comic::literalImageExtensions = QStringList() << "jpg" << "jpeg" << "png" << "gif" << "tiff" << "tif" << "bmp" << "webp";
|
||||
|
||||
#ifndef use_unarr
|
||||
const QStringList Comic::comicExtensions = QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.7z" << "*.cb7" << "*.arj" << "*.cbt";
|
||||
const QStringList Comic::literalComicExtensions = QStringList() << "cbr" << "cbz" << "rar" << "zip" << "tar" << "pdf" << "7z" << "cb7" << "arj" << "cbt";
|
||||
|
||||
#else
|
||||
const QStringList Comic::comicExtensions = QStringList() << "*.cbr" << "*.cbz" << "*.rar" << "*.zip" << "*.tar" << "*.pdf" << "*.cbt";
|
||||
const QStringList Comic::literalComicExtensions = QStringList() << "cbr" << "cbz" << "rar" << "zip" << "tar" << "pdf" << "cbt";
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
Comic::Comic()
|
||||
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
|
||||
@ -305,6 +309,7 @@ bool FileComic::load(const QString & path, const ComicDB & comic)
|
||||
else
|
||||
{
|
||||
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
@ -471,12 +476,14 @@ void FileComic::process()
|
||||
CompressedArchive archive(_path);
|
||||
if(!archive.toolsLoaded())
|
||||
{
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening(tr("7z not found"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!archive.isValid())
|
||||
{
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening(tr("Format not supported"));
|
||||
return;
|
||||
}
|
||||
@ -488,6 +495,7 @@ void FileComic::process()
|
||||
if(_fileNames.size()==0)
|
||||
{
|
||||
//QMessageBox::critical(NULL,tr("File error"),tr("File not found or not images in file"));
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return;
|
||||
}
|
||||
@ -507,6 +515,10 @@ void FileComic::process()
|
||||
|
||||
if(_firstPage == -1)
|
||||
_firstPage = bm->getLastPage();
|
||||
|
||||
if(_firstPage >= _pages.length())
|
||||
_firstPage = 0;
|
||||
|
||||
_index = _firstPage;
|
||||
emit(openAt(_index));
|
||||
|
||||
@ -527,9 +539,8 @@ void FileComic::process()
|
||||
emit imageLoaded(sortedIndex);
|
||||
emit imageLoaded(sortedIndex,_pages[sortedIndex]);
|
||||
}*/
|
||||
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit imagesLoaded();
|
||||
//moveToThread(QApplication::instance()->thread());
|
||||
}
|
||||
|
||||
|
||||
@ -587,6 +598,7 @@ void FolderComic::process()
|
||||
{
|
||||
//TODO emitir este mensaje en otro sitio
|
||||
//QMessageBox::critical(NULL,QObject::tr("No images found"),QObject::tr("There are not images on the selected folder"));
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
}
|
||||
else
|
||||
@ -594,6 +606,9 @@ void FolderComic::process()
|
||||
if(_firstPage == -1)
|
||||
_firstPage = bm->getLastPage();
|
||||
|
||||
if(_firstPage >= _pages.length())
|
||||
_firstPage = 0;
|
||||
|
||||
_index = _firstPage;
|
||||
|
||||
emit(openAt(_index));
|
||||
@ -617,8 +632,8 @@ void FolderComic::process()
|
||||
count++;
|
||||
}
|
||||
}
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit imagesLoaded();
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -660,6 +675,7 @@ bool PDFComic::load(const QString & path, int atPage)
|
||||
}
|
||||
else
|
||||
{
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
@ -682,6 +698,7 @@ bool PDFComic::load(const QString & path, const ComicDB & comic)
|
||||
else
|
||||
{
|
||||
//QMessageBox::critical(NULL,tr("Not found"),tr("Comic not found")+" : " + path);
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return false;
|
||||
}
|
||||
@ -705,11 +722,13 @@ void PDFComic::process()
|
||||
{
|
||||
//delete pdfComic;
|
||||
//pdfComic = 0;
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return;
|
||||
}
|
||||
if (pdfComic->isLocked())
|
||||
{
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit errorOpening();
|
||||
return;
|
||||
}
|
||||
@ -730,6 +749,10 @@ void PDFComic::process()
|
||||
|
||||
if(_firstPage == -1)
|
||||
_firstPage = bm->getLastPage();
|
||||
|
||||
if(_firstPage >= _pages.length())
|
||||
_firstPage = 0;
|
||||
|
||||
_index = _firstPage;
|
||||
emit(openAt(_index));
|
||||
|
||||
@ -741,8 +764,8 @@ void PDFComic::process()
|
||||
renderPage(i);
|
||||
|
||||
delete pdfComic;
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
emit imagesLoaded();
|
||||
moveToThread(QApplication::instance()->thread());
|
||||
}
|
||||
|
||||
void PDFComic::renderPage(int page)
|
||||
|
@ -355,7 +355,8 @@ void YACReaderFlowGL::paintGL()
|
||||
|
||||
void YACReaderFlowGL::resizeGL(int width, int height)
|
||||
{
|
||||
fontSize = (width + height) * 0.010;
|
||||
float pixelRatio = devicePixelRatio();
|
||||
fontSize = (width + height) * 0.010 * pixelRatio;
|
||||
if(fontSize < 10)
|
||||
fontSize = 10;
|
||||
|
||||
@ -368,12 +369,13 @@ void YACReaderFlowGL::resizeGL(int width, int height)
|
||||
|
||||
void YACReaderFlowGL::udpatePerspective(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
float pixelRatio = devicePixelRatio();
|
||||
glViewport(0, 0, width*pixelRatio, height*pixelRatio);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
gluPerspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0);
|
||||
gluPerspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
@ -384,7 +386,7 @@ void YACReaderFlowGL::calcPos(YACReader3DImage & image, int pos)
|
||||
{
|
||||
if(pos == 0){
|
||||
image.current = centerPos;
|
||||
}else{
|
||||
}else{
|
||||
if(pos > 0){
|
||||
image.current.x = (config.centerDistance)+(config.xDistance*pos);
|
||||
image.current.y = config.yDistance*pos*-1;
|
||||
@ -804,6 +806,8 @@ void YACReaderFlowGL::populate(int n)
|
||||
|
||||
void YACReaderFlowGL::reset()
|
||||
{
|
||||
makeCurrent();
|
||||
|
||||
startAnimationTimer();
|
||||
|
||||
currentSelected = 0;
|
||||
@ -819,6 +823,8 @@ void YACReaderFlowGL::reset()
|
||||
|
||||
if(!hasBeenInitialized)
|
||||
lazyPopulateObjects = -1;
|
||||
|
||||
doneCurrent();
|
||||
}
|
||||
|
||||
void YACReaderFlowGL::reload()
|
||||
@ -1101,8 +1107,9 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
float x,y;
|
||||
x = event->x();
|
||||
y = event->y();
|
||||
float pixelRatio = devicePixelRatio();
|
||||
x = event->x()*pixelRatio;
|
||||
y = event->y()*pixelRatio;
|
||||
GLint viewport[4];
|
||||
GLdouble modelview[16];
|
||||
GLdouble projection[16];
|
||||
@ -1139,8 +1146,9 @@ void YACReaderFlowGL::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
makeCurrent();
|
||||
float x,y;
|
||||
x = event->x();
|
||||
y = event->y();
|
||||
float pixelRatio = devicePixelRatio();
|
||||
x = event->x()*pixelRatio;
|
||||
y = event->y()*pixelRatio;
|
||||
GLint viewport[4];
|
||||
GLdouble modelview[16];
|
||||
GLdouble projection[16];
|
||||
@ -1269,6 +1277,8 @@ void YACReaderComicFlowGL::updateImageData()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] indexes;
|
||||
}
|
||||
|
||||
void YACReaderComicFlowGL::remove(int item)
|
||||
@ -1405,6 +1415,8 @@ void YACReaderPageFlowGL::updateImageData()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] indexes;
|
||||
}
|
||||
|
||||
void YACReaderPageFlowGL::populate(int n)
|
||||
|
@ -238,10 +238,10 @@ YACReaderFlowGL::YACReaderFlowGL(QWidget *parent,struct Preset p)
|
||||
|
||||
loaderThread->start();*/
|
||||
|
||||
QGLFormat f = format();
|
||||
/*QGLFormat f = format();
|
||||
f.setVersion(2, 1);
|
||||
f.setSwapInterval(0);
|
||||
setFormat(f);
|
||||
f.setSwapInterval(0);
|
||||
setFormat(f);*/
|
||||
|
||||
timerId = startTimer(updateInterval);
|
||||
|
||||
@ -325,8 +325,8 @@ void YACReaderFlowGL::paintGL()
|
||||
|
||||
void YACReaderFlowGL::resizeGL(int width, int height)
|
||||
{
|
||||
|
||||
fontSize = (width + height) * 0.010;
|
||||
float pixelRatio = devicePixelRatio();
|
||||
fontSize = (width + height) * 0.010 * pixelRatio;
|
||||
if(fontSize < 10)
|
||||
fontSize = 10;
|
||||
|
||||
@ -339,7 +339,8 @@ void YACReaderFlowGL::resizeGL(int width, int height)
|
||||
|
||||
void YACReaderFlowGL::udpatePerspective(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
float pixelRatio = devicePixelRatio();
|
||||
glViewport(0, 0, width*pixelRatio, height*pixelRatio);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
@ -938,26 +939,25 @@ void YACReaderFlowGL::setPerformance(Performance performance)
|
||||
}
|
||||
|
||||
void YACReaderFlowGL::useVSync(bool b)
|
||||
{
|
||||
if(bUseVSync != b)
|
||||
{/*if(bUseVSync != b)
|
||||
{
|
||||
bUseVSync = b;
|
||||
if(b)
|
||||
{
|
||||
QGLFormat f = format();
|
||||
f.setVersion(2, 1);
|
||||
//f.setVersion(2, 1);
|
||||
f.setSwapInterval(1);
|
||||
setFormat(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
QGLFormat f = format();
|
||||
f.setVersion(2, 1);
|
||||
//f.setVersion(2, 1);
|
||||
f.setSwapInterval(0);
|
||||
setFormat(f);
|
||||
}
|
||||
reset();
|
||||
}
|
||||
reset();
|
||||
}*/
|
||||
}
|
||||
void YACReaderFlowGL::setShowMarks(bool value)
|
||||
{
|
||||
@ -1079,8 +1079,9 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
float x,y;
|
||||
x = event->x();
|
||||
y = event->y();
|
||||
float pixelRatio = devicePixelRatio();
|
||||
x = event->x()*pixelRatio;
|
||||
y = event->y()*pixelRatio;
|
||||
GLint viewport[4];
|
||||
GLdouble modelview[16];
|
||||
GLdouble projection[16];
|
||||
@ -1114,8 +1115,9 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event)
|
||||
void YACReaderFlowGL::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
float x,y;
|
||||
x = event->x();
|
||||
y = event->y();
|
||||
float pixelRatio = devicePixelRatio();
|
||||
x = event->x()*pixelRatio;
|
||||
y = event->y()*pixelRatio;
|
||||
GLint viewport[4];
|
||||
GLdouble modelview[16];
|
||||
GLdouble projection[16];
|
||||
@ -1243,6 +1245,7 @@ void YACReaderComicFlowGL::updateImageData()
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete[] indexes;
|
||||
}
|
||||
|
||||
void YACReaderComicFlowGL::remove(int item)
|
||||
@ -1369,6 +1372,7 @@ void YACReaderPageFlowGL::updateImageData()
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete[] indexes;
|
||||
}
|
||||
|
||||
void YACReaderPageFlowGL::populate(int n)
|
||||
|
69
common/opengl_checker.cpp
Normal file
69
common/opengl_checker.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "opengl_checker.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
OpenGLChecker::OpenGLChecker()
|
||||
:compatibleOpenGLVersion(true)
|
||||
{
|
||||
QOpenGLContext * openGLContext = new QOpenGLContext();
|
||||
openGLContext->create();
|
||||
|
||||
if(!openGLContext->isValid())
|
||||
{
|
||||
compatibleOpenGLVersion = false;
|
||||
description = "unable to create QOpenGLContext";
|
||||
}
|
||||
|
||||
QSurfaceFormat format = openGLContext->format();
|
||||
|
||||
int majorVersion = format.majorVersion();
|
||||
int minorVersion = format.minorVersion();
|
||||
QString type;
|
||||
|
||||
switch (format.renderableType()) {
|
||||
case QSurfaceFormat::OpenGL:
|
||||
type = "desktop";
|
||||
break;
|
||||
|
||||
case QSurfaceFormat::OpenGLES:
|
||||
type = "OpenGL ES";
|
||||
break;
|
||||
|
||||
case QSurfaceFormat::OpenVG:
|
||||
type = "OpenVG";
|
||||
|
||||
default: case QSurfaceFormat::DefaultRenderableType:
|
||||
type = "unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
delete openGLContext;
|
||||
|
||||
description = QString("%1.%2 %3").arg(majorVersion).arg(minorVersion).arg(type);
|
||||
|
||||
if(format.renderableType() != QSurfaceFormat::OpenGL) //Desktop OpenGL
|
||||
compatibleOpenGLVersion = false;
|
||||
|
||||
#ifdef Q_OS_WIN //TODO check Qt version, and set this values depending on the use of QOpenGLWidget or QGLWidget
|
||||
static const int majorTargetVersion = 1;
|
||||
static const int minorTargetVersion = 4;
|
||||
#else
|
||||
static const int majorTargetVersion = 2;
|
||||
static const int minorTargetVersion = 0;
|
||||
#endif
|
||||
|
||||
if(majorVersion < majorTargetVersion)
|
||||
compatibleOpenGLVersion = false;
|
||||
if(majorVersion == majorTargetVersion && minorVersion < minorTargetVersion)
|
||||
compatibleOpenGLVersion = false;
|
||||
}
|
||||
|
||||
QString OpenGLChecker::textVersionDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
bool OpenGLChecker::hasCompatibleOpenGLVersion()
|
||||
{
|
||||
return compatibleOpenGLVersion;
|
||||
}
|
17
common/opengl_checker.h
Normal file
17
common/opengl_checker.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef OPENGL_CHECKER_H
|
||||
#define OPENGL_CHECKER_H
|
||||
|
||||
#include <QOpenGLContext>
|
||||
|
||||
class OpenGLChecker
|
||||
{
|
||||
public:
|
||||
OpenGLChecker();
|
||||
bool hasCompatibleOpenGLVersion();
|
||||
QString textVersionDescription();
|
||||
private:
|
||||
QString description;
|
||||
bool compatibleOpenGLVersion;
|
||||
};
|
||||
|
||||
#endif // OPENGL_CHECKER_H
|
Reference in New Issue
Block a user