mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Provide singleton class for version information
This commit is contained in:
parent
b06918eb47
commit
9c59efb985
3 changed files with 91 additions and 0 deletions
|
@ -88,6 +88,7 @@ SOURCES += \
|
||||||
src/common/NetworkRequest.cpp \
|
src/common/NetworkRequest.cpp \
|
||||||
src/common/NetworkResult.cpp \
|
src/common/NetworkResult.cpp \
|
||||||
src/common/UsernameSet.cpp \
|
src/common/UsernameSet.cpp \
|
||||||
|
src/common/Version.cpp \
|
||||||
src/controllers/accounts/Account.cpp \
|
src/controllers/accounts/Account.cpp \
|
||||||
src/controllers/accounts/AccountController.cpp \
|
src/controllers/accounts/AccountController.cpp \
|
||||||
src/controllers/accounts/AccountModel.cpp \
|
src/controllers/accounts/AccountModel.cpp \
|
||||||
|
|
67
src/common/Version.cpp
Normal file
67
src/common/Version.cpp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#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
|
||||||
|
#ifdef CHATTERINO_NIGHTLY_VERSION_STRING
|
||||||
|
this->dateOfBuild_ =
|
||||||
|
QString(FROM_EXTERNAL_DEFINE(CHATTERINO_NIGHTLY_VERSION_STRING))
|
||||||
|
.remove('"');
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// "Full" version string, as displayed in window title
|
||||||
|
this->fullVersion_ = "Chatterino ";
|
||||||
|
if (Modes::getInstance().isNightly)
|
||||||
|
{
|
||||||
|
this->fullVersion_ += "Nightly ";
|
||||||
|
}
|
||||||
|
|
||||||
|
this->fullVersion_ += this->version_;
|
||||||
|
|
||||||
|
if (Modes::getInstance().isNightly)
|
||||||
|
{
|
||||||
|
this->fullVersion_ += this->dateOfBuild_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Version &Version::getInstance()
|
||||||
|
{
|
||||||
|
static Version instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &Version::getVersion() const
|
||||||
|
{
|
||||||
|
return this->version_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &Version::getFullVersion() const
|
||||||
|
{
|
||||||
|
return this->fullVersion_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &Version::getCommitHash() const
|
||||||
|
{
|
||||||
|
return this->commitHash_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &Version::getDateOfBuild() const
|
||||||
|
{
|
||||||
|
return this->dateOfBuild_;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -13,3 +13,26 @@
|
||||||
#else
|
#else
|
||||||
# define CHATTERINO_OS "unknown"
|
# define CHATTERINO_OS "unknown"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
class Version
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Version &getInstance();
|
||||||
|
|
||||||
|
const QString &getVersion() const;
|
||||||
|
const QString &getCommitHash() const;
|
||||||
|
const QString &getDateOfBuild() const;
|
||||||
|
const QString &getFullVersion() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Version();
|
||||||
|
|
||||||
|
QString version_;
|
||||||
|
QString commitHash_;
|
||||||
|
QString dateOfBuild_;
|
||||||
|
QString fullVersion_;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue