Prevent user from entering incorrect characters in Live Notifications channels list (#3715)
Co-authored-by: Sidd <iProdigy@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "widgets/helper/RegExpItemDelegate.hpp"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
RegExpItemDelegate::RegExpItemDelegate(QObject *parent,
|
||||
QRegularExpression regexp)
|
||||
: QStyledItemDelegate(parent)
|
||||
, regexp_(regexp)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget *RegExpItemDelegate::createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
auto *editor = new QLineEdit(parent);
|
||||
editor->setValidator(
|
||||
new QRegularExpressionValidator(this->regexp_, editor));
|
||||
return editor;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user