Skip to content

Commit

Permalink
Merge pull request PrismLauncher#2415 from Trial97/configure_timeout
Browse files Browse the repository at this point in the history
Add config for transfer timeout
  • Loading branch information
Trial97 authored Jun 30, 2024
2 parents 7ff173d + 425a6e0 commit fc44507
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)

m_settings->registerSetting("NumberOfConcurrentTasks", 10);
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
m_settings->registerSetting("RequestTimeout", 60);

QString defaultMonospace;
int defaultSize = 11;
Expand Down
4 changes: 4 additions & 0 deletions launcher/net/NetRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ void NetRequest::executeTask()
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#if defined(LAUNCHER_APPLICATION)
request.setTransferTimeout(APPLICATION->settings()->get("RequestTimeout").toInt() * 1000);
#else
request.setTransferTimeout();
#endif
#endif

m_last_progress_time = m_clock.now();
Expand Down
2 changes: 2 additions & 0 deletions launcher/ui/pages/global/LauncherPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ void LauncherPage::applySettings()

s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
s->set("RequestTimeout", ui->timeoutSecondsSpinBox->value());

// Console settings
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
Expand Down Expand Up @@ -259,6 +260,7 @@ void LauncherPage::loadSettings()

ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
ui->timeoutSecondsSpinBox->setValue(s->get("RequestTimeout").toInt());

// Console settings
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
Expand Down
27 changes: 22 additions & 5 deletions launcher/ui/pages/global/LauncherPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>511</width>
<height>629</height>
<height>691</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -252,6 +252,13 @@
<string>Miscellaneous</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QSpinBox" name="numberOfConcurrentDownloadsSpinBox">
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="numberOfConcurrentTasksLabel">
<property name="text">
Expand All @@ -273,10 +280,20 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="numberOfConcurrentDownloadsSpinBox">
<property name="minimum">
<number>1</number>
<item row="2" column="0">
<widget class="QLabel" name="timeoutSecondsLabel">
<property name="toolTip">
<string>Seconds to wait until the requests are terminated</string>
</property>
<property name="text">
<string>Timeout for HTTP requests</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="timeoutSecondsSpinBox">
<property name="suffix">
<string>s</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit fc44507

Please sign in to comment.