diff --git a/YACReader/configuration.cpp b/YACReader/configuration.cpp index d3b954a7..841ce1e6 100644 --- a/YACReader/configuration.cpp +++ b/YACReader/configuration.cpp @@ -49,6 +49,8 @@ void Configuration::load(QSettings * settings) settings->setValue(ALWAYS_ON_TOP,false); if(!settings->contains(SHOW_TOOLBARS)) settings->setValue(SHOW_TOOLBARS, true); + if(!settings->contains(QUICK_NAVI_MODE)) + settings->setValue(QUICK_NAVI_MODE, true); //old fit stuff /*if(!settings->contains(FIT)) settings->setValue(FIT,false); diff --git a/YACReader/configuration.h b/YACReader/configuration.h index 4208c0ff..ec5932c9 100644 --- a/YACReader/configuration.h +++ b/YACReader/configuration.h @@ -18,7 +18,7 @@ using namespace YACReader; class Configuration : public QObject { Q_OBJECT - + private: QSettings * settings; @@ -43,8 +43,8 @@ using namespace YACReader; Configuration(); //Configuration(const Configuration & conf); void load(const QString & path = CONF_FILE_PATH); - - + + public: static Configuration & getConfiguration() { @@ -58,18 +58,18 @@ using namespace YACReader; void setMagnifyingGlassSize(const QSize & mgs) { settings->setValue(MAG_GLASS_SIZE,mgs);} QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize();} void setGotoSlideSize(const QSize & gss) { settings->setValue(GO_TO_FLOW_SIZE,gss);} - float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();} - void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);} - + float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();} + void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);} + //Unified enum based fitmode - YACReader::FitMode getFitMode() { return static_cast(settings->value(FITMODE, YACReader::FitMode::FullPage).toInt()); } + YACReader::FitMode getFitMode() { return static_cast(settings->value(FITMODE, YACReader::FitMode::FullPage).toInt()); } void setFitMode ( YACReader::FitMode fitMode ){ settings->setValue(FITMODE, static_cast(fitMode)); } - + //openRecent QStringList openRecentList() { return settings->value("recentFiles").toStringList(); } void updateOpenRecentList (QString path); void clearOpenRecentList() { settings->remove("recentFiles"); } - + //Old fitmodes /* bool getAdjustToWidth() {return settings->value(FIT).toBool();} @@ -79,12 +79,12 @@ using namespace YACReader; bool getAdjustToFullSize(){return settings->value(ADJUST_TO_FULL_SIZE).toBool();} void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);} */ - + FlowType getFlowType(){return (FlowType)settings->value(FLOW_TYPE_SW).toInt();} void setFlowType(FlowType type){settings->setValue(FLOW_TYPE_SW,type);} bool getFullScreen(){return settings->value(FULLSCREEN).toBool();} void setFullScreen(bool f){settings->setValue(FULLSCREEN,f);} - + QPoint getPos(){return settings->value(Y_WINDOW_POS).toPoint();} void setPos(QPoint p){settings->setValue(Y_WINDOW_POS,p);} QSize getSize(){return settings->value(Y_WINDOW_SIZE).toSize();} @@ -95,7 +95,7 @@ using namespace YACReader; 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);} - + QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value();} void setBackgroundColor(const QColor& color){settings->value(BACKGROUND_COLOR,color);} bool getAlwaysOnTop(){return settings->value(ALWAYS_ON_TOP).toBool();} @@ -108,6 +108,7 @@ using namespace YACReader; void setLastVersionCheck(const QDate & date){ settings->setValue(LAST_VERSION_CHECK,date);} int getNumDaysBetweenVersionChecks() {return settings->value(NUM_DAYS_BETWEEN_VERSION_CHECKS,1).toInt();} void setNumDaysBetweenVersionChecks(int days) {return settings->setValue(NUM_DAYS_BETWEEN_VERSION_CHECKS,days);} + bool getQuickNaviMode(){return settings->value(QUICK_NAVI_MODE).toBool();} }; #endif diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index 8ef1fd39..091924c5 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -27,7 +27,7 @@ GoToFlow::GoToFlow(QWidget *parent,FlowType flowType) -:GoToFlowWidget(parent),ready(false) + :GoToFlowWidget(parent),ready(false) { updateTimer = new QTimer; connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateImageData())); @@ -43,12 +43,12 @@ GoToFlow::GoToFlow(QWidget *parent,FlowType flowType) connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int))); connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int))); - connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(showSlide(unsigned int))); + connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(showSlide(unsigned int))); - mainLayout->addWidget(flow); - toolBar->raise(); + mainLayout->addWidget(flow); + toolBar->raise(); - resize(static_cast(5*imageSize.width()),toolBar->height() + static_cast(imageSize.height()*1.7)); + resize(static_cast(5*imageSize.width()),toolBar->height() + static_cast(imageSize.height()*1.7)); this->setCursor(QCursor(Qt::ArrowCursor)); } @@ -64,11 +64,11 @@ void GoToFlow::keyPressEvent(QKeyEvent *event) { switch (event->key()) { - case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up: - QApplication::sendEvent(flow,event); - return; - default: - break; + case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up: + QApplication::sendEvent(flow,event); + return; + default: + break; } GoToFlowWidget::keyPressEvent(event); @@ -76,10 +76,10 @@ void GoToFlow::keyPressEvent(QKeyEvent *event) void GoToFlow::resizeEvent(QResizeEvent *event) { - QWidget::resizeEvent(event); + QWidget::resizeEvent(event); - toolBar->move(0, event->size().height() - toolBar->height()); - toolBar->setFixedWidth(width()); + toolBar->move(0, event->size().height() - toolBar->height()); + toolBar->setFixedWidth(width()); } @@ -169,11 +169,11 @@ void GoToFlow::updateImageData() imagesLoaded[idx]=true; } - } + } - // try to load only few images on the left and right side + // try to load only few images on the left and right side // i.e. all visible ones plus some extra -#define COUNT 8 +#define COUNT 8 int indexes[2*COUNT+1]; int center = flow->centerIndex(); indexes[0] = center; @@ -181,7 +181,7 @@ void GoToFlow::updateImageData() { indexes[j*2+1] = center+j+1; indexes[j*2+2] = center-j-1; - } + } for(int c = 0; c < 2*COUNT+1; c++) { int i = indexes[c]; @@ -189,7 +189,7 @@ void GoToFlow::updateImageData() if(!imagesLoaded[i]&&imagesReady[i])//slide(i).isNull()) { // schedule thumbnail generation - + worker->generate(i, flow->slideSize(),rawImages[i]); return; } @@ -214,16 +214,14 @@ void GoToFlow::setFlowType(FlowType flowType) flow->setFlowType(flowType); } -void GoToFlow::updateSize() //TODO : fix. it doesn't work. -{ - imageSize = Configuration::getConfiguration().getGotoSlideSize(); - flow->setSlideSize(imageSize); - resize(static_cast(5*imageSize.width()),static_cast(imageSize.height()*1.7)); -} - void GoToFlow::updateConfig(QSettings * settings) { - Q_UNUSED(settings) + GoToFlowWidget::updateConfig(settings); + + imageSize = Configuration::getConfiguration().getGotoSlideSize(); + flow->setFlowType(Configuration::getConfiguration().getFlowType()); + resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7); + updateSize(); } void GoToFlow::setFlowRightToLeft(bool b) @@ -235,7 +233,7 @@ void GoToFlow::setFlowRightToLeft(bool b) //SlideInitializer //----------------------------------------------------------------------------- SlideInitializer::SlideInitializer(QMutex * m,PictureFlow * flow,int slides) -:QThread(),mutex(m),_flow(flow),_slides(slides) + :QThread(),mutex(m),_flow(flow),_slides(slides) { } @@ -255,8 +253,8 @@ void SlideInitializer::run() //----------------------------------------------------------------------------- -PageLoader::PageLoader(QMutex * m): -QThread(),mutex(m), restart(false), working(false), idx(-1) +PageLoader::PageLoader(QMutex * m): + QThread(),mutex(m), restart(false), working(false), idx(-1) { } @@ -271,7 +269,7 @@ PageLoader::~PageLoader() bool PageLoader::busy() const { return isRunning() ? working : false; -} +} void PageLoader::generate(int index, QSize size,const QByteArray & rImage) { diff --git a/YACReader/goto_flow.h b/YACReader/goto_flow.h index a82d78ff..be157fa7 100644 --- a/YACReader/goto_flow.h +++ b/YACReader/goto_flow.h @@ -61,7 +61,6 @@ private slots: void setNumSlides(unsigned int slides); void setImageReady(int index,const QByteArray & image); void setFlowType(FlowType flowType); - void updateSize(); void updateConfig(QSettings * settings); void setFlowRightToLeft(bool b); diff --git a/YACReader/goto_flow_gl.cpp b/YACReader/goto_flow_gl.cpp index 14cbe424..80dca124 100644 --- a/YACReader/goto_flow_gl.cpp +++ b/YACReader/goto_flow_gl.cpp @@ -26,12 +26,12 @@ GoToFlowGL::GoToFlowGL(QWidget* parent, FlowType flowType) connect(flow,SIGNAL(selected(unsigned int)),this,SIGNAL(goToPage(unsigned int))); connect(toolBar,SIGNAL(goTo(unsigned int)),this,SIGNAL(goToPage(unsigned int))); - connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(setCenterIndex(unsigned int))); + connect(toolBar,SIGNAL(setCenter(unsigned int)),flow,SLOT(setCenterIndex(unsigned int))); - mainLayout->addWidget(flow); - toolBar->raise(); + mainLayout->addWidget(flow); + toolBar->raise(); - resize(static_cast(5*imageSize.width()),toolBar->height() + static_cast(imageSize.height()*1.7)); + resize(static_cast(5*imageSize.width()),toolBar->height() + static_cast(imageSize.height()*1.7)); this->setCursor(QCursor(Qt::ArrowCursor)); } @@ -77,15 +77,11 @@ void GoToFlowGL::setImageReady(int index,const QByteArray & imageData) flow->imagesReady[index] = true; } -void GoToFlowGL::updateSize() -{ - -} - void GoToFlowGL::updateConfig(QSettings * settings) { - Performance performance = medium; + GoToFlowWidget::updateConfig(settings); + Performance performance = medium; switch (settings->value(PERFORMANCE).toInt()) { case 0: @@ -102,56 +98,56 @@ void GoToFlowGL::updateConfig(QSettings * settings) break; } + imageSize = Configuration::getConfiguration().getGotoSlideSize(); + resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7); + updateSize(); + flow->setPerformance(performance); switch (settings->value(FLOW_TYPE_GL).toInt()) { - case 0: + case FlowType::CoverFlowLike: flow->setPreset(presetYACReaderFlowClassicConfig); - return; - case 1: + break; + case FlowType::Strip: flow->setPreset(presetYACReaderFlowStripeConfig); - return; - case 2: + break; + case FlowType::StripOverlapped: flow->setPreset(presetYACReaderFlowOverlappedStripeConfig); - return; - case 3: + break; + case FlowType::Modern: flow->setPreset(defaultYACReaderFlowConfig); - return; - case 4: + break; + case FlowType::Roulette: flow->setPreset(pressetYACReaderFlowDownConfig); - return; + break; + case FlowType::Custom: + flow->setCF_RX(settings->value(X_ROTATION).toInt()); + flow->setCF_Y(settings->value(Y_POSITION).toInt()); + flow->setX_Distance(settings->value(COVER_DISTANCE).toInt()); + flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt()); + flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt()); + flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt()); + flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt()); + flow->setRotation(settings->value(COVER_ROTATION).toInt()); + flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt()); + flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt()); + flow->setMaxAngle(settings->value(MAX_ANGLE).toInt()); + break; } - - - //custom config - - flow->setCF_RX(settings->value(X_ROTATION).toInt()); - flow->setCF_Y(settings->value(Y_POSITION).toInt()); - flow->setX_Distance(settings->value(COVER_DISTANCE).toInt()); - flow->setCenter_Distance(settings->value(CENTRAL_DISTANCE).toInt()); - flow->setCF_Z(settings->value(ZOOM_LEVEL).toInt()); - flow->setY_Distance(settings->value(Y_COVER_OFFSET).toInt()); - flow->setZ_Distance(settings->value(Z_COVER_OFFSET).toInt()); - flow->setRotation(settings->value(COVER_ROTATION).toInt()); - flow->setFadeOutDist(settings->value(FADE_OUT_DIST).toInt()); - flow->setLightStrenght(settings->value(LIGHT_STRENGTH).toInt()); - flow->setMaxAngle(settings->value(MAX_ANGLE).toInt()); - -/* flow->setVisibility(settings->value("visibilityDistance").toInt()); - flow->setLightStrenght(settings->value("lightStrength").toInt())*/; - + if (Configuration::getConfiguration().getQuickNaviMode()) + flow->setFadeOutDist(20); } void GoToFlowGL::keyPressEvent(QKeyEvent* event) { switch (event->key()) { - case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up: - QApplication::sendEvent(flow,event); - return; - default: - break; + case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Up: + QApplication::sendEvent(flow,event); + return; + default: + break; } GoToFlowWidget::keyPressEvent(event); @@ -159,10 +155,10 @@ void GoToFlowGL::keyPressEvent(QKeyEvent* event) void GoToFlowGL::resizeEvent(QResizeEvent *event) { - QWidget::resizeEvent(event); + QWidget::resizeEvent(event); - toolBar->move(0, event->size().height() - toolBar->height()); - toolBar->setFixedWidth(width()); + toolBar->move(0, event->size().height() - toolBar->height()); + toolBar->setFixedWidth(width()); } void GoToFlowGL::setFlowRightToLeft(bool b) diff --git a/YACReader/goto_flow_gl.h b/YACReader/goto_flow_gl.h index 00a8ab81..1feca85d 100644 --- a/YACReader/goto_flow_gl.h +++ b/YACReader/goto_flow_gl.h @@ -23,7 +23,6 @@ public: void setFlowType(FlowType flowType); void setNumSlides(unsigned int slides); void setImageReady(int index,const QByteArray & image); - void updateSize(); void updateConfig(QSettings * settings); void setFlowRightToLeft(bool b); diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index 87692151..4fe09d79 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -2,18 +2,42 @@ #include +#include "configuration.h" + GoToFlowToolBar::GoToFlowToolBar(QWidget * parent) - :QWidget(parent) + :QStackedWidget(parent) { //elementos interactivos - QVBoxLayout * mainLayout = new QVBoxLayout; - bar = new QWidget(this); - QHBoxLayout * bottom = new QHBoxLayout(bar); - bottom->addStretch(); - bottom->addWidget(new QLabel("" + tr("Page : ") + "",bar)); - bottom->addWidget(edit = new QLineEdit(bar)); - v = new QIntValidator(bar); + QWidget * normal = new QWidget(this); // container widget + QWidget * quickNavi = new QWidget(this); // container widget + addWidget(normal); + addWidget(quickNavi); + QHBoxLayout * normalLayout = new QHBoxLayout(normal); + QHBoxLayout * naviLayout = new QHBoxLayout(quickNavi); + normal->setLayout(normalLayout); + quickNavi->setLayout(naviLayout); + + slider = new QSlider(Qt::Horizontal,this); + slider->setStyleSheet( + "QSlider::groove:horizontal {" + " border: 1px solid white;" + " border-radius: 6px;" + " background: rgba(255, 255, 255, 50);" + " margin: 2px 0;" + "}" + "QSlider::handle:horizontal {" + " background: rgba(0, 0, 0, 200);" + " border: 1px solid white;" + " width: 24px;" + " border-radius: 6px;" + "}" + ); + connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); }); + + pageHint = new QLabel("" + tr("Page : ") + "",this); + v = new QIntValidator(this); v->setBottom(1); + edit = new QLineEdit(this); edit->setValidator(v); edit->setAlignment(Qt::AlignRight|Qt::AlignVCenter); edit->setStyleSheet("QLineEdit {border: 1px solid #77000000; background: #55000000; color: white; padding: 3px 5px 5px 5px; margin: 13px 5px 12px 5px; font-weight:bold}"); @@ -29,41 +53,51 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget * parent) QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} " "QPushButton:focus { border: none; outline: none;}" "QPushButton:pressed {background-image: url(:/images/imgCenterSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} "; - centerButton = new QPushButton(bar); + centerButton = new QPushButton(this); //centerButton->setIcon(QIcon(":/images/center.png")); centerButton->setStyleSheet(centerButtonCSS); centerButton->setFixedSize(26,50); centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true); connect(centerButton,SIGNAL(clicked()),this,SLOT(centerSlide())); - bottom->addWidget(centerButton); QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} " "QPushButton:focus { border: none; outline: none;}" "QPushButton:pressed {background-image: url(:/images/imgGoToSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} "; - goToButton = new QPushButton(bar); + goToButton = new QPushButton(this); //goToButton->setIcon(QIcon(":/images/goto.png")); goToButton->setStyleSheet(goToButtonCSS); goToButton->setFixedSize(32,50); goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true); connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo())); - bottom->addWidget(goToButton); - bottom->addStretch(); - bottom->setMargin(0); - bottom->setSpacing(0); - - bar->setLayout(bottom); + normalLayout->setMargin(0); + normalLayout->setSpacing(0); + normalLayout->addStretch(); + normalLayout->addWidget(pageHint); + normalLayout->addWidget(edit); + normalLayout->addWidget(centerButton); + normalLayout->addWidget(goToButton); + normalLayout->addStretch(); - mainLayout->setMargin(0); - mainLayout->setSpacing(0); - mainLayout->addWidget(bar); + naviLayout->setContentsMargins(5, 0, 0, 0); + naviLayout->setSpacing(2); + naviLayout->addWidget(slider); + naviLayout->addWidget(goToButton); - setLayout(mainLayout); + switchLayout(); setFixedHeight(50); } +void GoToFlowToolBar::switchLayout() +{ + if (Configuration::getConfiguration().getQuickNaviMode()) + setCurrentIndex(1); + else + setCurrentIndex(0); +} + void GoToFlowToolBar::paintEvent(QPaintEvent *) { QPainter painter(this); @@ -78,11 +112,13 @@ void GoToFlowToolBar::paintEvent(QPaintEvent *) void GoToFlowToolBar::setPage(int pageNumber) { edit->setText(QString::number(pageNumber+1)); + slider->setValue(pageNumber); } void GoToFlowToolBar::setTop(int numPages) { v->setTop(numPages); + slider->setMaximum(numPages-1); // min is 0 } void GoToFlowToolBar::goTo() diff --git a/YACReader/goto_flow_toolbar.h b/YACReader/goto_flow_toolbar.h index cdd5bad7..803026c0 100644 --- a/YACReader/goto_flow_toolbar.h +++ b/YACReader/goto_flow_toolbar.h @@ -2,24 +2,30 @@ #define GOTO_FLOW_TOOLBAR_H #include +#include class QLineEdit; class QIntValidator; class QPushButton; +class QSlider; +class QLabel; -class GoToFlowToolBar : public QWidget +class GoToFlowToolBar : public QStackedWidget { Q_OBJECT private: QLineEdit * edit; + QSlider * slider; QIntValidator * v; QPushButton * centerButton; QPushButton * goToButton; + QLabel * pageHint; QWidget * bar; void paintEvent(QPaintEvent *); public: GoToFlowToolBar(QWidget * parent = 0); + void switchLayout(); public slots: void setPage(int pageNumber); void setTop(int numPages); diff --git a/YACReader/goto_flow_widget.cpp b/YACReader/goto_flow_widget.cpp index 83487b62..6714a733 100644 --- a/YACReader/goto_flow_widget.cpp +++ b/YACReader/goto_flow_widget.cpp @@ -6,20 +6,17 @@ #include #include "goto_flow_toolbar.h" +#include "configuration.h" GoToFlowWidget::GoToFlowWidget(QWidget * parent) :QWidget(parent) { mainLayout = new QVBoxLayout; - mainLayout->setMargin(0); mainLayout->setSpacing(0); toolBar = new GoToFlowToolBar(this); - mainLayout->setMargin(0); - mainLayout->setSpacing(0); - setLayout(mainLayout); //toolBar->installEventFilter(this); @@ -54,6 +51,21 @@ void GoToFlowWidget::keyPressEvent(QKeyEvent* event) event->accept(); } +void GoToFlowWidget::updateConfig(QSettings * settings) +{ + Q_UNUSED(settings) + toolBar->switchLayout(); +} + +void GoToFlowWidget::updateSize() +{ + // called by parent in resizeEvent + // no need to update width when QuickNaviMode disabled + // height is set in updateConfig + if (Configuration::getConfiguration().getQuickNaviMode() && parentWidget() != nullptr) + resize(parentWidget()->width(),height()); +} + /*bool GoToFlowWidget::eventFilter(QObject * target, QEvent * event) { if(event->type() == QEvent::KeyPress) diff --git a/YACReader/goto_flow_widget.h b/YACReader/goto_flow_widget.h index 845a4b05..a981fa2c 100644 --- a/YACReader/goto_flow_widget.h +++ b/YACReader/goto_flow_widget.h @@ -27,8 +27,8 @@ public slots: virtual void setFlowType(FlowType flowType) = 0; virtual void setNumSlides(unsigned int slides) = 0; virtual void setImageReady(int index,const QByteArray & image) = 0; - virtual void updateSize() = 0; - virtual void updateConfig(QSettings * settings) = 0; + virtual void updateSize(); + virtual void updateConfig(QSettings * settings); virtual void setFlowRightToLeft(bool b) = 0; protected: diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 42506dca..e3da7210 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -938,7 +938,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName) if(i < list.count()) index = i; - viewer->open(pathDir,i); + viewer->open(pathDir,index); } void MainWindowViewer::saveImage() diff --git a/YACReader/options_dialog.cpp b/YACReader/options_dialog.cpp index 77f1d4e9..b542d2c3 100644 --- a/YACReader/options_dialog.cpp +++ b/YACReader/options_dialog.cpp @@ -19,7 +19,7 @@ #endif OptionsDialog::OptionsDialog(QWidget * parent) -:YACReaderOptionsDialog(parent) + :YACReaderOptionsDialog(parent) { QTabWidget * tabWidget = new QTabWidget(); @@ -49,7 +49,7 @@ OptionsDialog::OptionsDialog(QWidget * parent) QHBoxLayout * path = new QHBoxLayout(); path->addWidget(pathEdit = new QLineEdit()); - path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"),"")); + path->addWidget(pathFindButton = new QPushButton(QIcon(":/images/find_folder.png"),"")); pathBox->setLayout(path); connect(pathFindButton,SIGNAL(clicked()),this,SLOT(findFolder())); @@ -91,7 +91,7 @@ OptionsDialog::OptionsDialog(QWidget * parent) //brightnessS->setText(tr("Brightness")); brightnessS->setTracking(false); connect(brightnessS,SIGNAL(valueChanged(int)),this,SLOT(brightnessChanged(int))); - + contrastS = new YACReaderSpinSliderWidget(this,true); contrastS->setRange(0,250); //contrastS->setText(tr("Contrast")); @@ -104,6 +104,8 @@ OptionsDialog::OptionsDialog(QWidget * parent) gammaS->setTracking(false); connect(gammaS,SIGNAL(valueChanged(int)),this,SLOT(gammaChanged(int))); //connect(brightnessS,SIGNAL(valueChanged(int)),this,SIGNAL(changedOptions())); + + quickNavi = new QCheckBox(tr("Quick Navigation Mode")); QHBoxLayout * buttons = new QHBoxLayout(); buttons->addStretch(); @@ -115,13 +117,14 @@ OptionsDialog::OptionsDialog(QWidget * parent) layoutGeneral->addWidget(slideSizeBox); //layoutGeneral->addWidget(fitBox); layoutGeneral->addWidget(colorBox); - layoutGeneral->addWidget(shortcutsBox); + layoutGeneral->addWidget(shortcutsBox); layoutGeneral->addStretch(); layoutFlow->addWidget(sw); #ifndef NO_OPENGL layoutFlow->addWidget(gl); layoutFlow->addWidget(useGL); #endif + layoutFlow->addWidget(quickNavi); layoutFlow->addStretch(); layoutImage->addWidget(new QLabel(tr("Brightness")),0,0); layoutImage->addWidget(new QLabel(tr("Contrast")),1,0); @@ -177,7 +180,7 @@ void OptionsDialog::findFolder() void OptionsDialog::saveOptions() { - + settings->setValue(GO_TO_FLOW_SIZE,QSize(static_cast(slideSize->sliderPosition()/SLIDE_ASPECT_RATIO),slideSize->sliderPosition())); if(sw->radio1->isChecked()) @@ -191,6 +194,7 @@ void OptionsDialog::saveOptions() settings->setValue(BACKGROUND_COLOR,colorDialog->currentColor()); //settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0); + settings->setValue(QUICK_NAVI_MODE,quickNavi->isChecked()); YACReaderOptionsDialog::saveOptions(); } @@ -198,22 +202,22 @@ void OptionsDialog::saveOptions() void OptionsDialog::restoreOptions(QSettings * settings) { YACReaderOptionsDialog::restoreOptions(settings); - + slideSize->setSliderPosition(settings->value(GO_TO_FLOW_SIZE).toSize().height()); switch(settings->value(FLOW_TYPE_SW).toInt()) { - case 0: - sw->radio1->setChecked(true); - break; - case 1: - sw->radio2->setChecked(true); - break; - case 2: - sw->radio3->setChecked(true); - break; - default: - sw->radio1->setChecked(true); - break; + case 0: + sw->radio1->setChecked(true); + break; + case 1: + sw->radio2->setChecked(true); + break; + case 2: + sw->radio3->setChecked(true); + break; + default: + sw->radio1->setChecked(true); + break; } pathEdit->setText(settings->value(PATH).toString()); @@ -221,6 +225,8 @@ void OptionsDialog::restoreOptions(QSettings * settings) updateColor(settings->value(BACKGROUND_COLOR).value()); //fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100); + quickNavi->setChecked(settings->value(QUICK_NAVI_MODE).toBool()); + brightnessS->setValue(settings->value(BRIGHTNESS,0).toInt()); contrastS->setValue(settings->value(CONTRAST,100).toInt()); gammaS->setValue(settings->value(GAMMA,100).toInt()); @@ -234,7 +240,7 @@ void OptionsDialog::updateColor(const QColor & color) backgroundColor->setPalette(pal); backgroundColor->setAutoFillBackground(true); colorDialog->setCurrentColor(color); - + settings->setValue(BACKGROUND_COLOR,color); emit(changedOptions()); diff --git a/YACReader/options_dialog.h b/YACReader/options_dialog.h index 767b28fd..df0a723b 100644 --- a/YACReader/options_dialog.h +++ b/YACReader/options_dialog.h @@ -23,6 +23,7 @@ Q_OBJECT //QLabel * pathLabel; QLineEdit * pathEdit; QPushButton * pathFindButton; + QCheckBox * quickNavi; QLabel * magGlassSizeLabel; diff --git a/YACReader/render.h b/YACReader/render.h index 9c525c55..d231be38 100644 --- a/YACReader/render.h +++ b/YACReader/render.h @@ -21,6 +21,7 @@ class Render; class ImageFilter { public: ImageFilter(){}; + virtual ~ImageFilter() {}; virtual QImage setFilter(const QImage & image) = 0; inline int getLevel() {return level;}; inline void setLevel(int l) {level = l;}; diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 420e725d..0e64f3bf 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -7,7 +7,7 @@ #include "goto_flow_gl.h" #else #include -#endif +#endif #include "bookmarks_dialog.h" #include "render.h" #include "goto_dialog.h" @@ -23,22 +23,21 @@ #include Viewer::Viewer(QWidget * parent) -:QScrollArea(parent), -currentPage(0), -magnifyingGlassShowed(false), -fullscreen(false), -information(false), -adjustToWidthRatio(1), -doublePage(false), -doubleMangaPage(false), -wheelStop(false), -direction(1), -restoreMagnifyingGlass(false), -drag(false), -numScrollSteps(22), -shouldOpenNext(false), -shouldOpenPrevious(false), -zoom(100) + :QScrollArea(parent), + currentPage(0), + magnifyingGlassShowed(false), + fullscreen(false), + information(false), + doublePage(false), + doubleMangaPage(false), + wheelStop(false), + direction(1), + restoreMagnifyingGlass(false), + drag(false), + numScrollSteps(22), + shouldOpenNext(false), + shouldOpenPrevious(false), + zoom(100) { translator = new YACReaderTranslator(this); translator->hide(); @@ -69,25 +68,25 @@ zoom(100) showCursor(); goToDialog = new GoToDialog(this); - + QSettings * settings = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat); - //CONFIG GOTO_FLOW-------------------------------------------------------- + //CONFIG GOTO_FLOW-------------------------------------------------------- #ifndef NO_OPENGL - OpenGLChecker openGLChecker; - bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion(); + OpenGLChecker openGLChecker; + bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion(); - if(openGLAvailable && !settings->contains(USE_OPEN_GL)) - settings->setValue(USE_OPEN_GL,2); - else - if(!openGLAvailable) - settings->setValue(USE_OPEN_GL,0); + if(openGLAvailable && !settings->contains(USE_OPEN_GL)) + settings->setValue(USE_OPEN_GL,2); + else + if(!openGLAvailable) + settings->setValue(USE_OPEN_GL,0); - if((settings->value(USE_OPEN_GL).toBool() == true)) - goToFlow = new GoToFlowGL(this,Configuration::getConfiguration().getFlowType()); - else - goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType()); + if((settings->value(USE_OPEN_GL).toBool() == true)) + goToFlow = new GoToFlowGL(this,Configuration::getConfiguration().getFlowType()); + else + goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType()); #else goToFlow = new GoToFlow(this,Configuration::getConfiguration().getFlowType()); #endif @@ -95,17 +94,17 @@ zoom(100) goToFlow->hide(); showGoToFlowAnimation = new QPropertyAnimation(goToFlow,"pos"); showGoToFlowAnimation->setDuration(150); - + bd = new BookmarksDialog(this->parentWidget()); - + render = new Render(); hideCursorTimer = new QTimer(); - hideCursorTimer->setSingleShot(true); + hideCursorTimer->setSingleShot(true); if(Configuration::getConfiguration().getDoublePage()) doublePageSwitch(); - + if(Configuration::getConfiguration().getDoubleMangaPage()) doubleMangaPageSwitch(); @@ -232,13 +231,13 @@ void Viewer::open(QString pathFile, const ComicDB & comic) void Viewer::showMessageErrorOpening() { - QMessageBox::critical(this,tr("Not found"),tr("Comic not found")); + QMessageBox::critical(this,tr("Not found"),tr("Comic not found")); //resetContent(); --> not needed } void Viewer::showMessageErrorOpening(QString message) { - QMessageBox::critical(this,tr("Error opening comic"),message); + QMessageBox::critical(this,tr("Error opening comic"),message); resetContent(); } @@ -271,7 +270,7 @@ void Viewer::prev() } else { - render->previousPage(); + render->previousPage(); } updateInformation(); shouldOpenNext = false; @@ -338,32 +337,32 @@ void Viewer::updateContentSize() YACReader::FitMode fitmode = Configuration::getConfiguration().getFitMode(); switch (fitmode) { - case YACReader::FitMode::FullRes: - pagefit=currentPage->size(); - break; - case YACReader::FitMode::ToWidth: - pagefit=currentPage->size(); - pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding); - break; - case YACReader::FitMode::ToHeight: - pagefit=currentPage->size(); - pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding); - break; + case YACReader::FitMode::FullRes: + pagefit=currentPage->size(); + break; + case YACReader::FitMode::ToWidth: + pagefit=currentPage->size(); + pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding); + break; + case YACReader::FitMode::ToHeight: + pagefit=currentPage->size(); + pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding); + break; //if everything fails showing the full page is a good idea - case YACReader::FitMode::FullPage: - default: - pagefit=currentPage->size(); - pagefit.scale(size(), Qt::KeepAspectRatio); - break; + case YACReader::FitMode::FullPage: + default: + pagefit=currentPage->size(); + pagefit.scale(size(), Qt::KeepAspectRatio); + break; } - - if(zoom != 100) - { - pagefit.scale(floor(pagefit.width()*zoom/100.0f), 0, Qt::KeepAspectRatioByExpanding); + + if(zoom != 100) + { + pagefit.scale(floor(pagefit.width()*zoom/100.0f), 0, Qt::KeepAspectRatioByExpanding); } //apply scaling content->resize(pagefit); - + //TODO: updtateContentSize should only scale the pixmap once if(devicePixelRatio()>1)//only in retina display { @@ -379,23 +378,23 @@ void Viewer::updateContentSize() void Viewer::increaseZoomFactor() { - zoom = std::min(zoom + 10, 500); + zoom = std::min(zoom + 10, 500); updateContentSize(); - notificationsLabel->setText(QString::number(getZoomFactor())+"%"); + notificationsLabel->setText(QString::number(getZoomFactor())+"%"); notificationsLabel->flash(); - emit zoomUpdated(zoom); + emit zoomUpdated(zoom); } void Viewer::decreaseZoomFactor() { - zoom = std::max(zoom - 10, 30); + zoom = std::max(zoom - 10, 30); updateContentSize(); - notificationsLabel->setText(QString::number(getZoomFactor())+"%"); + notificationsLabel->setText(QString::number(getZoomFactor())+"%"); notificationsLabel->flash(); - emit zoomUpdated(zoom); + emit zoomUpdated(zoom); } int Viewer::getZoomFactor() @@ -407,14 +406,14 @@ int Viewer::getZoomFactor() void Viewer::setZoomFactor(int z) { //this function is mostly used to reset the zoom after a fitmode switch - if (z > 500) - zoom = 500; - else if (z < 30) - zoom = 30; + if (z > 500) + zoom = 500; + else if (z < 30) + zoom = 30; else zoom = z; - emit zoomUpdated(zoom); + emit zoomUpdated(zoom); } void Viewer::updateVerticalScrollBar() @@ -601,38 +600,38 @@ void Viewer::scrollTo(int x, int y) void Viewer::keyPressEvent(QKeyEvent *event) { - if(render->hasLoadedComic()) - { - int _key = event->key(); - Qt::KeyboardModifiers modifiers = event->modifiers(); + if(render->hasLoadedComic()) + { + int _key = event->key(); + Qt::KeyboardModifiers modifiers = event->modifiers(); - if(modifiers & Qt::ShiftModifier) - _key |= Qt::SHIFT; - if (modifiers & Qt::ControlModifier) - _key |= Qt::CTRL; - if (modifiers & Qt::MetaModifier) - _key |= Qt::META; - if (modifiers & Qt::AltModifier) - _key |= Qt::ALT; + if(modifiers & Qt::ShiftModifier) + _key |= Qt::SHIFT; + if (modifiers & Qt::ControlModifier) + _key |= Qt::CTRL; + if (modifiers & Qt::MetaModifier) + _key |= Qt::META; + if (modifiers & Qt::AltModifier) + _key |= Qt::ALT; - QKeySequence key(_key); - /*if(goToFlow->isVisible() && event->key()!=Qt::Key_S) - QCoreApplication::sendEvent(goToFlow,event); - else*/ + QKeySequence key(_key); + /*if(goToFlow->isVisible() && event->key()!=Qt::Key_S) + QCoreApplication::sendEvent(goToFlow,event); + else*/ - if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y)) - { - posByStep = height()/numScrollSteps; - nextPos=verticalScrollBar()->sliderPosition()+static_cast((height()*0.80)); - scrollDown(); - } + if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y)) + { + posByStep = height()/numScrollSteps; + nextPos=verticalScrollBar()->sliderPosition()+static_cast((height()*0.80)); + scrollDown(); + } - else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y)) - { - posByStep = height()/numScrollSteps; - nextPos=verticalScrollBar()->sliderPosition()-static_cast((height()*0.80)); - scrollUp(); - } + else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y)) + { + posByStep = height()/numScrollSteps; + nextPos=verticalScrollBar()->sliderPosition()-static_cast((height()*0.80)); + scrollUp(); + } else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y)) { @@ -654,75 +653,75 @@ void Viewer::keyPressEvent(QKeyEvent *event) scrollBackwardVerticalFirst(); } - else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y) || - key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y) || - key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y) || - key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y)) - { - QAbstractScrollArea::keyPressEvent(event); - emit backgroundChanges(); - } + else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y) || + key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y) || + key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y) || + key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y)) + { + QAbstractScrollArea::keyPressEvent(event); + emit backgroundChanges(); + } - else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y)) - { - goTo(0); - } + else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y)) + { + goTo(0); + } - else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y)) - { - goTo(this->render->numPages()-1); - } + else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y)) + { + goTo(this->render->numPages()-1); + } - else - QAbstractScrollArea::keyPressEvent(event); + else + QAbstractScrollArea::keyPressEvent(event); - if(mglass->isVisible() && (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y) || - key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y) || - key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y) || - key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y))) - { - QCoreApplication::sendEvent(mglass,event); - } + if(mglass->isVisible() && (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y) || + key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y) || + key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y) || + key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y))) + { + QCoreApplication::sendEvent(mglass,event); + } - } - else - QAbstractScrollArea::keyPressEvent(event); + } + else + QAbstractScrollArea::keyPressEvent(event); } void Viewer::wheelEvent(QWheelEvent * event) { if(render->hasLoadedComic()) { - if((event->delta()<0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())) - { - if(wheelStop) - { - if(getMovement(event) == Forward) - { - next(); - verticalScroller->stop(); - event->accept(); - wheelStop = false; - } - return; - } - else - wheelStop = true; - } - else + if((event->delta()<0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())) + { + if(wheelStop) + { + if(getMovement(event) == Forward) + { + next(); + verticalScroller->stop(); + event->accept(); + wheelStop = false; + } + return; + } + else + wheelStop = true; + } + else { if((event->delta()>0)&&(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum())) { if(wheelStop) - { - if(getMovement(event) == Backward) - { - prev(); - verticalScroller->stop(); - event->accept(); - wheelStop = false; - } - return; + { + if(getMovement(event) == Backward) + { + prev(); + verticalScroller->stop(); + event->accept(); + wheelStop = false; + } + return; } else wheelStop = true; @@ -751,7 +750,8 @@ void Viewer::wheelEvent(QWheelEvent * event) void Viewer::resizeEvent(QResizeEvent * event) { updateContentSize(); - goToFlow->move(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height())); + goToFlow->updateSize(); + goToFlow->move((width()-goToFlow->width())/2,height()-goToFlow->height()); informationLabel->updatePosition(); QScrollArea::resizeEvent(event); } @@ -768,23 +768,23 @@ void Viewer::mouseMoveEvent(QMouseEvent * event) { if(showGoToFlowAnimation->state()!=QPropertyAnimation::Running) { - if(goToFlow->isVisible()) - { - QPoint gtfPos = goToFlow->mapFrom(this,event->pos()); - if(gtfPos.y() < 0 || gtfPos.x()<0 || gtfPos.x()>goToFlow->width())//TODO this extra check is for Mavericks (mouseMove over goToFlowGL seems to be broken) - animateHideGoToFlow(); - //goToFlow->hide(); - } - else - { - int umbral = (width()-goToFlow->width())/2; - if((event->y()>height()-15)&&(event->x()>umbral)&&(event->x()isVisible()) { - - animateShowGoToFlow(); - hideCursorTimer->stop(); + QPoint gtfPos = goToFlow->mapFrom(this,event->pos()); + if(gtfPos.y() < 0 || gtfPos.x()<0 || gtfPos.x()>goToFlow->width())//TODO this extra check is for Mavericks (mouseMove over goToFlowGL seems to be broken) + animateHideGoToFlow(); + //goToFlow->hide(); + } + else + { + int umbral = (width()-goToFlow->width())/2; + if((event->y()>height()-15)&&(event->x()>umbral)&&(event->x()stop(); + } } - } } if(drag) @@ -818,7 +818,7 @@ void Viewer::showMagnifyingGlass() QPoint p = QPoint(cursor().pos().x(),cursor().pos().y()); p = this->parentWidget()->mapFromGlobal(p); mglass->move(static_cast(p.x()-float(mglass->width())/2) - ,static_cast(p.y()-float(mglass->height())/2)); + ,static_cast(p.y()-float(mglass->height())/2)); mglass->show(); mglass->updateImage(mglass->x()+mglass->width()/2,mglass->y()+mglass->height()/2); magnifyingGlassShowed = true; @@ -882,7 +882,7 @@ void Viewer::animateShowGoToFlow() goToFlow->centerSlide(render->getIndex()); goToFlow->setPageNumber(render->getIndex()); goToFlow->show(); - goToFlow->setFocus(Qt::OtherFocusReason); + goToFlow->setFocus(Qt::OtherFocusReason); } } @@ -896,30 +896,30 @@ void Viewer::animateHideGoToFlow() showGoToFlowAnimation->setEndValue(QPoint((width()-goToFlow->width())/2,height())); showGoToFlowAnimation->start(); goToFlow->centerSlide(render->getIndex()); - goToFlow->setPageNumber(render->getIndex()); - this->setFocus(Qt::OtherFocusReason); + goToFlow->setPageNumber(render->getIndex()); + this->setFocus(Qt::OtherFocusReason); } } void Viewer::moveCursoToGoToFlow() { - //Move cursor to goToFlow widget on show (this avoid hide when mouse is moved) - int y = goToFlow->pos().y(); - int x1 = goToFlow->pos().x(); - int x2 = x1 + goToFlow->width(); - QPoint cursorPos = mapFromGlobal(cursor().pos()); - int cursorX = cursorPos.x(); - int cursorY = cursorPos.y(); + //Move cursor to goToFlow widget on show (this avoid hide when mouse is moved) + int y = goToFlow->pos().y(); + int x1 = goToFlow->pos().x(); + int x2 = x1 + goToFlow->width(); + QPoint cursorPos = mapFromGlobal(cursor().pos()); + int cursorX = cursorPos.x(); + int cursorY = cursorPos.y(); - if(cursorY <= y) - cursorY = y + 10; - if(cursorX <= x1) - cursorX = x1 + 10; - if(cursorX >= x2) - cursorX = x2 - 10; - cursor().setPos(mapToGlobal(QPoint(cursorX,cursorY))); - hideCursorTimer->stop(); - showCursor(); + if(cursorY <= y) + cursorY = y + 10; + if(cursorX <= x1) + cursorX = x1 + 10; + if(cursorX >= x2) + cursorX = x2 - 10; + cursor().setPos(mapToGlobal(QPoint(cursorX,cursorY))); + hideCursorTimer->stop(); + showCursor(); } void Viewer::rotateLeft() @@ -937,18 +937,18 @@ void Viewer::setBookmark(bool set) render->setBookmark(); if(set) //add bookmark { - render->setBookmark(); + render->setBookmark(); } else //remove bookmark { - render->removeBookmark(); + render->removeBookmark(); } } void Viewer::save () { if(render->hasLoadedComic()) - render->save(); + render->save(); } void Viewer::doublePageSwitch() @@ -998,8 +998,8 @@ void Viewer::setPageUnavailableMessage() void Viewer::configureContent(QString msg) { content->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); - if(!(devicePixelRatio()>1)) - content->setScaledContents(true); + if(!(devicePixelRatio()>1)) + content->setScaledContents(true); content->setAlignment(Qt::AlignTop|Qt::AlignHCenter); content->setText(msg); content->setFont(QFont("courier new", 12)); @@ -1026,11 +1026,10 @@ void Viewer::showCursor() void Viewer::updateOptions() { - + goToFlow->setFlowType(Configuration::getConfiguration().getFlowType()); updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor()); updateContentSize(); - //goToFlow->updateSize(); } void Viewer::updateBackgroundColor(const QColor & color) @@ -1079,27 +1078,27 @@ void Viewer::animateHideTranslator() void Viewer::mousePressEvent ( QMouseEvent * event ) { - if (event->button() == Qt::LeftButton) - { - drag = true; - yDragOrigin = event->y(); - xDragOrigin = event->x(); - setCursor(Qt::ClosedHandCursor); - event->accept(); - } + if (event->button() == Qt::LeftButton) + { + drag = true; + yDragOrigin = event->y(); + xDragOrigin = event->x(); + setCursor(Qt::ClosedHandCursor); + event->accept(); + } } void Viewer::mouseReleaseEvent ( QMouseEvent * event ) { - drag = false; - setCursor(Qt::OpenHandCursor); - event->accept(); + drag = false; + setCursor(Qt::OpenHandCursor); + event->accept(); } void Viewer::updateZoomRatio(int ratio) { - zoom = ratio; - updateContentSize(); + zoom = ratio; + updateContentSize(); } void Viewer::updateConfig(QSettings * settings) @@ -1143,7 +1142,7 @@ void Viewer::showIsCoverMessage() shouldOpenNext = false; //single page comic } - + void Viewer::showIsLastMessage() { if(!shouldOpenNext) @@ -1175,31 +1174,31 @@ void Viewer::updateComic(ComicDB & comic) { if(render->hasLoadedComic()) { - //set currentPage - comic.info.currentPage = render->getIndex()+1; - //set bookmarks - Bookmarks * boomarks = render->getBookmarks(); - QList boomarksList = boomarks->getBookmarkPages(); - int numBookmarks = boomarksList.size(); - if(numBookmarks > 0) - comic.info.bookmark1 = boomarksList[0]; - if(numBookmarks > 1) - comic.info.bookmark2 = boomarksList[1]; - if(numBookmarks > 2) - comic.info.bookmark3 = boomarksList[2]; - //set filters - //TODO: avoid use settings for this... - QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat); - int brightness = settings.value(BRIGHTNESS,0).toInt(); - int contrast = settings.value(CONTRAST,100).toInt(); - int gamma = settings.value(GAMMA,100).toInt(); + //set currentPage + comic.info.currentPage = render->getIndex()+1; + //set bookmarks + Bookmarks * boomarks = render->getBookmarks(); + QList boomarksList = boomarks->getBookmarkPages(); + int numBookmarks = boomarksList.size(); + if(numBookmarks > 0) + comic.info.bookmark1 = boomarksList[0]; + if(numBookmarks > 1) + comic.info.bookmark2 = boomarksList[1]; + if(numBookmarks > 2) + comic.info.bookmark3 = boomarksList[2]; + //set filters + //TODO: avoid use settings for this... + QSettings settings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat); + int brightness = settings.value(BRIGHTNESS,0).toInt(); + int contrast = settings.value(CONTRAST,100).toInt(); + int gamma = settings.value(GAMMA,100).toInt(); - if(brightness != 0 || comic.info.brightness!=-1) - comic.info.brightness = brightness; - if(contrast != 100 || comic.info.contrast!=-1) - comic.info.contrast = contrast; - if(gamma != 100 || comic.info.gamma!=-1) - comic.info.gamma = gamma; + if(brightness != 0 || comic.info.brightness!=-1) + comic.info.brightness = brightness; + if(contrast != 100 || comic.info.contrast!=-1) + comic.info.contrast = contrast; + if(gamma != 100 || comic.info.gamma!=-1) + comic.info.gamma = gamma; } diff --git a/YACReader/viewer.h b/YACReader/viewer.h index e7e450f8..e22bfb93 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -121,7 +121,6 @@ virtual void mouseReleaseEvent ( QMouseEvent * event ); QPropertyAnimation * showGoToFlowAnimation; GoToDialog * goToDialog; //!Image properties - float adjustToWidthRatio; //! Comic //Comic * comic; int index; diff --git a/YACReaderLibrary/db/reading_list_item.h b/YACReaderLibrary/db/reading_list_item.h index 6acf898b..06bcc3ec 100644 --- a/YACReaderLibrary/db/reading_list_item.h +++ b/YACReaderLibrary/db/reading_list_item.h @@ -17,6 +17,7 @@ public: QVariant data(int column) const; virtual qulonglong getId() const; QList itemData; + virtual ~ListItem() {} }; //------------------------------------------------------ diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index fe5b2e8b..45c30820 100644 --- a/common/gl/yacreader_flow_gl.cpp +++ b/common/gl/yacreader_flow_gl.cpp @@ -1460,7 +1460,8 @@ QImage ImageLoaderGL::loadImage(const QString& fileName) case high: image = image.scaledToWidth(320,Qt::SmoothTransformation); break; - + case ultraHigh: + break; //no scaling in ultraHigh } if(!result) diff --git a/common/gl_legacy/yacreader_flow_gl.cpp b/common/gl_legacy/yacreader_flow_gl.cpp index 635927e1..9234b6b3 100644 --- a/common/gl_legacy/yacreader_flow_gl.cpp +++ b/common/gl_legacy/yacreader_flow_gl.cpp @@ -1406,7 +1406,8 @@ QImage ImageLoaderGL::loadImage(const QString& fileName) case high: image = image.scaledToWidth(320,Qt::SmoothTransformation); break; - + case ultraHigh: + break; //no scaling in ultraHigh } if(!result) diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index f3858958..9c36bd56 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -27,6 +27,7 @@ #define CONTRAST "CONTRAST" #define GAMMA "GAMMA" #define SHOW_INFO "SHOW_INFO" +#define QUICK_NAVI_MODE "QUICK_NAVI_MODE" #define FLOW_TYPE_GL "FLOW_TYPE_GL" #define Y_POSITION "Y_POSITION"