Merge pull request #2004 from PrismLauncher/backport-1979-to-release-8.x

[Backport release-8.x] Mod downloader page improvements
This commit is contained in:
Alexandru Ionut Tripon 2024-01-03 22:47:27 +02:00 committed by GitHub
commit 744b81fc30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 2 deletions

View File

@ -122,6 +122,8 @@ struct ExtraPackData {
QString wikiUrl;
QString discordUrl;
QString status;
QString body;
};

View File

@ -104,6 +104,8 @@ void Modrinth::loadExtraPackData(ModPlatform::IndexedPack& pack, QJsonObject& ob
pack.extraData.donate.append(donate);
}
pack.extraData.status = Json::ensureString(obj, "status");
pack.extraData.body = Json::ensureString(obj, "body").remove("<br>");
pack.extraDataLoaded = true;

View File

@ -95,6 +95,8 @@ void loadIndexedInfo(Modpack& pack, QJsonObject& obj)
pack.extra.donate.append(donate);
}
pack.extra.status = Json::ensureString(obj, "status");
pack.extraInfoLoaded = true;
}

View File

@ -77,6 +77,8 @@ struct ModpackExtra {
QString discordUrl;
QList<DonationData> donate;
QString status;
};
struct ModpackVersion {

View File

@ -200,6 +200,11 @@ void ResourcePage::updateUi()
}
if (current_pack->extraDataLoaded) {
if (current_pack->extraData.status == "archived") {
text += "<br><br>" + tr("<b>This project has been archived. It will not receive any further updates unless the author decides "
"to unarchive the project.</b>");
}
if (!current_pack->extraData.donate.isEmpty()) {
text += "<br><br>" + tr("Donate information: ");
auto donateToStr = [](ModPlatform::DonationData& donate) -> QString {

View File

@ -142,7 +142,7 @@ void ModpackListModel::performPaginatedSearch()
callbacks.on_succeed = [this](auto& doc, auto& pack) { searchRequestForOneSucceeded(doc); };
callbacks.on_abort = [this] {
qCritical() << "Search task aborted by an unknown reason!";
searchRequestFailed("Abborted");
searchRequestFailed("Aborted");
};
static const ModrinthAPI api;
if (auto job = api.getProjectInfo({ projectId }, std::move(callbacks)); job) {

View File

@ -267,6 +267,11 @@ void ModrinthPage::updateUI()
text += "<br>" + tr(" by ") + QString("<a href=%1>%2</a>").arg(std::get<1>(current.author).toString(), std::get<0>(current.author));
if (current.extraInfoLoaded) {
if (current.extra.status == "archived") {
text += "<br><br>" + tr("<b>This project has been archived. It will not receive any further updates unless the author decides "
"to unarchive the project.</b>");
}
if (!current.extra.donate.isEmpty()) {
text += "<br><br>" + tr("Donate information: ");
auto donateToStr = [](Modrinth::DonationData& donate) -> QString {

View File

@ -88,7 +88,7 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
}
{ // Description painting
auto description = index.data(UserDataTypes::DESCRIPTION).toString();
auto description = index.data(UserDataTypes::DESCRIPTION).toString().simplified();
QTextLayout text_layout(description, opt.font);