Fixed new version message, now is less intrusive.

Fixed debug compilation
This commit is contained in:
Luis Ángel San Martín 2013-10-14 22:35:50 +02:00
parent 0d63bce2b5
commit 4e3b46a6ba
7 changed files with 86 additions and 50 deletions

View File

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

View File

@ -33,3 +33,4 @@ TRANSLATIONS = yacreader_es.ts \
yacreader_nl.ts \
yacreader_source.ts
#TODO: CONFIG += release on MacOSX and Linux (using qmake)

View File

@ -6,6 +6,7 @@
#include <QPoint>
#include <QColor>
#include <QSettings>
#include <QDate>
#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<QColor>();};
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<QColor>();}
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();

View File

@ -26,6 +26,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QImage>
#include <QDate>
#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;
}
}

View File

@ -49,6 +49,7 @@ class YACReaderSliderAction;
void reloadOptions();
void fitToWidth();
void fitToHeight();
void checkNewVersion();
/*void viewComic();
void prev();
void next();

View File

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

View File

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