Skip to content
Snippets Groups Projects
Commit 12ab9e69 authored by Felix Gerking's avatar Felix Gerking
Browse files

qt-guf-demo: Add git version tag to app (Demo 219 Design), refs #34916

* guf-show-demo.pro: Added define that keeps the current git version state
* main-cpp: Added a function to return the git tag, registerd the function to QML
* SettingsPage.qml: Added a GroupBox which displays the git tag

Change-Id: Ib68effe2b5ea5b4498e874d12d4bd2be0561d0b9
parent fa3a140b
No related branches found
No related tags found
No related merge requests found
QT += quick concurrent
CONFIG += c++17
# Get git version
GIT_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
......@@ -7,6 +9,9 @@ CONFIG += c++17
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# To use git version in C++
DEFINES += GIT_VERSION=\\\"$$GIT_VERSION\\\"
# DEFINES += GIT_VERSION=\\\"/usr/local/share/kphone\\\"
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
......
......@@ -14,6 +14,16 @@
#include "NetworkSettings.h"
#include "System.h"
// Set Git tag
static QJSValue appVersionSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
Q_UNUSED(engine)
QJSValue appInfo = scriptEngine->newObject();
appInfo.setProperty("version", GIT_VERSION);
return appInfo;
}
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
......@@ -21,6 +31,9 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
// Git tag to QML
qmlRegisterSingletonType("Native", 1, 0, "AppInfo", appVersionSingletonProvider);
System system;
NetworkSettings networkSettings;
KioskCart cart;
......
......@@ -3,6 +3,7 @@ import QtQuick.Window 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import Native 1.0
ContentPage {
id: page
......@@ -434,6 +435,74 @@ ContentPage {
}
}
}
GroupBox {
id: versionBox
title: 'Version'
implicitWidth: view.width
label: Text {
color: '#6c963d'
font.family: 'DINOT'
font.bold: true
font.pointSize: 16
text: versionBox.title
}
background: Item {
Rectangle {
anchors.fill: parent
anchors.topMargin: versionBox.topPadding - versionBox.padding
border.color: 'black'
border.width: 1
color: '#f4f4f4'
}
}
ColumnLayout {
anchors.fill: parent
spacing: 10
Item {
Layout.preferredWidth: parent.width
Layout.preferredHeight: 50
RowLayout {
id: versionToRow
anchors.fill: parent
spacing: 40
Text {
id: versionToLabel
text: 'Git-Tag'
color: 'black'
font.family: 'DINOT'
font.pointSize: 14
Layout.preferredWidth: 200
verticalAlignment: Text.AlignVCenter
Component.onCompleted: {
if ( Screen.width == 480 && Screen.height == 800 ) {
font.pointSize = 7
}
}
}
Text {
id: versionToText
Layout.minimumWidth: parent.width - emailToLabel.width - emailToRow.spacing - 10
Layout.maximumWidth: parent.width - emailToLabel.width - emailToRow.spacing - 10
font.family: 'DINOT'
font.pointSize: 14
color: "black"
Component.onCompleted: text = AppInfo.version //native
}
}
}
}
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment