Merge pull request #1563 from Trial97/modrinth_pack
Pack import fixes and improvements
This commit is contained in:
@ -237,8 +237,7 @@ void NewInstanceDialog::setSuggestedIcon(const QString& key)
|
||||
|
||||
InstanceTask* NewInstanceDialog::extractTask()
|
||||
{
|
||||
InstanceTask* extracted = creationTask.get();
|
||||
creationTask.release();
|
||||
InstanceTask* extracted = creationTask.release();
|
||||
|
||||
InstanceName inst_name(ui->instNameTextBox->placeholderText().trimmed(), importVersion);
|
||||
inst_name.setName(ui->instNameTextBox->text().trimmed());
|
||||
|
63
launcher/ui/pages/modplatform/OptionalModDialog.cpp
Normal file
63
launcher/ui/pages/modplatform/OptionalModDialog.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "OptionalModDialog.h"
|
||||
#include "ui_OptionalModDialog.h"
|
||||
|
||||
OptionalModDialog::OptionalModDialog(QWidget* parent, const QStringList& mods) : QDialog(parent), ui(new Ui::OptionalModDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
for (const QString& mod : mods) {
|
||||
auto item = new QListWidgetItem(mod, ui->list);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
item->setData(Qt::UserRole, mod);
|
||||
}
|
||||
|
||||
connect(ui->selectAllButton, &QPushButton::clicked, ui->list, [this] {
|
||||
for (int i = 0; i < ui->list->count(); i++)
|
||||
ui->list->item(i)->setCheckState(Qt::Checked);
|
||||
});
|
||||
connect(ui->clearAllButton, &QPushButton::clicked, ui->list, [this] {
|
||||
for (int i = 0; i < ui->list->count(); i++)
|
||||
ui->list->item(i)->setCheckState(Qt::Unchecked);
|
||||
});
|
||||
connect(ui->list, &QListWidget::itemActivated, [](QListWidgetItem* item) {
|
||||
if (item->checkState() == Qt::Checked)
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
else
|
||||
item->setCheckState(Qt::Checked);
|
||||
});
|
||||
}
|
||||
|
||||
OptionalModDialog::~OptionalModDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QStringList OptionalModDialog::getResult()
|
||||
{
|
||||
QStringList result;
|
||||
result.reserve(ui->list->count());
|
||||
for (int i = 0; i < ui->list->count(); i++) {
|
||||
auto item = ui->list->item(i);
|
||||
if (item->checkState() == Qt::Checked)
|
||||
result.append(item->data(Qt::UserRole).toString());
|
||||
}
|
||||
return result;
|
||||
}
|
39
launcher/ui/pages/modplatform/OptionalModDialog.h
Normal file
39
launcher/ui/pages/modplatform/OptionalModDialog.h
Normal file
@ -0,0 +1,39 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class OptionalModDialog;
|
||||
}
|
||||
|
||||
class OptionalModDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OptionalModDialog(QWidget* parent, const QStringList& mods);
|
||||
~OptionalModDialog() override;
|
||||
|
||||
QStringList getResult();
|
||||
|
||||
private:
|
||||
Ui::OptionalModDialog* ui;
|
||||
};
|
113
launcher/ui/pages/modplatform/OptionalModDialog.ui
Normal file
113
launcher/ui/pages/modplatform/OptionalModDialog.ui
Normal file
@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OptionalModDialog</class>
|
||||
<widget class="QDialog" name="OptionalModDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select Optional Mods</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="list">
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::IgnoreAction</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="selectAllButton">
|
||||
<property name="text">
|
||||
<string>Select All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearAllButton">
|
||||
<property name="text">
|
||||
<string>Deselect All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Unchecked mods will be disabled.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>OptionalModDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>274</x>
|
||||
<y>284</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>274</x>
|
||||
<y>154</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>OptionalModDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>274</x>
|
||||
<y>284</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>274</x>
|
||||
<y>154</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -63,7 +63,7 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
auto icon = APPLICATION->getThemedIcon("atlauncher-placeholder");
|
||||
|
||||
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(pack.safeName.toLower());
|
||||
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1").arg(pack.safeName);
|
||||
((ListModel*)this)->requestLogo(pack.safeName, url);
|
||||
|
||||
return icon;
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include <QAbstractListModel>
|
||||
#include <QDialog>
|
||||
|
||||
#include "modplatform/atlauncher/ATLPackIndex.h"
|
||||
#include "modplatform/atlauncher/ATLPackManifest.h"
|
||||
#include "net/NetJob.h"
|
||||
|
||||
namespace Ui {
|
||||
|
@ -114,8 +114,8 @@ void AtlPage::suggestCurrent()
|
||||
auto uiSupport = new AtlUserInteractionSupportImpl(this);
|
||||
dialog->setSuggestedPack(selected.name, selectedVersion, new ATLauncher::PackInstallTask(uiSupport, selected.name, selectedVersion));
|
||||
|
||||
auto editedLogoName = selected.safeName;
|
||||
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(selected.safeName.toLower());
|
||||
auto editedLogoName = "atl_" + selected.safeName;
|
||||
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1").arg(selected.safeName);
|
||||
listModel->getLogo(selected.safeName, url,
|
||||
[this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
|
||||
}
|
||||
|
@ -228,8 +228,7 @@ void FlamePage::suggestCurrent()
|
||||
extra_info.insert("pack_version_id", QString::number(version.fileId));
|
||||
|
||||
dialog->setSuggestedPack(current.name, new InstanceImportTask(version.downloadUrl, this, std::move(extra_info)));
|
||||
QString editedLogoName;
|
||||
editedLogoName = "curseforge_" + current.logoName;
|
||||
QString editedLogoName = "curseforge_" + current.logoName;
|
||||
listModel->getLogo(current.logoName, current.logoUrl,
|
||||
[this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void ImportFTBPage::suggestCurrent()
|
||||
}
|
||||
|
||||
dialog->setSuggestedPack(selected.name, new PackInstallTask(selected));
|
||||
QString editedLogoName = QString("ftb_%1").arg(selected.id);
|
||||
QString editedLogoName = QString("ftb_%1_%2,jpg").arg(selected.name, selected.id);
|
||||
dialog->setSuggestedIconFromFile(FS::PathCombine(selected.path, "folder.jpg"), editedLogoName);
|
||||
}
|
||||
|
||||
|
@ -179,15 +179,11 @@ void Page::suggestCurrent()
|
||||
}
|
||||
|
||||
dialog->setSuggestedPack(selected.name, selectedVersion, new PackInstallTask(APPLICATION->network(), selected, selectedVersion));
|
||||
QString editedLogoName;
|
||||
if (selected.logo.toLower().startsWith("ftb")) {
|
||||
editedLogoName = selected.logo;
|
||||
} else {
|
||||
editedLogoName = "ftb_" + selected.logo;
|
||||
QString editedLogoName = selected.logo;
|
||||
if (!selected.logo.toLower().startsWith("ftb")) {
|
||||
editedLogoName = "ftb_" + editedLogoName;
|
||||
}
|
||||
|
||||
editedLogoName = editedLogoName.left(editedLogoName.lastIndexOf(".png"));
|
||||
|
||||
if (selected.type == PackType::Public) {
|
||||
publicListModel->getLogo(selected.logo,
|
||||
[this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
|
||||
|
@ -41,7 +41,9 @@
|
||||
#include "net/ApiDownload.h"
|
||||
#include "ui/widgets/ProjectItem.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QIcon>
|
||||
#include <QUrl>
|
||||
|
||||
Technic::ListModel::ListModel(QObject* parent) : QAbstractListModel(parent) {}
|
||||
|
||||
@ -193,7 +195,7 @@ void Technic::ListModel::searchRequestFinished()
|
||||
pack.logoName = "null";
|
||||
} else {
|
||||
pack.logoUrl = rawURL;
|
||||
pack.logoName = rawURL.section(QLatin1Char('/'), -1);
|
||||
pack.logoName = pack.slug + "." + QFileInfo(QUrl(rawURL).fileName()).suffix();
|
||||
}
|
||||
pack.broken = false;
|
||||
newList.append(pack);
|
||||
@ -215,7 +217,7 @@ void Technic::ListModel::searchRequestFinished()
|
||||
auto iconUrl = Json::requireString(iconObj, "url");
|
||||
|
||||
pack.logoUrl = iconUrl;
|
||||
pack.logoName = iconUrl.section(QLatin1Char('/'), -1);
|
||||
pack.logoName = pack.slug + "." + QFileInfo(QUrl(iconUrl).fileName()).suffix();
|
||||
} else {
|
||||
pack.logoUrl = "null";
|
||||
pack.logoName = "null";
|
||||
|
Reference in New Issue
Block a user