2019-09-16 18:35:51 +02:00
|
|
|
#include "common/Version.hpp"
|
|
|
|
|
|
|
|
#include "common/Modes.hpp"
|
|
|
|
|
2021-08-21 14:16:00 +02:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
2019-09-16 18:35:51 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
Version::Version()
|
2023-06-17 19:43:39 +02:00
|
|
|
: version_(CHATTERINO_VERSION)
|
|
|
|
, commitHash_(QStringLiteral(CHATTERINO_GIT_HASH))
|
|
|
|
, isModified_(CHATTERINO_GIT_MODIFIED == 1)
|
|
|
|
, dateOfBuild_(QStringLiteral(CHATTERINO_CMAKE_GEN_DATE))
|
2019-09-16 18:35:51 +02:00
|
|
|
{
|
|
|
|
this->fullVersion_ = "Chatterino ";
|
2019-10-07 22:42:34 +02:00
|
|
|
if (Modes::instance().isNightly)
|
2019-09-16 18:35:51 +02:00
|
|
|
{
|
|
|
|
this->fullVersion_ += "Nightly ";
|
|
|
|
}
|
|
|
|
|
|
|
|
this->fullVersion_ += this->version_;
|
2020-08-24 12:02:56 +02:00
|
|
|
|
2022-06-04 21:00:42 +02:00
|
|
|
#ifndef NDEBUG
|
|
|
|
this->fullVersion_ += " DEBUG";
|
|
|
|
#endif
|
|
|
|
|
2020-08-24 12:02:56 +02:00
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MACOS)
|
|
|
|
this->isSupportedOS_ = true;
|
|
|
|
#else
|
|
|
|
this->isSupportedOS_ = false;
|
|
|
|
#endif
|
2022-06-04 21:00:42 +02:00
|
|
|
|
|
|
|
this->generateBuildString();
|
|
|
|
this->generateRunningString();
|
2019-09-16 18:35:51 +02:00
|
|
|
}
|
|
|
|
|
2019-10-07 22:42:34 +02:00
|
|
|
const Version &Version::instance()
|
2019-09-16 18:35:51 +02:00
|
|
|
{
|
|
|
|
static Version instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2019-10-07 22:32:11 +02:00
|
|
|
const QString &Version::version() const
|
2019-09-16 18:35:51 +02:00
|
|
|
{
|
|
|
|
return this->version_;
|
|
|
|
}
|
|
|
|
|
2019-10-07 22:32:11 +02:00
|
|
|
const QString &Version::fullVersion() const
|
2019-09-16 18:35:51 +02:00
|
|
|
{
|
|
|
|
return this->fullVersion_;
|
|
|
|
}
|
|
|
|
|
2019-10-07 22:32:11 +02:00
|
|
|
const QString &Version::commitHash() const
|
2019-09-16 18:35:51 +02:00
|
|
|
{
|
|
|
|
return this->commitHash_;
|
|
|
|
}
|
|
|
|
|
2022-06-04 21:00:42 +02:00
|
|
|
const bool &Version::isModified() const
|
|
|
|
{
|
|
|
|
return this->isModified_;
|
|
|
|
}
|
|
|
|
|
2019-10-07 22:32:11 +02:00
|
|
|
const QString &Version::dateOfBuild() const
|
2019-09-16 18:35:51 +02:00
|
|
|
{
|
|
|
|
return this->dateOfBuild_;
|
|
|
|
}
|
|
|
|
|
2020-08-24 12:02:56 +02:00
|
|
|
const bool &Version::isSupportedOS() const
|
|
|
|
{
|
|
|
|
return this->isSupportedOS_;
|
|
|
|
}
|
|
|
|
|
2021-08-21 13:00:01 +02:00
|
|
|
bool Version::isFlatpak() const
|
|
|
|
{
|
|
|
|
return QFileInfo::exists("/.flatpak-info");
|
|
|
|
}
|
|
|
|
|
2022-06-04 21:00:42 +02:00
|
|
|
QStringList Version::buildTags() const
|
|
|
|
{
|
|
|
|
QStringList tags;
|
|
|
|
|
|
|
|
tags.append("Qt " QT_VERSION_STR);
|
|
|
|
|
|
|
|
#ifdef USEWINSDK
|
|
|
|
tags.append("Windows SDK");
|
|
|
|
#endif
|
|
|
|
#ifdef _MSC_FULL_VER
|
|
|
|
tags.append("MSVC " + QString::number(_MSC_FULL_VER, 10));
|
|
|
|
#endif
|
2023-02-12 20:36:58 +01:00
|
|
|
#ifdef CHATTERINO_WITH_CRASHPAD
|
|
|
|
tags.append("Crashpad");
|
|
|
|
#endif
|
2022-06-04 21:00:42 +02:00
|
|
|
|
|
|
|
return tags;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &Version::buildString() const
|
|
|
|
{
|
|
|
|
return this->buildString_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &Version::runningString() const
|
|
|
|
{
|
|
|
|
return this->runningString_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Version::generateBuildString()
|
|
|
|
{
|
|
|
|
// e.g. Chatterino 2.3.5 or Chatterino Nightly 2.3.5
|
|
|
|
auto s = this->fullVersion();
|
|
|
|
|
|
|
|
// Add commit information
|
|
|
|
s +=
|
|
|
|
QString(
|
|
|
|
R"( (commit <a href="https://github.com/Chatterino/chatterino2/commit/%1">%1</a>)")
|
|
|
|
.arg(this->commitHash());
|
|
|
|
if (this->isModified())
|
|
|
|
{
|
|
|
|
s += " modified)";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s += ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
s += " built";
|
|
|
|
|
|
|
|
// If the build is a nightly build (decided with modes atm), include build date information
|
|
|
|
if (Modes::instance().isNightly)
|
|
|
|
{
|
|
|
|
s += " on " + this->dateOfBuild();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append build tags (e.g. compiler, qt version etc)
|
|
|
|
s += " with " + this->buildTags().join(", ");
|
|
|
|
|
|
|
|
this->buildString_ = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Version::generateRunningString()
|
|
|
|
{
|
|
|
|
auto s = QString("Running on %1, kernel: %2")
|
|
|
|
.arg(QSysInfo::prettyProductName(), QSysInfo::kernelVersion());
|
|
|
|
|
|
|
|
if (this->isFlatpak())
|
|
|
|
{
|
|
|
|
s += ", running from Flatpak";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this->isSupportedOS())
|
|
|
|
{
|
|
|
|
s += " (unsupported OS)";
|
|
|
|
}
|
|
|
|
|
|
|
|
this->runningString_ = s;
|
|
|
|
}
|
|
|
|
|
2019-09-16 18:35:51 +02:00
|
|
|
} // namespace chatterino
|