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,29 +32,38 @@ 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); edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("..."); return edit;
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; case Qt::SizeHintRole:
} else if (role == Qt::DecorationRole) { return QSize(0, 58);
if (m_logoMap.contains(pack.logoName)) { case UserDataTypes::TITLE:
return (m_logoMap.value(pack.logoName)); return pack.name;
} case UserDataTypes::DESCRIPTION:
QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder"); return pack.description;
((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl); case UserDataTypes::SELECTED:
return icon; return false;
} else if (role == Qt::UserRole) { default:
QVariant v; break;
v.setValue(pack);
return v;
} }
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>