mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
Since now Qt5.4 version support is officially dropped. It means that widgets now require ubuntu>=16.04 debian>8 opensuse>=42.1
140 lines
5.6 KiB
Diff
140 lines
5.6 KiB
Diff
diff --git a/sources/awesome-widget/plugin/awupdatehelper.cpp b/sources/awesome-widget/plugin/awupdatehelper.cpp
|
|
index f6b5338..b5a3163 100644
|
|
--- a/sources/awesome-widget/plugin/awupdatehelper.cpp
|
|
+++ b/sources/awesome-widget/plugin/awupdatehelper.cpp
|
|
@@ -35,7 +35,7 @@ AWUpdateHelper::AWUpdateHelper(QObject *_parent)
|
|
{
|
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
|
|
|
- m_foundVersion = QVersionNumber::fromString(VERSION);
|
|
+ m_foundVersion = VERSION;
|
|
m_genericConfig = QString("%1/awesomewidgets/general.ini")
|
|
.arg(QStandardPaths::writableLocation(
|
|
QStandardPaths::GenericDataLocation));
|
|
@@ -67,8 +67,7 @@ void AWUpdateHelper::checkUpdates(const bool _showAnyway)
|
|
bool AWUpdateHelper::checkVersion()
|
|
{
|
|
QSettings settings(m_genericConfig, QSettings::IniFormat);
|
|
- QVersionNumber version = QVersionNumber::fromString(
|
|
- settings.value("Version", QString(VERSION)).toString());
|
|
+ QString version = settings.value("Version", VERSION).toString();
|
|
// update version
|
|
settings.setValue("Version", QString(VERSION));
|
|
settings.sync();
|
|
@@ -91,12 +90,11 @@ bool AWUpdateHelper::checkVersion()
|
|
}
|
|
|
|
|
|
-void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
|
+void AWUpdateHelper::showInfo(const QString &_version)
|
|
{
|
|
qCDebug(LOG_AW) << "Version" << _version;
|
|
|
|
- QString text
|
|
- = i18n("You are using the actual version %1", _version.toString());
|
|
+ QString text = i18n("You are using the actual version %1", _version);
|
|
if (!QString(COMMIT_SHA).isEmpty())
|
|
text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
|
return genMessageBox(i18n("No new version found"), text, QMessageBox::Ok)
|
|
@@ -104,7 +102,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
|
}
|
|
|
|
|
|
-void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
|
|
+void AWUpdateHelper::showUpdates(const QString &_version)
|
|
{
|
|
qCDebug(LOG_AW) << "Version" << _version;
|
|
|
|
@@ -113,7 +111,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
|
|
text += QString(COMMIT_SHA).isEmpty()
|
|
? "\n"
|
|
: QString(" (%1)\n").arg(QString(COMMIT_SHA));
|
|
- text += i18n("New version : %1", _version.toString()) + "\n\n";
|
|
+ text += i18n("New version : %1", _version) + "\n\n";
|
|
text += i18n("Click \"Ok\" to download");
|
|
|
|
genMessageBox(i18n("There are updates"), text,
|
|
@@ -130,8 +128,7 @@ void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
|
|
|
|
switch (ret) {
|
|
case QMessageBox::AcceptRole:
|
|
- QDesktopServices::openUrl(QString(RELEASES)
|
|
- + m_foundVersion.toString());
|
|
+ QDesktopServices::openUrl(QString(RELEASES) + m_foundVersion);
|
|
break;
|
|
case QMessageBox::RejectRole:
|
|
default:
|
|
@@ -162,14 +159,23 @@ void AWUpdateHelper::versionReplyRecieved(QNetworkReply *_reply,
|
|
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
|
|
QString version = firstRelease["tag_name"].toString();
|
|
version.remove("V.");
|
|
- m_foundVersion = QVersionNumber::fromString(version);
|
|
+ m_foundVersion = version;
|
|
qCInfo(LOG_AW) << "Update found version to" << m_foundVersion;
|
|
|
|
- QVersionNumber oldVersion = QVersionNumber::fromString(VERSION);
|
|
- if (oldVersion < m_foundVersion)
|
|
- return showUpdates(m_foundVersion);
|
|
+ // FIXME: possible there is a better way to check versions
|
|
+ int old_major = QString(VERSION).split(QChar('.')).at(0).toInt();
|
|
+ int old_minor = QString(VERSION).split(QChar('.')).at(1).toInt();
|
|
+ int old_patch = QString(VERSION).split(QChar('.')).at(2).toInt();
|
|
+ int new_major = version.split(QChar('.')).at(0).toInt();
|
|
+ int new_minor = version.split(QChar('.')).at(1).toInt();
|
|
+ int new_patch = version.split(QChar('.')).at(2).toInt();
|
|
+ if ((old_major < new_major)
|
|
+ || ((old_major == new_major) && (old_minor < new_minor))
|
|
+ || ((old_major == new_major) && (old_minor == new_minor)
|
|
+ && (old_patch < new_patch)))
|
|
+ return showUpdates(version);
|
|
else if (_showAnyway)
|
|
- return showInfo(m_foundVersion);
|
|
+ return showInfo(version);
|
|
}
|
|
|
|
|
|
diff --git a/sources/awesome-widget/plugin/awupdatehelper.h b/sources/awesome-widget/plugin/awupdatehelper.h
|
|
index cfd26e7..b311be2 100644
|
|
--- a/sources/awesome-widget/plugin/awupdatehelper.h
|
|
+++ b/sources/awesome-widget/plugin/awupdatehelper.h
|
|
@@ -21,7 +21,6 @@
|
|
|
|
#include <QMessageBox>
|
|
#include <QObject>
|
|
-#include <QVersionNumber>
|
|
|
|
|
|
class QNetworkReply;
|
|
@@ -37,15 +36,15 @@ public:
|
|
bool checkVersion();
|
|
|
|
private slots:
|
|
- void showInfo(const QVersionNumber &_version);
|
|
- void showUpdates(const QVersionNumber &_version);
|
|
+ void showInfo(const QString &_version);
|
|
+ void showUpdates(const QString &_version);
|
|
void userReplyOnUpdates(QAbstractButton *_button);
|
|
void versionReplyRecieved(QNetworkReply *_reply, const bool _showAnyway);
|
|
|
|
private:
|
|
QMessageBox *genMessageBox(const QString &_title, const QString &_body,
|
|
const QMessageBox::StandardButtons _buttons);
|
|
- QVersionNumber m_foundVersion;
|
|
+ QString m_foundVersion;
|
|
QString m_genericConfig;
|
|
};
|
|
|
|
diff --git a/sources/libraries.cmake b/sources/libraries.cmake
|
|
index 6f171a6..004b39f 100644
|
|
--- a/sources/libraries.cmake
|
|
+++ b/sources/libraries.cmake
|
|
@@ -2,7 +2,7 @@
|
|
find_package(Gettext REQUIRED)
|
|
|
|
# main qt libraries
|
|
-find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core DBus Network Qml Test Widgets)
|
|
+find_package(Qt5 5.5.0 REQUIRED COMPONENTS Core DBus Network Qml Test Widgets)
|
|
add_definitions(
|
|
${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Network_DEFINITIONS}
|
|
${Qt5Qml_DEFINITIONS} ${Qt5Widgets_DEFINITIONS}
|