From 4d3a6631747a8cdad13b771f7fc05c676dc473e3 Mon Sep 17 00:00:00 2001
From: Aqua-sama
Date: Fri, 19 Jan 2018 13:07:27 +0100
Subject: Added revision and branch to about dialog
---
CMakeLists.txt | 6 ++++--
src/forms/aboutdialog.cpp | 51 ++++++++++++++++++++---------------------------
src/version.h.in | 10 +++++++---
3 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bb0c2ca..a0e6b9d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,8 +52,10 @@ add_subdirectory(plugins/ProfileEditor)
# configure a header file to pass version information
# if you don't have git, or are building this off the source tarball, define versions in version.h.in
-execute_process(COMMAND hg log -r '.' --template={latesttag} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsVersion OUTPUT_STRIP_TRAILING_WHITESPACE)
-execute_process(COMMAND hg identify --id WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsCommit OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND hg log -r '.' --template={latesttag} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsVersion OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND hg identify --id WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsCommit OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND hg identify --num WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND hg identify --branch WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VcsBranch OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file(src/version.h.in "${PROJECT_BINARY_DIR}/version.h")
set(SourceCode
diff --git a/src/forms/aboutdialog.cpp b/src/forms/aboutdialog.cpp
index 93ee86b..eb32533 100644
--- a/src/forms/aboutdialog.cpp
+++ b/src/forms/aboutdialog.cpp
@@ -9,27 +9,24 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
#include "version.h"
+#include
-constexpr const char *getCompiler()
-{
+// The extra level of indirection will allow the preprocessor to expand the macros before they are converted to strings.
+#define STR_HELPER(x) #x
+#define STR(x) STR_HELPER(x)
+
+// compiler
// clang also defines __GNUC__, so we need to check for clang first
#if defined(__clang__)
- return "Clang " __clang_version__;
+#define compiler "Clang " __clang_version__
#elif defined(__GNUC__)
- return "GCC " __VERSION__;
+#define compiler "GCC " __VERSION__
#else
- return "unknown compiler";
+#define compiler "unknown compiler";
#endif
-}
-inline const QString getLongVersion()
-{
-#ifdef SMOLBOTE_DESCRIBE
- return QString(SMOLBOTE_DESCRIBE);
-#else
- return qApp->applicationVersion();
-#endif
-}
+// libconfig
+#define LIBCONFIG_VERSION_STR STR(LIBCONFIGXX_VER_MAJOR) "." STR(LIBCONFIGXX_VER_MINOR) "." STR(LIBCONFIGXX_VER_REVISION)
AboutDialog::AboutDialog(QWidget *parent)
: QDialog(parent)
@@ -40,14 +37,13 @@ AboutDialog::AboutDialog(QWidget *parent)
ui->icon->setPixmap(qApp->windowIcon().pixmap(72, 72));
- QLabel *aboutLabel = new QLabel(this);
+ auto *aboutLabel = new QLabel(this);
aboutLabel->setWordWrap(true);
- aboutLabel->setText(tr("smolbote %1
"
- "yet another no-frills browser
")
- .arg(qApp->applicationVersion()));
+ aboutLabel->setText(tr("smolbote " SMOLBOTE_VERSION "
"
+ "yet another no-frills browser
"));
ui->toolBox->addItem(aboutLabel, tr("About"));
- QLabel *licenseLabel = new QLabel(this);
+ auto *licenseLabel = new QLabel(this);
licenseLabel->setWordWrap(true);
licenseLabel->setText(tr("Copyright (C) 2017 Xian Nox
"
"This program is free software, and you are welcome to use it under the conditions set by the GNU GPLv3:"
@@ -61,18 +57,15 @@ AboutDialog::AboutDialog(QWidget *parent)
"
You can find the full license text in LICENSE.md.
"));
ui->toolBox->addItem(licenseLabel, tr("License"));
- QLabel *libsLabel = new QLabel(this);
+ auto *libsLabel = new QLabel(this);
libsLabel->setWordWrap(true);
- libsLabel->setText(tr("Version %1
"
- ""
- "Based on Qt " QT_VERSION_STR "
"
- "Compiled with %2"
- "
"
+ libsLabel->setText(tr("Version " SMOLBOTE_DESCRIBE "
"
+ "Branch: " SMOLBOTE_BRANCH "
"
+ "Compiled with " compiler "
"
""
- "- Qt %3
"
- "- libconfig
"
- "
")
- .arg(getLongVersion(), getCompiler(), qVersion()));
+ "Qt " QT_VERSION_STR ""
+ "libconfig " LIBCONFIG_VERSION_STR ""
+ ""));
ui->toolBox->addItem(libsLabel, tr("Details"));
}
diff --git a/src/version.h.in b/src/version.h.in
index 0f597ed..88008cf 100644
--- a/src/version.h.in
+++ b/src/version.h.in
@@ -1,9 +1,13 @@
#ifndef VERSION_H
#define VERSION_H
-// 0.2.1
+// Version: 1.2.3
#define SMOLBOTE_VERSION "@VcsVersion@"
-// 0.2.1-0fd54a21a551+
-#define SMOLBOTE_DESCRIBE "@VcsVersion@-@VcsCommit@"
+
+// Describe: 1.2.3-r123-0123456789ab
+#define SMOLBOTE_DESCRIBE "@VcsVersion@-r@VcsRevision@-@VcsCommit@"
+
+// Branch: default
+#define SMOLBOTE_BRANCH "@VcsBranch@"
#endif //VERSION_H
--
cgit v1.2.1