| 269 | } |
| 270 | |
| 271 | void BinaryToolsManager::save() |
| 272 | { |
| 273 | QJsonArray groupsArray; |
| 274 | |
| 275 | auto iter = allTools.begin(); |
| 276 | for (; iter != allTools.end(); ++iter) { |
| 277 | QJsonObject groupObject; |
| 278 | groupObject[NameKey] = iter.key(); |
| 279 | |
| 280 | QJsonArray itemsArray; |
| 281 | for (const auto &item : iter.value()) { |
| 282 | QJsonObject itemObject; |
| 283 | itemObject[IdKey] = item.id; |
| 284 | itemObject[NameKey] = item.name; |
| 285 | itemObject[DescriptionKey] = item.description; |
| 286 | itemObject[TypeKey] = item.type; |
| 287 | itemObject[CommandKey] = item.command; |
| 288 | itemObject[ArgumentsKey] = item.arguments; |
| 289 | itemObject[WorkingDirectoryKey] = item.workingDirectory; |
| 290 | itemObject[OutputOptionKey] = item.outputOption; |
| 291 | itemObject[ErrorOutputOptionKey] = item.errorOutputOption; |
| 292 | itemObject[AddToToolbarKey] = item.addToToolbar; |
| 293 | itemObject[IconKey] = item.icon; |
| 294 | itemObject[EnvironmentKey] = QJsonDocument::fromVariant(item.environment).object(); |
| 295 | |
| 296 | QJsonObject advObject; |
| 297 | advObject[MissingHintKey] = item.advSettings.missingHint; |
| 298 | advObject[InstallCommandKey] = item.advSettings.installCommand; |
| 299 | advObject[ChannelDataKey] = item.advSettings.channelData; |
| 300 | advObject[TriggerEventKey] = item.advSettings.triggerEvent; |
| 301 | itemObject[AdvanceObject] = advObject; |
| 302 | |
| 303 | itemsArray.append(itemObject); |
| 304 | } |
| 305 | |
| 306 | groupObject[ToolObject] = itemsArray; |
| 307 | groupsArray.append(groupObject); |
| 308 | } |
| 309 | |
| 310 | QJsonObject obj; |
| 311 | obj[GroupObject] = groupsArray; |
| 312 | obj[VersionKey] = cfgVersion; |
| 313 | |
| 314 | QJsonDocument doc(obj); |
| 315 | QString confPath = CustomPaths::user(CustomPaths::Flags::Configures) + QDir::separator() + QString("binarytools.json"); |
| 316 | QFile file(confPath); |
| 317 | if (file.open(QIODevice::WriteOnly)) { |
| 318 | file.write(doc.toJson()); |
| 319 | file.close(); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | void BinaryToolsManager::setTools(const BinaryTools &dataMap) |
| 324 | { |
no test coverage detected