From e55c19efd3e094a7ed623b7e64a5121e6d7a16a8 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Tue, 5 Mar 2024 16:47:21 +0500 Subject: [PATCH] Fix skin upload & delete buttons Closes #7 --- launcher/ui/pages/global/AccountListPage.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index 58aa42bc4..e7c1f8c5c 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -54,6 +54,7 @@ #include "tasks/Task.h" #include "Application.h" +#include "DesktopServices.h" AccountListPage::AccountListPage(QWidget* parent) : QMainWindow(parent), ui(new Ui::AccountListPage) { @@ -229,16 +230,18 @@ void AccountListPage::updateButtonStates() bool hasSelection = !selection.empty(); bool accountIsReady = false; bool accountIsOnline = false; + bool accountCanDeleteSkin = false; if (hasSelection) { QModelIndex selected = selection.first(); MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value(); accountIsReady = !account->isActive(); accountIsOnline = account->accountType() != AccountType::Offline; + accountCanDeleteSkin = account->accountType() == AccountType::MSA; } ui->actionRemove->setEnabled(accountIsReady); ui->actionSetDefault->setEnabled(accountIsReady); ui->actionUploadSkin->setEnabled(accountIsReady && accountIsOnline); - ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline); + ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline && accountCanDeleteSkin); ui->actionRefresh->setEnabled(accountIsReady && accountIsOnline); if (m_accounts->defaultAccount().get() == nullptr) { @@ -257,6 +260,11 @@ void AccountListPage::on_actionUploadSkin_triggered() if (selection.size() > 0) { QModelIndex selected = selection.first(); MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value(); + if (account->accountType() == AccountType::Mojang) { + DesktopServices::openUrl(QUrl("https://ely.by/skins/add")); + return; + } + SkinUploadDialog dialog(account, this); dialog.exec(); }