2022-01-14 23:20:06 +00:00
|
|
|
/* Copyright 2013-2021 MultiMC & PolyMC Contributors
|
2015-10-01 23:12:53 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2022-01-14 23:20:06 +00:00
|
|
|
#include "PastePage.h"
|
|
|
|
#include "ui_PastePage.h"
|
2015-10-01 23:12:53 +01:00
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QStandardPaths>
|
2018-06-01 15:20:33 +01:00
|
|
|
#include <QTabBar>
|
2015-10-01 23:12:53 +01:00
|
|
|
|
|
|
|
#include "settings/SettingsObject.h"
|
|
|
|
#include "tools/BaseProfiler.h"
|
2021-11-20 15:22:22 +00:00
|
|
|
#include "Application.h"
|
2015-10-01 23:12:53 +01:00
|
|
|
|
2022-01-14 23:20:06 +00:00
|
|
|
PastePage::PastePage(QWidget *parent) :
|
2018-07-15 13:51:05 +01:00
|
|
|
QWidget(parent),
|
2022-01-14 23:20:06 +00:00
|
|
|
ui(new Ui::PastePage)
|
2015-10-01 23:12:53 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
ui->setupUi(this);
|
|
|
|
ui->tabWidget->tabBar()->hide();\
|
2022-01-14 23:20:06 +00:00
|
|
|
connect(ui->customAPIkeyEdit, &QLineEdit::textEdited, this, &PastePage::textEdited);
|
2018-07-15 13:51:05 +01:00
|
|
|
loadSettings();
|
2015-10-01 23:12:53 +01:00
|
|
|
}
|
|
|
|
|
2022-01-14 23:20:06 +00:00
|
|
|
PastePage::~PastePage()
|
2015-10-01 23:12:53 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
delete ui;
|
2015-10-01 23:12:53 +01:00
|
|
|
}
|
|
|
|
|
2022-01-14 23:20:06 +00:00
|
|
|
void PastePage::loadSettings()
|
2015-10-01 23:12:53 +01:00
|
|
|
{
|
2021-11-20 15:22:22 +00:00
|
|
|
auto s = APPLICATION->settings();
|
2022-01-14 23:30:02 +00:00
|
|
|
QString pastebin = s->get("PastebinURL");
|
|
|
|
int index = ui->urlChoices->findText(pastebin);
|
|
|
|
ui->urlChoices->setCurrentIndex(index);
|
2015-10-01 23:12:53 +01:00
|
|
|
}
|
|
|
|
|
2022-01-14 23:20:06 +00:00
|
|
|
void PastePage::applySettings()
|
2015-10-01 23:12:53 +01:00
|
|
|
{
|
2021-11-20 15:22:22 +00:00
|
|
|
auto s = APPLICATION->settings();
|
2015-10-01 23:12:53 +01:00
|
|
|
|
2018-07-15 13:51:05 +01:00
|
|
|
QString pasteKeyToUse;
|
|
|
|
if (ui->customButton->isChecked())
|
|
|
|
pasteKeyToUse = ui->customAPIkeyEdit->text();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pasteKeyToUse = "multimc";
|
|
|
|
}
|
|
|
|
s->set("PasteEEAPIKey", pasteKeyToUse);
|
2015-10-01 23:12:53 +01:00
|
|
|
}
|
|
|
|
|
2022-01-14 23:20:06 +00:00
|
|
|
bool PastePage::apply()
|
2015-10-01 23:12:53 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
applySettings();
|
|
|
|
return true;
|
2015-10-01 23:12:53 +01:00
|
|
|
}
|
|
|
|
|
2022-01-14 23:20:06 +00:00
|
|
|
void PastePage::textEdited(const QString& text)
|
2015-10-01 23:12:53 +01:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
ui->customButton->setChecked(true);
|
2015-10-01 23:12:53 +01:00
|
|
|
}
|