| 211 | } |
| 212 | macro.storageType = Macro::StorageType::JSON; |
| 213 | macro.name = name; |
| 214 | macro.fromJson(json.object()); |
| 215 | return true; |
| 216 | } |
| 217 | bool LoadQimMacro(Macro& macro, const QString& path, const QString& name) |
| 218 | { |
| 219 | auto data = File::FileReadAll(path.toStdWString()); |
| 220 | if (data.empty()) |
| 221 | { |
| 222 | MsgBox::Error(reinterpret_cast<const wchar_t*>(name.utf16()), lang_trans("加载宏失败").toStdWString()); |
| 223 | return false; |
| 224 | } |
| 225 | typepack::object pack = typepack::object::fromBinary(data); |
| 226 | if (pack.empty()) |
| 227 | { |
| 228 | MsgBox::Error(reinterpret_cast<const wchar_t*>(name.utf16()), lang_trans("宏数据错误").toStdWString()); |
| 229 | return false; |
| 230 | } |
| 231 | macro.storageType = Macro::StorageType::QIM; |
| 232 | macro.name = name; |
| 233 | macro.fromPack(pack); |
| 234 | return true; |