UltimMC: Actually make profile for local accounts, fixes #334

This commit is contained in:
Neptune
2024-03-07 23:57:59 -05:00
parent 17a06d8eab
commit 0b4b9a1783
18 changed files with 305 additions and 57 deletions

View File

@@ -27,12 +27,11 @@ void LocalLoginDialog::accept()
setUserInputsEnabled(false);
ui->progressBar->setVisible(true);
m_account = MinecraftAccount::createFromUsername(ui->userTextBox->text());
m_account->setProvider(AuthProviders::lookup("dummy"));
m_account = MinecraftAccount::createLocal(ui->userTextBox->text());
m_account->setProvider(AuthProviders::lookup("local"));
// Setup the login task and start it
const char *dummy_password = " ";
m_loginTask = m_account->login(QString::fromLatin1(dummy_password));
m_loginTask = m_account->loginLocal();
connect(m_loginTask.get(), &Task::failed, this, &LocalLoginDialog::onTaskFailed);
connect(m_loginTask.get(), &Task::succeeded, this, &LocalLoginDialog::onTaskSucceeded);
connect(m_loginTask.get(), &Task::status, this, &LocalLoginDialog::onTaskStatus);

View File

@@ -30,7 +30,7 @@ LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LoginDia
for(auto provider: AuthProviders::getAll()) {
auto providerId = provider->id();
// Exclude Microsoft and Local accounts from here...
if (providerId != "MSA" && providerId != "dummy") {
if (providerId != "MSA" && providerId != "local") {
QRadioButton *button = new QRadioButton(provider->displayName());
m_radioButtons[providerId] = button;
ui->radioLayout->addWidget(button);

View File

@@ -59,9 +59,7 @@ ProfileSetupDialog::~ProfileSetupDialog()
void ProfileSetupDialog::on_buttonBox_accepted()
{
//setNameStatus(NameStatus::Available);
accept();
//setupProfile(currentCheck);
setupProfile(currentCheck);
}
void ProfileSetupDialog::on_buttonBox_rejected()
@@ -173,8 +171,7 @@ void ProfileSetupDialog::checkFinished(
}
}
else {
setNameStatus(NameStatus::Available);
//setNameStatus(NameStatus::Error, tr("Failed to check name availability."));
setNameStatus(NameStatus::Error, tr("Failed to check name availability."));
}
isChecking = false;
}
@@ -241,7 +238,7 @@ void ProfileSetupDialog::setupProfileFinished(
requestor->deleteLater();
isWorking = false;
if(error != QNetworkReply::NoError) {
if(error == QNetworkReply::NoError) {
/*
* data contains the profile in the response
* ... we could parse it and update the account, but let's just return back to the normal login flow instead...

View File

@@ -215,24 +215,19 @@ void AccountListPage::updateButtonStates()
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
bool hasSelection = selection.size() > 0;
bool accountIsReady = false;
bool accountIsOnline = false;
if (hasSelection)
{
QModelIndex selected = selection.first();
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
accountIsReady = !account->isActive();
accountIsOnline = account->typeString() != "local" && account->typeString() != "elyby";
}
ui->actionRemove->setEnabled(accountIsReady);
ui->actionSetDefault->setEnabled(accountIsReady);
// Don't enable skin change buttons for dummy and ely.by accounts, they don't work.
if (hasSelection) {
QModelIndex selected = selection.first();
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
if (account->provider()->id() != "dummy" && account->provider()->id() != "elyby") {
ui->actionUploadSkin->setEnabled(accountIsReady);
ui->actionDeleteSkin->setEnabled(accountIsReady);
}
}
ui->actionRefresh->setEnabled(accountIsReady);
ui->actionUploadSkin->setEnabled(accountIsReady && accountIsOnline);
ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline);
ui->actionRefresh->setEnabled(accountIsReady && accountIsOnline);
if(m_accounts->defaultAccount().get() == nullptr) {
ui->actionNoDefault->setEnabled(false);