Make cleaning of user input optional

This commit is contained in:
WarmUpTill 2021-06-18 21:42:36 +02:00 committed by WarmUpTill
parent 80334088d0
commit 92711c5798
2 changed files with 6 additions and 3 deletions

View File

@ -16,7 +16,7 @@ public:
static bool AskForName(QWidget *parent, const QString &title,
const QString &text, std::string &userTextInput,
const QString &placeHolder = QString(""),
int maxSize = 170);
int maxSize = 170, bool clean = true);
private:
QLabel *label;

View File

@ -43,7 +43,8 @@ static void CleanWhitespace(std::string &str)
bool AdvSSNameDialog::AskForName(QWidget *parent, const QString &title,
const QString &text,
std::string &userTextInput,
const QString &placeHolder, int maxSize)
const QString &placeHolder, int maxSize,
bool clean)
{
if (maxSize <= 0 || maxSize > 32767) {
maxSize = 170;
@ -61,6 +62,8 @@ bool AdvSSNameDialog::AskForName(QWidget *parent, const QString &title,
return false;
}
userTextInput = dialog.userText->text().toUtf8().constData();
CleanWhitespace(userTextInput);
if (clean) {
CleanWhitespace(userTextInput);
}
return true;
}