mirror of
https://github.com/YACReader/yacreader
synced 2025-07-22 15:04:40 -04:00
Merged in selmf/yacreader (pull request #9)
Add support for double page suppression for spread pages and inverse reading order (aka manga mode) in double page mode
This commit is contained in:
@ -56,107 +56,3 @@ void Configuration::load(QSettings * settings)
|
|||||||
if(!settings->contains(SHOW_TOOLBARS))
|
if(!settings->contains(SHOW_TOOLBARS))
|
||||||
settings->setValue(SHOW_TOOLBARS, true);
|
settings->setValue(SHOW_TOOLBARS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::load(const QString & path)
|
|
||||||
{
|
|
||||||
//load default configuration
|
|
||||||
defaultPath = ".";
|
|
||||||
magnifyingGlassSize = QSize(350,175);
|
|
||||||
gotoSlideSize = QSize(126,200); //normal
|
|
||||||
//gotoSlideSize = QSize(79,125); //small
|
|
||||||
//gotoSlideSize = QSize(173,275); //big
|
|
||||||
//gotoSlideSize = QSize(220,350); //huge
|
|
||||||
zoomLevel = 0.5;
|
|
||||||
adjustToWidth = true;
|
|
||||||
flowType = Strip;
|
|
||||||
fullScreen = false;
|
|
||||||
fitToWidthRatio = 1;
|
|
||||||
windowSize = QSize(0,0);
|
|
||||||
maximized = false;
|
|
||||||
doublePage = false;
|
|
||||||
adjustToFullSize = false;
|
|
||||||
backgroundColor = QColor(40,40,40);
|
|
||||||
alwaysOnTop = false;
|
|
||||||
|
|
||||||
//load from file
|
|
||||||
QFile f(YACReader::getSettingsPath()+path);
|
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
QTextStream txtS(&f);
|
|
||||||
QString content = txtS.readAll();
|
|
||||||
QStringList lines = content.split('\n');
|
|
||||||
QString line,name;
|
|
||||||
int i=0;
|
|
||||||
foreach(line,lines)
|
|
||||||
{
|
|
||||||
if((i%2)==0)
|
|
||||||
{
|
|
||||||
name = line.trimmed();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(name==PATH)
|
|
||||||
defaultPath = line.trimmed();
|
|
||||||
else
|
|
||||||
if(name==MAG_GLASS_SIZE)
|
|
||||||
{
|
|
||||||
QStringList values = line.split(',');
|
|
||||||
magnifyingGlassSize = QSize(values[0].toInt(),values[1].toInt());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(name==ZOOM_LEVEL)
|
|
||||||
zoomLevel = line.toFloat();
|
|
||||||
else
|
|
||||||
if(name==SLIDE_SIZE)
|
|
||||||
{
|
|
||||||
int height = line.toInt();
|
|
||||||
gotoSlideSize = QSize(static_cast<int>(height/SLIDE_ASPECT_RATIO),height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(name==FIT)
|
|
||||||
adjustToWidth = line.toInt();
|
|
||||||
else
|
|
||||||
if(name==FLOW_TYPE)
|
|
||||||
flowType = (FlowType)line.toInt();
|
|
||||||
else
|
|
||||||
if(name==FULLSCREEN)
|
|
||||||
fullScreen = line.toInt();
|
|
||||||
else
|
|
||||||
if(name==FIT_TO_WIDTH_RATIO)
|
|
||||||
fitToWidthRatio = line.toFloat();
|
|
||||||
else
|
|
||||||
if(name==Y_WINDOW_POS)
|
|
||||||
{
|
|
||||||
QStringList l = line.split(',');
|
|
||||||
windowPos = QPoint(l[0].toInt(),l[1].toInt());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(name==Y_WINDOW_SIZE)
|
|
||||||
{
|
|
||||||
QStringList l = line.split(',');
|
|
||||||
windowSize = QSize(l[0].toInt(),l[1].toInt());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(name==MAXIMIZED)
|
|
||||||
maximized = line.toInt();
|
|
||||||
else
|
|
||||||
if(name==DOUBLE_PAGE)
|
|
||||||
doublePage = line.toInt();
|
|
||||||
else
|
|
||||||
if(name==ADJUST_TO_FULL_SIZE)
|
|
||||||
adjustToFullSize = line.toInt();
|
|
||||||
else
|
|
||||||
if(name==BACKGROUND_COLOR)
|
|
||||||
{
|
|
||||||
QStringList l = line.split(',');
|
|
||||||
backgroundColor = QColor(l[0].toInt(),l[1].toInt(),l[2].toInt());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(name==ALWAYS_ON_TOP)
|
|
||||||
alwaysOnTop = line.toInt();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -35,6 +35,7 @@ using namespace YACReader;
|
|||||||
QSize windowSize;
|
QSize windowSize;
|
||||||
bool maximized;
|
bool maximized;
|
||||||
bool doublePage;
|
bool doublePage;
|
||||||
|
bool doubleMangaPage;
|
||||||
bool alwaysOnTop;
|
bool alwaysOnTop;
|
||||||
bool adjustToFullSize;
|
bool adjustToFullSize;
|
||||||
QColor backgroundColor;
|
QColor backgroundColor;
|
||||||
@ -75,6 +76,8 @@ using namespace YACReader;
|
|||||||
void setMaximized(bool b){settings->setValue(MAXIMIZED,b);}
|
void setMaximized(bool b){settings->setValue(MAXIMIZED,b);}
|
||||||
bool getDoublePage(){return settings->value(DOUBLE_PAGE).toBool();}
|
bool getDoublePage(){return settings->value(DOUBLE_PAGE).toBool();}
|
||||||
void setDoublePage(bool b){settings->setValue(DOUBLE_PAGE,b);}
|
void setDoublePage(bool b){settings->setValue(DOUBLE_PAGE,b);}
|
||||||
|
bool getDoubleMangaPage(){return settings->value(DOUBLE_MANGA_PAGE).toBool();}
|
||||||
|
void setDoubleMangaPage(bool b){settings->setValue(DOUBLE_MANGA_PAGE,b);}
|
||||||
bool getAdjustToFullSize(){return settings->value(ADJUST_TO_FULL_SIZE).toBool();}
|
bool getAdjustToFullSize(){return settings->value(ADJUST_TO_FULL_SIZE).toBool();}
|
||||||
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);}
|
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);}
|
||||||
QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value<QColor>();}
|
QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value<QColor>();}
|
||||||
|
@ -94,6 +94,7 @@ MainWindowViewer::~MainWindowViewer()
|
|||||||
delete leftRotationAction;
|
delete leftRotationAction;
|
||||||
delete rightRotationAction;
|
delete rightRotationAction;
|
||||||
delete doublePageAction;
|
delete doublePageAction;
|
||||||
|
delete doubleMangaPageAction;
|
||||||
delete goToPageAction;
|
delete goToPageAction;
|
||||||
delete optionsAction;
|
delete optionsAction;
|
||||||
delete helpAboutAction;
|
delete helpAboutAction;
|
||||||
@ -302,6 +303,17 @@ void MainWindowViewer::createActions()
|
|||||||
doublePageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_PAGE_ACTION_Y));
|
doublePageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_PAGE_ACTION_Y));
|
||||||
connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch()));
|
connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch()));
|
||||||
|
|
||||||
|
//inversed pictures mode
|
||||||
|
doubleMangaPageAction = new QAction(tr("Double page manga mode"),this);
|
||||||
|
doubleMangaPageAction->setToolTip(tr("Reverse reading order in double page mode"));
|
||||||
|
doubleMangaPageAction->setIcon(QIcon(":/images/viewer_toolbar/doubleMangaPage.png"));
|
||||||
|
doubleMangaPageAction->setDisabled(true);
|
||||||
|
doubleMangaPageAction->setCheckable(true);
|
||||||
|
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
|
||||||
|
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
|
||||||
|
doubleMangaPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_MANGA_PAGE_ACTION_Y));
|
||||||
|
connect(doubleMangaPageAction, SIGNAL(triggered()),viewer,SLOT(doubleMangaPageSwitch()));
|
||||||
|
|
||||||
goToPageAction = new QAction(tr("Go To"),this);
|
goToPageAction = new QAction(tr("Go To"),this);
|
||||||
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
||||||
goToPageAction->setDisabled(true);
|
goToPageAction->setDisabled(true);
|
||||||
@ -506,6 +518,7 @@ void MainWindowViewer::createToolBars()
|
|||||||
comicToolBar->addAction(leftRotationAction);
|
comicToolBar->addAction(leftRotationAction);
|
||||||
comicToolBar->addAction(rightRotationAction);
|
comicToolBar->addAction(rightRotationAction);
|
||||||
comicToolBar->addAction(doublePageAction);
|
comicToolBar->addAction(doublePageAction);
|
||||||
|
comicToolBar->addAction(doubleMangaPageAction);
|
||||||
|
|
||||||
comicToolBar->addSeparator();
|
comicToolBar->addSeparator();
|
||||||
|
|
||||||
@ -785,6 +798,7 @@ void MainWindowViewer::enableActions()
|
|||||||
rightRotationAction->setDisabled(false);
|
rightRotationAction->setDisabled(false);
|
||||||
showMagnifyingGlassAction->setDisabled(false);
|
showMagnifyingGlassAction->setDisabled(false);
|
||||||
doublePageAction->setDisabled(false);
|
doublePageAction->setDisabled(false);
|
||||||
|
doubleMangaPageAction->setDisabled(false);
|
||||||
adjustToFullSizeAction->setDisabled(false);
|
adjustToFullSizeAction->setDisabled(false);
|
||||||
//setBookmark->setDisabled(false);
|
//setBookmark->setDisabled(false);
|
||||||
showBookmarksAction->setDisabled(false);
|
showBookmarksAction->setDisabled(false);
|
||||||
@ -805,6 +819,7 @@ void MainWindowViewer::disableActions()
|
|||||||
rightRotationAction->setDisabled(true);
|
rightRotationAction->setDisabled(true);
|
||||||
showMagnifyingGlassAction->setDisabled(true);
|
showMagnifyingGlassAction->setDisabled(true);
|
||||||
doublePageAction->setDisabled(true);
|
doublePageAction->setDisabled(true);
|
||||||
|
doubleMangaPageAction->setDisabled(true);
|
||||||
adjustToFullSizeAction->setDisabled(true);
|
adjustToFullSizeAction->setDisabled(true);
|
||||||
setBookmarkAction->setDisabled(true);
|
setBookmarkAction->setDisabled(true);
|
||||||
showBookmarksAction->setDisabled(true);
|
showBookmarksAction->setDisabled(true);
|
||||||
@ -1057,6 +1072,7 @@ void MainWindowViewer::setUpShortcutsManagement()
|
|||||||
<< leftRotationAction
|
<< leftRotationAction
|
||||||
<< rightRotationAction
|
<< rightRotationAction
|
||||||
<< doublePageAction
|
<< doublePageAction
|
||||||
|
<< doubleMangaPageAction
|
||||||
<< adjustToFullSizeAction);
|
<< adjustToFullSizeAction);
|
||||||
|
|
||||||
allActions << tmpList;
|
allActions << tmpList;
|
||||||
|
@ -108,6 +108,7 @@ class EditShortcutsDialog;
|
|||||||
QAction *showInfoAction;
|
QAction *showInfoAction;
|
||||||
QAction *closeAction;
|
QAction *closeAction;
|
||||||
QAction *doublePageAction;
|
QAction *doublePageAction;
|
||||||
|
QAction *doubleMangaPageAction;
|
||||||
QAction *showShorcutsAction;
|
QAction *showShorcutsAction;
|
||||||
QAction *showDictionaryAction;
|
QAction *showDictionaryAction;
|
||||||
QAction *alwaysOnTopAction;
|
QAction *alwaysOnTopAction;
|
||||||
|
@ -392,94 +392,12 @@ void PageRender::run()
|
|||||||
emit pageReady(numPage);
|
emit pageReady(numPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// DoublePageRender
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
DoublePageRender::DoublePageRender(Render * r, int np, const QByteArray & rd, const QByteArray & rd2, QImage * p,unsigned int d, QVector<ImageFilter *> f)
|
|
||||||
:PageRender(),
|
|
||||||
render(r),
|
|
||||||
numPage(np),
|
|
||||||
data(rd),
|
|
||||||
data2(rd2),
|
|
||||||
page(p),
|
|
||||||
degrees(d),
|
|
||||||
filters(f)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoublePageRender::run()
|
|
||||||
{
|
|
||||||
//QImage result;
|
|
||||||
QMutexLocker locker(&(render->mutex));
|
|
||||||
QImage img, img2;
|
|
||||||
if(!data.isEmpty())
|
|
||||||
img.loadFromData(data);
|
|
||||||
if(!data2.isEmpty())
|
|
||||||
img2.loadFromData(data2);
|
|
||||||
/*if(img.isNull())
|
|
||||||
img = QPixmap(img2.width(),img2.height());
|
|
||||||
if(img2.isNull())
|
|
||||||
img2 = QPixmap(img.width(),img.height());*/
|
|
||||||
|
|
||||||
if(img.isNull() && !img2.isNull())
|
|
||||||
{
|
|
||||||
img = img2;
|
|
||||||
img2 = QImage();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int totalWidth,totalHeight;
|
|
||||||
//x = img.width()+img2.width();
|
|
||||||
totalHeight = qMax(img.height(),img2.height());
|
|
||||||
|
|
||||||
//widths fiting the normalized height
|
|
||||||
int width1, width2;
|
|
||||||
|
|
||||||
//altura normalizada
|
|
||||||
if(!img2.isNull())
|
|
||||||
{
|
|
||||||
if(img.height()!=totalHeight)
|
|
||||||
totalWidth = (width1 = ((img.width() * totalHeight) / img.height())) + (width2 = img2.width());
|
|
||||||
else
|
|
||||||
totalWidth = (width1 = img.width()) + (width2 = ((img2.width() * totalHeight) / img2.height()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
totalWidth = width1 = img.width();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QImage auxImg(totalWidth,totalHeight,QImage::Format_RGB32);
|
|
||||||
QPainter painter(&auxImg);
|
|
||||||
painter.drawImage(QRect(0,0,width1,totalHeight),img);
|
|
||||||
if(!img2.isNull())
|
|
||||||
painter.drawImage(QRect(width1,0,width2,totalHeight),img2);
|
|
||||||
painter.end();
|
|
||||||
|
|
||||||
if(degrees > 0)
|
|
||||||
{
|
|
||||||
QMatrix m;
|
|
||||||
m.rotate(degrees);
|
|
||||||
auxImg = auxImg.transformed(m,Qt::SmoothTransformation);
|
|
||||||
}
|
|
||||||
for(int i=0;i<filters.size();i++)
|
|
||||||
{
|
|
||||||
auxImg = filters[i]->setFilter(auxImg);
|
|
||||||
}
|
|
||||||
|
|
||||||
*page = auxImg;
|
|
||||||
|
|
||||||
emit pageReady(numPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Render
|
// Render
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
Render::Render()
|
Render::Render()
|
||||||
:currentIndex(0),doublePage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(2),numRightPages(2)
|
:currentIndex(0),doublePage(false),doubleMangaPage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(4),numRightPages(4)
|
||||||
{
|
{
|
||||||
int size = numLeftPages+numRightPages+1;
|
int size = numLeftPages+numRightPages+1;
|
||||||
currentPageBufferedIndex = numLeftPages;
|
currentPageBufferedIndex = numLeftPages;
|
||||||
@ -522,20 +440,10 @@ void Render::render()
|
|||||||
{
|
{
|
||||||
if(pagesReady.size()>0)
|
if(pagesReady.size()>0)
|
||||||
{
|
{
|
||||||
if(doublePage)
|
|
||||||
{
|
|
||||||
if(pagesReady[currentIndex] && pagesReady[qMin(currentIndex+1,(int)comic->numPages()-1)])
|
|
||||||
if(currentIndex+1 > (int)comic->numPages()-1)
|
|
||||||
pageRenders[currentPageBufferedIndex] = new DoublePageRender(this,currentIndex,comic->getRawData()->at(currentIndex),QByteArray(),buffer[currentPageBufferedIndex],imageRotation,filters);
|
|
||||||
else
|
|
||||||
pageRenders[currentPageBufferedIndex] = new DoublePageRender(this,currentIndex,comic->getRawData()->at(currentIndex),comic->getRawData()->at(currentIndex+1),buffer[currentPageBufferedIndex],imageRotation,filters);
|
|
||||||
else
|
|
||||||
//las p<>ginas no est<73>n listas, y se est<73>n cargando en el c<>mic
|
|
||||||
emit processingPage(); //para evitar confusiones esta se<73>al deber<65>a llamarse de otra forma
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if(pagesReady[currentIndex])
|
if(pagesReady[currentIndex])
|
||||||
|
{
|
||||||
pageRenders[currentPageBufferedIndex] = new PageRender(this,currentIndex,comic->getRawData()->at(currentIndex),buffer[currentPageBufferedIndex],imageRotation,filters);
|
pageRenders[currentPageBufferedIndex] = new PageRender(this,currentIndex,comic->getRawData()->at(currentIndex),buffer[currentPageBufferedIndex],imageRotation,filters);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
//las p<>ginas no est<73>n listas, y se est<73>n cargando en el c<>mic
|
//las p<>ginas no est<73>n listas, y se est<73>n cargando en el c<>mic
|
||||||
emit processingPage(); //para evitar confusiones esta se<73>al deber<65>a llamarse de otra forma
|
emit processingPage(); //para evitar confusiones esta se<73>al deber<65>a llamarse de otra forma
|
||||||
@ -546,7 +454,7 @@ void Render::render()
|
|||||||
//se conecta la se<73>al pageReady del hilo, con el SLOT prepareAvailablePage
|
//se conecta la se<73>al pageReady del hilo, con el SLOT prepareAvailablePage
|
||||||
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
||||||
//se emite la se<73>al de procesando, debido a que los hilos se arrancan aqu<71>
|
//se emite la se<73>al de procesando, debido a que los hilos se arrancan aqu<71>
|
||||||
if(doublePage || filters.size()>0)
|
if(filters.size()>0)
|
||||||
emit processingPage();
|
emit processingPage();
|
||||||
pageRenders[currentPageBufferedIndex]->start();
|
pageRenders[currentPageBufferedIndex]->start();
|
||||||
pageRenders[currentPageBufferedIndex]->setPriority(QThread::TimeCriticalPriority);
|
pageRenders[currentPageBufferedIndex]->setPriority(QThread::TimeCriticalPriority);
|
||||||
@ -561,12 +469,11 @@ void Render::render()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
// la p<>gina actual est<73> lista
|
// la p<>gina actual est<73> lista
|
||||||
emit currentPageReady();
|
{
|
||||||
|
//emit currentPageReady();
|
||||||
//se renderizan las p<>ginas restantes para llenar el buffer.
|
//make prepareAvailablePage the only function that emits currentPageReady()
|
||||||
if(doublePage)
|
prepareAvailablePage(currentIndex);
|
||||||
fillBufferDoublePage();
|
}
|
||||||
else
|
|
||||||
fillBuffer();
|
fillBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -577,6 +484,190 @@ QPixmap * Render::getCurrentPage()
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap * Render::getCurrentDoublePage()
|
||||||
|
{
|
||||||
|
if (currentPageIsDoublePage())
|
||||||
|
{
|
||||||
|
QPoint leftpage(0,0);
|
||||||
|
QPoint rightpage(0,0);
|
||||||
|
QSize leftsize = buffer[currentPageBufferedIndex]->size();
|
||||||
|
QSize rightsize = buffer[currentPageBufferedIndex+1]->size();
|
||||||
|
int totalWidth,totalHeight;
|
||||||
|
switch (imageRotation)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
|
||||||
|
leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalWidth = leftsize.rwidth() + rightsize.rwidth();
|
||||||
|
rightpage.setX(leftsize.rwidth());
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
|
||||||
|
leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalHeight = leftsize.rheight() + rightsize.rheight();
|
||||||
|
rightpage.setY(leftsize.rheight());
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
|
||||||
|
leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalWidth = leftsize.rwidth() + rightsize.rwidth();
|
||||||
|
leftpage.setX(rightsize.rwidth());
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
|
||||||
|
leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalHeight = leftsize.rheight() + rightsize.rheight();
|
||||||
|
leftpage.setY(rightsize.rheight());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
QPixmap * page = new QPixmap(totalWidth, totalHeight);
|
||||||
|
QPainter painter(page);
|
||||||
|
painter.drawImage(QRect(leftpage,leftsize), *buffer[currentPageBufferedIndex]);
|
||||||
|
painter.drawImage(QRect(rightpage,rightsize), *buffer[currentPageBufferedIndex+1]);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap * Render::getCurrentDoubleMangaPage()
|
||||||
|
{
|
||||||
|
if (currentPageIsDoublePage())
|
||||||
|
{
|
||||||
|
QPoint leftpage(0,0);
|
||||||
|
QPoint rightpage(0,0);
|
||||||
|
QSize leftsize = buffer[currentPageBufferedIndex+1]->size();
|
||||||
|
QSize rightsize = buffer[currentPageBufferedIndex]->size();
|
||||||
|
int totalWidth,totalHeight;
|
||||||
|
switch (imageRotation)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
|
||||||
|
leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalWidth = leftsize.rwidth() + rightsize.rwidth();
|
||||||
|
rightpage.setX(leftsize.rwidth());
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
|
||||||
|
leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalHeight = leftsize.rheight() + rightsize.rheight();
|
||||||
|
rightpage.setY(leftsize.rheight());
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
totalHeight = qMax(leftsize.rheight(),rightsize.rheight());
|
||||||
|
leftsize.scale(leftsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(rightsize.rwidth(), totalHeight, Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalWidth = leftsize.rwidth() + rightsize.rwidth();
|
||||||
|
leftpage.setX(rightsize.rwidth());
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
totalWidth = qMax(leftsize.rwidth(), rightsize.rwidth());
|
||||||
|
leftsize.scale(totalWidth, leftsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
rightsize.scale(totalWidth, rightsize.rheight(), Qt::KeepAspectRatioByExpanding);
|
||||||
|
totalHeight = leftsize.rheight() + rightsize.rheight();
|
||||||
|
leftpage.setY(rightsize.rheight());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
QPixmap * page = new QPixmap(totalWidth, totalHeight);
|
||||||
|
QPainter painter(page);
|
||||||
|
painter.drawImage(QRect(rightpage, rightsize), *buffer[currentPageBufferedIndex]);
|
||||||
|
painter.drawImage(QRect(leftpage, leftsize), *buffer[currentPageBufferedIndex+1]);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Render::currentPageIsDoublePage()
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex]->isNull() || buffer[currentPageBufferedIndex+1]->isNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (imageRotation == 0 || imageRotation == 180)
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex]->height() > buffer[currentPageBufferedIndex]->width() &&
|
||||||
|
buffer[currentPageBufferedIndex+1]->height() > buffer[currentPageBufferedIndex+1]->width())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (imageRotation == 90 || imageRotation == 270)
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex]->width() > buffer[currentPageBufferedIndex]->height() &&
|
||||||
|
buffer[currentPageBufferedIndex+1]->width() > buffer[currentPageBufferedIndex+1]->height())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Render::nextPageIsDoublePage()
|
||||||
|
{
|
||||||
|
//this function is not used right now
|
||||||
|
if (buffer[currentPageBufferedIndex+2]->isNull() || buffer[currentPageBufferedIndex+3]->isNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (imageRotation == 0 || imageRotation == 180)
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex+2]->height() > buffer[currentPageBufferedIndex+2]->width() &&
|
||||||
|
buffer[currentPageBufferedIndex+3]->height() > buffer[currentPageBufferedIndex+3]->width())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (imageRotation == 90 || imageRotation == 270)
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex]->width() > buffer[currentPageBufferedIndex]->height() &&
|
||||||
|
buffer[currentPageBufferedIndex+1]->width() > buffer[currentPageBufferedIndex+1]->height())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Render::previousPageIsDoublePage()
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex-1]->isNull() || buffer[currentPageBufferedIndex-2]->isNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (imageRotation == 0 || imageRotation == 180)
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex-1]->height() > buffer[currentPageBufferedIndex-1]->width() &&
|
||||||
|
buffer[currentPageBufferedIndex-2]->height() > buffer[currentPageBufferedIndex-2]->width())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (imageRotation == 90 || imageRotation == 270)
|
||||||
|
{
|
||||||
|
if (buffer[currentPageBufferedIndex-1]->width() > buffer[currentPageBufferedIndex-1]->height() &&
|
||||||
|
buffer[currentPageBufferedIndex-2]->width() > buffer[currentPageBufferedIndex-2]->height())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Render::setRotation(int degrees)
|
void Render::setRotation(int degrees)
|
||||||
{
|
{
|
||||||
Q_UNUSED(degrees)
|
Q_UNUSED(degrees)
|
||||||
@ -595,8 +686,26 @@ void Render::setComic(Comic * c)
|
|||||||
|
|
||||||
void Render::prepareAvailablePage(int page)
|
void Render::prepareAvailablePage(int page)
|
||||||
{
|
{
|
||||||
if(currentIndex == page)
|
if(!doublePage)
|
||||||
|
{
|
||||||
|
if (currentIndex == page)
|
||||||
|
{
|
||||||
emit currentPageReady();
|
emit currentPageReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//check for last page in double page mode
|
||||||
|
if ((currentIndex == page) && (currentIndex + 1) >= (int)comic->numPages())
|
||||||
|
{
|
||||||
|
emit currentPageReady();
|
||||||
|
}
|
||||||
|
else if ((currentIndex == page && !buffer[currentPageBufferedIndex+1]->isNull()) ||
|
||||||
|
(currentIndex+1 == page && !buffer[currentPageBufferedIndex]->isNull()))
|
||||||
|
{
|
||||||
|
emit currentPageReady();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render::update()
|
void Render::update()
|
||||||
@ -731,21 +840,7 @@ void Render::reset()
|
|||||||
void Render::nextPage()
|
void Render::nextPage()
|
||||||
{
|
{
|
||||||
int nextPage; //indica cu<63>l ser<65> la pr<70>xima p<>gina
|
int nextPage; //indica cu<63>l ser<65> la pr<70>xima p<>gina
|
||||||
if(doublePage)
|
|
||||||
{
|
|
||||||
nextPage = currentIndex;
|
|
||||||
if(currentIndex+2<(int)comic->numPages())
|
|
||||||
{
|
|
||||||
nextPage = currentIndex+2;
|
|
||||||
if(currentIndex != nextPage)
|
|
||||||
comic->setIndex(nextPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nextPage = comic->nextPage();
|
nextPage = comic->nextPage();
|
||||||
}
|
|
||||||
|
|
||||||
//se fuerza renderizado si la p<>gina ha cambiado
|
//se fuerza renderizado si la p<>gina ha cambiado
|
||||||
if(currentIndex != nextPage)
|
if(currentIndex != nextPage)
|
||||||
{
|
{
|
||||||
@ -755,27 +850,41 @@ void Render::nextPage()
|
|||||||
emit pageChanged(currentIndex);
|
emit pageChanged(currentIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
emit isLast();
|
emit isLast();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
void Render::nextDoublePage()
|
||||||
|
{
|
||||||
|
int nextPage;
|
||||||
|
if (currentIndex +2 < (int)comic->numPages())
|
||||||
|
{
|
||||||
|
nextPage = currentIndex+2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nextPage = currentIndex;
|
||||||
|
}
|
||||||
|
if(currentIndex != nextPage)
|
||||||
|
{
|
||||||
|
comic->setIndex(nextPage);
|
||||||
|
previousIndex = currentIndex;
|
||||||
|
currentIndex = nextPage;
|
||||||
|
update();
|
||||||
|
emit pageChanged(currentIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit isLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//si se solicita la p<>gina anterior, se calcula cu<63>l debe ser en funci<63>n de si se lee en modo a doble p<>gina o no.
|
//si se solicita la p<>gina anterior, se calcula cu<63>l debe ser en funci<63>n de si se lee en modo a doble p<>gina o no.
|
||||||
//la p<>gina s<>lo se renderiza, si realmente ha cambiado.
|
//la p<>gina s<>lo se renderiza, si realmente ha cambiado.
|
||||||
void Render::previousPage()
|
void Render::previousPage()
|
||||||
{
|
{
|
||||||
int previousPage; //indica cu<63>l ser<65> la pr<70>xima p<>gina
|
int previousPage; //indica cu<63>l ser<65> la pr<70>xima p<>gina
|
||||||
if(doublePage)
|
|
||||||
{
|
|
||||||
if(currentIndex == 1)
|
|
||||||
invalidate();
|
|
||||||
previousPage = qMax(currentIndex-2,0);
|
|
||||||
if(currentIndex != previousPage)
|
|
||||||
{
|
|
||||||
comic->setIndex(previousPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
previousPage = comic->previousPage();
|
previousPage = comic->previousPage();
|
||||||
}
|
|
||||||
|
|
||||||
//se fuerza renderizado si la p<>gina ha cambiado
|
//se fuerza renderizado si la p<>gina ha cambiado
|
||||||
if(currentIndex != previousPage)
|
if(currentIndex != previousPage)
|
||||||
@ -786,8 +895,25 @@ void Render::previousPage()
|
|||||||
emit pageChanged(currentIndex);
|
emit pageChanged(currentIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
emit isCover();
|
emit isCover();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Render::previousDoublePage()
|
||||||
|
{
|
||||||
|
int previousPage; //indica cu<63>l ser<65> la pr<70>xima p<>gina
|
||||||
|
previousPage = qMax(currentIndex-2,0);
|
||||||
|
if(currentIndex != previousPage)
|
||||||
|
{
|
||||||
|
comic->setIndex(previousPage);
|
||||||
|
previousIndex = currentIndex;
|
||||||
|
currentIndex = previousPage;
|
||||||
|
update();
|
||||||
|
emit pageChanged(currentIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int Render::getIndex()
|
unsigned int Render::getIndex()
|
||||||
{
|
{
|
||||||
return comic->getIndex();
|
return comic->getIndex();
|
||||||
@ -819,18 +945,6 @@ void Render::pageRawDataReady(int page)
|
|||||||
pagesReady[pagesEmited.at(i)] = true;
|
pagesReady[pagesEmited.at(i)] = true;
|
||||||
if(pagesEmited.at(i) == currentIndex)
|
if(pagesEmited.at(i) == currentIndex)
|
||||||
update();
|
update();
|
||||||
|
|
||||||
if(doublePage)
|
|
||||||
{
|
|
||||||
if(pagesEmited.at(i)==currentIndex+1)
|
|
||||||
update();
|
|
||||||
|
|
||||||
if ( ((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex-2*numLeftPages)) ||
|
|
||||||
((pagesEmited.at(i) > currentIndex+1) && (pagesEmited.at(i) < currentIndex+1+2*numRightPages)) )
|
|
||||||
{
|
|
||||||
fillBufferDoublePage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex-numLeftPages)) ||
|
if ( ((pagesEmited.at(i) < currentIndex) && (pagesEmited.at(i) > currentIndex-numLeftPages)) ||
|
||||||
@ -853,12 +967,6 @@ void Render::goTo(int index)
|
|||||||
comic->setIndex(index);
|
comic->setIndex(index);
|
||||||
previousIndex = currentIndex;
|
previousIndex = currentIndex;
|
||||||
currentIndex = index;
|
currentIndex = index;
|
||||||
|
|
||||||
//si cambia la paridad de las p<>gina en modo a doble p<>gina, se rellena el buffer.
|
|
||||||
//esto solo deber<65>a orcurrir al llegar al principio o al final
|
|
||||||
if(doublePage && ((previousIndex - index) % 2)!=0)
|
|
||||||
invalidate();
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
emit pageChanged(currentIndex);
|
emit pageChanged(currentIndex);
|
||||||
}
|
}
|
||||||
@ -885,13 +993,7 @@ void Render::updateBuffer()
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
int windowSize = currentIndex - previousIndex;
|
int windowSize = currentIndex - previousIndex;
|
||||||
if(doublePage)
|
|
||||||
{
|
|
||||||
windowSize = windowSize/2;
|
|
||||||
if(currentIndex == 0 && windowSize == 0 && previousIndex == 1)
|
|
||||||
windowSize = -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
if(windowSize > 0)//add pages to right pages and remove on the left
|
if(windowSize > 0)//add pages to right pages and remove on the left
|
||||||
{
|
{
|
||||||
windowSize = qMin(windowSize,buffer.size());
|
windowSize = qMin(windowSize,buffer.size());
|
||||||
@ -951,10 +1053,10 @@ void Render::fillBuffer()
|
|||||||
buffer[currentPageBufferedIndex+i]->isNull() &&
|
buffer[currentPageBufferedIndex+i]->isNull() &&
|
||||||
i <= numRightPages &&
|
i <= numRightPages &&
|
||||||
pageRenders[currentPageBufferedIndex+i]==0 &&
|
pageRenders[currentPageBufferedIndex+i]==0 &&
|
||||||
pagesReady[currentIndex+1]) //preload next pages
|
pagesReady[currentIndex+i]) //preload next pages
|
||||||
{
|
{
|
||||||
pageRenders[currentPageBufferedIndex+i] = new PageRender(this,currentIndex+i,comic->getRawData()->at(currentIndex+i),buffer[currentPageBufferedIndex+i],imageRotation,filters);
|
pageRenders[currentPageBufferedIndex+i] = new PageRender(this,currentIndex+i,comic->getRawData()->at(currentIndex+i),buffer[currentPageBufferedIndex+i],imageRotation,filters);
|
||||||
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
connect(pageRenders[currentPageBufferedIndex+i],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
||||||
pageRenders[currentPageBufferedIndex+i]->start();
|
pageRenders[currentPageBufferedIndex+i]->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,48 +1064,15 @@ void Render::fillBuffer()
|
|||||||
buffer[currentPageBufferedIndex-i]->isNull() &&
|
buffer[currentPageBufferedIndex-i]->isNull() &&
|
||||||
i <= numLeftPages &&
|
i <= numLeftPages &&
|
||||||
pageRenders[currentPageBufferedIndex-i]==0 &&
|
pageRenders[currentPageBufferedIndex-i]==0 &&
|
||||||
pagesReady[currentIndex-1]) //preload previous pages
|
pagesReady[currentIndex-i]) //preload previous pages
|
||||||
{
|
{
|
||||||
pageRenders[currentPageBufferedIndex-i] = new PageRender(this,currentIndex-i,comic->getRawData()->at(currentIndex-i),buffer[currentPageBufferedIndex-i],imageRotation,filters);
|
pageRenders[currentPageBufferedIndex-i] = new PageRender(this,currentIndex-i,comic->getRawData()->at(currentIndex-i),buffer[currentPageBufferedIndex-i],imageRotation,filters);
|
||||||
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
connect(pageRenders[currentPageBufferedIndex-i],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
||||||
pageRenders[currentPageBufferedIndex-i]->start();
|
pageRenders[currentPageBufferedIndex-i]->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Render::fillBufferDoublePage()
|
|
||||||
{
|
|
||||||
for(int i = 1; i <= qMax(numLeftPages,numRightPages); i++)
|
|
||||||
{
|
|
||||||
if ((currentIndex+2*i < (int)comic->numPages()) &&
|
|
||||||
buffer[currentPageBufferedIndex+i]->isNull() &&
|
|
||||||
i <= numRightPages &&
|
|
||||||
pageRenders[currentPageBufferedIndex+i]==0 &&
|
|
||||||
(pagesReady[currentIndex+2*i] && pagesReady[qMin(currentIndex+(2*i)+1,(int)comic->numPages()-1)])) //preload next pages
|
|
||||||
{
|
|
||||||
if(currentIndex+(2*i)+1 > (int)comic->numPages()-1)
|
|
||||||
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(this,currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),QByteArray(),buffer[currentPageBufferedIndex+i],imageRotation,filters);
|
|
||||||
else
|
|
||||||
pageRenders[currentPageBufferedIndex+i] = new DoublePageRender(this,currentIndex+2*i,comic->getRawData()->at(currentIndex+(2*i)),comic->getRawData()->at(currentIndex+(2*i)+1),buffer[currentPageBufferedIndex+i],imageRotation,filters);
|
|
||||||
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
|
||||||
pageRenders[currentPageBufferedIndex+i]->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((currentIndex-2*i >= -1) &&
|
|
||||||
buffer[currentPageBufferedIndex-i]->isNull() &&
|
|
||||||
i <= numLeftPages &&
|
|
||||||
pageRenders[currentPageBufferedIndex-i]==0 &&
|
|
||||||
(pagesReady[qMax(currentIndex-2*i,0)] && pagesReady[qMin(currentIndex-(2*i)+1,(int)comic->numPages()-1)])) //preload previous pages
|
|
||||||
{
|
|
||||||
if(currentIndex-2*i == -1)
|
|
||||||
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(this,0,QByteArray(),comic->getRawData()->at(0),buffer[currentPageBufferedIndex-i],imageRotation,filters);
|
|
||||||
else
|
|
||||||
pageRenders[currentPageBufferedIndex-i] = new DoublePageRender(this,currentIndex-2*i,comic->getRawData()->at(currentIndex-(2*i)),comic->getRawData()->at(currentIndex-(2*i)+1),buffer[currentPageBufferedIndex-i],imageRotation,filters);
|
|
||||||
connect(pageRenders[currentPageBufferedIndex],SIGNAL(pageReady(int)),this,SLOT(prepareAvailablePage(int)));
|
|
||||||
pageRenders[currentPageBufferedIndex-i]->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//M<>todo que debe ser llamado cada vez que la estructura del buffer se vuelve inconsistente con el modo de lectura actual.
|
//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<63>n y se libera la memoria (de hilos e im<69>genes)
|
//se terminan todos los hilos en ejecuci<63>n y se libera la memoria (de hilos e im<69>genes)
|
||||||
@ -1031,7 +1100,17 @@ void Render::doublePageSwitch()
|
|||||||
doublePage = !doublePage;
|
doublePage = !doublePage;
|
||||||
if(comic)
|
if(comic)
|
||||||
{
|
{
|
||||||
invalidate();
|
//invalidate();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Render::doubleMangaPageSwitch()
|
||||||
|
{
|
||||||
|
doubleMangaPage = !doubleMangaPage;
|
||||||
|
if(comic&&doublePage)
|
||||||
|
{
|
||||||
|
//invalidate();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1040,7 +1119,15 @@ QString Render::getCurrentPagesInformation()
|
|||||||
{
|
{
|
||||||
QString s = QString::number(currentIndex+1);
|
QString s = QString::number(currentIndex+1);
|
||||||
if (doublePage && (currentIndex+1 < (int)comic->numPages()))
|
if (doublePage && (currentIndex+1 < (int)comic->numPages()))
|
||||||
|
{
|
||||||
|
if (currentPageIsDoublePage())
|
||||||
|
{
|
||||||
|
if (doubleMangaPage)
|
||||||
|
s = QString::number(currentIndex+2) + "-" + s;
|
||||||
|
else
|
||||||
s += "-"+QString::number(currentIndex+2);
|
s += "-"+QString::number(currentIndex+2);
|
||||||
|
}
|
||||||
|
}
|
||||||
s += "/"+QString::number(comic->numPages());
|
s += "/"+QString::number(comic->numPages());
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ signals:
|
|||||||
// RENDER
|
// RENDER
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class DoublePageRender : public PageRender
|
/*class DoublePageRender : public PageRender
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -113,7 +113,7 @@ signals:
|
|||||||
void pageReady(int);
|
void pageReady(int);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
class Render : public QObject {
|
class Render : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -124,8 +124,14 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void render();
|
void render();
|
||||||
QPixmap * getCurrentPage();
|
QPixmap * getCurrentPage();
|
||||||
|
QPixmap * getCurrentDoublePage();
|
||||||
|
QPixmap * getCurrentDoubleMangaPage();
|
||||||
|
bool currentPageIsDoublePage();
|
||||||
|
bool nextPageIsDoublePage();
|
||||||
|
bool previousPageIsDoublePage();
|
||||||
void goTo(int index);
|
void goTo(int index);
|
||||||
void doublePageSwitch();
|
void doublePageSwitch();
|
||||||
|
void doubleMangaPageSwitch();
|
||||||
void setRotation(int degrees);
|
void setRotation(int degrees);
|
||||||
void setComic(Comic * c);
|
void setComic(Comic * c);
|
||||||
void prepareAvailablePage(int page);
|
void prepareAvailablePage(int page);
|
||||||
@ -135,6 +141,8 @@ public slots:
|
|||||||
//--comic interface
|
//--comic interface
|
||||||
void nextPage();
|
void nextPage();
|
||||||
void previousPage();
|
void previousPage();
|
||||||
|
void nextDoublePage();
|
||||||
|
void previousDoublePage();
|
||||||
void load(const QString & path, const ComicDB & comic);
|
void load(const QString & path, const ComicDB & comic);
|
||||||
void load(const QString & path, int atPage);
|
void load(const QString & path, int atPage);
|
||||||
void createComic(const QString & path);
|
void createComic(const QString & path);
|
||||||
@ -148,7 +156,6 @@ public slots:
|
|||||||
bool hasLoadedComic();
|
bool hasLoadedComic();
|
||||||
void updateBuffer();
|
void updateBuffer();
|
||||||
void fillBuffer();
|
void fillBuffer();
|
||||||
void fillBufferDoublePage();
|
|
||||||
void invalidate();
|
void invalidate();
|
||||||
QString getCurrentPagesInformation();
|
QString getCurrentPagesInformation();
|
||||||
void setBookmark();
|
void setBookmark();
|
||||||
@ -182,6 +189,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
Comic * comic;
|
Comic * comic;
|
||||||
bool doublePage;
|
bool doublePage;
|
||||||
|
bool doubleMangaPage;
|
||||||
int previousIndex;
|
int previousIndex;
|
||||||
int currentIndex;
|
int currentIndex;
|
||||||
//QPixmap * currentPage;
|
//QPixmap * currentPage;
|
||||||
@ -201,8 +209,6 @@ private:
|
|||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
|
|
||||||
friend class PageRender;
|
friend class PageRender;
|
||||||
friend class DoublePageRender;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ fullscreen(false),
|
|||||||
information(false),
|
information(false),
|
||||||
adjustToWidthRatio(1),
|
adjustToWidthRatio(1),
|
||||||
doublePage(false),
|
doublePage(false),
|
||||||
|
doubleMangaPage(false),
|
||||||
wheelStop(false),
|
wheelStop(false),
|
||||||
direction(1),
|
direction(1),
|
||||||
restoreMagnifyingGlass(false),
|
restoreMagnifyingGlass(false),
|
||||||
@ -91,6 +92,9 @@ shouldOpenPrevious(false)
|
|||||||
if(Configuration::getConfiguration().getDoublePage())
|
if(Configuration::getConfiguration().getDoublePage())
|
||||||
doublePageSwitch();
|
doublePageSwitch();
|
||||||
|
|
||||||
|
if(Configuration::getConfiguration().getDoubleMangaPage())
|
||||||
|
doubleMangaPageSwitch();
|
||||||
|
|
||||||
createConnections();
|
createConnections();
|
||||||
|
|
||||||
hideCursorTimer->start(2500);
|
hideCursorTimer->start(2500);
|
||||||
@ -226,7 +230,14 @@ void Viewer::processCRCError(QString message)
|
|||||||
void Viewer::next()
|
void Viewer::next()
|
||||||
{
|
{
|
||||||
direction = 1;
|
direction = 1;
|
||||||
|
if (doublePage && render->currentPageIsDoublePage())
|
||||||
|
{
|
||||||
|
render->nextDoublePage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
render->nextPage();
|
render->nextPage();
|
||||||
|
}
|
||||||
updateInformation();
|
updateInformation();
|
||||||
shouldOpenPrevious = false;
|
shouldOpenPrevious = false;
|
||||||
}
|
}
|
||||||
@ -234,7 +245,14 @@ void Viewer::next()
|
|||||||
void Viewer::prev()
|
void Viewer::prev()
|
||||||
{
|
{
|
||||||
direction = -1;
|
direction = -1;
|
||||||
|
if (doublePage && render->previousPageIsDoublePage())
|
||||||
|
{
|
||||||
|
render->previousDoublePage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
render->previousPage();
|
render->previousPage();
|
||||||
|
}
|
||||||
updateInformation();
|
updateInformation();
|
||||||
shouldOpenNext = false;
|
shouldOpenNext = false;
|
||||||
}
|
}
|
||||||
@ -251,7 +269,23 @@ void Viewer::goTo(unsigned int page)
|
|||||||
void Viewer::updatePage()
|
void Viewer::updatePage()
|
||||||
{
|
{
|
||||||
QPixmap * previousPage = currentPage;
|
QPixmap * previousPage = currentPage;
|
||||||
|
if (doublePage)
|
||||||
|
{
|
||||||
|
if (!doubleMangaPage)
|
||||||
|
currentPage = render->getCurrentDoublePage();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentPage = render->getCurrentDoubleMangaPage();
|
||||||
|
}
|
||||||
|
if (currentPage == NULL)
|
||||||
|
{
|
||||||
currentPage = render->getCurrentPage();
|
currentPage = render->getCurrentPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentPage = render->getCurrentPage();
|
||||||
|
}
|
||||||
content->setPixmap(*currentPage);
|
content->setPixmap(*currentPage);
|
||||||
updateContentSize();
|
updateContentSize();
|
||||||
updateVerticalScrollBar();
|
updateVerticalScrollBar();
|
||||||
@ -692,6 +726,13 @@ void Viewer::doublePageSwitch()
|
|||||||
Configuration::getConfiguration().setDoublePage(doublePage);
|
Configuration::getConfiguration().setDoublePage(doublePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewer::doubleMangaPageSwitch()
|
||||||
|
{
|
||||||
|
doubleMangaPage = !doubleMangaPage;
|
||||||
|
render->doubleMangaPageSwitch();
|
||||||
|
Configuration::getConfiguration().setDoubleMangaPage(doubleMangaPage);
|
||||||
|
}
|
||||||
|
|
||||||
void Viewer::resetContent()
|
void Viewer::resetContent()
|
||||||
{
|
{
|
||||||
configureContent(tr("Press 'O' to open comic."));
|
configureContent(tr("Press 'O' to open comic."));
|
||||||
|
@ -64,6 +64,7 @@ class NotificationsLabelWidget;
|
|||||||
void setBookmark(bool);
|
void setBookmark(bool);
|
||||||
void save();
|
void save();
|
||||||
void doublePageSwitch();
|
void doublePageSwitch();
|
||||||
|
void doubleMangaPageSwitch();
|
||||||
void resetContent();
|
void resetContent();
|
||||||
void setLoadingMessage();
|
void setLoadingMessage();
|
||||||
void setPageUnavailableMessage();
|
void setPageUnavailableMessage();
|
||||||
@ -93,6 +94,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
|||||||
private:
|
private:
|
||||||
bool information;
|
bool information;
|
||||||
bool doublePage;
|
bool doublePage;
|
||||||
|
bool doubleMangaPage;
|
||||||
PageLabelWidget * informationLabel;
|
PageLabelWidget * informationLabel;
|
||||||
//QTimer * scroller;
|
//QTimer * scroller;
|
||||||
QPropertyAnimation * verticalScroller;
|
QPropertyAnimation * verticalScroller;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<file>../images/viewer_toolbar/bookmark.png</file>
|
<file>../images/viewer_toolbar/bookmark.png</file>
|
||||||
<file>../images/viewer_toolbar/close.png</file>
|
<file>../images/viewer_toolbar/close.png</file>
|
||||||
<file>../images/viewer_toolbar/doublePage.png</file>
|
<file>../images/viewer_toolbar/doublePage.png</file>
|
||||||
|
<file>../images/viewer_toolbar/doubleMangaPage.png</file>
|
||||||
<file>../images/viewer_toolbar/flow.png</file>
|
<file>../images/viewer_toolbar/flow.png</file>
|
||||||
<file>../images/viewer_toolbar/full.png</file>
|
<file>../images/viewer_toolbar/full.png</file>
|
||||||
<file>../images/viewer_toolbar/goto.png</file>
|
<file>../images/viewer_toolbar/goto.png</file>
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#define Y_WINDOW_SIZE "SIZE"
|
#define Y_WINDOW_SIZE "SIZE"
|
||||||
#define MAXIMIZED "MAXIMIZED"
|
#define MAXIMIZED "MAXIMIZED"
|
||||||
#define DOUBLE_PAGE "DOUBLE_PAGE"
|
#define DOUBLE_PAGE "DOUBLE_PAGE"
|
||||||
|
#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE"
|
||||||
#define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE"
|
#define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE"
|
||||||
#define BACKGROUND_COLOR "BACKGROUND_COLOR"
|
#define BACKGROUND_COLOR "BACKGROUND_COLOR"
|
||||||
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
|
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
|
||||||
|
BIN
images/viewer_toolbar/doubleMangaPage.png
Normal file
BIN
images/viewer_toolbar/doubleMangaPage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 514 B |
@ -39,6 +39,7 @@ void ShortcutsManager::initDefaultShorcuts()
|
|||||||
defaultShorcuts.insert(LEFT_ROTATION_ACTION_Y, Qt::Key_L);
|
defaultShorcuts.insert(LEFT_ROTATION_ACTION_Y, Qt::Key_L);
|
||||||
defaultShorcuts.insert(RIGHT_ROTATION_ACTION_Y, Qt::Key_R);
|
defaultShorcuts.insert(RIGHT_ROTATION_ACTION_Y, Qt::Key_R);
|
||||||
defaultShorcuts.insert(DOUBLE_PAGE_ACTION_Y, Qt::Key_D);
|
defaultShorcuts.insert(DOUBLE_PAGE_ACTION_Y, Qt::Key_D);
|
||||||
|
defaultShorcuts.insert(DOUBLE_MANGA_PAGE_ACTION_Y, Qt::Key_J);
|
||||||
defaultShorcuts.insert(GO_TO_PAGE_ACTION_Y, Qt::Key_G);
|
defaultShorcuts.insert(GO_TO_PAGE_ACTION_Y, Qt::Key_G);
|
||||||
defaultShorcuts.insert(OPTIONS_ACTION_Y, Qt::Key_C);
|
defaultShorcuts.insert(OPTIONS_ACTION_Y, Qt::Key_C);
|
||||||
defaultShorcuts.insert(HELP_ABOUT_ACTION_Y, Qt::Key_F1);
|
defaultShorcuts.insert(HELP_ABOUT_ACTION_Y, Qt::Key_F1);
|
||||||
|
@ -94,6 +94,7 @@ public:
|
|||||||
#define LEFT_ROTATION_ACTION_Y "LEFT_ROTATION_ACTION_Y"
|
#define LEFT_ROTATION_ACTION_Y "LEFT_ROTATION_ACTION_Y"
|
||||||
#define RIGHT_ROTATION_ACTION_Y "RIGHT_ROTATION_ACTION_Y"
|
#define RIGHT_ROTATION_ACTION_Y "RIGHT_ROTATION_ACTION_Y"
|
||||||
#define DOUBLE_PAGE_ACTION_Y "DOUBLE_PAGE_ACTION_Y"
|
#define DOUBLE_PAGE_ACTION_Y "DOUBLE_PAGE_ACTION_Y"
|
||||||
|
#define DOUBLE_MANGA_PAGE_ACTION_Y "DOUBLE_MANGA_PAGE_ACTION_Y"
|
||||||
#define GO_TO_PAGE_ACTION_Y "GO_TO_PAGE_ACTION_Y"
|
#define GO_TO_PAGE_ACTION_Y "GO_TO_PAGE_ACTION_Y"
|
||||||
#define OPTIONS_ACTION_Y "OPTIONS_ACTION_Y"
|
#define OPTIONS_ACTION_Y "OPTIONS_ACTION_Y"
|
||||||
#define HELP_ABOUT_ACTION_Y "HELP_ABOUT_ACTION_Y"
|
#define HELP_ABOUT_ACTION_Y "HELP_ABOUT_ACTION_Y"
|
||||||
|
Reference in New Issue
Block a user