From d54efa8cb872b6ecc7657dd215efeeabf04821e1 Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Mon, 30 Oct 2023 11:47:01 +0900
Subject: Add git hash to program version

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 src/AboutDialog.cpp   |  6 ++---
 src/CMakeLists.txt    | 51 +++++++++++++++++++-------------------
 src/UiGuiVersion.cpp  | 68 ---------------------------------------------------
 src/UiGuiVersion.h    | 14 ++---------
 src/main.cpp          |  6 ++---
 src/tclap/StdOutput.h |  2 +-
 6 files changed, 33 insertions(+), 114 deletions(-)
 delete mode 100644 src/UiGuiVersion.cpp

(limited to 'src')

diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp
index 9bb119d..e604852 100644
--- a/src/AboutDialog.cpp
+++ b/src/AboutDialog.cpp
@@ -52,8 +52,7 @@ AboutDialog::AboutDialog(TQWidget *parent, WFlags flags) :
 //----
 //----	TQString versionString = _dialogForm->versionTextBrowser->toHtml();
 //----	versionString =
-//----	        versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg(
-//----		UiGuiVersion::getBuildDate());
+//----	        versionString.arg(PROGRAM_VERSION_STRING);
 //----	_dialogForm->versionTextBrowser->setHtml(versionString);
 //----
 //----	_dialogForm->creditsTextBrowser->setHtml("<html><head></head><body>"
@@ -115,8 +114,7 @@ void AboutDialog::changeEvent(TQEvent *event)
 //----
 //----		TQString versionString = _dialogForm->versionTextBrowser->toHtml();
 //----		versionString =
-//----		        versionString.arg(PROGRAM_VERSION_STRING).arg(UiGuiVersion::getBuildRevision()).arg(
-//----			UiGuiVersion::getBuildDate());
+//----		        versionString.arg(PROGRAM_VERSION_STRING);
 //----		_dialogForm->versionTextBrowser->setHtml(versionString);
 //----	}
 //----	else
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 84845f3..1744c4a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,9 +7,9 @@
 #################################################
 
 include_directories(
-	${CMAKE_CURRENT_SOURCE_DIR}
-	${CMAKE_CURRENT_BINARY_DIR}
-	${CMAKE_BINARY_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${CMAKE_CURRENT_BINARY_DIR}
+  ${CMAKE_BINARY_DIR}
   ${TQT_INCLUDE_DIRS}
 )
 
@@ -26,31 +26,30 @@ link_directories(
 set( target universal-indent-gui-tqt )
 
 set( ${target}_SRCS
-	# completed
-	MainWindowBase.ui
-	ToolBarWidget.ui
-
-	IndentHandler.cpp
-	SettingsPaths.cpp
-	TemplateBatchScript.cpp
-	UiGuiErrorMessage.cpp
-	UiGuiHighlighter.cpp
-	UiGuiIniFileParser.cpp
-	UiGuiVersion.cpp
-
-	# ongoing
-	AboutDialogBase.ui
-	UiGuiSettingsDialogBase.ui
-
-	AboutDialog.cpp
-	MainWindow.cpp
-	main.cpp
-	UiGuiSettings.cpp
-	UiGuiSettingsDialog.cpp
+  # completed
+  MainWindowBase.ui
+  ToolBarWidget.ui
+
+  IndentHandler.cpp
+  SettingsPaths.cpp
+  TemplateBatchScript.cpp
+  UiGuiErrorMessage.cpp
+  UiGuiHighlighter.cpp
+  UiGuiIniFileParser.cpp
+
+  # ongoing
+  AboutDialogBase.ui
+  UiGuiSettingsDialogBase.ui
+
+  AboutDialog.cpp
+  MainWindow.cpp
+  main.cpp
+  UiGuiSettings.cpp
+  UiGuiSettingsDialog.cpp
 )
 
 tde_add_executable( ${target} AUTOMOC
   SOURCES ${${target}_SRCS}
-	LINK ${TQT_LIBRARIES} ${TQSCINTILLA_LIBRARIES}
-	DESTINATION ${BIN_INSTALL_DIR}
+  LINK ${TQT_LIBRARIES} ${TQSCINTILLA_LIBRARIES}
+  DESTINATION ${BIN_INSTALL_DIR}
 )
diff --git a/src/UiGuiVersion.cpp b/src/UiGuiVersion.cpp
deleted file mode 100644
index c996ff5..0000000
--- a/src/UiGuiVersion.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006-2012 by Thomas Schweitzer                          *
- *   thomas-schweitzer(at)arcor.de                                         *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License version 2.0 as   *
- *   published by the Free Software Foundation.                            *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program in the file LICENSE.GPL; if not, write to the *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "UiGuiVersion.h"
-
-#include <tqstring.h>
-#include <tqstringlist.h>
-#include <tqdatetime.h>
-
-namespace UiGuiVersion
-{
-	/*!
-	    \brief Returns the build date as a localized string, e.g. "9. Februar 2009". If
-	    there was some kind of error, the returned string is empty.
-	 */
-	TQString getBuildDate()
-	{
-		TQStringList monthNames;
-		monthNames << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"
-			         << "Jul" << "Aug" << "Sep" << "Oct" << "Nov" << "Dec";
-
-		TQString     buildDateString = "";
-    // __DATE__ returns a string like "Feb  4 2009"
-		TQStringList buildDateStringList = TQStringList::split(' ', TQString(__DATE__).simplifyWhiteSpace());
-		if (buildDateStringList.count() == 3)
-		{
-			TQDate buildDate(buildDateStringList.last().toInt(),
-			        monthNames.findIndex(buildDateStringList.first()) + 1,
-			        buildDateStringList.at(1)->toInt());
-			buildDateString = buildDate.toString("d. MMMM yyyy");
-		}
-
-		return buildDateString;
-	}
-
-	/*!
-	    \brief Returns the revision number, that the current build is based on, as string. If
-	    there was some kind of error, the returned string is empty.
-	 */
-	TQString getBuildRevision()
-	{
-		TQString     buildRevision = "";
-		TQStringList buildRevisionStringList = TQStringList::split(' ', TQString(PROGRAM_REVISION).simplifyWhiteSpace());
-
-		if (buildRevisionStringList.count() == 3)
-		{
-			buildRevision = *buildRevisionStringList.at(1); // PROGRAM_REVISION is eg "$Revision: 907 $"
-		}
-
-		return buildRevision;
-	}
-}
diff --git a/src/UiGuiVersion.h b/src/UiGuiVersion.h
index e01f512..cee8a06 100644
--- a/src/UiGuiVersion.h
+++ b/src/UiGuiVersion.h
@@ -20,19 +20,9 @@
 #ifndef UIGUIVERSION_H
 #define UIGUIVERSION_H
 
-class TQString;
+#include "config.h"
 
 // Define the version number here. Update this as the last file before a release.
-#define PROGRAM_VERSION         1.2.0
-#define PROGRAM_VERSION_STRING  "1.2.0"
-#define RESOURCE_VERSION        1, 2, 0, 0
-#define RESOURCE_VERSION_STRING "1,2,0,0\0"
-#define PROGRAM_REVISION        "$Revision: 1070 $"
-
-namespace UiGuiVersion
-{
-	TQString getBuildDate();
-	TQString getBuildRevision();
-}
+#define PROGRAM_VERSION_STRING  "1.2.0-" GIT_HASH
 
 #endif
diff --git a/src/main.cpp b/src/main.cpp
index 38decad..c71d80f 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -65,8 +65,8 @@ int main(int argc, char *argv[])
 	{
  		// Define the command line object.
  		TCLAP::CmdLine cmd("If -p and -s are set, -p will be used.\n"
-				    "Giving no parameters starts full gui without server.", ' ',
-				    "UiGUI version " PROGRAM_VERSION_STRING " " PROGRAM_REVISION);
+				    "Giving no parameters starts full gui without server.",
+						' ', PROGRAM_VERSION_STRING);
  		cmd.setExceptionHandling(false);
  
  		// Define a value argument and add it to the command line.
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
 // --     TSLogger::getInstance(verboseLevel);
 // -- #endif
 // --     qInstallMsgHandler(TSLogger::messageHandler);
-// --     TSLogger::messageHandler(TSLoggerInfoMsg, TQString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).arg(PROGRAM_REVISION).toAscii());
+// --     TSLogger::messageHandler(TSLoggerInfoMsg, TQString("Starting UiGUI Version %1 %2").arg(PROGRAM_VERSION_STRING).toAscii());
 // -- 
   // Start normal with full gui and without server.
   if (!startAsPlugin && !startAsServer) {
diff --git a/src/tclap/StdOutput.h b/src/tclap/StdOutput.h
index 24b90ed..71a7ed8 100644
--- a/src/tclap/StdOutput.h
+++ b/src/tclap/StdOutput.h
@@ -99,7 +99,7 @@ namespace TCLAP
 		std::string progName = _cmd.getProgramName();
 		std::string version  = _cmd.getVersion();
 
-		std::cout << std::endl << progName << "  version: " << version << std::endl << std::endl;
+		std::cout << std::endl << progName << " version " << version << std::endl << std::endl;
 	}
 
 	inline void StdOutput::usage(CmdLineInterface &_cmd)
-- 
cgit v1.2.1