chore(ManagedPackPage): format and add headers

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-11-12 13:27:09 -03:00
parent 74f7039abf
commit c5c426ecbc
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 33 additions and 16 deletions

View File

@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2022 flow <flowlnlnln@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-only
#include "ManagedPackPage.h"
#include "ui_ManagedPackPage.h"
@ -79,6 +83,8 @@ QString ManagedPackPage::displayName() const
auto type = m_inst->getManagedPackType();
if (type.isEmpty())
return {};
if (type == "flame")
type = "CurseForge";
return type.replace(0, 1, type[0].toUpper());
}
@ -159,6 +165,8 @@ ModrinthManagedPackPage::ModrinthManagedPackPage(BaseInstance* inst, InstanceWin
connect(ui->updateButton, &QPushButton::pressed, this, &ModrinthManagedPackPage::update);
}
// MODRINTH
void ModrinthManagedPackPage::parseManagedPack()
{
qDebug() << "Parsing Modrinth pack";
@ -271,6 +279,8 @@ void ModrinthManagedPackPage::update()
m_instance_window->close();
}
// FLAME
FlameManagedPackPage::FlameManagedPackPage(BaseInstance* inst, InstanceWindow* instance_window, QWidget* parent)
: ManagedPackPage(inst, instance_window, parent)
{
@ -279,14 +289,15 @@ FlameManagedPackPage::FlameManagedPackPage(BaseInstance* inst, InstanceWindow* i
connect(ui->updateButton, &QPushButton::pressed, this, &FlameManagedPackPage::update);
}
void FlameManagedPackPage::parseManagedPack() {
void FlameManagedPackPage::parseManagedPack()
{
qDebug() << "Parsing Flame pack";
// We need to tell the user to redownload the pack, since we didn't save the required info previously
if (m_inst->getManagedPackID().isEmpty()) {
setFailState();
QString message = tr(
"<h1>Hey there!</h1>"
QString message =
tr("<h1>Hey there!</h1>"
"<h4>"
"It seems like your Pack ID is null. This is because of a bug in older versions of the launcher.<br/>"
"Unfortunately, we can't do the proper API requests without this information.<br/>"
@ -294,8 +305,7 @@ void FlameManagedPackPage::parseManagedPack() {
"So, in order for this feature to work, you will need to re-download the modpack from the built-in downloader.<br/>"
"<br/>"
"Don't worry though, it will ask you to update this instance instead, so you'll not lose this instance!"
"</h4>"
);
"</h4>");
ui->changelogTextBrowser->setHtml(message);
return;
@ -327,7 +337,7 @@ void FlameManagedPackPage::parseManagedPack() {
Flame::loadIndexedPackVersions(m_pack, data);
} catch (const JSONValidationError& e) {
qDebug() << *response;
qWarning() << "Error while reading modrinth modpack version: " << e.cause();
qWarning() << "Error while reading flame modpack version: " << e.cause();
setFailState();
return;
@ -365,6 +375,7 @@ void FlameManagedPackPage::parseManagedPack() {
QString FlameManagedPackPage::url() const
{
// FIXME: We should display the websiteUrl field, but this requires doing the API request first :(
return {};
}

View File

@ -1,3 +1,7 @@
// SPDX-FileCopyrightText: 2022 flow <flowlnlnln@gmail.com>
//
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "BaseInstance.h"
@ -44,7 +48,7 @@ class ManagedPackPage : public QWidget, public BasePage {
/** Gets the necessary information about the managed pack, such as
* available versions*/
virtual void parseManagedPack() {};
virtual void parseManagedPack(){};
/** URL of the managed pack.
* Not the version-specific one.
@ -58,7 +62,7 @@ class ManagedPackPage : public QWidget, public BasePage {
*/
virtual void suggestVersion();
virtual void update() {};
virtual void update(){};
protected slots:
/** Does the necessary UI changes for when something failed.
@ -94,7 +98,9 @@ class GenericManagedPackPage final : public ManagedPackPage {
Q_OBJECT
public:
GenericManagedPackPage(BaseInstance* inst, InstanceWindow* instance_window, QWidget* parent = nullptr) : ManagedPackPage(inst, instance_window, parent) {}
GenericManagedPackPage(BaseInstance* inst, InstanceWindow* instance_window, QWidget* parent = nullptr)
: ManagedPackPage(inst, instance_window, parent)
{}
~GenericManagedPackPage() override = default;
// TODO: We may want to show this page with some useful info at some point.