NOISSUE implement deleting skins

This commit is contained in:
Petr Mrázek
2021-02-11 02:22:43 +01:00
parent 280903e52b
commit 1edcd9b86e
9 changed files with 118 additions and 19 deletions

View File

@ -30,6 +30,7 @@
#include "dialogs/SkinUploadDialog.h"
#include "tasks/Task.h"
#include "minecraft/auth/YggdrasilTask.h"
#include "minecraft/services/SkinDelete.h"
#include "MultiMC.h"
@ -142,6 +143,7 @@ void AccountListPage::updateButtonStates()
ui->actionRemove->setEnabled(selection.size() > 0);
ui->actionSetDefault->setEnabled(selection.size() > 0);
ui->actionUploadSkin->setEnabled(selection.size() > 0);
ui->actionDeleteSkin->setEnabled(selection.size() > 0);
if(m_accounts->activeAccount().get() == nullptr) {
ui->actionNoDefault->setEnabled(false);
@ -191,3 +193,25 @@ void AccountListPage::on_actionUploadSkin_triggered()
dialog.exec();
}
}
void AccountListPage::on_actionDeleteSkin_triggered()
{
QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes();
if (selection.size() <= 0)
return;
QModelIndex selected = selection.first();
AuthSessionPtr session = std::make_shared<AuthSession>();
MojangAccountPtr account = selected.data(MojangAccountList::PointerRole).value<MojangAccountPtr>();
auto login = account->login(session);
ProgressDialog prog(this);
if (prog.execWithTask((Task*)login.get()) != QDialog::Accepted) {
CustomMessageBox::selectable(this, tr("Skin Delete"), tr("Failed to login!"), QMessageBox::Warning)->exec();
return;
}
auto deleteSkinTask = std::make_shared<SkinDelete>(this, session);
if (prog.execWithTask((Task*)deleteSkinTask.get()) != QDialog::Accepted) {
CustomMessageBox::selectable(this, tr("Skin Delete"), tr("Failed to delete current skin!"), QMessageBox::Warning)->exec();
return;
}
}

View File

@ -59,35 +59,26 @@ public:
return "Getting-Started#adding-an-account";
}
private:
void changeEvent(QEvent * event) override;
QMenu * createPopupMenu() override;
public
slots:
public slots:
void on_actionAdd_triggered();
void on_actionRemove_triggered();
void on_actionSetDefault_triggered();
void on_actionNoDefault_triggered();
void on_actionUploadSkin_triggered();
void on_actionDeleteSkin_triggered();
void listChanged();
//! Updates the states of the dialog's buttons.
void updateButtonStates();
protected:
std::shared_ptr<MojangAccountList> m_accounts;
protected
slots:
protected slots:
void ShowContextMenu(const QPoint &pos);
void addAccount(const QString& errMsg="");
private:
void changeEvent(QEvent * event) override;
QMenu * createPopupMenu() override;
std::shared_ptr<MojangAccountList> m_accounts;
Ui::AccountListPage *ui;
};

View File

@ -40,7 +40,9 @@
<addaction name="actionRemove"/>
<addaction name="actionSetDefault"/>
<addaction name="actionNoDefault"/>
<addaction name="separator"/>
<addaction name="actionUploadSkin"/>
<addaction name="actionDeleteSkin"/>
</widget>
<action name="actionAdd">
<property name="text">
@ -70,6 +72,14 @@
<string>Upload Skin</string>
</property>
</action>
<action name="actionDeleteSkin">
<property name="text">
<string>Delete Skin</string>
</property>
<property name="toolTip">
<string>Delete the currently active skin and go back to the default one</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>