From 3481acbe3cd3c1692786d3cfeddd41fbdbd26dd2 Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Tue, 16 Oct 2018 02:03:29 +0200 Subject: [PATCH] Print the GUI version on application startup --- main.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 79223c0d..c685c670 100644 --- a/main.cpp +++ b/main.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include "clipboardAdapter.h" #include "filter.h" #include "oscursor.h" @@ -140,10 +141,24 @@ int main(int argc, char *argv[]) qreal physicalDpi = QGuiApplication::primaryScreen()->physicalDotsPerInch(); qreal calculated_ratio = physicalDpi/ref_dpi; - qWarning().nospace() << "Qt:" << QT_VERSION_STR << " | screen: " << rect.width() - << "x" << rect.height() << " - dpi: " << dpi << " - ratio:" - << calculated_ratio; + QString GUI_VERSION = "-"; + QFile f(":/version.js"); + if(!f.open(QFile::ReadOnly)) { + qWarning() << "Could not read qrc:///version.js"; + } else { + QByteArray contents = f.readAll(); + f.close(); + QRegularExpression re("var GUI_VERSION = \"(.*)\""); + QRegularExpressionMatch version_match = re.match(contents); + if (version_match.hasMatch()) { + GUI_VERSION = version_match.captured(1); // "v0.13.0.3" + } + } + + qWarning().nospace().noquote() << "Qt:" << QT_VERSION_STR << " GUI:" << GUI_VERSION + << " | screen: " << rect.width() << "x" << rect.height() + << " - dpi: " << dpi << " - ratio:" << calculated_ratio; // registering types for QML qmlRegisterType("moneroComponents.Clipboard", 1, 0, "Clipboard");