Merge remote-tracking branch 'upstream/develop' into unify-mc-settings

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2025-01-27 13:16:16 +00:00
310 changed files with 978 additions and 862 deletions

View File

@@ -112,7 +112,7 @@ static QStringList BrowseForFileInternal(QString context,
QFileDialog w(parentWidget, caption);
QSet<QString> locations;
auto f = [&](QStandardPaths::StandardLocation l) {
auto f = [&locations](QStandardPaths::StandardLocation l) {
QString location = QStandardPaths::writableLocation(l);
QFileInfo finfo(location);
if (!finfo.exists()) {

View File

@@ -154,7 +154,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
// Qt doesn't like vertical moving toolbars, so we have to force them...
// See https://github.com/PolyMC/PolyMC/issues/493
connect(ui->instanceToolBar, &QToolBar::orientationChanged,
[=](Qt::Orientation) { ui->instanceToolBar->setOrientation(Qt::Vertical); });
[this](Qt::Orientation) { ui->instanceToolBar->setOrientation(Qt::Vertical); });
// if you try to add a widget to a toolbar in a .ui file
// qt designer will delete it when you save the file >:(

View File

@@ -46,7 +46,7 @@ BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, cons
: QDialog(parent), ui(new Ui::BlockedModsDialog), m_mods(mods), m_hash_type(hash_type)
{
m_hashing_task = shared_qobject_ptr<ConcurrentTask>(
new ConcurrentTask(this, "MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
new ConcurrentTask("MakeHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()));
connect(m_hashing_task.get(), &Task::finished, this, &BlockedModsDialog::hashTaskFinished);
ui->setupUi(this);

View File

@@ -85,7 +85,7 @@ int MSALoginDialog::exec()
connect(m_authflow_task.get(), &AuthFlow::authorizeWithBrowserWithExtra, this, &MSALoginDialog::authorizeWithBrowserWithExtra);
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, m_authflow_task.get(), &Task::abort);
m_devicecode_task.reset(new AuthFlow(m_account->accountData(), AuthFlow::Action::DeviceCode, this));
m_devicecode_task.reset(new AuthFlow(m_account->accountData(), AuthFlow::Action::DeviceCode));
connect(m_devicecode_task.get(), &Task::failed, this, &MSALoginDialog::onTaskFailed);
connect(m_devicecode_task.get(), &Task::succeeded, this, &QDialog::accept);
connect(m_devicecode_task.get(), &Task::aborted, this, &MSALoginDialog::reject);

View File

@@ -148,10 +148,14 @@ void ResourceDownloadDialog::confirm()
QStringList depNames;
if (auto task = getModDependenciesTask(); task) {
connect(task.get(), &Task::failed, this,
[&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
[this](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
connect(task.get(), &Task::succeeded, this, [&]() {
QStringList warnings = task->warnings();
auto weak = task.toWeakRef();
connect(task.get(), &Task::succeeded, this, [this, weak]() {
QStringList warnings;
if (auto task = weak.lock()) {
warnings = task->warnings();
}
if (warnings.count()) {
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->exec();
}
@@ -298,7 +302,7 @@ GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask()
selectedVers.append(std::make_shared<GetModDependenciesTask::PackDependency>(selected->getPack(), selected->getVersion()));
}
return makeShared<GetModDependenciesTask>(this, m_instance, model, selectedVers);
return makeShared<GetModDependenciesTask>(m_instance, model, selectedVers);
}
}
return nullptr;

View File

@@ -45,8 +45,7 @@ ResourceUpdateDialog::ResourceUpdateDialog(QWidget* parent,
, m_parent(parent)
, m_resource_model(resource_model)
, m_candidates(search_for)
, m_second_try_metadata(
new ConcurrentTask(nullptr, "Second Metadata Search", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()))
, m_second_try_metadata(new ConcurrentTask("Second Metadata Search", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt()))
, m_instance(instance)
, m_include_deps(include_deps)
, m_filter_loaders(filter_loaders)
@@ -90,7 +89,7 @@ void ResourceUpdateDialog::checkCandidates()
auto versions = mcVersions(m_instance);
auto loadersList = m_filter_loaders ? mcLoadersList(m_instance) : QList<ModPlatform::ModLoaderType>();
SequentialTask check_task(m_parent, tr("Checking for updates"));
SequentialTask check_task(tr("Checking for updates"));
if (!m_modrinth_to_update.empty()) {
m_modrinth_check_task.reset(new ModrinthCheckUpdate(m_modrinth_to_update, versions, loadersList, m_resource_model));
@@ -111,9 +110,9 @@ void ResourceUpdateDialog::checkCandidates()
}
connect(&check_task, &Task::failed, this,
[&](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
[this](QString reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
connect(&check_task, &Task::succeeded, this, [&]() {
connect(&check_task, &Task::succeeded, this, [this, &check_task]() {
QStringList warnings = check_task.warnings();
if (warnings.count()) {
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->exec();
@@ -195,13 +194,17 @@ void ResourceUpdateDialog::checkCandidates()
auto* mod_model = dynamic_cast<ModFolderModel*>(m_resource_model.get());
if (mod_model != nullptr) {
auto depTask = makeShared<GetModDependenciesTask>(this, m_instance, mod_model, selectedVers);
auto depTask = makeShared<GetModDependenciesTask>(m_instance, mod_model, selectedVers);
connect(depTask.get(), &Task::failed, this,
[&](const QString& reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec(); });
connect(depTask.get(), &Task::succeeded, this, [&]() {
QStringList warnings = depTask->warnings();
connect(depTask.get(), &Task::failed, this, [this](const QString& reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->exec();
});
auto weak = depTask.toWeakRef();
connect(depTask.get(), &Task::succeeded, this, [this, weak]() {
QStringList warnings;
if (auto depTask = weak.lock()) {
warnings = depTask->warnings();
}
if (warnings.count()) {
CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->exec();
}
@@ -265,7 +268,7 @@ auto ResourceUpdateDialog::ensureMetadata() -> bool
{
auto index_dir = indexDir();
SequentialTask seq(m_parent, tr("Looking for metadata"));
SequentialTask seq(tr("Looking for metadata"));
// A better use of data structures here could remove the need for this QHash
QHash<QString, bool> should_try_others;
@@ -277,7 +280,7 @@ auto ResourceUpdateDialog::ensureMetadata() -> bool
bool skip_rest = false;
ModPlatform::ResourceProvider provider_rest = ModPlatform::ResourceProvider::MODRINTH;
auto addToTmp = [&](Resource* resource, ModPlatform::ResourceProvider p) {
auto addToTmp = [&modrinth_tmp, &flame_tmp](Resource* resource, ModPlatform::ResourceProvider p) {
switch (p) {
case ModPlatform::ResourceProvider::MODRINTH:
modrinth_tmp.push_back(resource);
@@ -422,7 +425,7 @@ void ResourceUpdateDialog::appendResource(CheckUpdateTask::Update const& info, Q
auto item_top = new QTreeWidgetItem(ui->modTreeWidget);
item_top->setCheckState(0, info.enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
if (!info.enabled) {
item_top->setToolTip(0, tr("Mod was disabled as it may be already instaled."));
item_top->setToolTip(0, tr("Mod was disabled as it may be already installed."));
}
item_top->setText(0, info.name);
item_top->setExpanded(true);

View File

@@ -41,7 +41,7 @@ void ReviewMessageBox::appendResource(ResourceInformation&& info)
itemTop->setCheckState(0, info.enabled ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
itemTop->setText(0, info.name);
if (!info.enabled) {
itemTop->setToolTip(0, tr("Mod was disabled as it may be already instaled."));
itemTop->setToolTip(0, tr("Mod was disabled as it may be already installed."));
}
auto filenameItem = new QTreeWidgetItem(itemTop);

View File

@@ -317,7 +317,7 @@ void InstallDialog::done(int result)
deletePath();
}
#if defined(Q_OS_MACOS)
auto seq = makeShared<SequentialTask>(this, tr("Install Java"));
auto seq = makeShared<SequentialTask>(tr("Install Java"));
seq->addTask(task);
seq->addTask(makeShared<Java::SymlinkTask>(final_path));
task = seq;

View File

@@ -46,317 +46,339 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QGroupBox" name="updateSettingsBox">
<property name="title">
<string>Update Settings</string>
<widget class="QScrollArea" name="scrollArea">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="autoUpdateCheckBox">
<property name="text">
<string>Check for updates automatically</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="updateSetingsLayout">
<item row="0" column="0">
<widget class="QLabel" name="updateIntervalLabel">
<property name="text">
<string>Update interval</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="updateIntervalSpinBox">
<property name="toolTip">
<string>Set it to 0 to only check on launch</string>
</property>
<property name="suffix">
<string>h</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>770</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="updateSettingsBox">
<property name="title">
<string>Update Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="autoUpdateCheckBox">
<property name="text">
<string>Check for updates automatically</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="updateSetingsLayout">
<item row="0" column="0">
<widget class="QLabel" name="updateIntervalLabel">
<property name="text">
<string>Update interval</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="updateIntervalSpinBox">
<property name="toolTip">
<string>Set it to 0 to only check on launch</string>
</property>
<property name="suffix">
<string>h</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>99999999</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="foldersBox">
<property name="title">
<string>Folders</string>
</property>
<layout class="QGridLayout" name="foldersBoxLayout">
<item row="8" column="0">
<widget class="QLabel" name="labelDownloadsDir">
<property name="text">
<string>&amp;Downloads:</string>
</property>
<property name="buddy">
<cstring>downloadsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QToolButton" name="downloadsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="iconsDirTextBox"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="javaDirTextBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelSkinsDir">
<property name="text">
<string>&amp;Skins:</string>
</property>
<property name="buddy">
<cstring>skinsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelIconsDir">
<property name="text">
<string>&amp;Icons:</string>
</property>
<property name="buddy">
<cstring>iconsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<widget class="QCheckBox" name="downloadsDirWatchRecursiveCheckBox">
<property name="toolTip">
<string>When enabled, in addition to the downloads folder, its sub folders will also be searched when looking for resources (e.g. when looking for blocked mods on CurseForge).</string>
</property>
<property name="text">
<string>Check downloads folder recursively</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="downloadsDirTextBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelJavaDir">
<property name="text">
<string>&amp;Java:</string>
</property>
<property name="buddy">
<cstring>javaDirTextBox</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelModsDir">
<property name="text">
<string>&amp;Mods:</string>
</property>
<property name="buddy">
<cstring>modsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="skinsDirTextBox"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="modsDirTextBox"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="instDirTextBox"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="modsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="instDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="iconsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelInstDir">
<property name="text">
<string>I&amp;nstances:</string>
</property>
<property name="buddy">
<cstring>instDirTextBox</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="javaDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="skinsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="modsBox">
<property name="title">
<string>Mods</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="metadataDisableBtn">
<property name="toolTip">
<string>Disable using metadata provided by mod providers (like Modrinth or CurseForge) for mods.</string>
</property>
<property name="text">
<string>Disable using metadata for mods</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="metadataWarningLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; color:#f5c211;&quot;&gt;Warning&lt;/span&gt;&lt;span style=&quot; color:#f5c211;&quot;&gt;: Disabling mod metadata may also disable some QoL features, such as mod updating!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dependenciesDisableBtn">
<property name="toolTip">
<string>Disable the automatic detection, installation, and updating of mod dependencies.</string>
</property>
<property name="text">
<string>Disable automatic mod dependency management</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="skipModpackUpdatePromptBtn">
<property name="toolTip">
<string>When creating a new modpack instance, do not suggest updating existing instances instead.</string>
</property>
<property name="text">
<string>Skip modpack update prompt</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="miscellaneousGroupBox">
<property name="title">
<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">
<string>Number of concurrent tasks</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="numberOfConcurrentTasksSpinBox">
<property name="minimum">
<number>1</number>
</property>
</widget>
</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="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>
<item row="3" 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="3" column="1">
<widget class="QSpinBox" name="timeoutSecondsSpinBox">
<property name="suffix">
<string>s</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_FeaturesTab">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="foldersBox">
<property name="title">
<string>Folders</string>
</property>
<layout class="QGridLayout" name="foldersBoxLayout">
<item row="8" column="0">
<widget class="QLabel" name="labelDownloadsDir">
<property name="text">
<string>&amp;Downloads:</string>
</property>
<property name="buddy">
<cstring>downloadsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QToolButton" name="downloadsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="iconsDirTextBox"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="javaDirTextBox"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelSkinsDir">
<property name="text">
<string>&amp;Skins:</string>
</property>
<property name="buddy">
<cstring>skinsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelIconsDir">
<property name="text">
<string>&amp;Icons:</string>
</property>
<property name="buddy">
<cstring>iconsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<widget class="QCheckBox" name="downloadsDirWatchRecursiveCheckBox">
<property name="toolTip">
<string>When enabled, in addition to the downloads folder, its sub folders will also be searched when looking for resources (e.g. when looking for blocked mods on CurseForge).</string>
</property>
<property name="text">
<string>Check downloads folder recursively</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="downloadsDirTextBox"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelJavaDir">
<property name="text">
<string>&amp;Java:</string>
</property>
<property name="buddy">
<cstring>javaDirTextBox</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelModsDir">
<property name="text">
<string>&amp;Mods:</string>
</property>
<property name="buddy">
<cstring>modsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="skinsDirTextBox"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="modsDirTextBox"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="instDirTextBox"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="modsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="instDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="iconsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelInstDir">
<property name="text">
<string>I&amp;nstances:</string>
</property>
<property name="buddy">
<cstring>instDirTextBox</cstring>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="javaDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="skinsDirBrowseBtn">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="modsBox">
<property name="title">
<string>Mods</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="metadataDisableBtn">
<property name="toolTip">
<string>Disable using metadata provided by mod providers (like Modrinth or CurseForge) for mods.</string>
</property>
<property name="text">
<string>Disable using metadata for mods</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="metadataWarningLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; color:#f5c211;&quot;&gt;Warning&lt;/span&gt;&lt;span style=&quot; color:#f5c211;&quot;&gt;: Disabling mod metadata may also disable some QoL features, such as mod updating!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dependenciesDisableBtn">
<property name="toolTip">
<string>Disable the automatic detection, installation, and updating of mod dependencies.</string>
</property>
<property name="text">
<string>Disable automatic mod dependency management</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="skipModpackUpdatePromptBtn">
<property name="toolTip">
<string>When creating a new modpack instance, do not suggest updating existing instances instead.</string>
</property>
<property name="text">
<string>Skip modpack update prompt</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="miscellaneousGroupBox">
<property name="title">
<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">
<string>Number of concurrent tasks</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="numberOfConcurrentTasksSpinBox">
<property name="minimum">
<number>1</number>
</property>
</widget>
</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="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>
<item row="3" 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="3" column="1">
<widget class="QSpinBox" name="timeoutSecondsSpinBox">
<property name="suffix">
<string>s</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_FeaturesTab">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="userInterfaceTab">

View File

@@ -112,6 +112,7 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared
m_model->loadColumns(ui->treeView);
connect(ui->treeView->header(), &QHeaderView::sectionResized, this, [this] { m_model->saveColumns(ui->treeView); });
connect(ui->filterEdit, &QLineEdit::textChanged, this, &ExternalResourcesPage::filterTextChanged);
}
ExternalResourcesPage::~ExternalResourcesPage()

View File

@@ -90,7 +90,7 @@ class LogFormatProxyModel : public QIdentityProxyModel {
QModelIndex find(const QModelIndex& start, const QString& value, bool reverse) const
{
QModelIndex parentIndex = parent(start);
auto compare = [&](int r) -> QModelIndex {
auto compare = [this, start, parentIndex, value](int r) -> QModelIndex {
QModelIndex idx = index(r, start.column(), parentIndex);
if (!idx.isValid() || idx == start) {
return QModelIndex();

View File

@@ -51,22 +51,15 @@
#include "Application.h"
#include "ui/GuiUtil.h"
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/ResourceDownloadDialog.h"
#include "ui/dialogs/ResourceUpdateDialog.h"
#include "DesktopServices.h"
#include "minecraft/PackProfile.h"
#include "minecraft/VersionFilterData.h"
#include "minecraft/mod/Mod.h"
#include "minecraft/mod/ModFolderModel.h"
#include "modplatform/ModIndex.h"
#include "modplatform/ResourceAPI.h"
#include "Version.h"
#include "tasks/ConcurrentTask.h"
#include "tasks/Task.h"
#include "ui/dialogs/ProgressDialog.h"
@@ -155,7 +148,7 @@ void ModFolderPage::downloadMods()
ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
if (mdownload.exec()) {
auto tasks = new ConcurrentTask(this, tr("Download Mods"), APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask(tr("Download Mods"), APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -238,7 +231,7 @@ void ModFolderPage::updateMods(bool includeDeps)
}
if (update_dialog.exec()) {
auto tasks = new ConcurrentTask(this, "Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -310,7 +303,7 @@ void ModFolderPage::changeModVersion()
ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance);
mdownload.setResourceMetadata((*mods_list.begin())->metadata());
if (mdownload.exec()) {
auto tasks = new ConcurrentTask(this, "Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();

View File

@@ -138,7 +138,7 @@ void OtherLogsPage::on_btnReload_clicked()
m_currentFile = QString();
QMessageBox::critical(this, tr("Error"), tr("Unable to open %1 for reading: %2").arg(m_currentFile, file.errorString()));
} else {
auto setPlainText = [&](const QString& text) {
auto setPlainText = [this](const QString& text) {
QString fontFamily = APPLICATION->settings()->get("ConsoleFont").toString();
bool conversionOk = false;
int fontSize = APPLICATION->settings()->get("ConsoleFontSize").toInt(&conversionOk);
@@ -149,7 +149,7 @@ void OtherLogsPage::on_btnReload_clicked()
doc->setDefaultFont(QFont(fontFamily, fontSize));
ui->text->setPlainText(text);
};
auto showTooBig = [&]() {
auto showTooBig = [setPlainText, &file]() {
setPlainText(tr("The file (%1) is too big. You may want to open it in a viewer optimized "
"for large files.")
.arg(file.fileName()));

View File

@@ -37,8 +37,6 @@
#include "ResourcePackPage.h"
#include "ResourceDownloadTask.h"
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/ProgressDialog.h"
#include "ui/dialogs/ResourceDownloadDialog.h"
@@ -88,8 +86,7 @@ void ResourcePackPage::downloadResourcePacks()
ResourceDownload::ResourcePackDownloadDialog mdownload(this, m_model, m_instance);
if (mdownload.exec()) {
auto tasks =
new ConcurrentTask(this, "Download Resource Pack", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Resource Pack", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -168,8 +165,7 @@ void ResourcePackPage::updateResourcePacks()
}
if (update_dialog.exec()) {
auto tasks =
new ConcurrentTask(this, "Download Resource Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Resource Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -234,7 +230,7 @@ void ResourcePackPage::changeResourcePackVersion()
if (rows.count() != 1)
return;
Resource &resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
Resource& resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
if (resource.metadata() == nullptr)
return;
@@ -242,8 +238,7 @@ void ResourcePackPage::changeResourcePackVersion()
ResourceDownload::ResourcePackDownloadDialog mdownload(this, m_model, m_instance);
mdownload.setResourceMetadata(resource.metadata());
if (mdownload.exec()) {
auto tasks =
new ConcurrentTask(this, "Download Resource Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Resource Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();

View File

@@ -83,7 +83,7 @@ void ShaderPackPage::downloadShaderPack()
ResourceDownload::ShaderPackDownloadDialog mdownload(this, m_model, m_instance);
if (mdownload.exec()) {
auto tasks = new ConcurrentTask(this, "Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -162,7 +162,7 @@ void ShaderPackPage::updateShaderPacks()
}
if (update_dialog.exec()) {
auto tasks = new ConcurrentTask(this, "Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -227,7 +227,7 @@ void ShaderPackPage::changeShaderPackVersion()
if (rows.count() != 1)
return;
Resource &resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
Resource& resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
if (resource.metadata() == nullptr)
return;
@@ -235,8 +235,7 @@ void ShaderPackPage::changeShaderPackVersion()
ResourceDownload::ShaderPackDownloadDialog mdownload(this, m_model, m_instance);
mdownload.setResourceMetadata(resource.metadata());
if (mdownload.exec()) {
auto tasks =
new ConcurrentTask(this, "Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Shader Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();

View File

@@ -92,8 +92,7 @@ void TexturePackPage::downloadTexturePacks()
ResourceDownload::TexturePackDownloadDialog mdownload(this, m_model, m_instance);
if (mdownload.exec()) {
auto tasks =
new ConcurrentTask(this, "Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -172,8 +171,7 @@ void TexturePackPage::updateTexturePacks()
}
if (update_dialog.exec()) {
auto tasks =
new ConcurrentTask(this, "Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();
@@ -223,7 +221,8 @@ void TexturePackPage::deleteTexturePackMetadata()
m_model->deleteMetadata(selection);
}
void TexturePackPage::changeTexturePackVersion() {
void TexturePackPage::changeTexturePackVersion()
{
if (m_instance->typeName() != "Minecraft")
return; // this is a null instance or a legacy instance
@@ -237,7 +236,7 @@ void TexturePackPage::changeTexturePackVersion() {
if (rows.count() != 1)
return;
Resource &resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
Resource& resource = m_model->at(m_filterModel->mapToSource(rows[0]).row());
if (resource.metadata() == nullptr)
return;
@@ -245,8 +244,7 @@ void TexturePackPage::changeTexturePackVersion() {
ResourceDownload::TexturePackDownloadDialog mdownload(this, m_model, m_instance);
mdownload.setResourceMetadata(resource.metadata());
if (mdownload.exec()) {
auto tasks =
new ConcurrentTask(this, "Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
auto tasks = new ConcurrentTask("Download Texture Packs", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt());
connect(tasks, &Task::failed, [this, tasks](QString reason) {
CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
tasks->deleteLater();

View File

@@ -435,7 +435,7 @@ void VersionPage::on_actionDownload_All_triggered()
if (updateTasks.isEmpty()) {
return;
}
auto task = makeShared<SequentialTask>(this);
auto task = makeShared<SequentialTask>();
for (auto t : updateTasks) {
task->addTask(t);
}

View File

@@ -337,7 +337,7 @@ std::optional<QIcon> ResourceModel::getIcon(QModelIndex& index, const QUrl& url)
auto icon_fetch_action = Net::ApiDownload::makeCached(url, cache_entry);
auto full_file_path = cache_entry->getFullPath();
connect(icon_fetch_action.get(), &Task::succeeded, this, [=] {
connect(icon_fetch_action.get(), &Task::succeeded, this, [this, url, full_file_path, index] {
auto icon = QIcon(full_file_path);
QPixmapCache::insert(url.toString(), icon.pixmap(icon.actualSize({ 64, 64 })));
@@ -345,7 +345,7 @@ std::optional<QIcon> ResourceModel::getIcon(QModelIndex& index, const QUrl& url)
emit dataChanged(index, index, { Qt::DecorationRole });
});
connect(icon_fetch_action.get(), &Task::failed, this, [=] {
connect(icon_fetch_action.get(), &Task::failed, this, [this, url] {
m_currently_running_icon_actions.remove(url);
m_failed_icon_actions.insert(url);
});

View File

@@ -57,7 +57,7 @@ void SetupWizard::pageChanged(int id)
if (basePagePtr->wantsRefreshButton()) {
setButtonLayout({ QWizard::CustomButton1, QWizard::Stretch, QWizard::BackButton, QWizard::NextButton, QWizard::FinishButton });
auto customButton = button(QWizard::CustomButton1);
connect(customButton, &QAbstractButton::clicked, [&]() {
connect(customButton, &QAbstractButton::clicked, [this]() {
auto basePagePtr = getCurrentBasePage();
if (basePagePtr) {
basePagePtr->refresh();

View File

@@ -181,7 +181,7 @@ bool CustomTheme::read(const QString& path, bool& hasCustomLogColors)
m_widgets = Json::requireString(root, "widgets", "Qt widget theme");
m_qssFilePath = Json::ensureString(root, "qssFilePath", "themeStyle.css");
auto readColor = [&](const QJsonObject& colors, const QString& colorName) -> QColor {
auto readColor = [](const QJsonObject& colors, const QString& colorName) -> QColor {
auto colorValue = Json::ensureString(colors, colorName, QString());
if (!colorValue.isEmpty()) {
QColor color(colorValue);
@@ -196,7 +196,7 @@ bool CustomTheme::read(const QString& path, bool& hasCustomLogColors)
if (root.contains("colors")) {
auto colorsRoot = Json::requireObject(root, "colors");
auto readAndSetPaletteColor = [&](QPalette::ColorRole role, const QString& colorName) {
auto readAndSetPaletteColor = [this, readColor, colorsRoot](QPalette::ColorRole role, const QString& colorName) {
auto color = readColor(colorsRoot, colorName);
if (color.isValid()) {
m_palette.setColor(role, color);
@@ -229,7 +229,7 @@ bool CustomTheme::read(const QString& path, bool& hasCustomLogColors)
hasCustomLogColors = true;
auto logColorsRoot = Json::requireObject(root, "logColors");
auto readAndSetLogColor = [&](MessageLevel::Enum level, bool fg, const QString& colorName) {
auto readAndSetLogColor = [this, readColor, logColorsRoot](MessageLevel::Enum level, bool fg, const QString& colorName) {
auto color = readColor(logColorsRoot, colorName);
if (color.isValid()) {
if (fg)

View File

@@ -460,7 +460,7 @@ void JavaWizardWidget::checkJavaPath(const QString& path)
}
setJavaStatus(JavaStatus::Pending);
m_checker.reset(
new JavaChecker(path, "", minHeapSize(), maxHeapSize(), m_permGenSpinBox->isVisible() ? m_permGenSpinBox->value() : 0, 0, this));
new JavaChecker(path, "", minHeapSize(), maxHeapSize(), m_permGenSpinBox->isVisible() ? m_permGenSpinBox->value() : 0, 0));
connect(m_checker.get(), &JavaChecker::checkFinished, this, &JavaWizardWidget::checkFinished);
m_checker->start();
}