| 41 | } |
| 42 | |
| 43 | void LaunchController::decideAccount() |
| 44 | { |
| 45 | if(m_accountToUse) { |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | // Find an account to use. |
| 50 | auto accounts = APPLICATION->accounts(); |
| 51 | if (accounts->count() <= 0) |
| 52 | { |
| 53 | // Tell the user they need to log in at least one account in order to play. |
| 54 | auto reply = CustomMessageBox::selectable( |
| 55 | m_parentWidget, |
| 56 | tr("No Accounts"), |
| 57 | tr("In order to play Minecraft, you must have at least one Mojang or Minecraft " |
| 58 | "account logged in." |
| 59 | "Would you like to open the account manager to add an account now?"), |
| 60 | QMessageBox::Information, |
| 61 | QMessageBox::Yes | QMessageBox::No |
| 62 | )->exec(); |
| 63 | |
| 64 | if (reply == QMessageBox::Yes) |
| 65 | { |
| 66 | // Open the account manager. |
| 67 | APPLICATION->ShowGlobalSettings(m_parentWidget, "accounts"); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | m_accountToUse = accounts->defaultAccount(); |
| 72 | if (!m_accountToUse) |
| 73 | { |
| 74 | // If no default account is set, ask the user which one to use. |
| 75 | ProfileSelectDialog selectDialog( |
| 76 | tr("Which account would you like to use?"), |
| 77 | ProfileSelectDialog::GlobalDefaultCheckbox, |
| 78 | m_parentWidget |
| 79 | ); |
| 80 | |
| 81 | selectDialog.exec(); |
| 82 | |
| 83 | // Launch the instance with the selected account. |
| 84 | m_accountToUse = selectDialog.selectedAccount(); |
| 85 | |
| 86 | // If the user said to use the account as default, do that. |
| 87 | if (selectDialog.useAsGlobalDefault() && m_accountToUse) { |
| 88 | accounts->setDefaultAccount(m_accountToUse); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | |
| 94 | void LaunchController::login() { |
nothing calls this directly
no test coverage detected