added error message for import skin from user
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
75fbdc2df5
commit
eaccdca02d
@ -148,21 +148,28 @@ void NetJob::updateState()
|
||||
void NetJob::emitFailed(QString reason)
|
||||
{
|
||||
#if defined(LAUNCHER_APPLICATION)
|
||||
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
||||
"The tasks failed\n"
|
||||
"Failed urls\n" +
|
||||
getFailedFiles().join("\n\t") +
|
||||
"\n"
|
||||
"If this continues to happen please check the logs of the application"
|
||||
"Do you want to retry?",
|
||||
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
->exec();
|
||||
if (m_ask_retry) {
|
||||
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
||||
"The tasks failed.\n"
|
||||
"Failed urls\n" +
|
||||
getFailedFiles().join("\n\t") +
|
||||
".\n"
|
||||
"If this continues to happen please check the logs of the application.\n"
|
||||
"Do you want to retry?",
|
||||
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
->exec();
|
||||
|
||||
if (response == QMessageBox::Yes) {
|
||||
m_try = 0;
|
||||
executeNextSubTask();
|
||||
return;
|
||||
if (response == QMessageBox::Yes) {
|
||||
m_try = 0;
|
||||
executeNextSubTask();
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ConcurrentTask::emitFailed(reason);
|
||||
}
|
||||
|
||||
void NetJob::setAskRetry(bool askRetry)
|
||||
{
|
||||
m_ask_retry = askRetry;
|
||||
}
|
@ -62,6 +62,7 @@ class NetJob : public ConcurrentTask {
|
||||
|
||||
auto getFailedActions() -> QList<Net::NetRequest*>;
|
||||
auto getFailedFiles() -> QList<QString>;
|
||||
void setAskRetry(bool askRetry);
|
||||
|
||||
public slots:
|
||||
// Qt can't handle auto at the start for some reason?
|
||||
@ -78,4 +79,5 @@ class NetJob : public ConcurrentTask {
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
|
||||
int m_try = 1;
|
||||
bool m_ask_retry = true;
|
||||
};
|
||||
|
@ -345,9 +345,9 @@ void SkinManageDialog::on_urlBtn_clicked()
|
||||
CustomMessageBox::selectable(this, tr("Invalid url"), tr("Invalid url"), QMessageBox::Critical)->show();
|
||||
return;
|
||||
}
|
||||
ui->urlLine->setText("");
|
||||
|
||||
NetJob::Ptr job{ new NetJob(tr("Download skin"), APPLICATION->network()) };
|
||||
job->setAskRetry(false);
|
||||
|
||||
auto path = FS::PathCombine(m_list.getDir(), url.fileName());
|
||||
job->addNetAction(Net::Download::makeFile(url, path));
|
||||
@ -361,6 +361,7 @@ void SkinManageDialog::on_urlBtn_clicked()
|
||||
QFile::remove(path);
|
||||
return;
|
||||
}
|
||||
ui->urlLine->setText("");
|
||||
if (QFileInfo(path).suffix().isEmpty()) {
|
||||
QFile::rename(path, path + ".png");
|
||||
}
|
||||
@ -397,11 +398,11 @@ void SkinManageDialog::on_userBtn_clicked()
|
||||
if (user.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ui->urlLine->setText("");
|
||||
MinecraftProfile mcProfile;
|
||||
auto path = FS::PathCombine(m_list.getDir(), user + ".png");
|
||||
|
||||
NetJob::Ptr job{ new NetJob(tr("Download user skin"), APPLICATION->network(), 1) };
|
||||
job->setAskRetry(false);
|
||||
|
||||
auto uuidOut = std::make_shared<QByteArray>();
|
||||
auto profileOut = std::make_shared<QByteArray>();
|
||||
@ -459,6 +460,14 @@ void SkinManageDialog::on_userBtn_clicked()
|
||||
dlg.execWithTask(job.get());
|
||||
|
||||
SkinModel s(path);
|
||||
if (!s.isValid()) {
|
||||
CustomMessageBox::selectable(this, tr("Usename not found"), tr("Unable to find the skin for '%1'.").arg(user),
|
||||
QMessageBox::Critical)
|
||||
->show();
|
||||
QFile::remove(path);
|
||||
return;
|
||||
}
|
||||
ui->urlLine->setText("");
|
||||
s.setModel(mcProfile.skin.variant.toUpper() == "SLIM" ? SkinModel::SLIM : SkinModel::CLASSIC);
|
||||
s.setURL(mcProfile.skin.url);
|
||||
if (m_capes.contains(mcProfile.currentCape)) {
|
||||
|
Loading…
Reference in New Issue
Block a user