mirror-chatterino2/src/common/Version.cpp
Nico Sonack 930351779c
(#1874) Disable updates on non-Windows, Linux or macOS platforms (#1914)
* (#1874) Disable update checking for unsupported platforms

As described #1874, only Windows, macOS and GNU/Linux are officially
supplied with builds. Thus checking for updates is unnecessary if we
are e.g. on FreeBSD, OpenBSD, illumos distros and possibly other
Operating Systems.

This fixes #1874 by ifdef-ing the 3 officially supported platforms
when checking for updates. Otherwise a debug warning will be emitted
and in the settings the checkbox for beta-updates is hidden and
replaced by a message, explaining the reason for why there are no beta
updates.

* Update CHANGELOG

In accordance with #1874

* (#1874) Move platform check into checkForUpdates

As discussed in #1914

* (#1874) Move check for supported OS to a seperate function.

As requested in #1914
2020-08-24 12:02:56 +02:00

75 lines
1.5 KiB
C++

#include "common/Version.hpp"
#include "common/Modes.hpp"
#define UGLYMACROHACK1(s) #s
#define FROM_EXTERNAL_DEFINE(s) UGLYMACROHACK1(s)
namespace chatterino {
Version::Version()
{
// Version
this->version_ = CHATTERINO_VERSION;
// Commit hash
this->commitHash_ =
QString(FROM_EXTERNAL_DEFINE(CHATTERINO_GIT_HASH)).remove('"');
// Date of build, this is depended on the format not changing
#ifdef CHATTERINO_NIGHTLY_VERSION_STRING
this->dateOfBuild_ =
QString(FROM_EXTERNAL_DEFINE(CHATTERINO_NIGHTLY_VERSION_STRING))
.remove('"')
.split(' ')[0];
#endif
// "Full" version string, as displayed in window title
this->fullVersion_ = "Chatterino ";
if (Modes::instance().isNightly)
{
this->fullVersion_ += "Nightly ";
}
this->fullVersion_ += this->version_;
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
this->isSupportedOS_ = true;
#else
this->isSupportedOS_ = false;
#endif
}
const Version &Version::instance()
{
static Version instance;
return instance;
}
const QString &Version::version() const
{
return this->version_;
}
const QString &Version::fullVersion() const
{
return this->fullVersion_;
}
const QString &Version::commitHash() const
{
return this->commitHash_;
}
const QString &Version::dateOfBuild() const
{
return this->dateOfBuild_;
}
const bool &Version::isSupportedOS() const
{
return this->isSupportedOS_;
}
} // namespace chatterino