handle gracefully the upload abort
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
6c362afc21
commit
211865a1e1
@ -393,11 +393,18 @@ void ScreenshotsPage::on_actionUpload_triggered()
|
|||||||
auto screenshot = std::make_shared<ScreenShot>(info);
|
auto screenshot = std::make_shared<ScreenShot>(info);
|
||||||
job->addNetAction(ImgurUpload::make(screenshot));
|
job->addNetAction(ImgurUpload::make(screenshot));
|
||||||
|
|
||||||
|
connect(job.get(), &Task::failed, [this](QString reason) {
|
||||||
|
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show();
|
||||||
|
});
|
||||||
|
connect(job.get(), &Task::aborted, [this] {
|
||||||
|
CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."),
|
||||||
|
QMessageBox::Information)
|
||||||
|
->show();
|
||||||
|
});
|
||||||
|
|
||||||
m_uploadActive = true;
|
m_uploadActive = true;
|
||||||
|
|
||||||
if (dialog.execWithTask(job.get()) != QDialog::Accepted) {
|
if (dialog.execWithTask(job.get()) == QDialog::Accepted) {
|
||||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
|
|
||||||
} else {
|
|
||||||
auto link = screenshot->m_url;
|
auto link = screenshot->m_url;
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
qDebug() << "ImgurUpload link" << link;
|
qDebug() << "ImgurUpload link" << link;
|
||||||
@ -426,18 +433,31 @@ void ScreenshotsPage::on_actionUpload_triggered()
|
|||||||
albumTask->addNetAction(imgurAlbum);
|
albumTask->addNetAction(imgurAlbum);
|
||||||
task.addTask(job);
|
task.addTask(job);
|
||||||
task.addTask(albumTask);
|
task.addTask(albumTask);
|
||||||
m_uploadActive = true;
|
|
||||||
if (dialog.execWithTask(&task) != QDialog::Accepted || imgurResult->id.isEmpty()) {
|
connect(&task, &Task::failed, [this](QString reason) {
|
||||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
|
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show();
|
||||||
} else {
|
});
|
||||||
auto link = QString("https://imgur.com/a/%1").arg(imgurResult->id);
|
connect(&task, &Task::aborted, [this] {
|
||||||
qDebug() << "ImgurUpload link" << link;
|
CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."),
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
|
||||||
clipboard->setText(link);
|
|
||||||
CustomMessageBox::selectable(this, tr("Upload finished"),
|
|
||||||
tr("The <a href=\"%1\">link to the uploaded album</a> has been placed in your clipboard.").arg(link),
|
|
||||||
QMessageBox::Information)
|
QMessageBox::Information)
|
||||||
->exec();
|
->show();
|
||||||
|
});
|
||||||
|
|
||||||
|
m_uploadActive = true;
|
||||||
|
if (dialog.execWithTask(&task) == QDialog::Accepted) {
|
||||||
|
if (imgurResult->id.isEmpty()) {
|
||||||
|
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
|
||||||
|
} else {
|
||||||
|
auto link = QString("https://imgur.com/a/%1").arg(imgurResult->id);
|
||||||
|
qDebug() << "ImgurUpload link" << link;
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
clipboard->setText(link);
|
||||||
|
CustomMessageBox::selectable(
|
||||||
|
this, tr("Upload finished"),
|
||||||
|
tr("The <a href=\"%1\">link to the uploaded album</a> has been placed in your clipboard.").arg(link),
|
||||||
|
QMessageBox::Information)
|
||||||
|
->exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_uploadActive = false;
|
m_uploadActive = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user