Merge pull request #1494 from jdpatdiscord/develop
Have API key validators tolerate whitespace
This commit is contained in:
commit
1b52829e6c
@ -40,10 +40,8 @@
|
|||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QRegularExpression>
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QTabBar>
|
#include <QTabBar>
|
||||||
#include <QValidator>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "settings/SettingsObject.h"
|
#include "settings/SettingsObject.h"
|
||||||
@ -82,9 +80,9 @@ APIPage::APIPage(QWidget *parent) :
|
|||||||
connect(ui->pasteTypeComboBox, currentIndexChangedSignal, this, &APIPage::updateBaseURLPlaceholder);
|
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.
|
// This function needs to be called even when the ComboBox's index is still in its default state.
|
||||||
updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex());
|
updateBaseURLPlaceholder(ui->pasteTypeComboBox->currentIndex());
|
||||||
ui->baseURLEntry->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->baseURLEntry));
|
ui->baseURLEntry->setValidator(new TrimmedRegExValidator(validUrlRegExp, ui->baseURLEntry));
|
||||||
ui->msaClientID->setValidator(new QRegularExpressionValidator(validMSAClientID, ui->msaClientID));
|
ui->msaClientID->setValidator(new TrimmedRegExValidator(validMSAClientID, ui->msaClientID));
|
||||||
ui->flameKey->setValidator(new QRegularExpressionValidator(validFlameKey, ui->flameKey));
|
ui->flameKey->setValidator(new TrimmedRegExValidator(validFlameKey, ui->flameKey));
|
||||||
|
|
||||||
ui->metaURL->setPlaceholderText(BuildConfig.META_URL);
|
ui->metaURL->setPlaceholderText(BuildConfig.META_URL);
|
||||||
ui->userAgentLineEdit->setPlaceholderText(BuildConfig.USER_AGENT);
|
ui->userAgentLineEdit->setPlaceholderText(BuildConfig.USER_AGENT);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
|
||||||
* Copyright (c) 2022 Lenny McLennington <lenny@sneed.church>
|
* Copyright (c) 2022 Lenny McLennington <lenny@sneed.church>
|
||||||
|
* Copyright (c) 2022 jdp_ (https://github.com/jdpatdiscord)
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -38,14 +39,29 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QValidator>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QRegularExpressionValidator>
|
||||||
|
|
||||||
#include "ui/pages/BasePage.h"
|
#include "ui/pages/BasePage.h"
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class APIPage;
|
class APIPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TrimmedRegExValidator : public QRegularExpressionValidator
|
||||||
|
{
|
||||||
|
using QRegularExpressionValidator::QRegularExpressionValidator;
|
||||||
|
|
||||||
|
virtual QValidator::State validate(QString& input, int& npos) const override
|
||||||
|
{
|
||||||
|
input = input.trimmed();
|
||||||
|
return QRegularExpressionValidator::validate(input, npos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class APIPage : public QWidget, public BasePage
|
class APIPage : public QWidget, public BasePage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Loading…
Reference in New Issue
Block a user