Merge branch 'develop' into list-image-append-fix

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2024-06-01 15:20:21 +01:00
committed by GitHub
152 changed files with 1881 additions and 3103 deletions

View File

@@ -40,6 +40,7 @@
#include <QItemSelectionModel>
#include <QMenu>
#include <QPushButton>
#include <QDebug>
@@ -134,8 +135,19 @@ void AccountListPage::listChanged()
void AccountListPage::on_actionAddMicrosoft_triggered()
{
MinecraftAccountPtr account =
MSALoginDialog::newAccount(this, tr("Please enter your Mojang account email and password to add your account."));
QMessageBox box(this);
box.setWindowTitle(tr("Add account"));
box.setText(tr("How do you want to login?"));
box.setIcon(QMessageBox::Question);
auto deviceCode = box.addButton(tr("Legacy"), QMessageBox::ButtonRole::YesRole);
auto authCode = box.addButton(tr("Recommended"), QMessageBox::ButtonRole::NoRole);
auto cancel = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::RejectRole);
box.setDefaultButton(authCode);
box.exec();
if ((box.clickedButton() != deviceCode && box.clickedButton() != authCode) || box.clickedButton() == cancel)
return;
MinecraftAccountPtr account = MSALoginDialog::newAccount(
this, tr("Please enter your Mojang account email and password to add your account."), box.clickedButton() == deviceCode);
if (account) {
m_accounts->addAccount(account);

View File

@@ -237,7 +237,7 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<spacer name="verticalSpacer_FeaturesTab">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -251,7 +251,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="generalTab">
<widget class="QWidget" name="userInterfaceTab">
<attribute name="title">
<string>User Interface</string>
</attribute>
@@ -374,7 +374,7 @@
</widget>
</item>
<item>
<spacer name="generalTabSpacer">
<spacer name="verticalSpacer_UserInterfaceTab">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>

View File

@@ -88,6 +88,7 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared
};
connect(selection_model, &QItemSelectionModel::selectionChanged, this, updateExtra);
connect(model.get(), &ResourceFolderModel::updateFinished, this, updateExtra);
connect(model.get(), &ResourceFolderModel::parseFinished, this, updateExtra);
connect(ui->filterEdit, &QLineEdit::textChanged, this, &ExternalResourcesPage::filterTextChanged);

View File

@@ -70,15 +70,15 @@
</layout>
</widget>
<widget class="WideBar" name="actionsToolbar">
<property name="useDefaultAction" stdset="0">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Actions</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
<property name="useDefaultAction" stdset="0">
<bool>true</bool>
</property>
<attribute name="toolBarArea">
<enum>RightToolBarArea</enum>
</attribute>
@@ -171,6 +171,17 @@
<string>Try to check or update all selected resources (all resources if none are selected)</string>
</property>
</action>
<action name="actionExportMetadata">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Export modlist</string>
</property>
<property name="toolTip">
<string>Export mod's metadata to text</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@@ -37,6 +37,7 @@
*/
#include "ModFolderPage.h"
#include "ui/dialogs/ExportToModListDialog.h"
#include "ui_ExternalResourcesPage.h"
#include <QAbstractItemModel>
@@ -121,6 +122,9 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
ui->actionsToolbar->insertActionAfter(ui->actionVisitItemPage, ui->actionExportMetadata);
connect(ui->actionExportMetadata, &QAction::triggered, this, &ModFolderPage::exportModMetadata);
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
@@ -372,3 +376,15 @@ void ModFolderPage::deleteModMetadata()
m_model->deleteModsMetadata(selection);
}
void ModFolderPage::exportModMetadata()
{
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
auto selectedMods = m_model->selectedMods(selection);
if (selectedMods.length() == 0)
selectedMods = m_model->allMods();
std::sort(selectedMods.begin(), selectedMods.end(), [](const Mod* a, const Mod* b) { return a->name() < b->name(); });
ExportToModListDialog dlg(m_instance->name(), selectedMods, this);
dlg.exec();
}

View File

@@ -62,6 +62,7 @@ class ModFolderPage : public ExternalResourcesPage {
private slots:
void removeItems(const QItemSelection& selection) override;
void deleteModMetadata();
void exportModMetadata();
void installMods();
void updateMods(bool includeDeps = false);

View File

@@ -55,7 +55,6 @@ CustomPage::CustomPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(par
connect(ui->alphaFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
connect(ui->betaFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
connect(ui->snapshotFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
connect(ui->oldSnapshotFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
connect(ui->releaseFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
connect(ui->experimentsFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
connect(ui->refreshBtn, &QPushButton::clicked, this, &CustomPage::refresh);
@@ -96,13 +95,11 @@ void CustomPage::filterChanged()
{
QStringList out;
if (ui->alphaFilter->isChecked())
out << "(old_alpha)";
out << "(alpha)";
if (ui->betaFilter->isChecked())
out << "(old_beta)";
out << "(beta)";
if (ui->snapshotFilter->isChecked())
out << "(snapshot)";
if (ui->oldSnapshotFilter->isChecked())
out << "(old_snapshot)";
if (ui->releaseFilter->isChecked())
out << "(release)";
if (ui->experimentsFilter->isChecked())

View File

@@ -93,16 +93,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="oldSnapshotFilter">
<property name="text">
<string>Old Snapshots</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="betaFilter">
<property name="text">
@@ -286,7 +276,6 @@
<tabstop>tabWidget</tabstop>
<tabstop>releaseFilter</tabstop>
<tabstop>snapshotFilter</tabstop>
<tabstop>oldSnapshotFilter</tabstop>
<tabstop>betaFilter</tabstop>
<tabstop>alphaFilter</tabstop>
<tabstop>experimentsFilter</tabstop>

View File

@@ -331,7 +331,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(), &NetAction::succeeded, this, [=] {
connect(icon_fetch_action.get(), &Task::succeeded, this, [=] {
auto icon = QIcon(full_file_path);
QPixmapCache::insert(url.toString(), icon.pixmap(icon.actualSize({ 64, 64 })));
@@ -339,7 +339,7 @@ std::optional<QIcon> ResourceModel::getIcon(QModelIndex& index, const QUrl& url)
emit dataChanged(index, index, { Qt::DecorationRole });
});
connect(icon_fetch_action.get(), &NetAction::failed, this, [=] {
connect(icon_fetch_action.get(), &Task::failed, this, [=] {
m_currently_running_icon_actions.remove(url);
m_failed_icon_actions.insert(url);
});

View File

@@ -352,10 +352,10 @@ void ModpackListModel::searchRequestForOneSucceeded(QJsonDocument& doc)
void ModpackListModel::searchRequestFailed(QString reason)
{
auto failed_action = dynamic_cast<NetJob*>(jobPtr.get())->getFailedActions().at(0);
if (!failed_action->m_reply) {
if (failed_action->replyStatusCode() == -1) {
// Network error
QMessageBox::critical(nullptr, tr("Error"), tr("A network error occurred. Could not load modpacks."));
} else if (failed_action->m_reply && failed_action->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409) {
} else if (failed_action->replyStatusCode() == 409) {
// 409 Gone, notify user to update
QMessageBox::critical(nullptr, tr("Error"),
//: %1 refers to the launcher itself