| 1 | // Copyright 2020 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/QtUtils/UTF8CodePointCountValidator.h" |
| 5 | |
| 6 | #include "Common/StringUtil.h" |
| 7 | |
| 8 | UTF8CodePointCountValidator::UTF8CodePointCountValidator(std::size_t max_count, QObject* parent) |
| 9 | : QValidator(parent), m_max_count(max_count) |
| 10 | { |
| 11 | } |
| 12 | |
| 13 | QValidator::State UTF8CodePointCountValidator::validate(QString& input, int& pos) const |
| 14 | { |
| 15 | if (StringUTF8CodePointCount(input.toStdString()) > m_max_count) |
| 16 | return QValidator::Invalid; |
| 17 | |
| 18 | return QValidator::Acceptable; |
| 19 | } |