aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-11-04 18:30:42 +0100
committerSefa Eyeoglu <contact@scrumplex.net>2022-11-04 18:30:42 +0100
commit21a7af535c8b5b9d231aa3c41f7a990689fde560 (patch)
treeaf106527454f91335ec02b17bd36746bf2c3af60 /launcher/ui/pages/modplatform
parenta241d3f187f07cd3049c0d17f711c674fd6e7ccd (diff)
parent8f045af8679e9ae1da120eb56e4cec452284ac56 (diff)
downloadPrismLauncher-21a7af535c8b5b9d231aa3c41f7a990689fde560.tar.gz
PrismLauncher-21a7af535c8b5b9d231aa3c41f7a990689fde560.tar.bz2
PrismLauncher-21a7af535c8b5b9d231aa3c41f7a990689fde560.zip
Merge branch 'develop' into macos-drag-n-drop
Diffstat (limited to 'launcher/ui/pages/modplatform')
-rw-r--r--launcher/ui/pages/modplatform/ModModel.cpp25
-rw-r--r--launcher/ui/pages/modplatform/ModModel.h1
-rw-r--r--launcher/ui/pages/modplatform/VanillaPage.cpp8
-rw-r--r--launcher/ui/pages/modplatform/VanillaPage.h12
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp2
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp9
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h4
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModel.cpp52
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.cpp10
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.ui9
10 files changed, 85 insertions, 47 deletions
diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp
index 49766fa6..ed58eb32 100644
--- a/launcher/ui/pages/modplatform/ModModel.cpp
+++ b/launcher/ui/pages/modplatform/ModModel.cpp
@@ -267,18 +267,25 @@ void ListModel::searchRequestFailed(QString reason)
.arg(m_parent->displayName())
.arg(tr("API version too old!\nPlease update %1!").arg(BuildConfig.LAUNCHER_DISPLAYNAME)));
}
+
jobPtr.reset();
+ searchState = Finished;
+}
- if (searchState == ResetRequested) {
- beginResetModel();
- modpacks.clear();
- endResetModel();
+void ListModel::searchRequestAborted()
+{
+ if (searchState != ResetRequested)
+ qCritical() << "Search task in ModModel aborted by an unknown reason!";
- nextSearchOffset = 0;
- performPaginatedSearch();
- } else {
- searchState = Finished;
- }
+ // Retry fetching
+ jobPtr.reset();
+
+ beginResetModel();
+ modpacks.clear();
+ endResetModel();
+
+ nextSearchOffset = 0;
+ performPaginatedSearch();
}
void ListModel::infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index)
diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h
index a58c7c55..d2636d87 100644
--- a/launcher/ui/pages/modplatform/ModModel.h
+++ b/launcher/ui/pages/modplatform/ModModel.h
@@ -51,6 +51,7 @@ class ListModel : public QAbstractListModel {
public slots:
void searchRequestFinished(QJsonDocument& doc);
void searchRequestFailed(QString reason);
+ void searchRequestAborted();
void infoRequestFinished(QJsonDocument& doc, ModPlatform::IndexedPack& pack, const QModelIndex& index);
diff --git a/launcher/ui/pages/modplatform/VanillaPage.cpp b/launcher/ui/pages/modplatform/VanillaPage.cpp
index 99190f31..29fecb85 100644
--- a/launcher/ui/pages/modplatform/VanillaPage.cpp
+++ b/launcher/ui/pages/modplatform/VanillaPage.cpp
@@ -187,12 +187,12 @@ void VanillaPage::retranslate()
ui->retranslateUi(this);
}
-BaseVersionPtr VanillaPage::selectedVersion() const
+BaseVersion::Ptr VanillaPage::selectedVersion() const
{
return m_selectedVersion;
}
-BaseVersionPtr VanillaPage::selectedLoaderVersion() const
+BaseVersion::Ptr VanillaPage::selectedLoaderVersion() const
{
return m_selectedLoaderVersion;
}
@@ -227,14 +227,14 @@ void VanillaPage::suggestCurrent()
dialog->setSuggestedIcon("default");
}
-void VanillaPage::setSelectedVersion(BaseVersionPtr version)
+void VanillaPage::setSelectedVersion(BaseVersion::Ptr version)
{
m_selectedVersion = version;
suggestCurrent();
loaderFilterChanged();
}
-void VanillaPage::setSelectedLoaderVersion(BaseVersionPtr version)
+void VanillaPage::setSelectedLoaderVersion(BaseVersion::Ptr version)
{
m_selectedLoaderVersion = version;
suggestCurrent();
diff --git a/launcher/ui/pages/modplatform/VanillaPage.h b/launcher/ui/pages/modplatform/VanillaPage.h
index 7193597d..39aba760 100644
--- a/launcher/ui/pages/modplatform/VanillaPage.h
+++ b/launcher/ui/pages/modplatform/VanillaPage.h
@@ -76,13 +76,13 @@ public:
void openedImpl() override;
- BaseVersionPtr selectedVersion() const;
- BaseVersionPtr selectedLoaderVersion() const;
+ BaseVersion::Ptr selectedVersion() const;
+ BaseVersion::Ptr selectedLoaderVersion() const;
QString selectedLoader() const;
public slots:
- void setSelectedVersion(BaseVersionPtr version);
- void setSelectedLoaderVersion(BaseVersionPtr version);
+ void setSelectedVersion(BaseVersion::Ptr version);
+ void setSelectedLoaderVersion(BaseVersion::Ptr version);
private slots:
void filterChanged();
@@ -98,7 +98,7 @@ private:
NewInstanceDialog *dialog = nullptr;
Ui::VanillaPage *ui = nullptr;
bool m_versionSetByUser = false;
- BaseVersionPtr m_selectedVersion;
- BaseVersionPtr m_selectedLoaderVersion;
+ BaseVersion::Ptr m_selectedVersion;
+ BaseVersion::Ptr m_selectedLoaderVersion;
QString m_selectedLoader;
};
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
index 004fdc57..9138dcbb 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
@@ -331,7 +331,7 @@ AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVers
connect(ui->clearAllButton, &QPushButton::clicked,
listModel, &AtlOptionalModListModel::clearAll);
connect(ui->installButton, &QPushButton::clicked,
- this, &QDialog::close);
+ this, &QDialog::accept);
}
AtlOptionalModDialog::~AtlOptionalModDialog() {
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
index 03196685..f5f50cae 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
@@ -43,14 +43,17 @@ AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget *parent) :
{
}
-QVector<QString> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
+std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
{
AtlOptionalModDialog optionalModDialog(m_parent, version, mods);
- optionalModDialog.exec();
+ auto result = optionalModDialog.exec();
+ if (result == QDialog::Rejected) {
+ return {};
+ }
return optionalModDialog.getResult();
}
-QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion)
+QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlist, QString minecraftVersion)
{
VersionSelectDialog vselect(vlist.get(), "Choose Version", m_parent, false);
if (minecraftVersion != nullptr) {
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
index aa22fc73..37010b3f 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
@@ -46,8 +46,8 @@ public:
AtlUserInteractionSupportImpl(QWidget* parent);
private:
- QString chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) override;
- QVector<QString> chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods) override;
+ QString chooseVersion(Meta::VersionList::Ptr vlist, QString minecraftVersion) override;
+ std::optional<QVector<QString>> chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods) override;
void displayMessage(QString message) override;
private:
diff --git a/launcher/ui/pages/modplatform/flame/FlameModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModel.cpp
index b9804681..9f8605eb 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModel.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModel.cpp
@@ -1,6 +1,7 @@
#include "FlameModel.h"
#include <Json.h>
#include "Application.h"
+#include "ui/widgets/ProjectItem.h"
#include <MMCStrings.h>
#include <Version.h>
@@ -31,29 +32,38 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
}
IndexedPack pack = modpacks.at(pos);
- if (role == Qt::DisplayRole) {
- return pack.name;
- } else if (role == Qt::ToolTipRole) {
- if (pack.description.length() > 100) {
- // some magic to prevent to long tooltips and replace html linebreaks
- QString edit = pack.description.left(97);
- edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
- return edit;
+ switch (role) {
+ case Qt::ToolTipRole: {
+ if (pack.description.length() > 100) {
+ // some magic to prevent to long tooltips and replace html linebreaks
+ QString edit = pack.description.left(97);
+ edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
+ return edit;
+ }
+ return pack.description;
+ } case Qt::DecorationRole: {
+ if (m_logoMap.contains(pack.logoName)) {
+ return (m_logoMap.value(pack.logoName));
+ }
+ QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
+ ((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
+ return icon;
+ } case Qt::UserRole: {
+ QVariant v;
+ v.setValue(pack);
+ return v;
}
- return pack.description;
- } else if (role == Qt::DecorationRole) {
- if (m_logoMap.contains(pack.logoName)) {
- return (m_logoMap.value(pack.logoName));
- }
- QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
- ((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
- return icon;
- } else if (role == Qt::UserRole) {
- QVariant v;
- v.setValue(pack);
- return v;
+ case Qt::SizeHintRole:
+ return QSize(0, 58);
+ case UserDataTypes::TITLE:
+ return pack.name;
+ case UserDataTypes::DESCRIPTION:
+ return pack.description;
+ case UserDataTypes::SELECTED:
+ return false;
+ default:
+ break;
}
-
return QVariant();
}
diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
index 7d2ba2e2..a65b6585 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
@@ -43,6 +43,10 @@
#include "InstanceImportTask.h"
#include "Json.h"
#include "ui/dialogs/NewInstanceDialog.h"
+#include "ui/widgets/ProjectItem.h"
+#include "modplatform/flame/FlameAPI.h"
+
+static FlameAPI api;
FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::FlamePage), dialog(dialog)
{
@@ -66,6 +70,9 @@ FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(paren
connect(ui->sortByBox, SIGNAL(currentIndexChanged(int)), this, SLOT(triggerSearch()));
connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FlamePage::onSelectionChanged);
connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FlamePage::onVersionSelectionChanged);
+
+ ui->packView->setItemDelegate(new ProjectItemDelegate(this));
+ ui->packDescription->setMetaEntry("FlamePacks");
}
FlamePage::~FlamePage()
@@ -250,7 +257,10 @@ void FlamePage::updateUi()
text += "- " + tr("Source code: <a href=%1>%1</a>").arg(current.extra.sourceUrl) + "<br>";
}
+
text += "<hr>";
+ text += api.getModDescription(current.addonId).toUtf8();
ui->packDescription->setHtml(text + current.description);
+ ui->packDescription->flush();
}
diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.ui b/launcher/ui/pages/modplatform/flame/FlamePage.ui
index 1a3d0225..71d19513 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.ui
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.ui
@@ -66,7 +66,7 @@
</widget>
</item>
<item>
- <widget class="QTextBrowser" name="packDescription">
+ <widget class="ProjectDescriptionPage" name="packDescription">
<property name="openExternalLinks">
<bool>true</bool>
</property>
@@ -99,6 +99,13 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>ProjectDescriptionPage</class>
+ <extends>QTextBrowser</extends>
+ <header>ui/widgets/ProjectDescriptionPage.h</header>
+ </customwidget>
+ </customwidgets>
<tabstops>
<tabstop>packView</tabstop>
<tabstop>packDescription</tabstop>