Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix links and add images to modpack changelogs #1370

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions launcher/ui/pages/instance/ManagedPackPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// SPDX-License-Identifier: GPL-3.0-only

#include "ManagedPackPage.h"
#include <QDesktopServices>
#include <QUrl>
#include <QUrlQuery>
#include "ui_ManagedPackPage.h"

#include <QListView>
Expand Down Expand Up @@ -103,6 +106,19 @@ ManagedPackPage::ManagedPackPage(BaseInstance* inst, InstanceWindow* instance_wi
// Pretend we're opening the page again
openedImpl();
});

connect(ui->changelogTextBrowser, &QTextBrowser::anchorClicked, this, [](const QUrl url) {
if (url.scheme().isEmpty()) {
auto querry =
QUrlQuery(url.query()).queryItemValue("remoteUrl", QUrl::FullyDecoded); // curseforge workaround for linkout?remoteUrl=
auto decoded = QUrl::fromPercentEncoding(querry.toUtf8());
auto newUrl = QUrl(decoded);
if (newUrl.isValid() && (newUrl.scheme() == "http" || newUrl.scheme() == "https"))
QDesktopServices ::openUrl(newUrl);
return;
}
QDesktopServices::openUrl(url);
});
}

ManagedPackPage::~ManagedPackPage()
Expand Down
12 changes: 11 additions & 1 deletion launcher/ui/pages/instance/ManagedPackPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTextBrowser" name="changelogTextBrowser">
<widget class="ProjectDescriptionPage" name="changelogTextBrowser">
<property name="placeholderText">
<string>No changelog available for this version!</string>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
Expand All @@ -188,6 +191,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ProjectDescriptionPage</class>
<extends>QTextBrowser</extends>
<header>ui/widgets/ProjectDescriptionPage.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>