Skip to content

Commit

Permalink
Fix skin upload & delete buttons
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
Octol1ttle committed Apr 24, 2024
1 parent 395f498 commit e55c19e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion launcher/ui/pages/global/AccountListPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "tasks/Task.h"

#include "Application.h"
#include "DesktopServices.h"

AccountListPage::AccountListPage(QWidget* parent) : QMainWindow(parent), ui(new Ui::AccountListPage)
{
Expand Down Expand Up @@ -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<MinecraftAccountPtr>();
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) {
Expand All @@ -257,6 +260,11 @@ void AccountListPage::on_actionUploadSkin_triggered()
if (selection.size() > 0) {
QModelIndex selected = selection.first();
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
if (account->accountType() == AccountType::Mojang) {
DesktopServices::openUrl(QUrl("https://ely.by/skins/add"));
return;
}

SkinUploadDialog dialog(account, this);
dialog.exec();
}
Expand Down

0 comments on commit e55c19e

Please sign in to comment.