mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-22 15:58:46 +00:00
Ignore invisible characters while checking if text have only emojis.
This commit is contained in:
parent
d5f7c9fde8
commit
0b01b07cde
2 changed files with 6 additions and 1 deletions
|
|
@ -696,6 +696,10 @@ bool Utils::codepointIsEmoji(uint code){
|
||||||
(code >= 0x1f000 && code <= 0x1faff) || code == 0x200d || code == 0xfe0f;
|
(code >= 0x1f000 && code <= 0x1faff) || code == 0x200d || code == 0xfe0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Utils::codepointIsVisible(uint code) {
|
||||||
|
return code > 0x00020;
|
||||||
|
}
|
||||||
|
|
||||||
QString Utils::encodeEmojiToQmlRichFormat(const QString &body){
|
QString Utils::encodeEmojiToQmlRichFormat(const QString &body){
|
||||||
QString fmtBody = "";
|
QString fmtBody = "";
|
||||||
QVector<uint> utf32_string = body.toUcs4();
|
QVector<uint> utf32_string = body.toUcs4();
|
||||||
|
|
@ -726,7 +730,7 @@ bool Utils::isOnlyEmojis(const QString& text){
|
||||||
if(text.isEmpty()) return false;
|
if(text.isEmpty()) return false;
|
||||||
QVector<uint> utf32_string = text.toUcs4();
|
QVector<uint> utf32_string = text.toUcs4();
|
||||||
for (auto &code : utf32_string)
|
for (auto &code : utf32_string)
|
||||||
if( !Utils::codepointIsEmoji(code))
|
if(codepointIsVisible(code) && !Utils::codepointIsEmoji(code))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ public:
|
||||||
Q_INVOKABLE static QPoint getCursorPosition();
|
Q_INVOKABLE static QPoint getCursorPosition();
|
||||||
Q_INVOKABLE static QString getFileChecksum(const QString& filePath);
|
Q_INVOKABLE static QString getFileChecksum(const QString& filePath);
|
||||||
static bool codepointIsEmoji(uint code);
|
static bool codepointIsEmoji(uint code);
|
||||||
|
static bool codepointIsVisible(uint code);
|
||||||
Q_INVOKABLE static bool isOnlyEmojis(const QString& text);
|
Q_INVOKABLE static bool isOnlyEmojis(const QString& text);
|
||||||
Q_INVOKABLE static QString encodeEmojiToQmlRichFormat(const QString &body);
|
Q_INVOKABLE static QString encodeEmojiToQmlRichFormat(const QString &body);
|
||||||
Q_INVOKABLE static QString encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options = QVariantMap());
|
Q_INVOKABLE static QString encodeTextToQmlRichFormat(const QString& text, const QVariantMap& options = QVariantMap());
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue