Disable skin buttons for offline accounts

This commit is contained in:
Gingeh 2022-06-29 18:46:39 +10:00
parent b606a2e040
commit d6f4ff26b5

View File

@ -255,18 +255,20 @@ void AccountListPage::updateButtonStates()
{ {
// If there is no selection, disable buttons that require something selected. // If there is no selection, disable buttons that require something selected.
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
bool hasSelection = selection.size() > 0; bool hasSelection = !selection.empty();
bool accountIsReady = false; bool accountIsReady = false;
bool accountIsOnline;
if (hasSelection) if (hasSelection)
{ {
QModelIndex selected = selection.first(); QModelIndex selected = selection.first();
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>(); MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
accountIsReady = !account->isActive(); accountIsReady = !account->isActive();
accountIsOnline = !account->isOffline();
} }
ui->actionRemove->setEnabled(accountIsReady); ui->actionRemove->setEnabled(accountIsReady);
ui->actionSetDefault->setEnabled(accountIsReady); ui->actionSetDefault->setEnabled(accountIsReady);
ui->actionUploadSkin->setEnabled(accountIsReady); ui->actionUploadSkin->setEnabled(accountIsReady && accountIsOnline);
ui->actionDeleteSkin->setEnabled(accountIsReady); ui->actionDeleteSkin->setEnabled(accountIsReady && accountIsOnline);
ui->actionRefresh->setEnabled(accountIsReady); ui->actionRefresh->setEnabled(accountIsReady);
if(m_accounts->defaultAccount().get() == nullptr) { if(m_accounts->defaultAccount().get() == nullptr) {