MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / fromJsonFile

Method fromJsonFile

src/common/settings/settings.cpp:36–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34};
35
36void 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
61void SettingsPrivate::fromJson(const QByteArray &json, SettingData *data)
62{

Callers 3

SettingsMethod · 0.80
loadMethod · 0.80
reloadMethod · 0.80

Calls 5

readAllMethod · 0.80
isEmptyMethod · 0.45
existsMethod · 0.45
openMethod · 0.45
errorStringMethod · 0.45

Tested by

no test coverage detected