|
29 | 29 |
|
30 | 30 | #include "programupdater.h"
|
31 | 31 |
|
| 32 | +#include <QtCore/qconfig.h> |
32 | 33 | #include <QtSystemDetection>
|
33 | 34 | #include <QDebug>
|
34 | 35 | #include <QDesktopServices>
|
35 | 36 | #include <QRegularExpression>
|
36 | 37 | #include <QXmlStreamReader>
|
37 | 38 |
|
| 39 | +#include <libtorrent/version.hpp> |
| 40 | + |
38 | 41 | #include "base/global.h"
|
39 | 42 | #include "base/net/downloadmanager.h"
|
40 | 43 | #include "base/preferences.h"
|
@@ -100,20 +103,36 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
|
100 | 103 | #ifdef QBT_USES_LIBTORRENT2
|
101 | 104 |
|
102 | 105 | #ifdef Q_OS_MACOS
|
103 |
| - const QString OS_TYPE = u"Mac OS X (lt20)"_s; |
| 106 | +#define BASE_OS "Mac OS X" |
104 | 107 | #elif defined(Q_OS_WIN)
|
105 |
| - const QString OS_TYPE = u"Windows x64 (lt20)"_s; |
106 |
| -#endif // Q_OS_MACOS |
| 108 | +#define BASE_OS "Windows x64" |
| 109 | +#endif |
107 | 110 |
|
108 |
| -#else // QBT_USES_LIBTORRENT2 |
| 111 | +#define STRINGIFY(s) #s |
109 | 112 |
|
110 |
| -#ifdef Q_OS_MACOS |
111 |
| - const QString OS_TYPE = u"Mac OS X"_s; |
112 |
| -#elif defined(Q_OS_WIN) |
113 |
| - const QString OS_TYPE = u"Windows x64"_s; |
114 |
| -#endif // Q_OS_MACOS |
| 113 | +#if (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR == 1) |
| 114 | +#define _TYPE() BASE_OS |
| 115 | +#define TYPE _TYPE() |
| 116 | + |
| 117 | +#elif (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR > 1) |
| 118 | +#define _TYPE(lt_major, lt_minor) BASE_OS " (lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")" |
| 119 | +#define TYPE _TYPE(LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR) |
| 120 | + |
| 121 | +#elif (QT_VERSION_MAJOR > 6) |
| 122 | +#define _TYPE(qt_major, lt_major, lt_minor) BASE_OS " (qt" STRINGIFY(qt_major) " lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")" |
| 123 | +#define TYPE _TYPE(QT_VERSION_MAJOR, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR) |
| 124 | + |
| 125 | +#else |
| 126 | +#error "OS_TYPE is undefined for the current Qt/libtorrent combination" |
| 127 | +#endif |
| 128 | + |
| 129 | + const QString OS_TYPE = TYPE; |
| 130 | + |
| 131 | +#undef TYPE |
| 132 | +#undef _TYPE |
| 133 | +#undef STRINGIFY |
| 134 | +#undef BASE_OS |
115 | 135 |
|
116 |
| -#endif // QBT_USES_LIBTORRENT2 |
117 | 136 |
|
118 | 137 | bool inItem = false;
|
119 | 138 | QString version;
|
|
0 commit comments