diff --git a/ZXTapeReviver.pro b/ZXTapeReviver.pro index e5f0f4d..0171951 100644 --- a/ZXTapeReviver.pro +++ b/ZXTapeReviver.pro @@ -65,10 +65,17 @@ TRANSLATIONS_GENERATED_FILENAME_CPP = $${TRANSLATIONS_GENERATED_FILENAME}.cpp write_file($${TRANSLATIONS_GENERATED_FILENAME_H}, TRANSLATION_IDS_HEADER) write_file($${TRANSLATIONS_GENERATED_FILENAME_CPP}, TRANSLATION_IDS_CODE) +contains(QMAKE_HOST.os, Windows) { + GIT_CMD = \"$$system(where git)\" +} +else { + GIT_CMD = $$system(which git) +} +ZXTAPEREVIVER_VERSION = $$system($${GIT_CMD} --git-dir $${PWD}/.git --work-tree $${PWD} describe --always --tags) DEFINES += TRANSLATION_IDS_HEADER="\\\"$${TRANSLATIONS_GENERATED_FILENAME_H}\\\"" \ - TRANSLATION_IDS_CODE="\\\"$${TRANSLATIONS_GENERATED_FILENAME_CPP}\\\"" - + TRANSLATION_IDS_CODE="\\\"$${TRANSLATIONS_GENERATED_FILENAME_CPP}\\\"" \ + ZXTAPEREVIVER_VERSION=\\\"$${ZXTAPEREVIVER_VERSION}\\\" SOURCES += \ sources/main.cpp \ diff --git a/qml/About.qml b/qml/About.qml index f518567..0db744e 100644 --- a/qml/About.qml +++ b/qml/About.qml @@ -16,6 +16,7 @@ import QtQuick.Controls 1.3 import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.15 +import com.models.zxtapereviver 1.0 import "." Dialog { @@ -30,7 +31,7 @@ Dialog { Text { id: zxTapeReviverText - text: 'ZX Tape Reviver (c) 2020-2021 Leonid Golouz' + text: 'ZX Tape Reviver %1 (c) 2020-2021 Leonid Golouz'.arg(ConfigurationManager.zxTapeReviverVersion) onLinkActivated: Qt.openUrlExternally(link) } Text { diff --git a/sources/configuration/configurationmanager.cpp b/sources/configuration/configurationmanager.cpp index ff087db..f4b49f8 100644 --- a/sources/configuration/configurationmanager.cpp +++ b/sources/configuration/configurationmanager.cpp @@ -227,6 +227,15 @@ ConfigurationManager::~ConfigurationManager() writeConfiguration(); } +QString ConfigurationManager::getZxTapeReviverVersion() const { + const auto split { getZxTapeReviverBuildTag().split('_', Qt::SkipEmptyParts) }; + return split.isEmpty() ? QString() : split.last(); +} + +QString ConfigurationManager::getZxTapeReviverBuildTag() const { + return ZXTAPEREVIVER_VERSION; +} + QString ConfigurationManager::getSettingKey(INISections section, INIKeys key) const { return getEnumName(section) + "/" + getEnumName(key); } diff --git a/sources/configuration/configurationmanager.h b/sources/configuration/configurationmanager.h index 3faf322..e432479 100644 --- a/sources/configuration/configurationmanager.h +++ b/sources/configuration/configurationmanager.h @@ -25,6 +25,9 @@ class ConfigurationManager final : public QObject, protected EnumMetaInfo { Q_OBJECT + Q_PROPERTY(QString zxTapeReviverVersion READ getZxTapeReviverVersion CONSTANT) + Q_PROPERTY(QString zxTapeReviverBuildTag READ getZxTapeReviverBuildTag CONSTANT) + public: enum class INISections { COLOR, @@ -194,6 +197,9 @@ class ConfigurationManager final : public QObject, protected EnumMetaInfo { virtual ~ConfigurationManager() override; + QString getZxTapeReviverVersion() const; + QString getZxTapeReviverBuildTag() const; + static ConfigurationManager* instance(); private: diff --git a/sources/main.cpp b/sources/main.cpp index 426e366..9286b9d 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -37,6 +37,7 @@ void registerTypes() qmlRegisterSingletonInstance("com.core.zxtapereviver", 1, 0, "WavReader", WavReader::instance()); qmlRegisterSingletonInstance("com.core.zxtapereviver", 1, 0, "WaveformParser", WaveformParser::instance()); qmlRegisterSingletonInstance("com.models.zxtapereviver", 1, 0, "ParserSettingsModel", ParserSettingsModel::instance()); + qmlRegisterSingletonInstance("com.models.zxtapereviver", 1, 0, "ConfigurationManager", ConfigurationManager::instance()); } int main(int argc, char *argv[])