|
| 1 | +// SPDX-License-Identifier: GPL-3.0-only |
| 2 | +/* |
| 3 | + * Freesm Launcher - Minecraft Launcher |
| 4 | + * Copyright (C) 2026 so5iso4ka <so5iso4ka@icloud.com> |
| 5 | + * |
| 6 | + * This program is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation, version 3. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | + |
| 19 | +#include <QLabel> |
| 20 | +#include <QPushButton> |
| 21 | +#include <QVBoxLayout> |
| 22 | + |
| 23 | +#include "Application.h" |
| 24 | +#include "ui/GuiUtil.h" |
| 25 | + |
| 26 | +#include "FlameApiKeyWizardPage.h" |
| 27 | + |
| 28 | +FlameAPIKeyWizardPage::FlameAPIKeyWizardPage(QWidget* parent) : BaseWizardPage(parent) |
| 29 | +{ |
| 30 | + auto layout = new QVBoxLayout{ this }; |
| 31 | + m_titleLabel = new QLabel{ this }; |
| 32 | + m_descriptionLabel = new QLabel{ this }; |
| 33 | + m_descriptionLabel->setWordWrap(true); |
| 34 | + m_fetchButton = new QPushButton{ this }; |
| 35 | + |
| 36 | + connect(m_fetchButton, &QPushButton::clicked, this, [this] { |
| 37 | + const auto& apiKey = GuiUtil::fetchFlameKey(this); |
| 38 | + if (!apiKey.isEmpty()) { |
| 39 | + APPLICATION->settings()->set("FlameKeyOverride", apiKey); |
| 40 | + APPLICATION->updateCapabilities(); |
| 41 | + } |
| 42 | + }); |
| 43 | + |
| 44 | + layout->addWidget(m_titleLabel); |
| 45 | + layout->addWidget(m_descriptionLabel); |
| 46 | + layout->addWidget(m_fetchButton); |
| 47 | + |
| 48 | + setLayout(layout); |
| 49 | + |
| 50 | + FlameAPIKeyWizardPage::retranslate(); |
| 51 | +} |
| 52 | + |
| 53 | +void FlameAPIKeyWizardPage::initializePage() |
| 54 | +{ |
| 55 | + APPLICATION->settings()->set("FlameKeyShouldBeFetchedOnStartup", false); |
| 56 | +} |
| 57 | + |
| 58 | +void FlameAPIKeyWizardPage::retranslate() |
| 59 | +{ |
| 60 | + m_titleLabel->setText( |
| 61 | + tr(R"(<html><head/><body><p><span style="font-size:14pt; font-weight:600;">Fetch CurseForge API key</span></p></body></html>)")); |
| 62 | + m_descriptionLabel->setText( |
| 63 | + tr("Using the official CurseForge app's API key may break CurseForge's terms of service but should allow Freesm Launcher to " |
| 64 | + "download all mods in a modpack without you needing to download any of them manually. This can be done later in the settings.")); |
| 65 | + m_fetchButton->setText(tr("Fetch Official Launcher's Key")); |
| 66 | +} |
0 commit comments