From 317101430148e3bbc52995aa92d668b8473026d9 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 29 Aug 2021 22:55:33 +0200 Subject: GH-3392 checking for migration status and refresh button in accounts list --- launcher/pages/global/AccountListPage.cpp | 17 +++++++++++++++++ launcher/pages/global/AccountListPage.h | 1 + launcher/pages/global/AccountListPage.ui | 9 +++++++++ 3 files changed, 27 insertions(+) (limited to 'launcher/pages') diff --git a/launcher/pages/global/AccountListPage.cpp b/launcher/pages/global/AccountListPage.cpp index 45b778de..6bb07b22 100644 --- a/launcher/pages/global/AccountListPage.cpp +++ b/launcher/pages/global/AccountListPage.cpp @@ -153,6 +153,22 @@ void AccountListPage::on_actionRemove_triggered() } } +void AccountListPage::on_actionRefresh_triggered() { + QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); + if (selection.size() > 0) { + QModelIndex selected = selection.first(); + MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value(); + AuthSessionPtr session = std::make_shared(); + auto task = account->refresh(session); + if (task) { + ProgressDialog progDialog(this); + progDialog.execWithTask(task.get()); + // TODO: respond to results of the task + } + } +} + + void AccountListPage::on_actionSetDefault_triggered() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); @@ -178,6 +194,7 @@ void AccountListPage::updateButtonStates() ui->actionSetDefault->setEnabled(selection.size() > 0); ui->actionUploadSkin->setEnabled(selection.size() > 0); ui->actionDeleteSkin->setEnabled(selection.size() > 0); + ui->actionRefresh->setEnabled(selection.size() > 0); if(m_accounts->activeAccount().get() == nullptr) { ui->actionNoDefault->setEnabled(false); diff --git a/launcher/pages/global/AccountListPage.h b/launcher/pages/global/AccountListPage.h index 24bb96da..4474802e 100644 --- a/launcher/pages/global/AccountListPage.h +++ b/launcher/pages/global/AccountListPage.h @@ -63,6 +63,7 @@ public slots: void on_actionAddMojang_triggered(); void on_actionAddMicrosoft_triggered(); void on_actionRemove_triggered(); + void on_actionRefresh_triggered(); void on_actionSetDefault_triggered(); void on_actionNoDefault_triggered(); void on_actionUploadSkin_triggered(); diff --git a/launcher/pages/global/AccountListPage.ui b/launcher/pages/global/AccountListPage.ui index 887c3d48..8af23a2f 100644 --- a/launcher/pages/global/AccountListPage.ui +++ b/launcher/pages/global/AccountListPage.ui @@ -54,6 +54,7 @@ + @@ -102,6 +103,14 @@ Add Microsoft + + + Refresh + + + Refresh the account tokens + + -- cgit