Split in two the options
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
cebb4dd17a
commit
db9f5f44e0
@ -529,7 +529,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
|
|
||||||
m_settings->registerSetting("MenuBarInsteadOfToolBar", false);
|
m_settings->registerSetting("MenuBarInsteadOfToolBar", false);
|
||||||
|
|
||||||
m_settings->registerSetting("NumberOfConcurrentTasks", 6);
|
m_settings->registerSetting("NumberOfConcurrentTasks", 10);
|
||||||
|
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
|
||||||
|
|
||||||
QString defaultMonospace;
|
QString defaultMonospace;
|
||||||
int defaultSize = 11;
|
int defaultSize = 11;
|
||||||
|
@ -33,6 +33,7 @@ ResourceFolderModel::ResourceFolderModel(QDir dir, BaseInstance* instance, QObje
|
|||||||
|
|
||||||
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &ResourceFolderModel::directoryChanged);
|
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &ResourceFolderModel::directoryChanged);
|
||||||
connect(&m_helper_thread_task, &ConcurrentTask::finished, this, [this] { m_helper_thread_task.clear(); });
|
connect(&m_helper_thread_task, &ConcurrentTask::finished, this, [this] { m_helper_thread_task.clear(); });
|
||||||
|
m_helper_thread_task.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceFolderModel::~ResourceFolderModel()
|
ResourceFolderModel::~ResourceFolderModel()
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <MurmurHash2.h>
|
#include <MurmurHash2.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "Application.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
|
||||||
#include "minecraft/mod/Mod.h"
|
#include "minecraft/mod/Mod.h"
|
||||||
@ -33,7 +34,7 @@ EnsureMetadataTask::EnsureMetadataTask(Mod* mod, QDir dir, ModPlatform::Resource
|
|||||||
EnsureMetadataTask::EnsureMetadataTask(QList<Mod*>& mods, QDir dir, ModPlatform::ResourceProvider prov)
|
EnsureMetadataTask::EnsureMetadataTask(QList<Mod*>& mods, QDir dir, ModPlatform::ResourceProvider prov)
|
||||||
: Task(nullptr), m_index_dir(dir), m_provider(prov), m_current_task(nullptr)
|
: Task(nullptr), m_index_dir(dir), m_provider(prov), m_current_task(nullptr)
|
||||||
{
|
{
|
||||||
m_hashing_task.reset(new ConcurrentTask(this, "MakeHashesTask"));
|
m_hashing_task.reset(new ConcurrentTask(this, "MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
|
||||||
for (auto* mod : mods) {
|
for (auto* mod : mods) {
|
||||||
auto hash_task = createNewHash(mod);
|
auto hash_task = createNewHash(mod);
|
||||||
if (!hash_task)
|
if (!hash_task)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <QtConcurrentRun>
|
#include <QtConcurrentRun>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "Application.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
@ -108,7 +109,8 @@ void FlamePackExportTask::collectHashes()
|
|||||||
setStatus(tr("Finding file hashes..."));
|
setStatus(tr("Finding file hashes..."));
|
||||||
setProgress(1, 5);
|
setProgress(1, 5);
|
||||||
auto allMods = mcInstance->loaderModList()->allMods();
|
auto allMods = mcInstance->loaderModList()->allMods();
|
||||||
ConcurrentTask::Ptr hashingTask(new ConcurrentTask(this, "MakeHashesTask"));
|
ConcurrentTask::Ptr hashingTask(
|
||||||
|
new ConcurrentTask(this, "MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
|
||||||
task.reset(hashingTask);
|
task.reset(hashingTask);
|
||||||
for (const QFileInfo& file : files) {
|
for (const QFileInfo& file : files) {
|
||||||
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
||||||
|
@ -39,7 +39,7 @@ void ModrinthCheckUpdate::executeTask()
|
|||||||
QStringList hashes;
|
QStringList hashes;
|
||||||
auto best_hash_type = ProviderCaps.hashType(ModPlatform::ResourceProvider::MODRINTH).first();
|
auto best_hash_type = ProviderCaps.hashType(ModPlatform::ResourceProvider::MODRINTH).first();
|
||||||
|
|
||||||
ConcurrentTask hashing_task(this, "MakeModrinthHashesTask");
|
ConcurrentTask hashing_task(this, "MakeModrinthHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
||||||
for (auto* mod : m_mods) {
|
for (auto* mod : m_mods) {
|
||||||
if (!mod->enabled()) {
|
if (!mod->enabled()) {
|
||||||
emit checkFailed(mod, tr("Disabled mods won't be updated, to prevent mod duplication issues!"));
|
emit checkFailed(mod, tr("Disabled mods won't be updated, to prevent mod duplication issues!"));
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "NetJob.h"
|
#include "NetJob.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
NetJob::NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> network)
|
||||||
|
: ConcurrentTask(nullptr, job_name, APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt()), m_network(network)
|
||||||
|
{}
|
||||||
|
|
||||||
auto NetJob::addNetAction(NetAction::Ptr action) -> bool
|
auto NetJob::addNetAction(NetAction::Ptr action) -> bool
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ class NetJob : public ConcurrentTask {
|
|||||||
public:
|
public:
|
||||||
using Ptr = shared_qobject_ptr<NetJob>;
|
using Ptr = shared_qobject_ptr<NetJob>;
|
||||||
|
|
||||||
explicit NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> network) : ConcurrentTask(nullptr, job_name), m_network(network) {}
|
explicit NetJob(QString job_name, shared_qobject_ptr<QNetworkAccessManager> network);
|
||||||
~NetJob() override = default;
|
~NetJob() override = default;
|
||||||
|
|
||||||
void startNext() override;
|
void startNext() override;
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "Application.h"
|
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
class ConcurrentTask : public Task {
|
class ConcurrentTask : public Task {
|
||||||
@ -49,11 +48,12 @@ class ConcurrentTask : public Task {
|
|||||||
public:
|
public:
|
||||||
using Ptr = shared_qobject_ptr<ConcurrentTask>;
|
using Ptr = shared_qobject_ptr<ConcurrentTask>;
|
||||||
|
|
||||||
explicit ConcurrentTask(QObject* parent = nullptr,
|
explicit ConcurrentTask(QObject* parent = nullptr, QString task_name = "", int max_concurrent = 6);
|
||||||
QString task_name = "",
|
|
||||||
int max_concurrent = APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
|
||||||
~ConcurrentTask() override;
|
~ConcurrentTask() override;
|
||||||
|
|
||||||
|
// safe to call before starting the task
|
||||||
|
void setMaxConcurrent(int max_concurrent) { m_total_max_size = max_concurrent; }
|
||||||
|
|
||||||
bool canAbort() const override { return true; }
|
bool canAbort() const override { return true; }
|
||||||
|
|
||||||
inline auto isMultiStep() const -> bool override { return totalSize() > 1; };
|
inline auto isMultiStep() const -> bool override { return totalSize() > 1; };
|
||||||
|
@ -44,7 +44,8 @@
|
|||||||
BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods)
|
BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods)
|
||||||
: QDialog(parent), ui(new Ui::BlockedModsDialog), m_mods(mods)
|
: QDialog(parent), ui(new Ui::BlockedModsDialog), m_mods(mods)
|
||||||
{
|
{
|
||||||
m_hashing_task = shared_qobject_ptr<ConcurrentTask>(new ConcurrentTask(this, "MakeHashesTask"));
|
m_hashing_task = shared_qobject_ptr<ConcurrentTask>(
|
||||||
|
new ConcurrentTask(this, "MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
|
||||||
connect(m_hashing_task.get(), &Task::finished, this, &BlockedModsDialog::hashTaskFinished);
|
connect(m_hashing_task.get(), &Task::finished, this, &BlockedModsDialog::hashTaskFinished);
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -43,7 +43,8 @@ ModUpdateDialog::ModUpdateDialog(QWidget* parent,
|
|||||||
, m_parent(parent)
|
, m_parent(parent)
|
||||||
, m_mod_model(mods)
|
, m_mod_model(mods)
|
||||||
, m_candidates(search_for)
|
, m_candidates(search_for)
|
||||||
, m_second_try_metadata(new ConcurrentTask())
|
, m_second_try_metadata(
|
||||||
|
new ConcurrentTask(nullptr, "Second Metadata Search", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()))
|
||||||
, m_instance(instance)
|
, m_instance(instance)
|
||||||
{
|
{
|
||||||
ReviewMessageBox::setGeometry(0, 0, 800, 600);
|
ReviewMessageBox::setGeometry(0, 0, 800, 600);
|
||||||
@ -89,15 +90,17 @@ void ModUpdateDialog::checkCandidates()
|
|||||||
|
|
||||||
if (!m_modrinth_to_update.empty()) {
|
if (!m_modrinth_to_update.empty()) {
|
||||||
m_modrinth_check_task.reset(new ModrinthCheckUpdate(m_modrinth_to_update, versions, loaders, m_mod_model));
|
m_modrinth_check_task.reset(new ModrinthCheckUpdate(m_modrinth_to_update, versions, loaders, m_mod_model));
|
||||||
connect(m_modrinth_check_task.get(), &CheckUpdateTask::checkFailed, this,
|
connect(m_modrinth_check_task.get(), &CheckUpdateTask::checkFailed, this, [this](Mod* mod, QString reason, QUrl recover_url) {
|
||||||
[this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.append({mod, reason, recover_url}); });
|
m_failed_check_update.append({ mod, reason, recover_url });
|
||||||
|
});
|
||||||
check_task.addTask(m_modrinth_check_task);
|
check_task.addTask(m_modrinth_check_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_flame_to_update.empty()) {
|
if (!m_flame_to_update.empty()) {
|
||||||
m_flame_check_task.reset(new FlameCheckUpdate(m_flame_to_update, versions, loaders, m_mod_model));
|
m_flame_check_task.reset(new FlameCheckUpdate(m_flame_to_update, versions, loaders, m_mod_model));
|
||||||
connect(m_flame_check_task.get(), &CheckUpdateTask::checkFailed, this,
|
connect(m_flame_check_task.get(), &CheckUpdateTask::checkFailed, this, [this](Mod* mod, QString reason, QUrl recover_url) {
|
||||||
[this](Mod* mod, QString reason, QUrl recover_url) { m_failed_check_update.append({mod, reason, recover_url}); });
|
m_failed_check_update.append({ mod, reason, recover_url });
|
||||||
|
});
|
||||||
check_task.addTask(m_flame_check_task);
|
check_task.addTask(m_flame_check_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +165,7 @@ void ModUpdateDialog::checkCandidates()
|
|||||||
if (!recover_url.isEmpty())
|
if (!recover_url.isEmpty())
|
||||||
//: %1 is the link to download it manually
|
//: %1 is the link to download it manually
|
||||||
text += tr("Possible solution: Getting the latest version manually:<br>%1<br>")
|
text += tr("Possible solution: Getting the latest version manually:<br>%1<br>")
|
||||||
.arg(QString("<a href='%1'>%1</a>").arg(recover_url.toString()));
|
.arg(QString("<a href='%1'>%1</a>").arg(recover_url.toString()));
|
||||||
text += "<br>";
|
text += "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +345,7 @@ void ModUpdateDialog::onMetadataFailed(Mod* mod, bool try_others, ModPlatform::R
|
|||||||
} else {
|
} else {
|
||||||
QString reason{ tr("Couldn't find a valid version on the selected mod provider(s)") };
|
QString reason{ tr("Couldn't find a valid version on the selected mod provider(s)") };
|
||||||
|
|
||||||
m_failed_metadata.append({mod, reason});
|
m_failed_metadata.append({ mod, reason });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ void LauncherPage::applySettings()
|
|||||||
s->set("MenuBarInsteadOfToolBar", ui->preferMenuBarCheckBox->isChecked());
|
s->set("MenuBarInsteadOfToolBar", ui->preferMenuBarCheckBox->isChecked());
|
||||||
|
|
||||||
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
|
s->set("NumberOfConcurrentTasks", ui->numberOfConcurrentTasksSpinBox->value());
|
||||||
|
s->set("NumberOfConcurrentDownloads", ui->numberOfConcurrentDownloadsSpinBox->value());
|
||||||
|
|
||||||
// Console settings
|
// Console settings
|
||||||
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
|
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
|
||||||
@ -254,6 +255,7 @@ void LauncherPage::loadSettings()
|
|||||||
ui->preferMenuBarCheckBox->setChecked(s->get("MenuBarInsteadOfToolBar").toBool());
|
ui->preferMenuBarCheckBox->setChecked(s->get("MenuBarInsteadOfToolBar").toBool());
|
||||||
|
|
||||||
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
|
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
|
||||||
|
ui->numberOfConcurrentDownloadsSpinBox->setValue(s->get("NumberOfConcurrentDownloads").toInt());
|
||||||
|
|
||||||
// Console settings
|
// Console settings
|
||||||
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
|
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
|
||||||
|
@ -209,6 +209,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="numberOfConcurrentDownloadsLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Number of concurrent downloads</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="numberOfConcurrentDownloadsSpinBox">
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -166,7 +166,7 @@ void ModFolderPage::installMods()
|
|||||||
|
|
||||||
ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
|
ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
|
||||||
if (mdownload.exec()) {
|
if (mdownload.exec()) {
|
||||||
ConcurrentTask* tasks = new ConcurrentTask(this);
|
auto tasks = new ConcurrentTask(this, "Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
tasks->deleteLater();
|
tasks->deleteLater();
|
||||||
@ -225,7 +225,7 @@ void ModFolderPage::updateMods()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (update_dialog.exec()) {
|
if (update_dialog.exec()) {
|
||||||
ConcurrentTask* tasks = new ConcurrentTask(this);
|
auto tasks = new ConcurrentTask(this, "Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
tasks->deleteLater();
|
tasks->deleteLater();
|
||||||
|
@ -72,7 +72,8 @@ void ResourcePackPage::downloadRPs()
|
|||||||
|
|
||||||
ResourceDownload::ResourcePackDownloadDialog mdownload(this, std::static_pointer_cast<ResourcePackFolderModel>(m_model), m_instance);
|
ResourceDownload::ResourcePackDownloadDialog mdownload(this, std::static_pointer_cast<ResourcePackFolderModel>(m_model), m_instance);
|
||||||
if (mdownload.exec()) {
|
if (mdownload.exec()) {
|
||||||
auto tasks = new ConcurrentTask(this);
|
auto tasks =
|
||||||
|
new ConcurrentTask(this, "Download Resource Pack", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
tasks->deleteLater();
|
tasks->deleteLater();
|
||||||
|
@ -65,7 +65,7 @@ void ShaderPackPage::downloadShaders()
|
|||||||
|
|
||||||
ResourceDownload::ShaderPackDownloadDialog mdownload(this, std::static_pointer_cast<ShaderPackFolderModel>(m_model), m_instance);
|
ResourceDownload::ShaderPackDownloadDialog mdownload(this, std::static_pointer_cast<ShaderPackFolderModel>(m_model), m_instance);
|
||||||
if (mdownload.exec()) {
|
if (mdownload.exec()) {
|
||||||
auto tasks = new ConcurrentTask(this);
|
auto tasks = new ConcurrentTask(this, "Download Shaders", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
tasks->deleteLater();
|
tasks->deleteLater();
|
||||||
|
@ -74,7 +74,8 @@ void TexturePackPage::downloadTPs()
|
|||||||
|
|
||||||
ResourceDownload::TexturePackDownloadDialog mdownload(this, std::static_pointer_cast<TexturePackFolderModel>(m_model), m_instance);
|
ResourceDownload::TexturePackDownloadDialog mdownload(this, std::static_pointer_cast<TexturePackFolderModel>(m_model), m_instance);
|
||||||
if (mdownload.exec()) {
|
if (mdownload.exec()) {
|
||||||
auto tasks = new ConcurrentTask(this);
|
auto tasks =
|
||||||
|
new ConcurrentTask(this, "Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
connect(tasks, &Task::failed, [this, tasks](QString reason) {
|
||||||
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
|
||||||
tasks->deleteLater();
|
tasks->deleteLater();
|
||||||
|
@ -31,6 +31,7 @@ QHash<ResourceModel*, bool> ResourceModel::s_running_models;
|
|||||||
ResourceModel::ResourceModel(ResourceAPI* api) : QAbstractListModel(), m_api(api)
|
ResourceModel::ResourceModel(ResourceAPI* api) : QAbstractListModel(), m_api(api)
|
||||||
{
|
{
|
||||||
s_running_models.insert(this, true);
|
s_running_models.insert(this, true);
|
||||||
|
m_current_info_job.setMaxConcurrent(APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceModel::~ResourceModel()
|
ResourceModel::~ResourceModel()
|
||||||
|
Loading…
Reference in New Issue
Block a user