mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
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:
parent
addcbb10f9
commit
3bf1756579
7 changed files with 46 additions and 6 deletions
|
@ -12,7 +12,7 @@
|
||||||
- Minor: Sorted usernames in /vips message to be case-insensitive. (#3696)
|
- 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: 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: 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)
|
- 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 for usernames containing uppercase characters. (#3646)
|
||||||
- Bugfix: Fixed live notifications not getting updated for closed streams going offline. (#3678)
|
- Bugfix: Fixed live notifications not getting updated for closed streams going offline. (#3678)
|
||||||
|
|
|
@ -306,6 +306,7 @@ SOURCES += \
|
||||||
src/widgets/helper/NotebookTab.cpp \
|
src/widgets/helper/NotebookTab.cpp \
|
||||||
src/widgets/helper/QColorPicker.cpp \
|
src/widgets/helper/QColorPicker.cpp \
|
||||||
src/widgets/helper/RegExpItemDelegate.cpp \
|
src/widgets/helper/RegExpItemDelegate.cpp \
|
||||||
|
src/widgets/helper/TrimRegExpValidator.cpp \
|
||||||
src/widgets/helper/ResizingTextEdit.cpp \
|
src/widgets/helper/ResizingTextEdit.cpp \
|
||||||
src/widgets/helper/ScrollbarHighlight.cpp \
|
src/widgets/helper/ScrollbarHighlight.cpp \
|
||||||
src/widgets/helper/SearchPopup.cpp \
|
src/widgets/helper/SearchPopup.cpp \
|
||||||
|
@ -590,6 +591,7 @@ HEADERS += \
|
||||||
src/widgets/helper/NotebookTab.hpp \
|
src/widgets/helper/NotebookTab.hpp \
|
||||||
src/widgets/helper/QColorPicker.hpp \
|
src/widgets/helper/QColorPicker.hpp \
|
||||||
src/widgets/helper/RegExpItemDelegate.hpp \
|
src/widgets/helper/RegExpItemDelegate.hpp \
|
||||||
|
src/widgets/helper/TrimRegExpValidator.hpp \
|
||||||
src/widgets/helper/ResizingTextEdit.hpp \
|
src/widgets/helper/ResizingTextEdit.hpp \
|
||||||
src/widgets/helper/ScrollbarHighlight.hpp \
|
src/widgets/helper/ScrollbarHighlight.hpp \
|
||||||
src/widgets/helper/SearchPopup.hpp \
|
src/widgets/helper/SearchPopup.hpp \
|
||||||
|
|
|
@ -422,6 +422,8 @@ set(SOURCE_FILES
|
||||||
widgets/helper/QColorPicker.hpp
|
widgets/helper/QColorPicker.hpp
|
||||||
widgets/helper/RegExpItemDelegate.cpp
|
widgets/helper/RegExpItemDelegate.cpp
|
||||||
widgets/helper/RegExpItemDelegate.hpp
|
widgets/helper/RegExpItemDelegate.hpp
|
||||||
|
widgets/helper/TrimRegExpValidator.cpp
|
||||||
|
widgets/helper/TrimRegExpValidator.hpp
|
||||||
widgets/helper/ResizingTextEdit.cpp
|
widgets/helper/ResizingTextEdit.cpp
|
||||||
widgets/helper/ResizingTextEdit.hpp
|
widgets/helper/ResizingTextEdit.hpp
|
||||||
widgets/helper/ScrollbarHighlight.cpp
|
widgets/helper/ScrollbarHighlight.cpp
|
||||||
|
|
|
@ -15,11 +15,11 @@
|
||||||
#include "widgets/Notebook.hpp"
|
#include "widgets/Notebook.hpp"
|
||||||
#include "widgets/Scrollbar.hpp"
|
#include "widgets/Scrollbar.hpp"
|
||||||
#include "widgets/helper/ChannelView.hpp"
|
#include "widgets/helper/ChannelView.hpp"
|
||||||
|
#include "widgets/helper/TrimRegExpValidator.hpp"
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QRegularExpressionValidator>
|
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -166,7 +166,6 @@ EmotePopup::EmotePopup(QWidget *parent)
|
||||||
|
|
||||||
QRegularExpression searchRegex("\\S*");
|
QRegularExpression searchRegex("\\S*");
|
||||||
searchRegex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
searchRegex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||||
QValidator *searchValidator = new QRegularExpressionValidator(searchRegex);
|
|
||||||
|
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
|
@ -177,7 +176,7 @@ EmotePopup::EmotePopup(QWidget *parent)
|
||||||
|
|
||||||
this->search_ = new QLineEdit();
|
this->search_ = new QLineEdit();
|
||||||
this->search_->setPlaceholderText("Search all emotes...");
|
this->search_->setPlaceholderText("Search all emotes...");
|
||||||
this->search_->setValidator(searchValidator);
|
this->search_->setValidator(new TrimRegExpValidator(searchRegex));
|
||||||
this->search_->setClearButtonEnabled(true);
|
this->search_->setClearButtonEnabled(true);
|
||||||
this->search_->findChild<QAbstractButton *>()->setIcon(
|
this->search_->findChild<QAbstractButton *>()->setIcon(
|
||||||
QPixmap(":/buttons/clearSearch.png"));
|
QPixmap(":/buttons/clearSearch.png"));
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "widgets/helper/RegExpItemDelegate.hpp"
|
#include "widgets/helper/RegExpItemDelegate.hpp"
|
||||||
|
|
||||||
|
#include "widgets/helper/TrimRegExpValidator.hpp"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
@ -16,8 +18,7 @@ QWidget *RegExpItemDelegate::createEditor(QWidget *parent,
|
||||||
const QModelIndex &index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
auto *editor = new QLineEdit(parent);
|
auto *editor = new QLineEdit(parent);
|
||||||
editor->setValidator(
|
editor->setValidator(new TrimRegExpValidator(this->regexp_, editor));
|
||||||
new QRegularExpressionValidator(this->regexp_, editor));
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
src/widgets/helper/TrimRegExpValidator.cpp
Normal file
17
src/widgets/helper/TrimRegExpValidator.cpp
Normal 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
|
19
src/widgets/helper/TrimRegExpValidator.hpp
Normal file
19
src/widgets/helper/TrimRegExpValidator.hpp
Normal 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
|
Loading…
Reference in a new issue