diff --git a/YACReader/YACReader.pri b/YACReader/YACReader.pri index 86fb7a57..fbc4a9c9 100644 --- a/YACReader/YACReader.pri +++ b/YACReader/YACReader.pri @@ -25,7 +25,7 @@ LIBS += -L/usr/local/lib -lpoppler-qt4 } QT += network opengl -CONFIG += release +#CONFIG += release CONFIG -= flat isEqual(QT_MAJOR_VERSION, 5) { diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index 3c09f91c..2d99fba0 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -33,3 +33,4 @@ TRANSLATIONS = yacreader_es.ts \ yacreader_nl.ts \ yacreader_source.ts +#TODO: CONFIG += release on MacOSX and Linux (using qmake) diff --git a/YACReader/configuration.h b/YACReader/configuration.h index fd0c53ba..558d2b81 100644 --- a/YACReader/configuration.h +++ b/YACReader/configuration.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "yacreader_global.h" @@ -50,40 +51,44 @@ using namespace YACReader; return configuration; }; void load(QSettings * settings); - QString getDefaultPath() { return settings->value(PATH).toString(); }; - void setDefaultPath(QString defaultPath){settings->setValue(PATH,defaultPath);}; - QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize();}; - 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);}; - bool getAdjustToWidth() {return settings->value(FIT).toBool();}; - void setAdjustToWidth(bool atw=true) {settings->setValue(FIT,atw);}; - 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);}; - float getFitToWidthRatio(){return settings->value(FIT_TO_WIDTH_RATIO).toFloat();}; - void setFitToWidthRatio(float r){settings->setValue(FIT_TO_WIDTH_RATIO,r);}; - 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();}; - void setSize(QSize s){settings->setValue(Y_WINDOW_SIZE,s);}; - bool getMaximized(){return settings->value(MAXIMIZED).toBool();}; - 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 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();}; - void setBackgroundColor(const QColor& color){settings->value(BACKGROUND_COLOR,color);}; - bool getAlwaysOnTop(){return settings->value(ALWAYS_ON_TOP).toBool();}; - void setAlwaysOnTop(bool b){ settings->setValue(ALWAYS_ON_TOP,b);}; - bool getShowToolbars(){return settings->value(SHOW_TOOLBARS).toBool();}; - void setShowToolbars(bool b){settings->setValue(SHOW_TOOLBARS,b);}; - bool getShowInformation(){return settings->value(SHOW_INFO,false).toBool();}; - void setShowInformation(bool b){settings->setValue(SHOW_INFO,b);}; + QString getDefaultPath() { return settings->value(PATH).toString(); } + void setDefaultPath(QString defaultPath){settings->setValue(PATH,defaultPath);} + QSize getMagnifyingGlassSize() { return settings->value(MAG_GLASS_SIZE).toSize();} + 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);} + bool getAdjustToWidth() {return settings->value(FIT).toBool();} + void setAdjustToWidth(bool atw=true) {settings->setValue(FIT,atw);} + 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);} + float getFitToWidthRatio(){return settings->value(FIT_TO_WIDTH_RATIO).toFloat();} + void setFitToWidthRatio(float r){settings->setValue(FIT_TO_WIDTH_RATIO,r);} + 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();} + void setSize(QSize s){settings->setValue(Y_WINDOW_SIZE,s);} + bool getMaximized(){return settings->value(MAXIMIZED).toBool();} + 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 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();} + void setBackgroundColor(const QColor& color){settings->value(BACKGROUND_COLOR,color);} + bool getAlwaysOnTop(){return settings->value(ALWAYS_ON_TOP).toBool();} + void setAlwaysOnTop(bool b){ settings->setValue(ALWAYS_ON_TOP,b);} + bool getShowToolbars(){return settings->value(SHOW_TOOLBARS).toBool();} + void setShowToolbars(bool b){settings->setValue(SHOW_TOOLBARS,b);} + bool getShowInformation(){return settings->value(SHOW_INFO,false).toBool();} + void setShowInformation(bool b){settings->setValue(SHOW_INFO,b);} + QDate getLastVersionCheck(){return settings->value(LAST_VERSION_CHECK).toDate();} + 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);} void save(); diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index eb1adee9..e7437771 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #ifdef Q_OS_MAC class MacToolBarSeparator : public QWidget @@ -162,17 +163,7 @@ void MainWindowViewer::setupUI() openFromArgv(); - versionChecker = new HttpVersionChecker(); - - connect(versionChecker,SIGNAL(newVersionDetected()), - this,SLOT(newVersion())); - - QTimer * tT = new QTimer; - - tT->setSingleShot(true); - connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get())); - //versionChecker->get(); //TODÓ - tT->start(100); + checkNewVersion(); viewer->setFocusPolicy(Qt::StrongFocus); @@ -870,6 +861,28 @@ void MainWindowViewer::fitToHeight() viewer->updatePage(); } } + +void MainWindowViewer::checkNewVersion() +{ + Configuration & conf = Configuration::getConfiguration(); + QDate lastCheck = conf.getLastVersionCheck(); + QDate current = QDate::currentDate(); + if(lastCheck.isNull() || lastCheck.daysTo(current) >= conf.getNumDaysBetweenVersionChecks()) + { + versionChecker = new HttpVersionChecker(); + + connect(versionChecker,SIGNAL(newVersionDetected()), + this,SLOT(newVersion())); + + QTimer * tT = new QTimer; + tT->setSingleShot(true); + connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get())); + //versionChecker->get(); //TODÓ + tT->start(100); + + conf.setLastVersionCheck(current); + } +} void MainWindowViewer::changeFit() { Configuration & conf = Configuration::getConfiguration(); @@ -882,14 +895,25 @@ void MainWindowViewer::newVersion() QMessageBox msgBox; msgBox.setText(tr("There is a new version avaliable")); msgBox.setInformativeText(tr("Do you want to download the new version?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Ignore | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); + msgBox.button(QMessageBox::Ignore)->setText(tr("Remind me in 14 days")); + msgBox.button(QMessageBox::No)->setText(tr("Not now")); msgBox.setWindowFlags(Qt::WindowStaysOnTopHint); msgBox.setModal(true); int ret = msgBox.exec(); - if(ret==QMessageBox::Yes){ - QDesktopServices::openUrl(QUrl("http://www.yacreader.com")); + switch(ret) + { + case QMessageBox::Yes: + QDesktopServices::openUrl(QUrl("http://www.yacreader.com")); + break; + case QMessageBox::No: + Configuration::getConfiguration().setNumDaysBetweenVersionChecks(1); + break; + case QMessageBox::Ignore: + Configuration::getConfiguration().setNumDaysBetweenVersionChecks(14); + break; } } diff --git a/YACReader/main_window_viewer.h b/YACReader/main_window_viewer.h index 0c3ec9f6..b6082c6b 100644 --- a/YACReader/main_window_viewer.h +++ b/YACReader/main_window_viewer.h @@ -49,6 +49,7 @@ class YACReaderSliderAction; void reloadOptions(); void fitToWidth(); void fitToHeight(); + void checkNewVersion(); /*void viewComic(); void prev(); void next(); diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 1368bfc0..959312f6 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -35,7 +35,7 @@ INCLUDEPATH += /usr/local/include/poppler/qt4 LIBS += -L/usr/local/lib -lpoppler-qt4 } -CONFIG += release +#CONFIG += release CONFIG -= flat QT += sql network opengl script @@ -151,3 +151,5 @@ isEqual(QT_MAJOR_VERSION, 5) { Release:DESTDIR = ../release Debug:DESTDIR = ../debug } + +#TODO: CONFIG += release on MacOSX and Linux (using qmake) diff --git a/common/yacreader_global.h b/common/yacreader_global.h index 5d05be64..73b4673f 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -48,6 +48,9 @@ #define COMICS_VIEW_HEADERS "COMICS_VIEW_HEADERS" #define COMICS_VIEW_HEADERS_GEOMETRY "COMICS_VIEW_HEADERS_GEOMETRY" +#define NUM_DAYS_BETWEEN_VERSION_CHECKS "NUM_DAYS_BETWEEN_VERSION_CHECKS" +#define LAST_VERSION_CHECK "LAST_VERSION_CHECK" + #define YACREADERLIBRARY_GUID "ea343ff3-2005-4865-b212-7fa7c43999b8" namespace YACReader