| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qinputmethod.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | QInputMethod::QInputMethod() | - | ||||||||||||||||||
| 9 | : QObject(*new QInputMethodPrivate) | - | ||||||||||||||||||
| 10 | { | - | ||||||||||||||||||
| 11 | } | - | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | QInputMethod::~QInputMethod() | - | ||||||||||||||||||
| 17 | { | - | ||||||||||||||||||
| 18 | } | - | ||||||||||||||||||
| 19 | QTransform QInputMethod::inputItemTransform() const | - | ||||||||||||||||||
| 20 | { | - | ||||||||||||||||||
| 21 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 22 | return d->inputItemTransform; | - | ||||||||||||||||||
| 23 | } | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | void QInputMethod::setInputItemTransform(const QTransform &transform) | - | ||||||||||||||||||
| 31 | { | - | ||||||||||||||||||
| 32 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 33 | if (d->inputItemTransform == transform
| 0 | ||||||||||||||||||
| 34 | return; never executed: return; | 0 | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | d->inputItemTransform = transform; | - | ||||||||||||||||||
| 37 | cursorRectangleChanged(); | - | ||||||||||||||||||
| 38 | anchorRectangleChanged(); | - | ||||||||||||||||||
| 39 | } never executed: end of block | 0 | ||||||||||||||||||
| 40 | QRectF QInputMethod::inputItemRectangle() const | - | ||||||||||||||||||
| 41 | { | - | ||||||||||||||||||
| 42 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 43 | return d->inputRectangle; | - | ||||||||||||||||||
| 44 | } | - | ||||||||||||||||||
| 45 | void QInputMethod::setInputItemRectangle(const QRectF &rect) | - | ||||||||||||||||||
| 46 | { | - | ||||||||||||||||||
| 47 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 48 | d->inputRectangle = rect; | - | ||||||||||||||||||
| 49 | } | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | static QRectF QInputMethodinputMethodQueryRectangle_helper(Qt::cursorRectangle()InputMethodQuery imquery, const QTransform &xform) | - | ||||||||||||||||||
| 52 | { | - | ||||||||||||||||||
| 53 | const QInputMethodPrivate * const d = d_func();QRectF r; | - | ||||||||||||||||||
| 54 | if (QObject *focusObject = (static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusObject();
| 0 | ||||||||||||||||||
if (!
| ||||||||||||||||||||
return QRectF();
| ||||||||||||||||||||
| 55 | QInputMethodQueryEvent query(Qt::ImCursorRectangleimquery); | - | ||||||||||||||||||
| 56 | QGuiApplication::sendEvent(focusObject, &query); | - | ||||||||||||||||||
| 57 | QRectFr = query.value(Qt::ImCursorRectangleimquery).toRectF(); | - | ||||||||||||||||||
| 58 | if (!(r.isValid()
| 0 | ||||||||||||||||||
| 59 | r = xform.mapRect(r); never executed: r = xform.mapRect(r); | 0 | ||||||||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||||||||
| 61 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 62 | } | - | ||||||||||||||||||
| 63 | QRectF QInputMethod::cursorRectangle() const | - | ||||||||||||||||||
| 64 | { | - | ||||||||||||||||||
| 65 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 66 | return never executed: inputMethodQueryRectangle_helper(Qt::ImCursorRectangle, d->inputItemTransform.mapRect);return inputMethodQueryRectangle_helper(Qt::ImCursorRectangle, d->inputItemTransform);never executed: return inputMethodQueryRectangle_helper(Qt::ImCursorRectangle, d->inputItemTransform); | 0 | ||||||||||||||||||
| 67 | } | - | ||||||||||||||||||
| 68 | QRectF QInputMethod::anchorRectangle() const | - | ||||||||||||||||||
| 69 | { | - | ||||||||||||||||||
| 70 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 71 | return never executed: inputMethodQueryRectangle_helperreturn inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform);never executed: return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform);never executed: (rQt::ImAnchorRectangle, d->inputItemTransform);return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform);never executed: return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform); | 0 | ||||||||||||||||||
| 72 | } | - | ||||||||||||||||||
| 73 | QRectF QInputMethod::keyboardRectangle() const | - | ||||||||||||||||||
| 74 | { | - | ||||||||||||||||||
| 75 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 76 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 77 | if (ic) | - | ||||||||||||||||||
| 78 | return ic->keyboardRect(); | - | ||||||||||||||||||
| 79 | return QRectF(); | - | ||||||||||||||||||
| 80 | } | - | ||||||||||||||||||
| 81 | QRectF QInputMethod::inputItemClipRectangle() const | - | ||||||||||||||||||
| 82 | { | - | ||||||||||||||||||
| 83 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 84 | return never executed: return inputMethodQueryRectangle_helper(Qt::ImInputItemClipRectangle, d->inputItemTransform);never executed: inputMethodQueryRectangle_helper(Qt::ImInputItemClipRectangle, d->inputItemTransform);return inputMethodQueryRectangle_helper(Qt::ImInputItemClipRectangle, d->inputItemTransform);never executed: return inputMethodQueryRectangle_helper(Qt::ImInputItemClipRectangle, d->inputItemTransform); | 0 | ||||||||||||||||||
| 85 | } | - | ||||||||||||||||||
| 86 | void QInputMethod::show() | - | ||||||||||||||||||
| 87 | { | - | ||||||||||||||||||
| 88 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 89 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 90 | if (ic) | - | ||||||||||||||||||
| 91 | ic->showInputPanel(); | - | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | void QInputMethod::hide() | - | ||||||||||||||||||
| 94 | { | - | ||||||||||||||||||
| 95 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 96 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 97 | if (ic) | - | ||||||||||||||||||
| 98 | ic->hideInputPanel(); | - | ||||||||||||||||||
| 99 | } | - | ||||||||||||||||||
| 100 | bool QInputMethod::isVisible() const | - | ||||||||||||||||||
| 101 | { | - | ||||||||||||||||||
| 102 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 103 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 104 | if (ic) | - | ||||||||||||||||||
| 105 | return ic->isInputPanelVisible(); | - | ||||||||||||||||||
| 106 | return false; | - | ||||||||||||||||||
| 107 | } | - | ||||||||||||||||||
| 108 | void QInputMethod::setVisible(bool visible) | - | ||||||||||||||||||
| 109 | { | - | ||||||||||||||||||
| 110 | visible ? show() : hide(); | - | ||||||||||||||||||
| 111 | } | - | ||||||||||||||||||
| 112 | bool QInputMethod::isAnimating() const | - | ||||||||||||||||||
| 113 | { | - | ||||||||||||||||||
| 114 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 115 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 116 | if (ic) | - | ||||||||||||||||||
| 117 | return ic->isAnimating(); | - | ||||||||||||||||||
| 118 | return false; | - | ||||||||||||||||||
| 119 | } | - | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | QLocale QInputMethod::locale() const | - | ||||||||||||||||||
| 126 | { | - | ||||||||||||||||||
| 127 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 128 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 129 | if (ic) | - | ||||||||||||||||||
| 130 | return ic->locale(); | - | ||||||||||||||||||
| 131 | return QLocale::c(); | - | ||||||||||||||||||
| 132 | } | - | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | Qt::LayoutDirection QInputMethod::inputDirection() const | - | ||||||||||||||||||
| 139 | { | - | ||||||||||||||||||
| 140 | const QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 141 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 142 | if (ic) | - | ||||||||||||||||||
| 143 | return ic->inputDirection(); | - | ||||||||||||||||||
| 144 | return Qt::LeftToRight; | - | ||||||||||||||||||
| 145 | } | - | ||||||||||||||||||
| 146 | void QInputMethod::update(Qt::InputMethodQueries queries) | - | ||||||||||||||||||
| 147 | { | - | ||||||||||||||||||
| 148 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | if (queries & Qt::ImEnabled
| 0 | ||||||||||||||||||
| 151 | QObject *focus = (static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusObject(); | - | ||||||||||||||||||
| 152 | bool enabled = d->objectAcceptsInputMethod(focus); | - | ||||||||||||||||||
| 153 | QPlatformInputContextPrivate::setInputMethodAccepted(enabled); | - | ||||||||||||||||||
| 154 | } never executed: end of block | 0 | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 157 | if (ic
| 0 | ||||||||||||||||||
| 158 | ic->update(queries); never executed: ic->update(queries); | 0 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | if (queries & Qt::ImCursorRectangle
| 0 | ||||||||||||||||||
| 161 | cursorRectangleChanged(); never executed: cursorRectangleChanged(); | 0 | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | if (queries & (Qt::ImAnchorRectangle)
| 0 | ||||||||||||||||||
| 164 | anchorRectangleChanged(); never executed: anchorRectangleChanged(); | 0 | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | if (queries & (Qt::ImInputItemClipRectangle)
| 0 | ||||||||||||||||||
| 167 | inputItemClipRectangleChanged never executed: inputItemClipRectangleChanged();never executed: ();inputItemClipRectangleChanged();never executed: inputItemClipRectangleChanged(); | 0 | ||||||||||||||||||
| 168 | } never executed: end of block | 0 | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | void QInputMethod::reset() | - | ||||||||||||||||||
| 177 | { | - | ||||||||||||||||||
| 178 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 179 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 180 | if (ic) | - | ||||||||||||||||||
| 181 | ic->reset(); | - | ||||||||||||||||||
| 182 | } | - | ||||||||||||||||||
| 183 | void QInputMethod::commit() | - | ||||||||||||||||||
| 184 | { | - | ||||||||||||||||||
| 185 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 186 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 187 | if (ic) | - | ||||||||||||||||||
| 188 | ic->commit(); | - | ||||||||||||||||||
| 189 | } | - | ||||||||||||||||||
| 190 | void QInputMethod::invokeAction(Action a, int cursorPosition) | - | ||||||||||||||||||
| 191 | { | - | ||||||||||||||||||
| 192 | QInputMethodPrivate * const d = d_func(); | - | ||||||||||||||||||
| 193 | QPlatformInputContext *ic = d->platformInputContext(); | - | ||||||||||||||||||
| 194 | if (ic) | - | ||||||||||||||||||
| 195 | ic->invokeAction(a, cursorPosition); | - | ||||||||||||||||||
| 196 | } | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | bool QInputMethodPrivate::objectAcceptsInputMethod(QObject *object) | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | bool enabled = false; | - | ||||||||||||||||||
| 201 | if (object) { | - | ||||||||||||||||||
| 202 | QInputMethodQueryEvent query(Qt::ImEnabled); | - | ||||||||||||||||||
| 203 | QGuiApplication::sendEvent(object, &query); | - | ||||||||||||||||||
| 204 | enabled = query.value(Qt::ImEnabled).toBool(); | - | ||||||||||||||||||
| 205 | } | - | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | return enabled; | - | ||||||||||||||||||
| 208 | } | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | QVariant QInputMethod::queryFocusObject(Qt::InputMethodQuery query, QVariant argument) | - | ||||||||||||||||||
| 214 | { | - | ||||||||||||||||||
| 215 | QVariant retval; | - | ||||||||||||||||||
| 216 | QObject *focusObject = (static_cast<QGuiApplication *>(QCoreApplication::instance()))->focusObject(); | - | ||||||||||||||||||
| 217 | if (!focusObject) | - | ||||||||||||||||||
| 218 | return retval; | - | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | bool newMethodWorks = QMetaObject::invokeMethod(focusObject, "inputMethodQuery", | - | ||||||||||||||||||
| 221 | Qt::DirectConnection, | - | ||||||||||||||||||
| 222 | QReturnArgument<QVariant >("QVariant", retval), | - | ||||||||||||||||||
| 223 | QArgument<Qt::InputMethodQuery >("Qt::InputMethodQuery", query), | - | ||||||||||||||||||
| 224 | QArgument<QVariant >("QVariant", argument)); | - | ||||||||||||||||||
| 225 | if (newMethodWorks) | - | ||||||||||||||||||
| 226 | return retval; | - | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | QInputMethodQueryEvent queryEvent(query); | - | ||||||||||||||||||
| 229 | QCoreApplication::sendEvent(focusObject, &queryEvent); | - | ||||||||||||||||||
| 230 | return queryEvent.value(query); | - | ||||||||||||||||||
| 231 | } | - | ||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |