This commit is contained in:
Felix Kauselmann 2014-06-29 21:39:53 +02:00
commit f514b8d00e
11 changed files with 129 additions and 65 deletions

View File

@ -74,6 +74,7 @@ void Configuration::load(const QString & path)
windowSize = QSize(0,0); windowSize = QSize(0,0);
maximized = false; maximized = false;
doublePage = false; doublePage = false;
doubleMangaPage = false;
adjustToFullSize = false; adjustToFullSize = false;
backgroundColor = QColor(40,40,40); backgroundColor = QColor(40,40,40);
alwaysOnTop = false; alwaysOnTop = false;
@ -95,65 +96,74 @@ void Configuration::load(const QString & path)
else else
{ {
if(name==PATH) if(name==PATH)
{
defaultPath = line.trimmed(); defaultPath = line.trimmed();
else }
if(name==MAG_GLASS_SIZE) if(name==MAG_GLASS_SIZE)
{ {
QStringList values = line.split(','); QStringList values = line.split(',');
magnifyingGlassSize = QSize(values[0].toInt(),values[1].toInt()); magnifyingGlassSize = QSize(values[0].toInt(),values[1].toInt());
} }
else if(name==ZOOM_LEVEL)
if(name==ZOOM_LEVEL) {
zoomLevel = line.toFloat(); zoomLevel = line.toFloat();
else }
if(name==SLIDE_SIZE) if(name==SLIDE_SIZE)
{ {
int height = line.toInt(); int height = line.toInt();
gotoSlideSize = QSize(static_cast<int>(height/SLIDE_ASPECT_RATIO),height); gotoSlideSize = QSize(static_cast<int>(height/SLIDE_ASPECT_RATIO),height);
} }
else if(name==FIT)
if(name==FIT) {
adjustToWidth = line.toInt(); adjustToWidth = line.toInt();
else }
if(name==FLOW_TYPE) if(name==FLOW_TYPE)
flowType = (FlowType)line.toInt(); {
else flowType = (FlowType)line.toInt();
if(name==FULLSCREEN) }
fullScreen = line.toInt(); if(name==FULLSCREEN)
else {
if(name==FIT_TO_WIDTH_RATIO) fullScreen = line.toInt();
fitToWidthRatio = line.toFloat(); }
else if(name==FIT_TO_WIDTH_RATIO)
if(name==Y_WINDOW_POS) {
{ fitToWidthRatio = line.toFloat();
QStringList l = line.split(','); }
windowPos = QPoint(l[0].toInt(),l[1].toInt()); if(name==Y_WINDOW_POS)
} {
else QStringList l = line.split(',');
if(name==Y_WINDOW_SIZE) windowPos = QPoint(l[0].toInt(),l[1].toInt());
{ }
QStringList l = line.split(','); if(name==Y_WINDOW_SIZE)
windowSize = QSize(l[0].toInt(),l[1].toInt()); {
} QStringList l = line.split(',');
else windowSize = QSize(l[0].toInt(),l[1].toInt());
if(name==MAXIMIZED) }
maximized = line.toInt(); if(name==MAXIMIZED)
else {
if(name==DOUBLE_PAGE) maximized = line.toInt();
doublePage = line.toInt(); }
else if(name==DOUBLE_PAGE)
if(name==ADJUST_TO_FULL_SIZE) {
adjustToFullSize = line.toInt(); doublePage = line.toInt();
else }
if(name==BACKGROUND_COLOR) if(name==DOUBLE_MANGA_PAGE)
{ {
QStringList l = line.split(','); doubleMangaPage = line.toInt();
backgroundColor = QColor(l[0].toInt(),l[1].toInt(),l[2].toInt()); }
} if(name==ADJUST_TO_FULL_SIZE)
else {
if(name==ALWAYS_ON_TOP) adjustToFullSize = line.toInt();
alwaysOnTop = line.toInt(); }
if(name==BACKGROUND_COLOR)
{
QStringList l = line.split(',');
backgroundColor = QColor(l[0].toInt(),l[1].toInt(),l[2].toInt());
}
if(name==ALWAYS_ON_TOP)
{
alwaysOnTop = line.toInt();
}
} }

View File

@ -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>();}

View File

@ -92,6 +92,7 @@ MainWindowViewer::~MainWindowViewer()
delete leftRotationAction; delete leftRotationAction;
delete rightRotationAction; delete rightRotationAction;
delete doublePageAction; delete doublePageAction;
delete doubleMangaPageAction;
delete goToPage; delete goToPage;
delete optionsAction; delete optionsAction;
delete helpAboutAction; delete helpAboutAction;
@ -326,7 +327,20 @@ void MainWindowViewer::createActions()
doublePageAction->setCheckable(true); doublePageAction->setCheckable(true);
doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage()); doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch())); connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch()));
//tests for inversed mode!
doubleMangaPageAction = new QAction(tr("Double page manga mode"),this);
doubleMangaPageAction->setToolTip(tr("Reverse reading order in double page mode"));
//TODO: Find a good shortcut for this
//doubleMangaPageAction->setShortcut(tr("M"));
doubleMangaPageAction->setIcon(QIcon(":/images/viewer_toolbar/doubleMangaPage.png"));
doubleMangaPageAction->setDisabled(true);
doubleMangaPageAction->setCheckable(true);
//TODO: Configuration?
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
connect(doubleMangaPageAction, SIGNAL(triggered()),viewer,SLOT(doubleMangaPageSwitch()));
//
goToPage = new QAction(tr("Go To"),this); goToPage = new QAction(tr("Go To"),this);
goToPage->setShortcut(tr("G")); goToPage->setShortcut(tr("G"));
goToPage->setIcon(QIcon(":/images/viewer_toolbar/goto.png")); goToPage->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
@ -502,6 +516,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);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
comicToolBar->addWidget(new MacToolBarSeparator); comicToolBar->addWidget(new MacToolBarSeparator);
@ -748,6 +763,7 @@ void MainWindowViewer::enableActions()
rightRotationAction->setDisabled(false); rightRotationAction->setDisabled(false);
showMagnifyingGlass->setDisabled(false); showMagnifyingGlass->setDisabled(false);
doublePageAction->setDisabled(false); doublePageAction->setDisabled(false);
doubleMangaPageAction->setDisabled(false);
adjustToFullSizeAction->setDisabled(false); adjustToFullSizeAction->setDisabled(false);
//setBookmark->setDisabled(false); //setBookmark->setDisabled(false);
showBookmarks->setDisabled(false); showBookmarks->setDisabled(false);
@ -768,6 +784,7 @@ void MainWindowViewer::disableActions()
rightRotationAction->setDisabled(true); rightRotationAction->setDisabled(true);
showMagnifyingGlass->setDisabled(true); showMagnifyingGlass->setDisabled(true);
doublePageAction->setDisabled(true); doublePageAction->setDisabled(true);
doubleMangaPageAction->setDisabled(false);
adjustToFullSizeAction->setDisabled(true); adjustToFullSizeAction->setDisabled(true);
setBookmark->setDisabled(true); setBookmark->setDisabled(true);
showBookmarks->setDisabled(true); showBookmarks->setDisabled(true);

View File

@ -96,6 +96,7 @@ class YACReaderSliderAction;
QAction *showInfo; QAction *showInfo;
QAction *closeAction; QAction *closeAction;
QAction *doublePageAction; QAction *doublePageAction;
QAction *doubleMangaPageAction;
QAction *showShorcutsAction; QAction *showShorcutsAction;
QAction *showDictionaryAction; QAction *showDictionaryAction;
QAction *alwaysOnTopAction; QAction *alwaysOnTopAction;

View File

@ -453,11 +453,20 @@ void DoublePageRender::run()
QImage auxImg(totalWidth,totalHeight,QImage::Format_RGB32); QImage auxImg(totalWidth,totalHeight,QImage::Format_RGB32);
QPainter painter(&auxImg); QPainter painter(&auxImg);
painter.drawImage(QRect(0,0,width1,totalHeight),img); if (render->doubleMangaPage) {
if(!img2.isNull()) qDebug() << "we are in the double Manga Page tree" << render->doubleMangaPage;
painter.drawImage(QRect(width1,0,width2,totalHeight),img2); painter.drawImage(QRect(width2,0,width1,totalHeight),img);
painter.end(); if(!img2.isNull())
painter.drawImage(QRect(0,0,width2,totalHeight),img2);
painter.end();
}
else {
qDebug() << "no double Manga Page" << render->doubleMangaPage;
painter.drawImage(QRect(0,0,width1,totalHeight),img);
if(!img2.isNull())
painter.drawImage(QRect(width1,0,width2,totalHeight),img2);
painter.end();
}
if(degrees > 0) if(degrees > 0)
{ {
QMatrix m; QMatrix m;
@ -479,7 +488,7 @@ void DoublePageRender::run()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
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(2),numRightPages(2)
{ {
int size = numLeftPages+numRightPages+1; int size = numLeftPages+numRightPages+1;
currentPageBufferedIndex = numLeftPages; currentPageBufferedIndex = numLeftPages;
@ -1030,6 +1039,16 @@ void Render::doublePageSwitch()
} }
} }
void Render::doubleMangaPageSwitch()
{
doubleMangaPage = !doubleMangaPage;
if(comic&&doublePage)
{
invalidate();
update();
}
}
QString Render::getCurrentPagesInformation() QString Render::getCurrentPagesInformation()
{ {
QString s = QString::number(currentIndex+1); QString s = QString::number(currentIndex+1);

View File

@ -126,6 +126,7 @@ public slots:
QPixmap * getCurrentPage(); QPixmap * getCurrentPage();
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);
@ -182,6 +183,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;

View File

@ -23,6 +23,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),
@ -688,6 +689,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."));

View File

@ -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;

View File

@ -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>

View 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"

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B