From 599f7ffcf396d1cea75c712787ef23994caa5693 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Sun, 29 Jun 2014 21:38:00 +0200 Subject: [PATCH 1/4] Add a manga reading mode which displays image in reverse order in double page mode. The mode is triggered by selecting the "21" double page icon next to the double page icon. --- YACReader/configuration.cpp | 126 ++++++++++++---------- YACReader/configuration.h | 3 + YACReader/main_window_viewer.cpp | 19 +++- YACReader/main_window_viewer.h | 1 + YACReader/render.cpp | 31 ++++-- YACReader/render.h | 2 + YACReader/viewer.cpp | 8 ++ YACReader/viewer.h | 2 + YACReader/yacreader_images_win.qrc | 1 + common/yacreader_global.h | 1 + images/viewer_toolbar/doubleMangaPage.png | Bin 0 -> 514 bytes 11 files changed, 129 insertions(+), 65 deletions(-) create mode 100644 images/viewer_toolbar/doubleMangaPage.png diff --git a/YACReader/configuration.cpp b/YACReader/configuration.cpp index a89aab3d..69b3ffe6 100644 --- a/YACReader/configuration.cpp +++ b/YACReader/configuration.cpp @@ -74,6 +74,7 @@ void Configuration::load(const QString & path) windowSize = QSize(0,0); maximized = false; doublePage = false; + doubleMangaPage = false; adjustToFullSize = false; backgroundColor = QColor(40,40,40); alwaysOnTop = false; @@ -95,65 +96,74 @@ void Configuration::load(const QString & path) 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(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(); - + } + if(name==MAG_GLASS_SIZE) + { + QStringList values = line.split(','); + magnifyingGlassSize = QSize(values[0].toInt(),values[1].toInt()); + } + if(name==ZOOM_LEVEL) + { + zoomLevel = line.toFloat(); + } + if(name==SLIDE_SIZE) + { + int height = line.toInt(); + gotoSlideSize = QSize(static_cast(height/SLIDE_ASPECT_RATIO),height); + } + if(name==FIT) + { + adjustToWidth = line.toInt(); + } + if(name==FLOW_TYPE) + { + flowType = (FlowType)line.toInt(); + } + if(name==FULLSCREEN) + { + fullScreen = line.toInt(); + } + if(name==FIT_TO_WIDTH_RATIO) + { + fitToWidthRatio = line.toFloat(); + } + if(name==Y_WINDOW_POS) + { + QStringList l = line.split(','); + windowPos = QPoint(l[0].toInt(),l[1].toInt()); + } + if(name==Y_WINDOW_SIZE) + { + QStringList l = line.split(','); + windowSize = QSize(l[0].toInt(),l[1].toInt()); + } + if(name==MAXIMIZED) + { + maximized = line.toInt(); + } + if(name==DOUBLE_PAGE) + { + doublePage = line.toInt(); + } + if(name==DOUBLE_MANGA_PAGE) + { + doubleMangaPage = line.toInt(); + } + if(name==ADJUST_TO_FULL_SIZE) + { + adjustToFullSize = 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(); + } } diff --git a/YACReader/configuration.h b/YACReader/configuration.h index 7ef6b7ff..ba9e1531 100644 --- a/YACReader/configuration.h +++ b/YACReader/configuration.h @@ -35,6 +35,7 @@ using namespace YACReader; QSize windowSize; bool maximized; bool doublePage; + bool doubleMangaPage; bool alwaysOnTop; bool adjustToFullSize; QColor backgroundColor; @@ -75,6 +76,8 @@ using namespace YACReader; void setMaximized(bool b){settings->setValue(MAXIMIZED,b);} bool getDoublePage(){return settings->value(DOUBLE_PAGE).toBool();} 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();} void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);} QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value();} diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index ee3d148e..7498dde9 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -92,6 +92,7 @@ MainWindowViewer::~MainWindowViewer() delete leftRotationAction; delete rightRotationAction; delete doublePageAction; + delete doubleMangaPageAction; delete goToPage; delete optionsAction; delete helpAboutAction; @@ -326,7 +327,20 @@ void MainWindowViewer::createActions() doublePageAction->setCheckable(true); doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage()); 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->setShortcut(tr("G")); goToPage->setIcon(QIcon(":/images/viewer_toolbar/goto.png")); @@ -502,6 +516,7 @@ void MainWindowViewer::createToolBars() comicToolBar->addAction(leftRotationAction); comicToolBar->addAction(rightRotationAction); comicToolBar->addAction(doublePageAction); + comicToolBar->addAction(doubleMangaPageAction); #ifdef Q_OS_MAC comicToolBar->addWidget(new MacToolBarSeparator); @@ -748,6 +763,7 @@ void MainWindowViewer::enableActions() rightRotationAction->setDisabled(false); showMagnifyingGlass->setDisabled(false); doublePageAction->setDisabled(false); + doubleMangaPageAction->setDisabled(false); adjustToFullSizeAction->setDisabled(false); //setBookmark->setDisabled(false); showBookmarks->setDisabled(false); @@ -768,6 +784,7 @@ void MainWindowViewer::disableActions() rightRotationAction->setDisabled(true); showMagnifyingGlass->setDisabled(true); doublePageAction->setDisabled(true); + doubleMangaPageAction->setDisabled(false); adjustToFullSizeAction->setDisabled(true); setBookmark->setDisabled(true); showBookmarks->setDisabled(true); diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index 6b33c434..f757a4c8 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -96,6 +96,7 @@ class YACReaderSliderAction; QAction *showInfo; QAction *closeAction; QAction *doublePageAction; + QAction *doubleMangaPageAction; QAction *showShorcutsAction; QAction *showDictionaryAction; QAction *alwaysOnTopAction; diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 81db733b..ce91ac89 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -453,11 +453,20 @@ void DoublePageRender::run() 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 (render->doubleMangaPage) { + qDebug() << "we are in the double Manga Page tree" << render->doubleMangaPage; + painter.drawImage(QRect(width2,0,width1,totalHeight),img); + 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) { QMatrix m; @@ -479,7 +488,7 @@ void DoublePageRender::run() //----------------------------------------------------------------------------- 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; currentPageBufferedIndex = numLeftPages; @@ -1030,6 +1039,16 @@ void Render::doublePageSwitch() } } +void Render::doubleMangaPageSwitch() +{ + doubleMangaPage = !doubleMangaPage; + if(comic&&doublePage) + { + invalidate(); + update(); + } +} + QString Render::getCurrentPagesInformation() { QString s = QString::number(currentIndex+1); diff --git a/YACReader/render.h b/YACReader/render.h index 423d7955..bb466762 100644 --- a/YACReader/render.h +++ b/YACReader/render.h @@ -126,6 +126,7 @@ public slots: QPixmap * getCurrentPage(); void goTo(int index); void doublePageSwitch(); + void doubleMangaPageSwitch(); void setRotation(int degrees); void setComic(Comic * c); void prepareAvailablePage(int page); @@ -182,6 +183,7 @@ signals: private: Comic * comic; bool doublePage; + bool doubleMangaPage; int previousIndex; int currentIndex; //QPixmap * currentPage; diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index d90c0f95..cb47cd05 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -23,6 +23,7 @@ fullscreen(false), information(false), adjustToWidthRatio(1), doublePage(false), +doubleMangaPage(false), wheelStop(false), direction(1), restoreMagnifyingGlass(false), @@ -688,6 +689,13 @@ void Viewer::doublePageSwitch() Configuration::getConfiguration().setDoublePage(doublePage); } +void Viewer::doubleMangaPageSwitch() +{ + doubleMangaPage = !doubleMangaPage; + render->doubleMangaPageSwitch(); + Configuration::getConfiguration().setDoubleMangaPage(doubleMangaPage); +} + void Viewer::resetContent() { configureContent(tr("Press 'O' to open comic.")); diff --git a/YACReader/viewer.h b/YACReader/viewer.h index 4abd7ec7..e2ff3291 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -64,6 +64,7 @@ class NotificationsLabelWidget; void setBookmark(bool); void save(); void doublePageSwitch(); + void doubleMangaPageSwitch(); void resetContent(); void setLoadingMessage(); void setPageUnavailableMessage(); @@ -93,6 +94,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event ); private: bool information; bool doublePage; + bool doubleMangaPage; PageLabelWidget * informationLabel; //QTimer * scroller; QPropertyAnimation * verticalScroller; diff --git a/YACReader/yacreader_images_win.qrc b/YACReader/yacreader_images_win.qrc index 3476e623..e7251da4 100644 --- a/YACReader/yacreader_images_win.qrc +++ b/YACReader/yacreader_images_win.qrc @@ -3,6 +3,7 @@ ../images/viewer_toolbar/bookmark.png ../images/viewer_toolbar/close.png ../images/viewer_toolbar/doublePage.png + ../images/viewer_toolbar/doubleMangaPage.png ../images/viewer_toolbar/flow.png ../images/viewer_toolbar/full.png ../images/viewer_toolbar/goto.png diff --git a/common/yacreader_global.h b/common/yacreader_global.h index f92952c4..ee782fa4 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -25,6 +25,7 @@ #define Y_WINDOW_SIZE "SIZE" #define MAXIMIZED "MAXIMIZED" #define DOUBLE_PAGE "DOUBLE_PAGE" +#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE" #define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE" #define BACKGROUND_COLOR "BACKGROUND_COLOR" #define ALWAYS_ON_TOP "ALWAYS_ON_TOP" diff --git a/images/viewer_toolbar/doubleMangaPage.png b/images/viewer_toolbar/doubleMangaPage.png new file mode 100644 index 0000000000000000000000000000000000000000..99ee1720a393be9028e011626ce9eb16bfdbeba0 GIT binary patch literal 514 zcmeAS@N?(olHy`uVBq!ia0vp^{6Ngd!2%?sn)_0KltQvckS_y6l_~>6Lo)-z&;LOB zB?CjL0RzLU1O^7H84L{K`IF+0x&hTPC3(BMF#K=tKeHdm<1FxqEM{Qf76xHPhFNnY zK!Rljj_E)eY!5>fyAse+MrKbJ#}J9jwih;Li6#mh{doWT-PnM2u3F7g^(T1cT#9)( z$&H0u(E9cg56vG;W&2uu7j>-V2;^Xiwiad4mUivY2y8j=Zl1{QoyKPk+9l8Z7n!Me zOzO&29}}H7JG$P_t4<55t+D3R|3BW-72}nm79Ln9i#8(&KE}4`8J+$+qrAmXMvK()?d09d0+EweNn2h z+JXJbkF3*;%lq(!8dS;#O_yLZ@sj$DrB4DmO4Ss{&*5FY*b5JBT7;dOH!?p zi&B9UgOP!uiLQZ}u90Pkk%5(|rIm@9wt Date: Sun, 29 Jun 2014 20:00:34 +0000 Subject: [PATCH 2/4] main_window_viewer.cpp edited online with Bitbucket --- YACReader/main_window_viewer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 7498dde9..fa356772 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -784,7 +784,7 @@ void MainWindowViewer::disableActions() rightRotationAction->setDisabled(true); showMagnifyingGlass->setDisabled(true); doublePageAction->setDisabled(true); - doubleMangaPageAction->setDisabled(false); + doubleMangaPageAction->setDisabled(true); adjustToFullSizeAction->setDisabled(true); setBookmark->setDisabled(true); showBookmarks->setDisabled(true); @@ -917,7 +917,7 @@ void MainWindowViewer::checkNewVersion() QTimer * tT = new QTimer; tT->setSingleShot(true); connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get())); - //versionChecker->get(); //TODÓ + //versionChecker->get(); //TOD� tT->start(100); conf.setLastVersionCheck(current); @@ -1159,7 +1159,7 @@ void MainWindowViewer::alwaysOnTopSwitch() void MainWindowViewer::adjustToFullSizeSwitch() { - Configuration::getConfiguration().setAdjustToFullSize(!Configuration::getConfiguration().getAdjustToFullSize()); + Configuration::getConfiguration().setAdjustToFullSize(!ConfdoubleMangaPageAction->setDisablediguration::getConfiguration().getAdjustToFullSize()); viewer->updatePage(); } From 0cfae101cadd13f9b4f3f5cee2d8289c1affba07 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Sun, 29 Jun 2014 20:24:25 +0000 Subject: [PATCH 3/4] main_window_viewer.cpp edited online with Bitbucket --- YACReader/main_window_viewer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index fa356772..f04703a0 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -1159,7 +1159,7 @@ void MainWindowViewer::alwaysOnTopSwitch() void MainWindowViewer::adjustToFullSizeSwitch() { - Configuration::getConfiguration().setAdjustToFullSize(!ConfdoubleMangaPageAction->setDisablediguration::getConfiguration().getAdjustToFullSize()); + Configuration::getConfiguration().setAdjustToFullSize(!Configuration::getConfiguration().getAdjustToFullSize()); viewer->updatePage(); } From 5a933f577e2240d34b63089468e2ba0a69e7a86a Mon Sep 17 00:00:00 2001 From: Felix Kauselmann <2039670+selmf@users.noreply.github.com> Date: Sun, 29 Jun 2014 21:23:43 +0000 Subject: [PATCH 4/4] Sync doubleMangaPage with saved config when we create connections --- YACReader/viewer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index cb47cd05..e8c69861 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -97,6 +97,9 @@ shouldOpenPrevious(false) if(Configuration::getConfiguration().getDoublePage()) doublePageSwitch(); + + if(Configuration::getConfiguration().getDoubleMangaPage()) + doubleMangaPageSwitch(); createConnections();