Made custom url function
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
54d7477679
commit
ce4a86fbcd
@ -166,6 +166,13 @@ auto Mod::homeurl() const -> QString
|
||||
return details().homeurl;
|
||||
}
|
||||
|
||||
auto Mod::metaurl() const -> QString
|
||||
{
|
||||
if (metadata() == nullptr)
|
||||
return homeurl();
|
||||
return ModPlatform::getMetaURL(metadata()->provider, metadata()->project_id);
|
||||
}
|
||||
|
||||
auto Mod::description() const -> QString
|
||||
{
|
||||
return details().description;
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
auto provider() const -> std::optional<QString>;
|
||||
auto licenses() const -> const QList<ModLicense>&;
|
||||
auto issueTracker() const -> QString;
|
||||
auto metaurl() const -> QString;
|
||||
|
||||
/** Get the intneral path to the mod's icon file*/
|
||||
QString iconPath() const { return m_local_details.icon_file; };
|
||||
|
@ -70,11 +70,17 @@ auto ProviderCapabilities::hash(ResourceProvider p, QIODevice* device, QString t
|
||||
}
|
||||
|
||||
QCryptographicHash hash(algo);
|
||||
if(!hash.addData(device))
|
||||
if (!hash.addData(device))
|
||||
qCritical() << "Failed to read JAR to create hash!";
|
||||
|
||||
Q_ASSERT(hash.result().length() == hash.hashLength(algo));
|
||||
return { hash.result().toHex() };
|
||||
}
|
||||
|
||||
QString getMetaURL(ResourceProvider provider, QVariant projectID)
|
||||
{
|
||||
return ((provider == ModPlatform::ResourceProvider::FLAME) ? "https://www.curseforge.com/projects/" : "https://modrinth.com/mod/") +
|
||||
projectID.toString();
|
||||
}
|
||||
|
||||
} // namespace ModPlatform
|
||||
|
@ -144,6 +144,7 @@ inline auto getOverrideDeps() -> QList<OverrideDep>
|
||||
{ "qvIfYCYJ", "P7dR8mSH", "API", ModPlatform::ResourceProvider::MODRINTH },
|
||||
{ "lwVhp9o5", "Ha28R6CL", "KotlinLibraries", ModPlatform::ResourceProvider::MODRINTH } };
|
||||
};
|
||||
QString getMetaURL(ResourceProvider provider, QVariant projectID);
|
||||
|
||||
} // namespace ModPlatform
|
||||
|
||||
|
@ -298,17 +298,9 @@ bool NilModFolderPage::shouldDisplay() const
|
||||
void ModFolderPage::visitModPages()
|
||||
{
|
||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||
for (auto mod : m_model->selectedMods(selection))
|
||||
if (auto meta = mod->metadata(); meta != nullptr) {
|
||||
auto slug = meta->slug.remove(".pw.toml");
|
||||
switch (meta->provider) {
|
||||
case ModPlatform::ResourceProvider::MODRINTH:
|
||||
DesktopServices::openUrl(QString("https://modrinth.com/mod/%1").arg(slug));
|
||||
break;
|
||||
case ModPlatform::ResourceProvider::FLAME:
|
||||
DesktopServices::openUrl(QString("https://www.curseforge.com/minecraft/mc-mods/%1").arg(slug));
|
||||
break;
|
||||
}
|
||||
} else if (mod->homeurl().size() != 0)
|
||||
DesktopServices::openUrl(mod->homeurl());
|
||||
for (auto mod : m_model->selectedMods(selection)) {
|
||||
auto url = mod->metaurl();
|
||||
if (!url.isEmpty())
|
||||
DesktopServices::openUrl(url);
|
||||
}
|
||||
}
|
@ -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(", ");
|
||||
|
Loading…
x
Reference in New Issue
Block a user