fix: try finding a good height for short changelogs

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-07-01 11:54:32 -03:00
parent 2b65ee433f
commit 79b0a16f7a
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469

View File

@ -358,7 +358,6 @@ void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info)
auto changelog = new QTreeWidgetItem(changelog_item); auto changelog = new QTreeWidgetItem(changelog_item);
auto changelog_area = new QTextBrowser(); auto changelog_area = new QTextBrowser();
switch (info.provider) { switch (info.provider) {
case ModPlatform::Provider::MODRINTH: { case ModPlatform::Provider::MODRINTH: {
HoeDown h; HoeDown h;
@ -379,6 +378,12 @@ void ModUpdateDialog::appendMod(CheckUpdateTask::UpdatableMod const& info)
} }
changelog_area->setOpenExternalLinks(true); changelog_area->setOpenExternalLinks(true);
changelog_area->setLineWrapMode(QTextBrowser::LineWrapMode::NoWrap);
changelog_area->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
// HACK: Is there a better way of achieving this?
auto font_height = QFontMetrics(changelog_area->font()).height();
changelog_area->setMaximumHeight((changelog_area->toPlainText().count(QRegularExpression("\n|<br>")) + 2) * font_height);
ui->modTreeWidget->setItemWidget(changelog, 0, changelog_area); ui->modTreeWidget->setItemWidget(changelog, 0, changelog_area);