Skip to content

Commit

Permalink
Fixed [ZXTR-36] [FR] App version in "About..."
Browse files Browse the repository at this point in the history
  • Loading branch information
lgolouz committed Nov 1, 2021
1 parent 4382746 commit bccbd21
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
11 changes: 9 additions & 2 deletions ZXTapeReviver.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 2 additions & 1 deletion qml/About.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -30,7 +31,7 @@ Dialog {

Text {
id: zxTapeReviverText
text: 'ZX Tape Reviver (c) 2020-2021 <a href="mailto:[email protected]">Leonid Golouz</a>'
text: '<b>ZX Tape Reviver</b> <i>%1</i> (c) 2020-2021 <a href="mailto:[email protected]">Leonid Golouz</a>'.arg(ConfigurationManager.zxTapeReviverVersion)
onLinkActivated: Qt.openUrlExternally(link)
}
Text {
Expand Down
9 changes: 9 additions & 0 deletions sources/configuration/configurationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 6 additions & 0 deletions sources/configuration/configurationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -194,6 +197,9 @@ class ConfigurationManager final : public QObject, protected EnumMetaInfo {

virtual ~ConfigurationManager() override;

QString getZxTapeReviverVersion() const;
QString getZxTapeReviverBuildTag() const;

static ConfigurationManager* instance();

private:
Expand Down
1 change: 1 addition & 0 deletions sources/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void registerTypes()
qmlRegisterSingletonInstance<WavReader>("com.core.zxtapereviver", 1, 0, "WavReader", WavReader::instance());
qmlRegisterSingletonInstance<WaveformParser>("com.core.zxtapereviver", 1, 0, "WaveformParser", WaveformParser::instance());
qmlRegisterSingletonInstance<ParserSettingsModel>("com.models.zxtapereviver", 1, 0, "ParserSettingsModel", ParserSettingsModel::instance());
qmlRegisterSingletonInstance<ConfigurationManager>("com.models.zxtapereviver", 1, 0, "ConfigurationManager", ConfigurationManager::instance());
}

int main(int argc, char *argv[])
Expand Down

0 comments on commit bccbd21

Please sign in to comment.