diff --git a/launcher/updater/prismupdater/GitHubRelease.cpp b/launcher/updater/prismupdater/GitHubRelease.cpp index 25e60e885..3beae31b1 100644 --- a/launcher/updater/prismupdater/GitHubRelease.cpp +++ b/launcher/updater/prismupdater/GitHubRelease.cpp @@ -1,36 +1,93 @@ +// SPDX-FileCopyrightText: 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> +// +// SPDX-License-Identifier: GPL-3.0-only + +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include "GitHubRelease.h" QDebug operator<<(QDebug debug, const GitHubReleaseAsset& asset) { QDebugStateSaver saver(debug); - debug.nospace() << "GitHubReleaseAsset( " - "id: " << asset.id << ", " - "name " << asset.name << ", " - "label: " << asset.label << ", " - "content_type: " << asset.content_type << ", " - "size: " << asset.size << ", " - "created_at: " << asset.created_at << ", " - "updated_at: " << asset.updated_at << ", " - "browser_download_url: " << asset.browser_download_url << " " - ")"; + debug.nospace() << "GitHubReleaseAsset( " + "id: " + << asset.id + << ", " + "name " + << asset.name + << ", " + "label: " + << asset.label + << ", " + "content_type: " + << asset.content_type + << ", " + "size: " + << asset.size + << ", " + "created_at: " + << asset.created_at + << ", " + "updated_at: " + << asset.updated_at + << ", " + "browser_download_url: " + << asset.browser_download_url + << " " + ")"; return debug; } QDebug operator<<(QDebug debug, const GitHubRelease& rls) { QDebugStateSaver saver(debug); - debug.nospace() << "GitHubRelease( " - "id: " << rls.id << ", " - "name " << rls.name << ", " - "tag_name: " << rls.tag_name << ", " - "created_at: " << rls.created_at << ", " - "published_at: " << rls.published_at << ", " - "prerelease: " << rls.prerelease << ", " - "draft: " << rls.draft << ", " - "version" << rls.version << ", " - "body: " << rls.body << ", " - "assets: " << rls.assets << " " - ")"; + debug.nospace() << "GitHubRelease( " + "id: " + << rls.id + << ", " + "name " + << rls.name + << ", " + "tag_name: " + << rls.tag_name + << ", " + "created_at: " + << rls.created_at + << ", " + "published_at: " + << rls.published_at + << ", " + "prerelease: " + << rls.prerelease + << ", " + "draft: " + << rls.draft + << ", " + "version" + << rls.version + << ", " + "body: " + << rls.body + << ", " + "assets: " + << rls.assets + << " " + ")"; return debug; } - diff --git a/launcher/updater/prismupdater/GitHubRelease.h b/launcher/updater/prismupdater/GitHubRelease.h index 0c190333f..798c6b7ae 100644 --- a/launcher/updater/prismupdater/GitHubRelease.h +++ b/launcher/updater/prismupdater/GitHubRelease.h @@ -1,3 +1,25 @@ +// SPDX-FileCopyrightText: 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> +// +// SPDX-License-Identifier: GPL-3.0-only + +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #pragma once #include #include @@ -37,4 +59,3 @@ struct GitHubRelease { QDebug operator<<(QDebug debug, const GitHubReleaseAsset& rls); QDebug operator<<(QDebug debug, const GitHubRelease& rls); - diff --git a/launcher/updater/prismupdater/PrismUpdater.h b/launcher/updater/prismupdater/PrismUpdater.h index 113747b75..f879ad7ad 100644 --- a/launcher/updater/prismupdater/PrismUpdater.h +++ b/launcher/updater/prismupdater/PrismUpdater.h @@ -42,7 +42,7 @@ #define PRISM_EXTERNAL_EXE #include "FileSystem.h" -#include "updater/prismupdater/GitHubRelease.h" +#include "GitHubRelease.h" class PrismUpdaterApp : public QApplication { // friends for the purpose of limiting access to deprecated stuff diff --git a/launcher/updater/prismupdater/UpdaterDialogs.cpp b/launcher/updater/prismupdater/UpdaterDialogs.cpp index 14c584918..395b658db 100644 --- a/launcher/updater/prismupdater/UpdaterDialogs.cpp +++ b/launcher/updater/prismupdater/UpdaterDialogs.cpp @@ -1,3 +1,25 @@ +// SPDX-FileCopyrightText: 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> +// +// SPDX-License-Identifier: GPL-3.0-only + +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include "UpdaterDialogs.h" #include "ui_SelectReleaseDialog.h" @@ -9,25 +31,25 @@ SelectReleaseDialog::SelectReleaseDialog(const Version& current_version, const Q : QDialog(parent), m_releases(releases), m_currentVersion(current_version), ui(new Ui::SelectReleaseDialog) { ui->setupUi(this); - + ui->changelogTextBrowser->setOpenExternalLinks(true); ui->changelogTextBrowser->setLineWrapMode(QTextBrowser::LineWrapMode::WidgetWidth); ui->changelogTextBrowser->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded); - + ui->versionsTree->setColumnCount(2); ui->versionsTree->header()->setSectionResizeMode(0, QHeaderView::Stretch); - ui->versionsTree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); - ui->versionsTree->setHeaderLabels({tr("Version"), tr("Published Date")}); + ui->versionsTree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + ui->versionsTree->setHeaderLabels({ tr("Version"), tr("Published Date") }); ui->versionsTree->header()->setStretchLastSection(false); - + ui->eplainLabel->setText(tr("Select a version to install.\n" - "\n" - "Currently installed version: %1") - .arg(m_currentVersion.toString())); - + "\n" + "Currently installed version: %1") + .arg(m_currentVersion.toString())); + loadReleases(); - + connect(ui->versionsTree, &QTreeWidget::currentItemChanged, this, &SelectReleaseDialog::selectionChanged); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SelectReleaseDialog::accept); @@ -57,10 +79,11 @@ void SelectReleaseDialog::appendRelease(GitHubRelease const& release) ui->versionsTree->addTopLevelItem(rls_item); } -GitHubRelease SelectReleaseDialog::getRelease(QTreeWidgetItem* item) { +GitHubRelease SelectReleaseDialog::getRelease(QTreeWidgetItem* item) +{ int id = item->data(0, Qt::UserRole).toInt(); GitHubRelease release; - for (auto rls: m_releases) { + for (auto rls : m_releases) { if (rls.id == id) release = rls; } @@ -76,30 +99,28 @@ void SelectReleaseDialog::selectionChanged(QTreeWidgetItem* current, QTreeWidget ui->changelogTextBrowser->setHtml(body); } - - -SelectReleaseAssetDialog::SelectReleaseAssetDialog( const QList& assets, QWidget* parent) - : QDialog(parent), m_assets(assets), ui(new Ui::SelectReleaseDialog) +SelectReleaseAssetDialog::SelectReleaseAssetDialog(const QList& assets, QWidget* parent) + : QDialog(parent), m_assets(assets), ui(new Ui::SelectReleaseDialog) { ui->setupUi(this); - + ui->changelogTextBrowser->setOpenExternalLinks(true); ui->changelogTextBrowser->setLineWrapMode(QTextBrowser::LineWrapMode::WidgetWidth); ui->changelogTextBrowser->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded); - + ui->versionsTree->setColumnCount(2); ui->versionsTree->header()->setSectionResizeMode(0, QHeaderView::Stretch); - ui->versionsTree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); - ui->versionsTree->setHeaderLabels({tr("Version"), tr("Published Date")}); + ui->versionsTree->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + ui->versionsTree->setHeaderLabels({ tr("Version"), tr("Published Date") }); ui->versionsTree->header()->setStretchLastSection(false); - + ui->eplainLabel->setText(tr("Select a version to install.")); ui->changelogTextBrowser->setHidden(true); - + loadAssets(); - + connect(ui->versionsTree, &QTreeWidget::currentItemChanged, this, &SelectReleaseAssetDialog::selectionChanged); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SelectReleaseAssetDialog::accept); @@ -129,10 +150,11 @@ void SelectReleaseAssetDialog::appendAsset(GitHubReleaseAsset const& asset) ui->versionsTree->addTopLevelItem(rls_item); } -GitHubReleaseAsset SelectReleaseAssetDialog::getAsset(QTreeWidgetItem* item) { +GitHubReleaseAsset SelectReleaseAssetDialog::getAsset(QTreeWidgetItem* item) +{ int id = item->data(0, Qt::UserRole).toInt(); GitHubReleaseAsset selected_asset; - for (auto asset: m_assets) { + for (auto asset : m_assets) { if (asset.id == id) selected_asset = asset; } diff --git a/launcher/updater/prismupdater/UpdaterDialogs.h b/launcher/updater/prismupdater/UpdaterDialogs.h index c5e31b5a4..249ca1b5d 100644 --- a/launcher/updater/prismupdater/UpdaterDialogs.h +++ b/launcher/updater/prismupdater/UpdaterDialogs.h @@ -1,10 +1,32 @@ +// SPDX-FileCopyrightText: 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> +// +// SPDX-License-Identifier: GPL-3.0-only + +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #pragma once #include #include #include "Version.h" -#include "updater/prismupdater/GitHubRelease.h" +#include "GitHubRelease.h" namespace Ui { class SelectReleaseDialog; diff --git a/launcher/updater/prismupdater/updater_main.cpp b/launcher/updater/prismupdater/updater_main.cpp index 6bc7dd208..89c1d1198 100644 --- a/launcher/updater/prismupdater/updater_main.cpp +++ b/launcher/updater/prismupdater/updater_main.cpp @@ -20,17 +20,14 @@ * */ - - -#include "updater/prismupdater/PrismUpdater.h" +#include "PrismUpdater.h" int main(int argc, char* argv[]) { PrismUpdaterApp wUpApp(argc, argv); - switch(wUpApp.status()) { + switch (wUpApp.status()) { case PrismUpdaterApp::Starting: - case PrismUpdaterApp::Initialized: - { + case PrismUpdaterApp::Initialized: { return wUpApp.exec(); } case PrismUpdaterApp::Failed: @@ -40,5 +37,4 @@ int main(int argc, char* argv[]) default: return -1; } - }