| 328 | } |
| 329 | |
| 330 | bool Component::customize() |
| 331 | { |
| 332 | if (isCustom()) { |
| 333 | return false; |
| 334 | } |
| 335 | |
| 336 | auto filename = getFilename(); |
| 337 | if (!FS::ensureFilePathExists(filename)) { |
| 338 | return false; |
| 339 | } |
| 340 | // FIXME: get rid of this try-catch. |
| 341 | try { |
| 342 | QSaveFile jsonFile(filename); |
| 343 | if (!jsonFile.open(QIODevice::WriteOnly)) { |
| 344 | return false; |
| 345 | } |
| 346 | auto vfile = getVersionFile(); |
| 347 | if (!vfile) { |
| 348 | return false; |
| 349 | } |
| 350 | auto document = OneSixVersionFormat::versionFileToJson(vfile); |
| 351 | jsonFile.write(document.toJson()); |
| 352 | if (!jsonFile.commit()) { |
| 353 | return false; |
| 354 | } |
| 355 | m_file = vfile; |
| 356 | m_metaVersion.reset(); |
| 357 | emit dataChanged(); |
| 358 | } catch (const Exception& error) { |
| 359 | qWarning() << "Version could not be loaded:" << error.cause(); |
| 360 | } |
| 361 | return true; |
| 362 | } |
| 363 | |
| 364 | bool Component::revert() |
| 365 | { |
no test coverage detected