Skip to content

Commit

Permalink
Use cpp macros for OS_TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
sledgehammer999 committed Aug 25, 2024
1 parent 434dd2f commit 58f71de
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/gui/programupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@

#include "programupdater.h"

#include <QtCore/qconfig.h>
#include <QtSystemDetection>
#include <QDebug>
#include <QDesktopServices>
#include <QRegularExpression>
#include <QXmlStreamReader>

#include <libtorrent/version.hpp>

#include "base/global.h"
#include "base/net/downloadmanager.h"
#include "base/preferences.h"
Expand Down Expand Up @@ -97,23 +100,37 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
: QString {};
};

#ifdef QBT_USES_LIBTORRENT2

#ifdef Q_OS_MACOS
const QString OS_TYPE = u"Mac OS X (lt20)"_s;
#define BASE_OS "Mac OS X"
#elif defined(Q_OS_WIN)
const QString OS_TYPE = u"Windows x64 (lt20)"_s;
#endif // Q_OS_MACOS
#define BASE_OS "Windows x64"
#endif

#else // QBT_USES_LIBTORRENT2
#define STRINGIFY(s) #s

#ifdef Q_OS_MACOS
const QString OS_TYPE = u"Mac OS X"_s;
#elif defined(Q_OS_WIN)
const QString OS_TYPE = u"Windows x64"_s;
#endif // Q_OS_MACOS
#if (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR == 1)
#define _TYPE() BASE_OS
#define TYPE _TYPE()

#elif (QT_VERSION_MAJOR == 6) && (LIBTORRENT_VERSION_MAJOR > 1)
#define _TYPE(lt_major, lt_minor) BASE_OS " (lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")"
#define TYPE _TYPE(LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR)

#elif (QT_VERSION_MAJOR > 6)
#define _TYPE(qt_major, lt_major, lt_minor) BASE_OS " (qt" STRINGIFY(qt_major) " lt" STRINGIFY(lt_major) STRINGIFY(lt_minor) ")"
#define TYPE _TYPE(QT_VERSION_MAJOR, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR)

#else
#error "OS_TYPE is undefined for the current Qt/libtorrent combination"
#endif

const QString OS_TYPE = TYPE;

#undef TYPE
#undef _TYPE
#undef STRINGIFY
#undef BASE_OS

#endif // QBT_USES_LIBTORRENT2

bool inItem = false;
QString version;
Expand Down

0 comments on commit 58f71de

Please sign in to comment.