Merge pull request #215 from forkiesassds/develop

This commit is contained in:
flow 2022-10-22 10:48:00 -03:00 committed by GitHub
commit 81f1305270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 22 deletions

View File

@ -1,6 +1,7 @@
#include "FlameModel.h" #include "FlameModel.h"
#include <Json.h> #include <Json.h>
#include "Application.h" #include "Application.h"
#include "ui/widgets/ProjectItem.h"
#include <MMCStrings.h> #include <MMCStrings.h>
#include <Version.h> #include <Version.h>
@ -31,9 +32,8 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
} }
IndexedPack pack = modpacks.at(pos); IndexedPack pack = modpacks.at(pos);
if (role == Qt::DisplayRole) { switch (role) {
return pack.name; case Qt::ToolTipRole: {
} else if (role == Qt::ToolTipRole) {
if (pack.description.length() > 100) { if (pack.description.length() > 100) {
// some magic to prevent to long tooltips and replace html linebreaks // some magic to prevent to long tooltips and replace html linebreaks
QString edit = pack.description.left(97); QString edit = pack.description.left(97);
@ -41,19 +41,29 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
return edit; return edit;
} }
return pack.description; return pack.description;
} else if (role == Qt::DecorationRole) { } case Qt::DecorationRole: {
if (m_logoMap.contains(pack.logoName)) { if (m_logoMap.contains(pack.logoName)) {
return (m_logoMap.value(pack.logoName)); return (m_logoMap.value(pack.logoName));
} }
QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder"); QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl); ((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
return icon; return icon;
} else if (role == Qt::UserRole) { } case Qt::UserRole: {
QVariant v; QVariant v;
v.setValue(pack); v.setValue(pack);
return v; 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(); return QVariant();
} }

View File

@ -43,6 +43,10 @@
#include "InstanceImportTask.h" #include "InstanceImportTask.h"
#include "Json.h" #include "Json.h"
#include "ui/dialogs/NewInstanceDialog.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) 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->sortByBox, SIGNAL(currentIndexChanged(int)), this, SLOT(triggerSearch()));
connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FlamePage::onSelectionChanged); connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FlamePage::onSelectionChanged);
connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FlamePage::onVersionSelectionChanged); connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FlamePage::onVersionSelectionChanged);
ui->packView->setItemDelegate(new ProjectItemDelegate(this));
ui->packDescription->setMetaEntry("FlamePacks");
} }
FlamePage::~FlamePage() FlamePage::~FlamePage()
@ -250,7 +257,10 @@ void FlamePage::updateUi()
text += "- " + tr("Source code: <a href=%1>%1</a>").arg(current.extra.sourceUrl) + "<br>"; text += "- " + tr("Source code: <a href=%1>%1</a>").arg(current.extra.sourceUrl) + "<br>";
} }
text += "<hr>"; text += "<hr>";
text += api.getModDescription(current.addonId).toUtf8();
ui->packDescription->setHtml(text + current.description); ui->packDescription->setHtml(text + current.description);
ui->packDescription->flush();
} }

View File

@ -66,7 +66,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTextBrowser" name="packDescription"> <widget class="ProjectDescriptionPage" name="packDescription">
<property name="openExternalLinks"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -99,6 +99,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>ProjectDescriptionPage</class>
<extends>QTextBrowser</extends>
<header>ui/widgets/ProjectDescriptionPage.h</header>
</customwidget>
</customwidgets>
<tabstops> <tabstops>
<tabstop>packView</tabstop> <tabstop>packView</tabstop>
<tabstop>packDescription</tabstop> <tabstop>packDescription</tabstop>