feat: improve changelog and sort updatable mods
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
parent
5f75e531e6
commit
dfd6cb29be
@ -16,8 +16,7 @@
|
||||
#include "modplatform/modrinth/ModrinthCheckUpdate.h"
|
||||
|
||||
#include <HoeDown.h>
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QTextBrowser>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
static ModPlatform::ProviderCapabilities ProviderCaps;
|
||||
@ -47,7 +46,6 @@ ModUpdateDialog::ModUpdateDialog(QWidget* parent,
|
||||
|
||||
ui->explainLabel->setText(tr("You're about to update the following mods:"));
|
||||
ui->onlyCheckedLabel->setText(tr("Only mods with a check will be updated!"));
|
||||
|
||||
}
|
||||
|
||||
void ModUpdateDialog::checkCandidates()
|
||||
@ -178,8 +176,21 @@ void ModUpdateDialog::checkCandidates()
|
||||
}
|
||||
|
||||
// If there's no mod to be updated
|
||||
if (ui->modTreeWidget->topLevelItemCount() == 0)
|
||||
if (ui->modTreeWidget->topLevelItemCount() == 0) {
|
||||
m_no_updates = true;
|
||||
} else {
|
||||
// FIXME: Find a more efficient way of doing this!
|
||||
|
||||
// Sort major items in alphabetical order (also sorts the children unfortunately)
|
||||
ui->modTreeWidget->sortItems(0, Qt::SortOrder::AscendingOrder);
|
||||
|
||||
// Re-sort the children
|
||||
auto* item = ui->modTreeWidget->topLevelItem(0);
|
||||
for (int i = 1; item != nullptr; ++i) {
|
||||
item->sortChildren(0, Qt::SortOrder::DescendingOrder);
|
||||
item = ui->modTreeWidget->topLevelItem(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_aborted || m_no_updates)
|
||||
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
|
||||
@ -344,20 +355,23 @@ void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info)
|
||||
changelog_item->setText(0, tr("Changelog of the latest version"));
|
||||
|
||||
auto changelog = new QTreeWidgetItem(changelog_item);
|
||||
auto changelog_area = new QTextBrowser();
|
||||
|
||||
auto changelog_area = new QTextEdit();
|
||||
switch (info.provider) {
|
||||
case ModPlatform::Provider::MODRINTH: {
|
||||
HoeDown h;
|
||||
changelog_area->setText(h.process(info.changelog.toUtf8()));
|
||||
changelog_area->setReadOnly(true);
|
||||
if (info.changelog.size() < 250) // heuristic
|
||||
changelog_area->setSizeAdjustPolicy(QTextEdit::SizeAdjustPolicy::AdjustToContents);
|
||||
changelog_area->setHtml(h.process(info.changelog.toUtf8()));
|
||||
break;
|
||||
}
|
||||
case ModPlatform::Provider::FLAME: {
|
||||
changelog_area->setHtml(info.changelog);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
changelog_area->setOpenExternalLinks(true);
|
||||
|
||||
ui->modTreeWidget->setItemWidget(changelog, 0, changelog_area);
|
||||
changelog_item->insertChildren(0, { changelog });
|
||||
|
||||
item_top->insertChildren(0, { old_version_item });
|
||||
item_top->insertChildren(1, { new_version_item });
|
||||
item_top->insertChildren(2, { changelog_item });
|
||||
|
||||
ui->modTreeWidget->addTopLevelItem(item_top);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user