Skip to content
Snippets Groups Projects
Commit 7611d56f authored by Martin Straka's avatar Martin Straka
Browse files

Show change log dialog after update on new version.

parent 2f99ea58
Branches
1 merge request!379Show ChangeLog
......@@ -238,6 +238,7 @@ qt_add_qml_module(mobile-datovka
res/../qml/components/FilterBar.qml
res/../qml/components/GovFormList.qml
res/../qml/components/GovServiceList.qml
res/../qml/components/ChangeLogBox.qml
res/../qml/components/MessageBox.qml
res/../qml/components/MessageList.qml
res/../qml/components/PageHeader.qml
......
/*
* Copyright (C) 2014-2025 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.2
/*
* Provides a simple change log dialog.
*/
Popup {
id: root
anchors.centerIn: parent
modal: true
property int preferredMinWidth: 280
property string logContent: qsTr("
Added a preferences editor.
Using dedicated redirection URL to access donation page.
Custom images can be assigned to individual data boxes as logos in the data-box list.
Fixed white border around launcher icon in iOS.
On application start-up when INI configuration is missing the application searches for a copy before creating a blank INI file.
")
/* Public interface. */
function showChangeLog() {
changeLogText.text = logContent
root.open()
}
background: Rectangle {
color: datovkaPalette.base
border.color: datovkaPalette.text
radius: defaultMargin
}
ColumnLayout {
spacing: defaultMargin * 2
AccessibleText {
font.bold: true
Layout.alignment: Qt.AlignCenter
color: datovkaPalette.highlightedText
text: qsTr("Version") + ": " + Qt.application.version
}
AccessibleText {
Layout.preferredWidth: root.preferredMinWidth
horizontalAlignment : Text.Center
wrapMode: Text.Wrap
font.bold: true
text: qsTr("What is news?")
}
Flickable {
clip: true
Layout.preferredWidth: root.preferredMinWidth
implicitHeight: preferredMinWidth
contentHeight: flickContent.implicitHeight
Pane {
id: flickContent
anchors.fill: parent
AccessibleText {
id: changeLogText
width: parent.width
wrapMode: Text.WordWrap
}
}
ScrollIndicator.vertical: ScrollIndicator {}
}
AccessibleButton {
Layout.alignment: Qt.AlignCenter
text: "OK"
onClicked: root.close()
}
}
}
......@@ -262,6 +262,10 @@ ApplicationWindow {
id: okMsgBox
}
ChangeLogBox {
id: changeLogBox
}
DrawerMenuDatovka {
id: drawerMenuDatovka
}
......@@ -480,6 +484,10 @@ ApplicationWindow {
target: settings
function onRunOnAppStartUpSig() {
console.log("Running actions after application start-up.")
var isNewVersion = settings.isNewVersion()
if (isNewVersion) {
changeLogBox.showChangeLog()
}
var areNews = messages.checkNewDatabasesFormat()
if (!areNews) {
pageView.push(pageConvertDatabase, {
......
......@@ -88,6 +88,12 @@ Page {
+ "<br/>"
+ "<a href=\"%1\">%2</a>".arg("https://datovka.nic.cz/redirect/donation-mobile.html").arg(qsTr("Make a donation."))
}
AccessibleButton {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Show ChangeLog")
accessibleName: qsTr("What is news?")
onClicked: changeLogBox.showChangeLog()
}
AccessibleTextInfo {
horizontalAlignment: Text.AlignHCenter
textFormat: TextEdit.RichText
......
......@@ -24,6 +24,7 @@
<file>../qml/components/FilterBar.qml</file>
<file>../qml/components/GovFormList.qml</file>
<file>../qml/components/GovServiceList.qml</file>
<file>../qml/components/ChangeLogBox.qml</file>
<file>../qml/components/MessageBox.qml</file>
<file>../qml/components/MessageList.qml</file>
<file>../qml/components/PageHeader.qml</file>
......
......@@ -194,6 +194,7 @@ const struct QmlTypeEntry qmlComponents[] = {
{ "FilterBar", 1, 0 },
{ "GovFormList", 1, 0 },
{ "GovServiceList", 1, 0 },
{ "ChangeLogBox", 1, 0 },
{ "MessageBox", 1, 0 },
{ "MessageList", 1, 0 },
{ "PageHeader", 1, 0 },
......
......@@ -22,6 +22,7 @@
*/
#include <QtGlobal> /* QT_VERSION, qVersion() */
#include <QVersionNumber>
#if defined (Q_OS_ANDROID)
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
......@@ -782,3 +783,71 @@ bool GlobalSettingsQmlWrapper::useIosDocumentPicker(void)
return false;
}
}
/*!
* @brief Compare current app version and pref db version.
*
* @param[in] cVersion App current version string.
* @param[in] dbVersion Pref database version string.
* @return True if current app version is higher.
*/
static
bool compareVersionStrings(const QString &cVersion, const QString &dbVersion)
{
QVersionNumber v1 = QVersionNumber::fromString(cVersion);
if (v1.isNull()) {
logErrorNL(
"Version string '%s' does not match required format.",
cVersion.toUtf8().constData());
return false;
}
QVersionNumber v2 = QVersionNumber::fromString(dbVersion);
if (v2.isNull()) {
logErrorNL(
"Version string '%s' does not match required format.",
dbVersion.toUtf8().constData());
return false;
}
int cmp = QVersionNumber::compare(v1, v2);
if (cmp < 0) {
return false;
} else if (cmp == 0) {
return false;
} else {
return true;
}
}
bool GlobalSettingsQmlWrapper::isNewVersion(void)
{
bool isNew = true;
QString dbVersion;
if (GlobInstcs::prefsPtr != Q_NULLPTR) {
GlobInstcs::prefsPtr->strVal("app.version", dbVersion);
} else {
Q_ASSERT(0);
}
if (Q_UNLIKELY(dbVersion.isEmpty())) {
if (GlobInstcs::prefsPtr != Q_NULLPTR) {
GlobInstcs::prefsPtr->setStrVal("app.version", VERSION);
return isNew;
} else {
Q_ASSERT(0);
}
}
isNew = compareVersionStrings(VERSION, dbVersion);
if (isNew) {
if (GlobInstcs::prefsPtr != Q_NULLPTR) {
GlobInstcs::prefsPtr->setStrVal("app.version", VERSION);
return isNew;
} else {
Q_ASSERT(0);
}
}
return isNew;
}
......@@ -491,6 +491,14 @@ public:
Q_INVOKABLE static
bool useIosDocumentPicker(void);
/*!
* @brief Check if new version after first startup.
*
* @return True if it is new version after first startup.
*/
Q_INVOKABLE static
bool isNewVersion(void);
signals:
/*!
* @brief Send PIN verification result to QML.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment