MCPcopy Create free account
hub / github.com/ChiyukiGana/Quickinput / LoadJsonMacro

Function LoadJsonMacro

source/src/macro.cpp:194–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192 acRun.fromPack(pack.get("actions").toArray());
193 acEnd.fromPack(pack.get("actionsEnding").toArray());
194 acEnt.fromPack(pack.get("actionsEntry").toArray());
195}
196
197#if !defined(Q_ENCRYPT) || defined(Q_ENCRYPT_CVT)
198bool LoadJsonMacro(Macro& macro, const QString& path, const QString& name)
199{
200 QByteArray text;
201 if (!File::LoadText(path, text))
202 {
203 MsgBox::Error(reinterpret_cast<const wchar_t*>(name.utf16()), lang_trans("加载宏失败").toStdWString());
204 return false;
205 }
206 QJsonDocument json(QJsonDocument::fromJson(text));
207 if (!json.isObject())
208 {
209 MsgBox::Error(reinterpret_cast<const wchar_t*>(name.utf16()), lang_trans("宏数据错误").toStdWString());
210 return false;
211 }
212 macro.storageType = Macro::StorageType::JSON;
213 macro.name = name;
214 macro.fromJson(json.object());
215 return true;

Callers 1

loadAllMethod · 0.85

Calls 4

ErrorEnum · 0.85
fromJsonFunction · 0.85
isObjectMethod · 0.80
fromJsonMethod · 0.45

Tested by

no test coverage detected