From 94b1dcc90d4cdbcdf1820ecfebd68a5e052becfe Mon Sep 17 00:00:00 2001 From: Alexandr Zarubkin Date: Fri, 13 Sep 2013 15:59:36 +0400 Subject: [PATCH 1/3] Revert "reinstate access to QSettings to store ignored version". The application author, not library, should decide how to store settings. This reverts commit c76d4bc0aa83c24027155773cbcecd1b1beb6a63. Signed-off-by: Alexandr Zarubkin --- fvignoredversions.cpp | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/fvignoredversions.cpp b/fvignoredversions.cpp index c665f9c..3c47ef5 100644 --- a/fvignoredversions.cpp +++ b/fvignoredversions.cpp @@ -4,12 +4,14 @@ #include #include +extern QSettings* settings; + // QSettings key for the latest skipped version #define FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY "FVLatestSkippedVersion" FVIgnoredVersions::FVIgnoredVersions(QObject *parent) : -QObject(parent) + QObject(parent) { // noop } @@ -21,32 +23,27 @@ bool FVIgnoredVersions::VersionIsIgnored(QString version) // 2) The version that was skipped before and thus stored in QSettings (ignore) // 3) A newer version (don't ignore) // 'version' is not likely to contain an older version in any case. - + if (version == QCoreApplication::applicationVersion()) { return true; } - - QSettings settings(QSettings::NativeFormat, - QSettings::UserScope, - QCoreApplication::organizationDomain(), - QCoreApplication::applicationName()); - + //QSettings settings; - if (settings.contains(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY)) { - QString lastSkippedVersion = settings.value(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY).toString(); + if (settings->contains(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY)) { + QString lastSkippedVersion = settings->value(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY).toString(); if (version == lastSkippedVersion) { // Implicitly skipped version - skip return true; } } - + std::string currentAppVersion = QCoreApplication::applicationVersion().toStdString(); std::string suggestedVersion = std::string(version.toStdString()); if (FvVersionComparator::CompareVersions(currentAppVersion, suggestedVersion) == FvVersionComparator::kAscending) { // Newer version - do not skip return false; } - + // Fallback - skip return true; } @@ -57,18 +54,13 @@ void FVIgnoredVersions::IgnoreVersion(QString version) // Don't ignore the current version return; } - + if (version.isEmpty()) { return; } - - QSettings settings(QSettings::NativeFormat, - QSettings::UserScope, - QCoreApplication::organizationDomain(), - QCoreApplication::applicationName()); - - settings.setValue(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY, version); - + //QSettings settings; + settings->setValue(FV_IGNORED_VERSIONS_LATEST_SKIPPED_VERSION_KEY, version); + return; -} \ No newline at end of file +} From 831b81013f3bd5de80d6a62b2586b3ee503e91eb Mon Sep 17 00:00:00 2001 From: Alexandr Zarubkin Date: Fri, 13 Sep 2013 16:18:33 +0400 Subject: [PATCH 2/3] Fixed compilation on Windows with Qt 5.1.1. Added an option to disable GUI, this time for both Qt 4 and Qt 5. Signed-off-by: Alexandr Zarubkin --- Fervor.pri | 13 ++++++++----- fvupdater.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Fervor.pri b/Fervor.pri index f4c3973..bde6d55 100644 --- a/Fervor.pri +++ b/Fervor.pri @@ -1,12 +1,15 @@ +QT += core network +!build_pass:message("If you want to enable GUI for Fervor, add CONFIG += fervor_gui to your .pro file") contains(QT_VERSION, ^5\\.[0-9]\\..*){ - QT += core widgets webkitwidgets network + fervor_gui { + DEFINES += FV_GUI + QT += webkitwidgets + } win32:INCLUDEPATH += $$[QT_INSTALL_PREFIX]/include/QtZlib }else{ - #QT += core gui webkit network - QT += core webkit network fervor_gui { DEFINES += FV_GUI - QT += gui + QT += gui webkit } win32:INCLUDEPATH += $$[QT_INSTALL_PREFIX]/../../../../QtSources/4.8.1/src/3rdparty/zlib } @@ -15,7 +18,7 @@ DEFINES += FV_APP_VERSION=\\\"$$VERSION\\\" -DEFINES +=QUAZIP_BUILD QUAZIP_STATIC +DEFINES += QUAZIP_BUILD QUAZIP_STATIC INCLUDEPATH += $$PWD/quazip HEADERS += $$PWD/quazip/crypt.h \ diff --git a/fvupdater.cpp b/fvupdater.cpp index 3fb99b3..45f8855 100644 --- a/fvupdater.cpp +++ b/fvupdater.cpp @@ -786,12 +786,12 @@ void FvUpdater::finishUpdate(QString pathToFinish) void FvUpdater::restartApplication() { // Spawn a new instance of myApplication: - QString app = QApplication::applicationFilePath(); - QStringList arguments = QApplication::arguments(); + QString app = QCoreApplication::applicationFilePath(); + QStringList arguments = QCoreApplication::arguments(); QString wd = QDir::currentPath(); qDebug() << app << arguments << wd; QProcess::startDetached(app, arguments, wd); - QApplication::exit(); + QCoreApplication::exit(); } void FvUpdater::setRequiredSslFingerPrint(QString md5) @@ -903,4 +903,4 @@ void FvUpdater::decideWhatToDoWithCurrentUpdateProposal() RemindMeLater(); } -#endif \ No newline at end of file +#endif From a1f42f7a156b3b040551d932ab52c0e00a6852ae Mon Sep 17 00:00:00 2001 From: Alexandr Zarubkin Date: Fri, 13 Sep 2013 18:03:10 +0400 Subject: [PATCH 3/3] Added automatic recompilation of affected files after GUI option changes. Removed unnecessary conditional define for Qt 5 - it compiles fine with #include . Signed-off-by: Alexandr Zarubkin --- Fervor.pri | 12 +++++++++++- fvupdatewindow.h | 6 +----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Fervor.pri b/Fervor.pri index bde6d55..1985715 100644 --- a/Fervor.pri +++ b/Fervor.pri @@ -16,7 +16,17 @@ contains(QT_VERSION, ^5\\.[0-9]\\..*){ DEFINES += FV_APP_NAME=\\\"$$TARGET\\\" DEFINES += FV_APP_VERSION=\\\"$$VERSION\\\" - +PREVIOUS_FERVOR_GUI = $$cat($$PWD/fervor.gui) +fervor_gui { + CURRENT_FERVOR_GUI = enabled +} else { + CURRENT_FERVOR_GUI = disabled +} +# if last build was with another GUI option, recompile some files +!equals(PREVIOUS_FERVOR_GUI, $$CURRENT_FERVOR_GUI) { + write_file($$PWD/fervor.gui, CURRENT_FERVOR_GUI) + touch($$PWD/fvupdater.h, $$PWD/fervor.gui) +} DEFINES += QUAZIP_BUILD QUAZIP_STATIC diff --git a/fvupdatewindow.h b/fvupdatewindow.h index b2e3feb..f9b2fcb 100644 --- a/fvupdatewindow.h +++ b/fvupdatewindow.h @@ -1,11 +1,7 @@ #ifndef FVUPDATEWINDOW_H #define FVUPDATEWINDOW_H -#if QT_VERSION >= 0x050000 - #include -#else - #include -#endif +#include class QGraphicsScene;