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:
kornes 2022-05-16 09:42:17 +00:00 committed by GitHub
parent addcbb10f9
commit 3bf1756579
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 6 deletions

View file

@ -12,7 +12,7 @@
- Minor: Sorted usernames in /vips message to be case-insensitive. (#3696)
- Minor: Added option to open a user's chat in a new tab from the usercard profile picture context menu. (#3625)
- Minor: Fixed tag parsing for consecutive escaped characters. (#3711)
- Minor: Prevent user from entering incorrect characters in Live Notifications channels list. (#3715)
- Minor: Prevent user from entering incorrect characters in Live Notifications channels list. (#3715, #3730)
- Minor: Fixed automod caught message notice appearing twice for mods. (#3717)
- Bugfix: Fixed live notifications for usernames containing uppercase characters. (#3646)
- Bugfix: Fixed live notifications not getting updated for closed streams going offline. (#3678)

View file

@ -306,6 +306,7 @@ SOURCES += \
src/widgets/helper/NotebookTab.cpp \
src/widgets/helper/QColorPicker.cpp \
src/widgets/helper/RegExpItemDelegate.cpp \
src/widgets/helper/TrimRegExpValidator.cpp \
src/widgets/helper/ResizingTextEdit.cpp \
src/widgets/helper/ScrollbarHighlight.cpp \
src/widgets/helper/SearchPopup.cpp \
@ -590,6 +591,7 @@ HEADERS += \
src/widgets/helper/NotebookTab.hpp \
src/widgets/helper/QColorPicker.hpp \
src/widgets/helper/RegExpItemDelegate.hpp \
src/widgets/helper/TrimRegExpValidator.hpp \
src/widgets/helper/ResizingTextEdit.hpp \
src/widgets/helper/ScrollbarHighlight.hpp \
src/widgets/helper/SearchPopup.hpp \

View file

@ -422,6 +422,8 @@ set(SOURCE_FILES
widgets/helper/QColorPicker.hpp
widgets/helper/RegExpItemDelegate.cpp
widgets/helper/RegExpItemDelegate.hpp
widgets/helper/TrimRegExpValidator.cpp
widgets/helper/TrimRegExpValidator.hpp
widgets/helper/ResizingTextEdit.cpp
widgets/helper/ResizingTextEdit.hpp
widgets/helper/ScrollbarHighlight.cpp

View file

@ -15,11 +15,11 @@
#include "widgets/Notebook.hpp"
#include "widgets/Scrollbar.hpp"
#include "widgets/helper/ChannelView.hpp"
#include "widgets/helper/TrimRegExpValidator.hpp"
#include <QAbstractButton>
#include <QHBoxLayout>
#include <QRegularExpression>
#include <QRegularExpressionValidator>
#include <QTabWidget>
namespace chatterino {
@ -166,7 +166,6 @@ EmotePopup::EmotePopup(QWidget *parent)
QRegularExpression searchRegex("\\S*");
searchRegex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
QValidator *searchValidator = new QRegularExpressionValidator(searchRegex);
layout->setMargin(0);
layout->setSpacing(0);
@ -177,7 +176,7 @@ EmotePopup::EmotePopup(QWidget *parent)
this->search_ = new QLineEdit();
this->search_->setPlaceholderText("Search all emotes...");
this->search_->setValidator(searchValidator);
this->search_->setValidator(new TrimRegExpValidator(searchRegex));
this->search_->setClearButtonEnabled(true);
this->search_->findChild<QAbstractButton *>()->setIcon(
QPixmap(":/buttons/clearSearch.png"));

View file

@ -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;
}

View file

@ -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

View file

@ -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