| 554 | } |
| 555 | |
| 556 | bool AccountList::loadV3(QJsonObject& root) { |
| 557 | beginResetModel(); |
| 558 | QJsonArray accounts = root.value("accounts").toArray(); |
| 559 | for (QJsonValue accountVal : accounts) |
| 560 | { |
| 561 | QJsonObject accountObj = accountVal.toObject(); |
| 562 | MinecraftAccountPtr account = MinecraftAccount::loadFromJsonV3(accountObj); |
| 563 | if (account.get() != nullptr) |
| 564 | { |
| 565 | auto profileId = account->profileId(); |
| 566 | if(profileId.size()) { |
| 567 | if(findAccountByProfileId(profileId) != -1) { |
| 568 | continue; |
| 569 | } |
| 570 | } |
| 571 | connect(account.get(), &MinecraftAccount::changed, this, &AccountList::accountChanged); |
| 572 | connect(account.get(), &MinecraftAccount::activityChanged, this, &AccountList::accountActivityChanged); |
| 573 | m_accounts.append(account); |
| 574 | if(accountObj.value("active").toBool(false)) { |
| 575 | m_defaultAccount = account; |
| 576 | } |
| 577 | } |
| 578 | else |
| 579 | { |
| 580 | qWarning() << "Failed to load an account."; |
| 581 | } |
| 582 | } |
| 583 | endResetModel(); |
| 584 | return true; |
| 585 | } |
| 586 | |
| 587 | |
| 588 | bool AccountList::saveList() |