| 34 | }; |
| 35 | |
| 36 | void SettingsPrivate::fromJsonFile(const QString &fileName, SettingData *data) |
| 37 | { |
| 38 | if (fileName.isEmpty()) |
| 39 | return; |
| 40 | |
| 41 | QFile file(fileName); |
| 42 | if (!file.exists() && !makeFilePath(fileName)) { |
| 43 | qWarning() << "The setting file does not exist and failed to be created : " << fileName; |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | if (!file.open(QFile::ReadOnly)) { |
| 48 | qWarning() << "Failed to open the setting file. Error: " << file.errorString(); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | const QByteArray &json = file.readAll(); |
| 53 | if (json.isEmpty()) { |
| 54 | qWarning() << "The setting file is empty."; |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | fromJson(json, data); |
| 59 | } |
| 60 | |
| 61 | void SettingsPrivate::fromJson(const QByteArray &json, SettingData *data) |
| 62 | { |