Made custom url function

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-06-25 10:41:29 +03:00
parent 54d7477679
commit ce4a86fbcd
6 changed files with 24 additions and 32 deletions

View File

@ -41,9 +41,7 @@
#include "ui/dialogs/CustomMessageBox.h"
InfoFrame::InfoFrame(QWidget *parent) :
QFrame(parent),
ui(new Ui::InfoFrame)
InfoFrame::InfoFrame(QWidget* parent) : QFrame(parent), ui(new Ui::InfoFrame)
{
ui->setupUi(this);
ui->descriptionLabel->setHidden(true);
@ -67,31 +65,18 @@ void InfoFrame::updateWithMod(Mod const& m)
QString text = "";
QString name = "";
QString link = "";
QString link = m.metaurl();
QString toolTip = "";
if (m.name().isEmpty())
name = m.internal_id();
else
name = m.name();
if (auto meta = m.metadata(); meta != nullptr) {
auto slug = meta->slug.remove(".pw.toml");
switch (meta->provider) {
case ModPlatform::ResourceProvider::MODRINTH:
link = QString("https://modrinth.com/mod/%1").arg(slug);
break;
case ModPlatform::ResourceProvider::FLAME:
link = QString("https://www.curseforge.com/minecraft/mc-mods/%1").arg(slug);
break;
}
} else if (!m.homeurl().isEmpty())
link = m.homeurl();
if (link.isEmpty())
text = name;
else {
text = "<a href=\"" + link + "\">" + name + "</a>";
toolTip = tr("Go to mod's home page");
toolTip = link;
}
if (!m.authors().isEmpty())
text += " by " + m.authors().join(", ");