1/* GCompris - ChangeLog.qml
2 *
3 * SPDX-FileCopyrightText: 2016 Johnny Jazeix <jazeix@gmail.com>
4 *
5 * Authors:
6 *   Johnny Jazeix <jazeix@gmail.com>
7 *
8 *   SPDX-License-Identifier: GPL-3.0-or-later
9 */
10
11import QtQuick 2.9
12import GCompris 1.0
13/**
14 * Container object with a list of all the changes by version.
15 * @ingroup infrastructure
16 *
17 */
18QtObject {
19    /**
20     * type: list
21     * List of changelog objects.
22     *
23     * A changelog object consists of the properties @c versionCode
24     * and an optional @c content (which changes have been added in this version).
25     * The activities added in this version are retrieved from the ActivityInfoTree and directly displayed.
26     *
27     */
28    property var changelog: [
29            { "versionCode": 20000, "content": [
30                qsTr("Translation added for Azerbaijani"),
31                qsTr("New maps and update of the maps for geography activities"),
32                qsTr("New dataset containing loops operations for programming maze, and make tutorial images translated"),
33                qsTr("Addition of a level to teach voltage source loop in analog electricity activity"),
34                qsTr("Many new images"),
35                qsTr("Many usability improvements")
36                ]
37            },
38            { "versionCode": 10100, "content": [qsTr("Many usability improvements"),
39                qsTr("Many new images"),
40                qsTr("Many bug fixes")
41                ]
42            },
43            { "versionCode": 10000, "content": [qsTr("New Activity Settings menu, with dataset selection"),
44                qsTr("Many usability improvements"),
45                qsTr("Many new images"),
46                qsTr("Many bug fixes")
47                ]
48            },
49            { "versionCode": 9700, "content": [qsTr("New sub-categories to organize activities"),
50                qsTr("Translation added for Macedonian."),
51                qsTr("New activities Programming Maze and Baby Tangram"),
52                qsTr("New background music and volume settings."),
53                qsTr("New speed setting in several activities."),
54                qsTr("New option in chess to display captured pieces."),
55                qsTr("New images in Colors, Advanced colors and Target game."),
56                qsTr("New voices for US English."),
57                qsTr("Many little fixes and improvements.")] },
58            { "versionCode": 9600, "content": [qsTr("Translation updated for multiple languages (Breton, Brazilian Portuguese, Finnish...)."),
59                qsTr("Add Russian dataset for Click on letter activity."),
60                qsTr("Lang activity now available in Dutch.")] },
61            { "versionCode": 9500, "content": [qsTr("Merge Norwegian counties Nord-Trøndelag and Sør-Trøndelag into Trøndelag in geo-country activity."),
62                qsTr("Fix in braille activities where the cells start at 1, not 0."),
63                qsTr("Translation added for Basque, Hungarian and Malayalam."),
64                qsTr("Loading/saving of creations (Baby Wordprocessor, Balance Box and Piano Composition).")] },
65            { "versionCode": 9100, "content": [qsTr("Many little fixes and improvements."), qsTr("Translations added for Scottish Gaelic.")] },
66            { "versionCode": 9000, "content": [qsTr("License page added in configuration."), qsTr("Multiple changes on layouts to improve the ergonomy.")] },
67            { "versionCode": 8000, "content": [qsTr("Lang activity now available in Polish, Swedish and Ukrainian.")] },
68            { "versionCode": 7000, "content": [qsTr("Search feature.")] },
69            { "versionCode": 6000, "content": [qsTr("A Changelog.")] },
70            { "versionCode": 5200, "content": [qsTr("Many little fixes."), qsTr("Lang activity now available in French.")] },
71            { "versionCode": 5000, "content": [qsTr("Adding a loading overlay to let the user know that some actions are taking place (loading an activity for example) and can take some seconds."), qsTr("Translations added for: Catalan (Valencian), Chinese Traditional, Finnish (92% translated), Russian (98% translated), Slovak (92% translated), Turkish.")] },
72            { "versionCode": 4000, "content": [qsTr("Translations added for: Slovenian, German, Galician.")] }
73        ]
74
75    function isNewerVersion(previousVersion, newVersion) {
76        return newVersion > previousVersion
77    }
78
79    function getLogBetween(previousVersion, newVersion) {
80        var filtered = changelog.filter(function filter(obj) {
81            return isNewerVersion(previousVersion, obj['versionCode'])
82        });
83        var output = "";
84        // Retrieve all the activities created between the two versions
85        ActivityInfoTree.filterCreatedWithinVersions(previousVersion, newVersion);
86        var activities = ActivityInfoTree.menuTree;
87        // display for each version an optional text ("content") then the new activities
88        filtered.map(function filter(obj) {
89            var major = Math.floor((obj['versionCode'] / 10000));
90            var minor = (obj['versionCode'] % 10000 / 100);
91            var patch = (obj['versionCode'] % 100);
92
93            var version = major + "." + minor;
94            if(patch !== 0) {
95                version += "."+patch;
96            }
97            output += "<b>" + qsTr("Version %1:").arg(version) + "</b>";
98            output += "<ul>";
99            // display free text if exist
100            for(var i = 0; i < obj['content'].length; i++)
101                output += "<li>" + obj['content'][i] + "</li>";
102            // display the activity titles
103            for(var j in activities) {
104                var activity = activities[j];
105                if(activity.createdInVersion === obj['versionCode'] && activity.enabled) {
106                    output += "<li>" + activity.title + "</li>";
107                }
108            }
109            output += "</ul>";
110        });
111
112        // restore menu context
113        ActivityInfoTree.filterByTag("favorite")
114        ActivityInfoTree.filterEnabledActivities()
115
116        return output
117    }
118}
119