aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConfuSomu2024-01-05 16:23:11 +0100
committerConfuSomu2024-01-05 16:58:41 +0100
commit5c60ecddaa4db927cf246933a5ba9802c3c8a2e8 (patch)
treec9f7c3ca3ab89dc6598cc60f259741267116b931
parent6a07ef99d9f98b1db4fad91b3cd69e6146c1f01e (diff)
downloadActorViewer-5c60ecddaa4db927cf246933a5ba9802c3c8a2e8.tar
ActorViewer-5c60ecddaa4db927cf246933a5ba9802c3c8a2e8.tar.gz
ActorViewer-5c60ecddaa4db927cf246933a5ba9802c3c8a2e8.zip
Display commit hash in about dialog
-rw-r--r--CMakeLists.txt13
-rw-r--r--src/aboutdialog.cpp7
-rw-r--r--src/aboutdialog.ui2
3 files changed, 19 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83d8b99..551afac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,18 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Concurrent)
find_package(mastodonpp REQUIRED)
+# Get Git commit hash, from http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/
+# Get the latest commit hash of the working branch
+execute_process(
+ COMMAND git log -1 --format=%H
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE GIT_COMMIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# Put the hash between " so it is a string litteral
+string(PREPEND GIT_COMMIT_HASH "\"")
+string(APPEND GIT_COMMIT_HASH "\"")
+
# add_subdirectory will happen later…
set(PROJECT_SOURCES
src/main.cpp
@@ -95,6 +107,7 @@ else()
endif()
endif()
+target_compile_definitions(ActorViewer PRIVATE GIT_COMMIT_HASH=${GIT_COMMIT_HASH})
target_link_libraries(ActorViewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets mastodonpp)
set_target_properties(ActorViewer PROPERTIES
diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp
index 0a96e59..97e2e90 100644
--- a/src/aboutdialog.cpp
+++ b/src/aboutdialog.cpp
@@ -6,8 +6,11 @@ AboutDialog::AboutDialog(QWidget* parent)
{
ui->setupUi(this);
- // TODO: show version or git build in about text
- //ui->label->setText(ui->label->text().arg("aaa"));
+#ifdef GIT_COMMIT_HASH
+ ui->label->setText(ui->label->text().arg(tr("(commit %1)").arg(GIT_COMMIT_HASH)));
+#else
+ ui->label->setText(ui->label->text().arg(""));
+#endif
// I have been saved by https://stackoverflow.com/a/22565649
// It's not more complicated than that… thankfully
diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui
index dd31ae1..4733bbd 100644
--- a/src/aboutdialog.ui
+++ b/src/aboutdialog.ui
@@ -41,7 +41,7 @@
</sizepolicy>
</property>
<property name="text">
- <string extracomment="about dialog">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;ActorViewer&lt;/span&gt;&lt;span style=&quot; font-weight:600;&quot;&gt; %1&lt;/span&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;ActorViewer is an application that allow one to browse through Fediverse data exports via the help of a Qt-based user interface. It permits one to filter through different types of posts, search through them and view all embedded content related to an Activity.&lt;/p&gt;&lt;p&gt;This application is licensed under the GNU General Public License, version 3. Please see the LICENSE file, which lists your rights as a user, available in the source code repository's root directory.&lt;/p&gt;&lt;p&gt;The source code is available at the following web address: &lt;a href=&quot;https://git.twilightsparkle.space/ActorViewer/about/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#ae82c1;&quot;&gt;https://git.twilightsparkle.space/ActorViewer/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string extracomment="about dialog">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt; font-weight:600;&quot;&gt;ActorViewer&lt;/span&gt;&lt;span style=&quot; font-size:8pt;font-weight:600;&quot;&gt; %1&lt;/span&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;ActorViewer is an application which allows one to browse through Fediverse data exports via the help of a Qt-based user interface. It permits one to filter through different types of posts, search through them and view all embedded content related to an Activity.&lt;/p&gt;&lt;p&gt;This application is licensed under the GNU General Public License, version 3. Please see the LICENSE file, which lists your rights as a user, available in the source code repository's root directory.&lt;/p&gt;&lt;p&gt;The source code is available at the following web address: &lt;a href=&quot;https://git.twilightsparkle.space/ActorViewer/about/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#ae82c1;&quot;&gt;https://git.twilightsparkle.space/ActorViewer/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>