Change paste settings and add copyright headers
- There's now a notice reminding people to change the base URL if they had a custom base URL and change the paste type (that was something I personally had problems with when I was testing, so a reminder was helpful for me). - Broke down some of the long lines on APIPage.cpp to be more readable. - Added copyright headers where they were missing. - Changed the paste service display names to the names they are more commonly known by. - Changed the default hastebin base URL to https://hst.sh due to the acquisition of https://hastebin.com by Toptal.
This commit is contained in:
parent
35f71f5793
commit
caf6d02728
@ -2,6 +2,7 @@
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2022 Lenny McLennington <lenny@sneed.church>
|
||||
*
|
||||
* 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
|
||||
@ -672,7 +673,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
|
||||
m_settings->registerSetting("UpdateDialogGeometry", "");
|
||||
|
||||
// This code feels so stupid is there a less stupid way of doing this?
|
||||
// HACK: This code feels so stupid is there a less stupid way of doing this?
|
||||
{
|
||||
m_settings->registerSetting("PastebinURL", "");
|
||||
QString pastebinURL = m_settings->get("PastebinURL").toString();
|
||||
@ -694,7 +695,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
}
|
||||
|
||||
bool ok;
|
||||
unsigned int pasteType = m_settings->get("PastebinType").toUInt(&ok);
|
||||
int pasteType = m_settings->get("PastebinType").toInt(&ok);
|
||||
// If PastebinType is invalid then reset the related settings.
|
||||
if (!ok || !(PasteUpload::PasteType::First <= pasteType && pasteType <= PasteUpload::PasteType::Last))
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Lenny McLennington <lenny@sneed.church>
|
||||
* Copyright (C) 2022 Swirl <swurl@swurl.xyz>
|
||||
*
|
||||
* 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
|
||||
@ -43,10 +45,10 @@
|
||||
#include <QFile>
|
||||
|
||||
std::array<PasteUpload::PasteTypeInfo, 4> PasteUpload::PasteTypes = {
|
||||
{{"0x0", "https://0x0.st", ""},
|
||||
{"hastebin", "https://hastebin.com", "/documents"},
|
||||
{"paste (paste.gg)", "https://paste.gg", "/api/v1/pastes"},
|
||||
{"mclogs", "https://api.mclo.gs", "/1/log"}}};
|
||||
{{"0x0.st", "https://0x0.st", ""},
|
||||
{"hastebin", "https://hst.sh", "/documents"},
|
||||
{"paste.gg", "https://paste.gg", "/api/v1/pastes"},
|
||||
{"mclo.gs", "https://api.mclo.gs", "/1/log"}}};
|
||||
|
||||
PasteUpload::PasteUpload(QWidget *window, QString text, QString baseUrl, PasteType pasteType) : m_window(window), m_baseUrl(baseUrl), m_pasteType(pasteType), m_text(text.toUtf8())
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Lenny McLennington <lenny@sneed.church>
|
||||
*
|
||||
* 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
|
||||
@ -45,7 +46,7 @@ class PasteUpload : public Task
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum PasteType : unsigned int {
|
||||
enum PasteType : int {
|
||||
// 0x0.st
|
||||
NullPointer,
|
||||
// hastebin.com
|
||||
|
@ -1,3 +1,38 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Lenny McLennington <lenny@sneed.church>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This file incorporates work covered by the following copyright and
|
||||
* permission notice:
|
||||
*
|
||||
* Copyright 2013-2021 MultiMC Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "GuiUtil.h"
|
||||
|
||||
#include <QClipboard>
|
||||
@ -16,7 +51,7 @@
|
||||
QString GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
|
||||
{
|
||||
ProgressDialog dialog(parentWidget);
|
||||
auto pasteTypeSetting = static_cast<PasteUpload::PasteType>(APPLICATION->settings()->get("PastebinType").toUInt());
|
||||
auto pasteTypeSetting = static_cast<PasteUpload::PasteType>(APPLICATION->settings()->get("PastebinType").toInt());
|
||||
auto pasteCustomAPIBaseSetting = APPLICATION->settings()->get("PastebinCustomAPIBase").toString();
|
||||
std::unique_ptr<PasteUpload> paste(new PasteUpload(parentWidget, text, pasteCustomAPIBaseSetting, pasteTypeSetting));
|
||||
|
||||
|
@ -53,8 +53,8 @@ APIPage::APIPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::APIPage)
|
||||
{
|
||||
// this is here so you can reorder the entries in the combobox without messing stuff up
|
||||
unsigned int comboBoxEntries[] = {
|
||||
// This is here so you can reorder the entries in the combobox without messing stuff up
|
||||
int comboBoxEntries[] = {
|
||||
PasteUpload::PasteType::Mclogs,
|
||||
PasteUpload::PasteType::NullPointer,
|
||||
PasteUpload::PasteType::PasteGG,
|
||||
@ -69,13 +69,18 @@ APIPage::APIPage(QWidget *parent) :
|
||||
ui->pasteTypeComboBox->addItem(PasteUpload::PasteTypes.at(pasteType).name, pasteType);
|
||||
}
|
||||
|
||||
connect(ui->pasteTypeComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &APIPage::updateBaseURLPlaceholder);
|
||||
void (QComboBox::*currentIndexChangedSignal)(int) (&QComboBox::currentIndexChanged);
|
||||
connect(ui->pasteTypeComboBox, currentIndexChangedSignal, this, &APIPage::updateBaseURLPlaceholder);
|
||||
// This function needs to be called even when the ComboBox's index is still in its default state.
|
||||
updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex());
|
||||
ui->baseURLEntry->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->baseURLEntry));
|
||||
ui->tabWidget->tabBar()->hide();
|
||||
|
||||
loadSettings();
|
||||
|
||||
resetBaseURLNote();
|
||||
connect(ui->pasteTypeComboBox, currentIndexChangedSignal, this, &APIPage::updateBaseURLNote);
|
||||
connect(ui->baseURLEntry, &QLineEdit::textEdited, this, &APIPage::resetBaseURLNote);
|
||||
}
|
||||
|
||||
APIPage::~APIPage()
|
||||
@ -83,16 +88,36 @@ APIPage::~APIPage()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void APIPage::resetBaseURLNote()
|
||||
{
|
||||
ui->baseURLNote->hide();
|
||||
baseURLPasteType = ui->pasteTypeComboBox->currentIndex();
|
||||
}
|
||||
|
||||
void APIPage::updateBaseURLNote(int index)
|
||||
{
|
||||
if (baseURLPasteType == index)
|
||||
{
|
||||
ui->baseURLNote->hide();
|
||||
}
|
||||
else if (!ui->baseURLEntry->text().isEmpty())
|
||||
{
|
||||
ui->baseURLNote->show();
|
||||
}
|
||||
}
|
||||
|
||||
void APIPage::updateBaseURLPlaceholder(int index)
|
||||
{
|
||||
ui->baseURLEntry->setPlaceholderText(PasteUpload::PasteTypes.at(ui->pasteTypeComboBox->itemData(index).toUInt()).defaultBase);
|
||||
int pasteType = ui->pasteTypeComboBox->itemData(index).toInt();
|
||||
QString pasteDefaultURL = PasteUpload::PasteTypes.at(pasteType).defaultBase;
|
||||
ui->baseURLEntry->setPlaceholderText(pasteDefaultURL);
|
||||
}
|
||||
|
||||
void APIPage::loadSettings()
|
||||
{
|
||||
auto s = APPLICATION->settings();
|
||||
|
||||
unsigned int pasteType = s->get("PastebinType").toUInt();
|
||||
int pasteType = s->get("PastebinType").toInt();
|
||||
QString pastebinURL = s->get("PastebinCustomAPIBase").toString();
|
||||
|
||||
ui->baseURLEntry->setText(pastebinURL);
|
||||
@ -115,7 +140,7 @@ void APIPage::applySettings()
|
||||
{
|
||||
auto s = APPLICATION->settings();
|
||||
|
||||
s->set("PastebinType", ui->pasteTypeComboBox->currentData().toUInt());
|
||||
s->set("PastebinType", ui->pasteTypeComboBox->currentData().toInt());
|
||||
s->set("PastebinCustomAPIBase", ui->baseURLEntry->text());
|
||||
|
||||
QString msaClientID = ui->msaClientID->text();
|
||||
|
@ -3,6 +3,7 @@
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
* Copyright (c) 2022 Lenny McLennington <lenny@sneed.church>
|
||||
*
|
||||
* 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
|
||||
@ -73,6 +74,9 @@ public:
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
int baseURLPasteType;
|
||||
void resetBaseURLNote();
|
||||
void updateBaseURLNote(int index);
|
||||
void updateBaseURLPlaceholder(int index);
|
||||
void loadSettings();
|
||||
void applySettings();
|
||||
|
@ -61,6 +61,19 @@
|
||||
<property name="placeholderText">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="baseURLNote">
|
||||
<property name="text">
|
||||
<string>Note: you probably want to change or clear the Base URL after changing the paste service type.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user