Change organizationName and use QSettings:IniFormat (#1213)

* Remove organizationName

* Use QSettings::IniFormat and migrate if possible

* Use RadareOrg as the organizationName
This commit is contained in:
Florian Märkl 2019-02-22 14:38:02 +01:00 committed by GitHub
parent 5313017c54
commit 2d2b9c8a28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,14 +2,35 @@
#include "CutterApplication.h"
#include "MainWindow.h"
/*!
* \brief Migrate Settings used before Cutter 1.8
*/
static void migrateSettings(QSettings &newSettings)
{
QSettings oldSettings(QSettings::NativeFormat, QSettings::Scope::UserScope, "Cutter", "Cutter");
for (const QString &key : oldSettings.allKeys()) {
newSettings.setValue(key, oldSettings.value(key));
}
oldSettings.clear();
QFile settingsFile(oldSettings.fileName());
settingsFile.remove();
}
int main(int argc, char *argv[])
{
qRegisterMetaType<QList<StringDescription>>();
qRegisterMetaType<QList<FunctionDescription>>();
// Application info setup, required to be set before any instance of QSettings will be instantiated
QCoreApplication::setOrganizationName("Cutter");
QCoreApplication::setOrganizationName("RadareOrg");
QCoreApplication::setApplicationName("Cutter");
QSettings::setDefaultFormat(QSettings::IniFormat);
QSettings settings;
if (!settings.value("settings_migrated", false).toBool()) {
qInfo() << "Settings have not been migrated before, trying to migrate from pre-1.8 if possible.";
migrateSettings(settings);
settings.setValue("settings_migrated", true);
}
CutterApplication a(argc, argv);