Fix: ignore whitespaces pasted in EmotePopup search (#3730)
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "widgets/helper/RegExpItemDelegate.hpp"
|
||||
|
||||
#include "widgets/helper/TrimRegExpValidator.hpp"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
namespace chatterino {
|
||||
@@ -16,8 +18,7 @@ QWidget *RegExpItemDelegate::createEditor(QWidget *parent,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
auto *editor = new QLineEdit(parent);
|
||||
editor->setValidator(
|
||||
new QRegularExpressionValidator(this->regexp_, editor));
|
||||
editor->setValidator(new TrimRegExpValidator(this->regexp_, editor));
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "widgets/helper/TrimRegExpValidator.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
TrimRegExpValidator::TrimRegExpValidator(const QRegularExpression &re,
|
||||
QObject *parent)
|
||||
: QRegularExpressionValidator(re, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QValidator::State TrimRegExpValidator::validate(QString &input, int &pos) const
|
||||
{
|
||||
input = input.trimmed();
|
||||
return QRegularExpressionValidator::validate(input, pos);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class TrimRegExpValidator : public QRegularExpressionValidator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrimRegExpValidator(const QRegularExpression &re,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
QValidator::State validate(QString &input, int &pos) const override;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user