diff --git a/src/app/mainapplication.cpp b/src/app/mainapplication.cpp index e40b30ce0..e48fcb6bb 100644 --- a/src/app/mainapplication.cpp +++ b/src/app/mainapplication.cpp @@ -37,6 +37,7 @@ #include "qtwin.h" #include "mainapplication.h" #include "webhistoryinterface.h" +#include "globalfunctions.h" MainApplication::MainApplication(const QList &cmdActions, int &argc, char **argv) : QtSingleApplication("QupZillaWebBrowser", argc, argv) @@ -646,16 +647,12 @@ bool MainApplication::checkSettingsDir() QString homePath = QDir::homePath(); homePath+="/.qupzilla/"; - QByteArray rData; + QString profileVersion; if (QDir(homePath).exists()) { - QFile versionFile(homePath+"version"); - versionFile.open(QFile::ReadOnly); - rData = versionFile.readAll(); - if (rData.contains(QupZilla::VERSION.toAscii())) { - versionFile.close(); + profileVersion = qz_readAllFileContents(homePath + "version"); + + if (profileVersion == QupZilla::VERSION) return true; - } - versionFile.close(); #ifdef UNRELEASED_BUILD return true; #endif @@ -668,30 +665,30 @@ bool MainApplication::checkSettingsDir() dir.cd(".qupzilla"); //.qupzilla - QFile(homePath+"version").remove(); - QFile versionFile(homePath+"version"); + QFile(homePath + "version").remove(); + QFile versionFile(homePath + "version"); versionFile.open(QFile::WriteOnly); versionFile.write(QupZilla::VERSION.toAscii()); versionFile.close(); - if (rData.contains("1.0.0-b3")) // Data not changed from this version + if (Updater::parseVersionFromString(QupZilla::VERSION) >= Updater::parseVersionFromString("1.0.0-b3") ) // Data not changed from this version return true; dir.mkdir("profiles"); dir.cd("profiles"); //.qupzilla/profiles - QFile(homePath+"profiles/profiles.ini").remove(); - QFile(DATADIR+"data/default/profiles/profiles.ini").copy(homePath+"profiles/profiles.ini"); + QFile(homePath + "profiles/profiles.ini").remove(); + QFile(DATADIR + "data/default/profiles/profiles.ini").copy(homePath + "profiles/profiles.ini"); dir.mkdir("default"); dir.cd("default"); //.qupzilla/profiles/default - QFile(homePath+"profiles/default/browsedata.db").remove(); - QFile(DATADIR+"data/default/profiles/default/browsedata.db").copy(homePath+"profiles/default/browsedata.db"); - QFile(homePath+"profiles/default/background.png").remove(); - QFile(DATADIR+"data/default/profiles/default/background.png").copy(homePath+"profiles/default/background.png"); + QFile(homePath + "profiles/default/browsedata.db").remove(); + QFile(DATADIR + "data/default/profiles/default/browsedata.db").copy(homePath + "profiles/default/browsedata.db"); + QFile(homePath + "profiles/default/background.png").remove(); + QFile(DATADIR + "data/default/profiles/default/background.png").copy(homePath + "profiles/default/background.png"); return dir.isReadable(); } diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index 332beb743..f88ae7c29 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -61,7 +61,7 @@ const QString QupZilla::VERSION = "1.0.0-rc1"; const QString QupZilla::BUILDTIME = __DATE__" "__TIME__; const QString QupZilla::AUTHOR = "nowrep"; const QString QupZilla::COPYRIGHT = "2010-2011"; -const QString QupZilla::WWWADDRESS = "http://qupzilla.ic.cz"; +const QString QupZilla::WWWADDRESS = "http://qupzilla.co.cc"; const QString QupZilla::WIKIADDRESS = "https://github.com/nowrep/QupZilla/wiki"; const QString QupZilla::WEBKITVERSION = qWebKitVersion(); diff --git a/src/other/updater.h b/src/other/updater.h index 8488f14b6..7a2f97d1d 100644 --- a/src/other/updater.h +++ b/src/other/updater.h @@ -31,14 +31,6 @@ public: explicit Updater(QupZilla* mainClass, QObject* parent = 0); ~Updater(); -signals: - -private slots: - void downCompleted(QNetworkReply* reply); - void start(); - void downloadNewVersion(); - -private: struct Version { bool isValid; int majorVersion; @@ -67,11 +59,44 @@ private: { return !operator<(other); } + + bool operator==(const Version &other) const + { + if (!this->isValid || !other.isValid) + return false; + + return (this->majorVersion == other.majorVersion && + this->minorVersion == other.minorVersion && + this->revisionNumber == other.revisionNumber && + this->specialSymbol == other.specialSymbol); + } + + bool operator>=(const Version &other) const + { + if (*this == other) + return true; + return *this > other; + } + + bool operator<=(const Version &other) const + { + if (*this == other) + return true; + return *this < other; + } }; - Version parseVersionFromString(const QString &string); + static Version parseVersionFromString(const QString &string); static bool isBiggerThan_SpecialSymbol(QString one, QString two); +signals: + +private slots: + void downCompleted(QNetworkReply* reply); + void start(); + void downloadNewVersion(); + +private: void startDownloadingUpdateInfo(const QUrl &url); QupZilla* p_QupZilla;