NOISSUE Add pack author and description to technic modpack import page
This commit is contained in:
parent
6aa126be30
commit
f4d58e17ee
@ -33,6 +33,9 @@ struct Modpack {
|
|||||||
QString minecraftVersion;
|
QString minecraftVersion;
|
||||||
|
|
||||||
bool metadataLoaded = false;
|
bool metadataLoaded = false;
|
||||||
|
QString websiteUrl;
|
||||||
|
QString author;
|
||||||
|
QString description;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +158,9 @@ void TechnicPage::suggestCurrent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
current.minecraftVersion = Json::ensureString(obj, "minecraft", QString(), "__placeholder__");
|
current.minecraftVersion = Json::ensureString(obj, "minecraft", QString(), "__placeholder__");
|
||||||
|
current.websiteUrl = Json::ensureString(obj, "platformUrl", QString(), "__placeholder__");
|
||||||
|
current.author = Json::ensureString(obj, "user", QString(), "__placeholder__");
|
||||||
|
current.description = Json::ensureString(obj, "description", QString(), "__placeholder__");
|
||||||
current.metadataLoaded = true;
|
current.metadataLoaded = true;
|
||||||
metadataLoaded();
|
metadataLoaded();
|
||||||
});
|
});
|
||||||
@ -168,29 +171,22 @@ void TechnicPage::suggestCurrent()
|
|||||||
// expects current.metadataLoaded to be true
|
// expects current.metadataLoaded to be true
|
||||||
void TechnicPage::metadataLoaded()
|
void TechnicPage::metadataLoaded()
|
||||||
{
|
{
|
||||||
/*QString text = "";
|
QString text = "";
|
||||||
QString name = current.name;
|
QString name = current.name;
|
||||||
|
|
||||||
if (current.websiteUrl.isEmpty())
|
if (current.websiteUrl.isEmpty())
|
||||||
|
// This allows injecting HTML here.
|
||||||
text = name;
|
text = name;
|
||||||
else
|
else
|
||||||
|
// URL not properly escaped for inclusion in HTML. The name allows for injecting HTML.
|
||||||
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
|
||||||
if (!current.authors.empty()) {
|
if (!current.author.isEmpty()) {
|
||||||
auto authorToStr = [](Technic::ModpackAuthor & author) {
|
// This allows injecting HTML here
|
||||||
if(author.url.isEmpty()) {
|
text += tr(" by ") + current.author;
|
||||||
return author.name;
|
|
||||||
}
|
|
||||||
return QString("<a href=\"%1\">%2</a>").arg(author.url, author.name);
|
|
||||||
};
|
|
||||||
QStringList authorStrs;
|
|
||||||
for(auto & author: current.authors) {
|
|
||||||
authorStrs.push_back(authorToStr(author));
|
|
||||||
}
|
|
||||||
text += tr(" by ") + authorStrs.join(", ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->frame->setModText(text);
|
ui->frame->setModText(text);
|
||||||
ui->frame->setModDescription(current.description);*/
|
ui->frame->setModDescription(current.description);
|
||||||
if (!current.isSolder)
|
if (!current.isSolder)
|
||||||
{
|
{
|
||||||
dialog->setSuggestedPack(current.name, new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
|
dialog->setSuggestedPack(current.name, new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
|
||||||
|
@ -55,8 +55,37 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="MCModInfoFrame" name="frame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>MCModInfoFrame</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>widgets/MCModInfoFrame.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>searchEdit</tabstop>
|
||||||
|
<tabstop>searchButton</tabstop>
|
||||||
|
<tabstop>packView</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -135,6 +135,7 @@ void MCModInfoFrame::setModDescription(QString text)
|
|||||||
ui->label_ModDescription->setOpenExternalLinks(false);
|
ui->label_ModDescription->setOpenExternalLinks(false);
|
||||||
ui->label_ModDescription->setTextFormat(Qt::TextFormat::RichText);
|
ui->label_ModDescription->setTextFormat(Qt::TextFormat::RichText);
|
||||||
desc = text;
|
desc = text;
|
||||||
|
// This allows injecting HTML here.
|
||||||
labeltext.append("<html><body>" + finaltext.left(287) + "<a href=\"#mod_desc\">...</a></body></html>");
|
labeltext.append("<html><body>" + finaltext.left(287) + "<a href=\"#mod_desc\">...</a></body></html>");
|
||||||
QObject::connect(ui->label_ModDescription, &QLabel::linkActivated, this, &MCModInfoFrame::modDescEllipsisHandler);
|
QObject::connect(ui->label_ModDescription, &QLabel::linkActivated, this, &MCModInfoFrame::modDescEllipsisHandler);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user