update retry netjob dialog
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
5cf7466e4c
commit
7a200a337f
@ -559,6 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
|||||||
|
|
||||||
m_settings->registerSetting("NumberOfConcurrentTasks", 10);
|
m_settings->registerSetting("NumberOfConcurrentTasks", 10);
|
||||||
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
|
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
|
||||||
|
m_settings->registerSetting("NumberOfManualRetries", 1);
|
||||||
|
|
||||||
QString defaultMonospace;
|
QString defaultMonospace;
|
||||||
int defaultSize = 11;
|
int defaultSize = 11;
|
||||||
|
@ -58,7 +58,6 @@ auto ApiDownload::makeFile(QUrl url, QString path, Options options) -> Download:
|
|||||||
|
|
||||||
void ApiDownload::init()
|
void ApiDownload::init()
|
||||||
{
|
{
|
||||||
qDebug() << "Setting up api download";
|
|
||||||
auto api_headers = new ApiHeaderProxy();
|
auto api_headers = new ApiHeaderProxy();
|
||||||
addHeaderProxy(api_headers);
|
addHeaderProxy(api_headers);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ Upload::Ptr ApiUpload::makeByteArray(QUrl url, std::shared_ptr<QByteArray> outpu
|
|||||||
|
|
||||||
void ApiUpload::init()
|
void ApiUpload::init()
|
||||||
{
|
{
|
||||||
qDebug() << "Setting up api upload";
|
|
||||||
auto api_headers = new ApiHeaderProxy();
|
auto api_headers = new ApiHeaderProxy();
|
||||||
addHeaderProxy(api_headers);
|
addHeaderProxy(api_headers);
|
||||||
}
|
}
|
||||||
|
@ -144,21 +144,29 @@ void NetJob::updateState()
|
|||||||
void NetJob::emitFailed(QString reason)
|
void NetJob::emitFailed(QString reason)
|
||||||
{
|
{
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
if (m_ask_retry || m_manual_try < APPLICATION->settings()->get("NumberOfManualRetries").toInt()) {
|
||||||
"The tasks failed\n"
|
m_manual_try++;
|
||||||
"Failed urls\n" +
|
auto response = CustomMessageBox::selectable(nullptr, "Confirm retry",
|
||||||
getFailedFiles().join("\n\t") +
|
"The tasks failed\n"
|
||||||
"\n"
|
"Failed urls\n" +
|
||||||
"If this continues to happen please check the logs of the application"
|
getFailedFiles().join("\n\t") +
|
||||||
"Do you want to retry?",
|
"\n"
|
||||||
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
"If this continues to happen please check the logs of the application"
|
||||||
->exec();
|
"Do you want to retry?",
|
||||||
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||||
|
->exec();
|
||||||
|
|
||||||
if (response == QMessageBox::Yes) {
|
if (response == QMessageBox::Yes) {
|
||||||
m_try = 0;
|
m_try = 0;
|
||||||
executeNextSubTask();
|
executeNextSubTask();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ConcurrentTask::emitFailed(reason);
|
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 getFailedActions() -> QList<Net::NetRequest*>;
|
||||||
auto getFailedFiles() -> QList<QString>;
|
auto getFailedFiles() -> QList<QString>;
|
||||||
|
void setAskRetry(bool askRetry);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Qt can't handle auto at the start for some reason?
|
// Qt can't handle auto at the start for some reason?
|
||||||
@ -78,4 +79,6 @@ class NetJob : public ConcurrentTask {
|
|||||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
int m_try = 1;
|
int m_try = 1;
|
||||||
|
bool m_ask_retry = true;
|
||||||
|
int m_manual_try = 0;
|
||||||
};
|
};
|
||||||
|
@ -191,6 +191,7 @@ void LauncherPage::applySettings()
|
|||||||
|
|
||||||
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
|
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
|
||||||
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
|
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
|
||||||
|
s->set("NumberOfManualRetries", ui->numberOfManualRetriesSpinBox->value());
|
||||||
|
|
||||||
// Console settings
|
// Console settings
|
||||||
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
|
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
|
||||||
@ -245,6 +246,7 @@ void LauncherPage::loadSettings()
|
|||||||
|
|
||||||
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
|
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
|
||||||
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
|
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
|
||||||
|
ui->numberOfManualRetriesSpinBox->setValue(s->get("NumberOfManualRetries").toInt());
|
||||||
|
|
||||||
// Console settings
|
// Console settings
|
||||||
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
|
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>511</width>
|
<width>511</width>
|
||||||
<height>629</height>
|
<height>691</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -233,6 +233,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="numberOfManualRetriesLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Number of manual retries</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="numberOfManualRetriesSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -80,7 +80,7 @@ void VariableSizedImageObject::drawObject(QPainter* painter,
|
|||||||
{
|
{
|
||||||
if (!format.hasProperty(ImageData)) {
|
if (!format.hasProperty(ImageData)) {
|
||||||
QUrl image_url{ qvariant_cast<QString>(format.property(QTextFormat::ImageName)) };
|
QUrl image_url{ qvariant_cast<QString>(format.property(QTextFormat::ImageName)) };
|
||||||
if (m_fetching_images.contains(image_url))
|
if (m_fetching_images.contains(image_url) || image_url.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto meta = std::make_shared<ImageMetadata>();
|
auto meta = std::make_shared<ImageMetadata>();
|
||||||
@ -140,6 +140,7 @@ void VariableSizedImageObject::loadImage(QTextDocument* doc, std::shared_ptr<Ima
|
|||||||
QString("images/%1").arg(QString(QCryptographicHash::hash(meta->url.toEncoded(), QCryptographicHash::Algorithm::Sha1).toHex())));
|
QString("images/%1").arg(QString(QCryptographicHash::hash(meta->url.toEncoded(), QCryptographicHash::Algorithm::Sha1).toHex())));
|
||||||
|
|
||||||
auto job = new NetJob(QString("Load Image: %1").arg(meta->url.fileName()), APPLICATION->network());
|
auto job = new NetJob(QString("Load Image: %1").arg(meta->url.fileName()), APPLICATION->network());
|
||||||
|
job->setAskRetry(false);
|
||||||
job->addNetAction(Net::ApiDownload::makeCached(meta->url, entry));
|
job->addNetAction(Net::ApiDownload::makeCached(meta->url, entry));
|
||||||
|
|
||||||
auto full_entry_path = entry->getFullPath();
|
auto full_entry_path = entry->getFullPath();
|
||||||
|
Loading…
Reference in New Issue
Block a user