diff --git a/app/qml/ApplicationSettings.qml b/app/qml/ApplicationSettings.qml index 1742d89..3a44e6f 100644 --- a/app/qml/ApplicationSettings.qml +++ b/app/qml/ApplicationSettings.qml @@ -24,7 +24,9 @@ import QtQuick.Controls 1.0 import "utils.js" as Utils QtObject{ - property string version: "1.0.1" + readonly property string version: "1.0.1" + readonly property int profileVersion: 2 + // STATIC CONSTANTS //////////////////////////////////////////////////////// diff --git a/app/qml/SettingsGeneralTab.qml b/app/qml/SettingsGeneralTab.qml index 3df37f5..ec4cf55 100644 --- a/app/qml/SettingsGeneralTab.qml +++ b/app/qml/SettingsGeneralTab.qml @@ -107,12 +107,15 @@ Tab{ if (!name) throw "Profile doesn't have a name"; + var version = profileObject.version !== undefined ? profileObject.version : 1; + if (version !== appSettings.profileVersion) + throw "This profile is not supported on this version of CRT."; + delete profileObject.name; appSettings.appendCustomProfile(name, JSON.stringify(profileObject)); } catch (err) { - console.log(err); - messageDialog.text = qsTr("There has been an error reading the file.") + messageDialog.text = qsTr(err) messageDialog.open(); } } @@ -144,6 +147,7 @@ Tab{ var profileObject = appSettings.profilesList.get(currentIndex); var profileSettings = JSON.parse(profileObject.obj_string); profileSettings["name"] = profileObject.text; + profileSettings["version"] = appSettings.profileVersion; var result = fileIO.write(url, JSON.stringify(profileSettings, undefined, 2)); if (!result) diff --git a/app/qml/Storage.qml b/app/qml/Storage.qml index a95dd02..6554314 100644 --- a/app/qml/Storage.qml +++ b/app/qml/Storage.qml @@ -22,10 +22,12 @@ import QtQuick 2.2 import QtQuick.LocalStorage 2.0 QtObject { + readonly property string dbMajorVersion: "1" + readonly property string dbMinorVersion: "1.0" property bool initialized: false function getDatabase() { - return LocalStorage.openDatabaseSync("coolretroterm", "1.0", "StorageDatabase", 100000); + return LocalStorage.openDatabaseSync("coolretroterm" + dbMajorVersion, dbMinorVersion, "StorageDatabase", 100000); } function initialize() {