7#include <QGuiApplication>
10#include <QTextCharFormat>
12#ifdef QT_BUILD_WAYLANDCOMPOSITOR_LIB
13#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v2.h>
14#include <QtWaylandCompositor/private/qwayland-server-text-input-unstable-v4-wip.h>
16#include <QtWaylandClient/private/qwayland-text-input-unstable-v2.h>
17#include <QtWaylandClient/private/qwayland-text-input-unstable-v4-wip.h>
33 m_preeditStyles.
clear();
44 m_deleteBefore = beforeLength;
45 m_deleteAfter = afterLength;
53 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_NONE:
55 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_DEFAULT:
56 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_UNDERLINE:
57 format.setFontUnderline(
true);
61 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_ACTIVE:
62 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INACTIVE:
64 format.setFontUnderline(
true);
68 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_HIGHLIGHT:
69 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_SELECTION:
71 format.setFontUnderline(
true);
79 case ZWP_TEXT_INPUT_V2_PREEDIT_STYLE_INCORRECT:
80 format.setFontUnderline(
true);
92 m_preeditCursor =
index;
101 if (m_cursor != 0 || m_anchor != 0) {
107 const int absoluteOffset = absoluteCursor -
cursor;
114 indexFromWayland(surrounding, m_cursor, cursorAfterCommit) + absoluteOffset,
115 indexFromWayland(surrounding, m_anchor, cursorAfterCommit) + absoluteOffset,
120 event->setCommitString(
text, replacement.
first, replacement.second);
129 if (m_preeditCursor < 0) {
144 event->setCommitString(
QString(), replacement.
first, replacement.second);
149QPair<int, int> QWaylandInputMethodEventBuilder::replacementForDeleteSurrounding()
151 if (m_deleteBefore == 0 && m_deleteAfter == 0)
158 const int selectionStart =
qMin(
cursor, anchor);
159 const int selectionEnd =
qMax(
cursor, anchor);
161 const int deleteBefore = selectionStart -
indexFromWayland(surrounding, -m_deleteBefore, selectionStart);
162 const int deleteAfter =
indexFromWayland(surrounding, m_deleteAfter, selectionEnd) - selectionEnd;
169 uint32_t
hint = ZWP_TEXT_INPUT_V2_CONTENT_HINT_NONE;
170 uint32_t
purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_NORMAL;
173 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_HIDDEN_TEXT;
175 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_SENSITIVE_DATA;
177 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_AUTO_CAPITALIZATION;
182 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_UPPERCASE;
184 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_LOWERCASE;
186 hint |= (ZWP_TEXT_INPUT_V2_CONTENT_HINT_AUTO_COMPLETION
187 | ZWP_TEXT_INPUT_V2_CONTENT_HINT_AUTO_CORRECTION);
191 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_DATE;
193 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_DATETIME;
195 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_TIME;
198 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_LATIN;
200 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_MULTILINE;
202 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_DIGITS;
204 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_NUMBER;
206 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_UPPERCASE;
208 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_LOWERCASE;
210 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_PHONE;
212 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_EMAIL;
214 purpose = ZWP_TEXT_INPUT_V2_CONTENT_PURPOSE_URL;
216 hint |= ZWP_TEXT_INPUT_V2_CONTENT_HINT_LATIN;
223 uint32_t
hint = ZWP_TEXT_INPUT_V4_CONTENT_HINT_NONE;
224 uint32_t
purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_NORMAL;
227 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_HIDDEN_TEXT;
229 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_SENSITIVE_DATA;
231 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_AUTO_CAPITALIZATION;
236 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_UPPERCASE;
238 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_LOWERCASE;
240 hint |= (ZWP_TEXT_INPUT_V4_CONTENT_HINT_COMPLETION
241 | ZWP_TEXT_INPUT_V4_CONTENT_HINT_SPELLCHECK);
245 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_DATE;
247 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_DATETIME;
249 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_TIME;
251 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_LATIN;
253 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_MULTILINE;
255 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_DIGITS;
257 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_NUMBER;
259 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_UPPERCASE;
261 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_LOWERCASE;
263 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_PHONE;
265 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_EMAIL;
267 purpose = ZWP_TEXT_INPUT_V4_CONTENT_PURPOSE_URL;
269 hint |= ZWP_TEXT_INPUT_V4_CONTENT_HINT_LATIN;
300 for (
int i = 0;
i < 4;
i++) {
306 if (ch < 0x80 || ch > 0xbf)
316 for (
int i = 0;
i < 4;
i++) {
319 if (ch < 0x80 || ch > 0xbf)
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
QByteArray left(qsizetype len) const
Returns a byte array that contains the first len bytes of this byte array.
The QColor class provides colors based on RGB, HSV or CMYK values.
void push_back(parameter_type t)
void append(parameter_type t)
The QPalette class contains color groups for each widget state.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
qsizetype size() const
Returns the number of characters in this string.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
QString first(qsizetype n) const
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
QByteArray toUtf8() const &
qsizetype length() const
Returns the number of characters in this string.
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
Combined button and popup list for selecting options.
@ ImhFormattedNumbersOnly
@ ImhDialableCharactersOnly
std::pair< T1, T2 > QPair
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum format
static QWaylandInputMethodContentType convertV4(Qt::InputMethodHints hints)
static QWaylandInputMethodContentType convert(Qt::InputMethodHints hints)