Merge pull request #1315 from leon-richardt/commit-hash-settings
Add Version Information to "About" Page
This commit is contained in:
@@ -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
|
||||
# define CHATTERINO_OS "unknown"
|
||||
#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_;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
+1
-19
@@ -364,30 +364,12 @@ void Window::addMenuBar()
|
||||
[=] { this->notebook_->selectPreviousTab(); });
|
||||
}
|
||||
|
||||
#define UGLYMACROHACK1(s) #s
|
||||
#define UGLYMACROHACK(s) UGLYMACROHACK1(s)
|
||||
|
||||
void Window::onAccountSelected()
|
||||
{
|
||||
auto user = getApp()->accounts->twitch.getCurrent();
|
||||
|
||||
// update title
|
||||
QString title = "Chatterino ";
|
||||
if (Modes::getInstance().isNightly)
|
||||
{
|
||||
title += "Nightly ";
|
||||
}
|
||||
title += CHATTERINO_VERSION;
|
||||
|
||||
if (Modes::getInstance().isNightly)
|
||||
{
|
||||
#ifdef CHATTERINO_NIGHTLY_VERSION_STRING
|
||||
title +=
|
||||
QString(" (" UGLYMACROHACK(CHATTERINO_NIGHTLY_VERSION_STRING) ")");
|
||||
#endif
|
||||
}
|
||||
|
||||
this->setWindowTitle(title);
|
||||
this->setWindowTitle(Version::getInstance().getFullVersion());
|
||||
|
||||
// update user
|
||||
if (user->isAnon())
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "AboutPage.hpp"
|
||||
|
||||
#include "common/Modes.hpp"
|
||||
#include "common/Version.hpp"
|
||||
#include "debug/Log.hpp"
|
||||
#include "util/LayoutCreator.hpp"
|
||||
#include "util/RemoveScrollAreaBackground.hpp"
|
||||
@@ -71,6 +73,24 @@ AboutPage::AboutPage()
|
||||
// }
|
||||
}*/
|
||||
|
||||
auto versionInfo = layout.emplace<QGroupBox>("Version");
|
||||
{
|
||||
auto version = Version::getInstance();
|
||||
QString text = QString("%1 (commit %2%3)")
|
||||
.arg(version.getFullVersion())
|
||||
.arg("<a "
|
||||
"href=\"https://github.com/Chatterino/"
|
||||
"chatterino2/commit/" +
|
||||
version.getCommitHash() + "\">" +
|
||||
version.getCommitHash() + "</a>")
|
||||
.arg(Modes::getInstance().isNightly ? ", " + version.getDateOfBuild() : "");
|
||||
|
||||
auto versionLabel = versionInfo.emplace<QLabel>(text);
|
||||
versionLabel->setOpenExternalLinks(true);
|
||||
versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse |
|
||||
Qt::LinksAccessibleByMouse);
|
||||
}
|
||||
|
||||
auto licenses =
|
||||
layout.emplace<QGroupBox>("Open source software used...");
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user