QStringList QQmlGuiProvider::fontFamilies() { return QStringList(); }
bool QQmlGuiProvider::openUrlExternally(QUrl &) { return false; }
+#ifndef QT_NO_IM
QObject *QQmlGuiProvider::inputMethod()
{
// We don't have any input method code by default
o->setObjectName(QString::fromLatin1("No inputMethod available"));
return o;
}
+#endif
static QQmlGuiProvider *guiProvider = 0;
public:
virtual ~QQmlGuiProvider();
virtual QObject *application(QObject *parent);
+#ifndef QT_NO_IM
virtual QObject *inputMethod();
+#endif
virtual QStringList fontFamilies();
virtual bool openUrlExternally(QUrl &);
};
if (m_engine) {
qt->SetAccessor(v8::String::New("application"), getApplication, 0, v8::External::New(this));
+#ifndef QT_NO_IM
qt->SetAccessor(v8::String::New("inputMethod"), getInputMethod, 0, v8::External::New(this));
+#endif
qt->Set(v8::String::New("lighter"), V8FUNCTION(lighter, this));
qt->Set(v8::String::New("darker"), V8FUNCTION(darker, this));
qt->Set(v8::String::New("tint"), V8FUNCTION(tint, this));
return engine->newQObject(engine->m_application);
}
+#ifndef QT_NO_IM
v8::Handle<v8::Value> QV8Engine::getInputMethod(v8::Local<v8::String>, const v8::AccessorInfo &info)
{
QV8Engine *engine = reinterpret_cast<QV8Engine*>(v8::External::Unwrap(info.Data()));
return engine->newQObject(QQml_guiProvider()->inputMethod(), CppOwnership);
}
+#endif
void QV8GCCallback::registerGcPrologueCallback()
{
void addRelationshipForGC(QObject *object, QObject *other);
static v8::Handle<v8::Value> getApplication(v8::Local<v8::String> property, const v8::AccessorInfo &info);
+#ifndef QT_NO_IM
static v8::Handle<v8::Value> getInputMethod(v8::Local<v8::String> property, const v8::AccessorInfo &info);
+#endif
struct ThreadData {
ThreadData();
if (m_next) m_next->keyReleased(event, post);
}
+#ifndef QT_NO_IM
void QQuickItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post)
{
if (m_next)
if (m_next) return m_next->inputMethodQuery(query);
return QVariant();
}
+#endif // QT_NO_IM
void QQuickItemKeyFilter::componentComplete()
{
void QQuickKeysAttached::componentComplete()
{
Q_D(QQuickKeysAttached);
+#ifndef QT_NO_IM
if (d->item) {
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *targetItem = d->targets.at(ii);
}
}
}
+#endif
}
void QQuickKeysAttached::keyPressed(QKeyEvent *event, bool post)
if (!event->isAccepted()) QQuickItemKeyFilter::keyReleased(event, post);
}
+#ifndef QT_NO_IM
void QQuickKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post)
{
Q_D(QQuickKeysAttached);
}
return QQuickItemKeyFilter::inputMethodQuery(query);
}
+#endif // QT_NO_IM
QQuickKeysAttached *QQuickKeysAttached::qmlAttachedProperties(QObject *obj)
{
event->ignore();
}
+#ifndef QT_NO_IM
/*!
This event handler can be reimplemented in a subclass to receive input
method events for an item. The event information is provided by the
{
event->ignore();
}
+#endif // QT_NO_IM
/*!
This event handler can be reimplemented in a subclass to receive focus-in
}
}
+#ifndef QT_NO_IM
/*!
This method is only relevant for input items.
return v;
}
+#endif // QT_NO_IM
QQuickAnchorLine QQuickItemPrivate::left() const
{
}
}
+#ifndef QT_NO_IM
void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e)
{
Q_Q(QQuickItem);
extra->keyHandler->inputMethodEvent(e, true);
}
}
+#endif // QT_NO_IM
void QQuickItemPrivate::deliverFocusEvent(QFocusEvent *e)
{
Q_UNUSED(value);
}
+#ifndef QT_NO_IM
/*!
Notify input method on updated query values if needed. \a queries indicates
the changed attributes.
if (hasActiveFocus())
qApp->inputMethod()->update(queries);
}
+#endif // QT_NO_IM
/*! \internal */
// XXX todo - do we want/need this anymore?
return QObject::event(ev);
}
#endif
+#ifndef QT_NO_IM
if (ev->type() == QEvent::InputMethodQuery) {
QInputMethodQueryEvent *query = static_cast<QInputMethodQueryEvent *>(ev);
Qt::InputMethodQueries queries = query->queries();
} else if (ev->type() == QEvent::InputMethod) {
inputMethodEvent(static_cast<QInputMethodEvent *>(ev));
return true;
- } else if (ev->type() == QEvent::StyleAnimationUpdate) {
+ } else
+#endif // QT_NO_IM
+ if (ev->type() == QEvent::StyleAnimationUpdate) {
update();
return true;
}
public:
enum Flag {
ItemClipsChildrenToShape = 0x01,
+#ifndef QT_NO_IM
ItemAcceptsInputMethod = 0x02,
+#endif
ItemIsFocusScope = 0x04,
ItemHasContents = 0x08,
ItemAcceptsDrops = 0x10
Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const;
+#ifndef QT_NO_IM
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+#endif
struct UpdatePaintNodeData {
QSGTransformNode *transformNode;
bool isComponentComplete() const;
virtual void itemChange(ItemChange, const ItemChangeData &);
+#ifndef QT_NO_IM
void updateInputMethod(Qt::InputMethodQueries queries = Qt::ImQueryInput);
+#endif
bool widthValid() const; // ### better name?
bool heightValid() const; // ### better name?
virtual void keyPressEvent(QKeyEvent *event);
virtual void keyReleaseEvent(QKeyEvent *event);
+#ifndef QT_NO_IM
virtual void inputMethodEvent(QInputMethodEvent *);
+#endif
virtual void focusInEvent(QFocusEvent *);
virtual void focusOutEvent(QFocusEvent *);
virtual void mousePressEvent(QMouseEvent *event);
virtual void transformChanged();
void deliverKeyEvent(QKeyEvent *);
+#ifndef QT_NO_IM
void deliverInputMethodEvent(QInputMethodEvent *);
+#endif
void deliverFocusEvent(QFocusEvent *);
void deliverMouseEvent(QMouseEvent *);
void deliverWheelEvent(QWheelEvent *);
virtual void keyPressed(QKeyEvent *event, bool post);
virtual void keyReleased(QKeyEvent *event, bool post);
+#ifndef QT_NO_IM
virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+#endif
virtual void componentComplete();
bool m_processPost;
private:
virtual void keyPressed(QKeyEvent *event, bool post);
virtual void keyReleased(QKeyEvent *event, bool post);
+#ifndef QT_NO_IM
virtual void inputMethodEvent(QInputMethodEvent *, bool post);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
+#endif
const QByteArray keyToSignal(int key) {
QByteArray keySignal;
if (key >= Qt::Key_0 && key <= Qt::Key_9) {
bool QQuickTextPrivate::determineHorizontalAlignment()
{
if (hAlignImplicit) {
+#ifndef QT_NO_IM
bool alignToRight = text.isEmpty() ? qApp->inputMethod()->inputDirection() == Qt::RightToLeft : rightToLeftText;
+#else
+ bool alignToRight = rightToLeftText;
+#endif
return setHAlign(alignToRight ? QQuickText::AlignRight : QQuickText::AlignLeft);
}
return false;
QQuickTextControlPrivate::QQuickTextControlPrivate()
: doc(0),
+#ifndef QT_NO_IM
preeditCursor(0),
+#endif
interactionFlags(Qt::TextEditorInteraction),
cursorOn(false),
cursorIsFocusIndicator(false),
{
Q_Q(QQuickTextControl);
+#ifndef QT_NO_IM
cancelPreedit();
+#endif
// for use when called from setPlainText. we may want to re-use the currently
// set char format then.
{
Q_Q(QQuickTextControl);
if (forceEmitSelectionChanged) {
+#ifndef QT_NO_IM
if (hasFocus)
qGuiApp->inputMethod()->update(Qt::ImCurrentSelection);
+#endif
emit q->selectionChanged();
}
lastSelectionState = current;
emit q->copyAvailable(current);
if (!forceEmitSelectionChanged) {
+#ifndef QT_NO_IM
if (hasFocus)
qGuiApp->inputMethod()->update(Qt::ImCurrentSelection);
+#endif
emit q->selectionChanged();
}
q->updateCursorRectangle(true);
void QQuickTextControl::setTextCursor(const QTextCursor &cursor)
{
Q_D(QQuickTextControl);
+#ifndef QT_NO_IM
d->commitPreedit();
+#endif
d->cursorIsFocusIndicator = false;
const bool posChanged = cursor.position() != d->cursor.position();
const QTextCursor oldSelection = d->cursor;
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
d->mouseDoubleClickEvent(ev, matrix.map(ev->localPos()));
break; }
+#ifndef QT_NO_IM
case QEvent::InputMethod:
d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
break;
+#endif
case QEvent::FocusIn:
case QEvent::FocusOut:
d->focusEvent(static_cast<QFocusEvent *>(e));
const QTextLayout *layout = block.layout();
const QPointF layoutPos = q->blockBoundingRect(block).topLeft();
int relativePos = position - block.position();
+#ifndef QT_NO_IM
if (preeditCursor != 0) {
int preeditPos = layout->preeditAreaPosition();
if (relativePos == preeditPos)
else if (relativePos > preeditPos)
relativePos += layout->preeditAreaText().length();
}
+#endif
QTextLine line = layout->lineForTextPosition(relativePos);
int cursorWidth;
const QTextCursor oldSelection = cursor;
const int oldCursorPos = cursor.position();
+#ifndef QT_NO_IM
commitPreedit();
+#endif
if (trippleClickTimer.isActive()
&& ((pos - trippleClickPoint).toPoint().manhattanLength() < qApp->styleHints()->startDragDistance())) {
int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit);
+#ifndef QT_NO_IM
if (isPreediting()) {
// note: oldCursorPos not including preedit
int selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit);
setCursorPosition(selectionStartPos);
}
}
+#endif
if (newCursorPos == -1)
return;
extendBlockwiseSelection(newCursorPos);
else if (selectedWordOnDoubleClick.hasSelection())
extendWordwiseSelection(newCursorPos, mouseX);
+#ifndef QT_NO_IM
else if (!isPreediting())
setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
+#endif
if (interactionFlags & Qt::TextEditable) {
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
_q_updateCurrentCharFormatAndSelection();
+#ifndef QT_NO_IM
if (qGuiApp)
qGuiApp->inputMethod()->update(Qt::ImQueryInput);
+#endif
} else if (cursor.position() != oldCursorPos) {
emit q->cursorPositionChanged();
}
Q_Q(QQuickTextControl);
if (e->button() == Qt::LeftButton && (interactionFlags & Qt::TextSelectableByMouse)) {
+#ifndef QT_NO_IM
commitPreedit();
+#endif
const QTextCursor oldSelection = cursor;
setCursorPosition(pos);
return false;
}
+#ifndef QT_NO_IM
void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
{
Q_Q(QQuickTextControl);
return QVariant();
}
}
+#endif // QT_NO_IM
void QQuickTextControlPrivate::focusEvent(QFocusEvent *e)
{
emit q_func()->linkActivated(href);
}
+#ifndef QT_NO_IM
bool QQuickTextControlPrivate::isPreediting() const
{
QTextLayout *layout = cursor.block().layout();
QInputMethodEvent event;
QCoreApplication::sendEvent(q->parent(), &event);
}
+#endif // QT_NO_IM
void QQuickTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags)
{
virtual void processEvent(QEvent *e, const QMatrix &matrix);
void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF());
+#ifndef QT_NO_IM
virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+#endif
virtual QMimeData *createMimeDataFromSelection() const;
virtual bool canInsertFromMimeData(const QMimeData *source) const;
void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &pos);
bool sendMouseEventToInputContext(QMouseEvent *event, const QPointF &pos);
void focusEvent(QFocusEvent *e);
+#ifndef QT_NO_IM
void inputMethodEvent(QInputMethodEvent *);
+#endif
void activateLinkUnderCursor(QString href = QString());
+#ifndef QT_NO_IM
bool isPreediting() const;
void commitPreedit();
void cancelPreedit();
+#endif
QPointF trippleClickPoint;
QPointF mousePressPos;
QBasicTimer cursorBlinkTimer;
QBasicTimer trippleClickTimer;
+#ifndef QT_NO_IM
int preeditCursor;
+#endif
Qt::TextInteractionFlags interactionFlags;
}
updateSize();
updateDocument();
+#ifndef QT_NO_IM
updateInputMethod(Qt::ImCursorRectangle | Qt::ImFont);
+#endif
}
emit fontChanged(d->sourceFont);
}
Q_Q(QQuickTextEdit);
if (hAlignImplicit && q->isComponentComplete()) {
Qt::LayoutDirection direction = contentDirection;
+#ifndef QT_NO_IM
if (direction == Qt::LayoutDirectionAuto) {
const QString preeditText = control->textCursor().block().layout()->preeditAreaText();
direction = textDirection(preeditText);
}
if (direction == Qt::LayoutDirectionAuto)
direction = qGuiApp->inputMethod()->inputDirection();
+#endif
return setHAlign(direction == Qt::RightToLeft ? QQuickTextEdit::AlignRight : QQuickTextEdit::AlignLeft);
}
y -= d->yoff;
int r = d->document->documentLayout()->hitTest(QPointF(x, y), Qt::FuzzyHit);
+#ifndef QT_NO_IM
QTextCursor cursor = d->control->textCursor();
if (r > cursor.position()) {
// The cursor position includes positions within the preedit text, but only positions in the
: cursor.position();
}
}
+#endif
return r;
}
\endlist
*/
+#ifndef QT_NO_IM
Qt::InputMethodHints QQuickTextEdit::inputMethodHints() const
{
Q_D(const QQuickTextEdit);
updateInputMethod(Qt::ImHints);
emit inputMethodHintsChanged();
}
+#endif // QT_NO_IM
void QQuickTextEdit::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
if (r == isReadOnly())
return;
+#ifndef QT_NO_IM
setFlag(QQuickItem::ItemAcceptsInputMethod, !r);
+#endif
Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse;
if (d->selectByMouse)
flags = flags | Qt::TextSelectableByMouse;
if (!r)
d->control->moveCursor(QTextCursor::End);
+#ifndef QT_NO_IM
updateInputMethod(Qt::ImEnabled);
+#endif
q_canPasteChanged();
emit readOnlyChanged(r);
}
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus();
// re-open input panel on press if already focused
+#ifndef QT_NO_IM
if (hasActiveFocus() && hadActiveFocus && !isReadOnly())
qGuiApp->inputMethod()->show();
+#endif
}
if (!event->isAccepted())
QQuickImplicitSizeItem::mousePressEvent(event);
QQuickImplicitSizeItem::mouseMoveEvent(event);
}
+#ifndef QT_NO_IM
/*!
\overload
Handles the given input method \a event.
if (wasComposing != isInputMethodComposing())
emit inputMethodComposingChanged();
}
+#endif // QT_NO_IM
void QQuickTextEdit::itemChange(ItemChange change, const ItemChangeData &value)
{
d->control->processEvent(&focusEvent, QPointF(-d->xoff, -d->yoff));
if (value.boolValue) {
q_updateAlignment();
+#ifndef QT_NO_IM
connect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
this, SLOT(q_updateAlignment()));
} else {
disconnect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
this, SLOT(q_updateAlignment()));
+#endif
}
}
QQuickItem::itemChange(change, value);
}
+#ifndef QT_NO_IM
/*!
\overload
Returns the value of the given \a property.
return v;
}
+#endif // QT_NO_IM
void QQuickTextEdit::triggerPreprocess()
{
return d->document->isRedoAvailable();
}
+#ifndef QT_NO_IM
/*!
\qmlproperty bool QtQuick2::TextEdit::inputMethodComposing
Q_D(const QQuickTextEdit);
return d->control->hasImState();
}
+#endif // QT_NO_IM
void QQuickTextEditPrivate::init()
{
#endif
q->setAcceptedMouseButtons(Qt::LeftButton);
+#ifndef QT_NO_IM
q->setFlag(QQuickItem::ItemAcceptsInputMethod);
+#endif
q->setFlag(QQuickItem::ItemHasContents);
document = new QQuickTextDocumentWithImageResources(q);
void QQuickTextEdit::moveCursorDelegate()
{
Q_D(QQuickTextEdit);
+#ifndef QT_NO_IM
updateInputMethod();
+#endif
emit cursorRectangleChanged();
if (!d->cursorItem)
return;
else
opt.setAlignment(Qt::Alignment(vAlign));
+#ifndef QT_NO_IM
if (contentDirection == Qt::LayoutDirectionAuto) {
opt.setTextDirection(qGuiApp->inputMethod()->inputDirection());
- } else {
+ } else
+#endif
+ {
opt.setTextDirection(contentDirection);
}
void QQuickTextEdit::focusInEvent(QFocusEvent *event)
{
Q_D(const QQuickTextEdit);
+#ifndef QT_NO_IM
if (d->focusOnPress && !isReadOnly())
qGuiApp->inputMethod()->show();
+#endif
QQuickImplicitSizeItem::focusInEvent(event);
}
Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
+#ifndef QT_NO_IM
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
+#endif
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
+#ifndef QT_NO_IM
Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
+#endif
Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
qreal textMargin() const;
void setTextMargin(qreal margin);
+#ifndef QT_NO_IM
Qt::InputMethodHints inputMethodHints() const;
void setInputMethodHints(Qt::InputMethodHints hints);
+#endif
bool selectByMouse() const;
void setSelectByMouse(bool);
QRectF cursorRectangle() const;
+#ifndef QT_NO_IM
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+#endif
qreal contentWidth() const;
qreal contentHeight() const;
QRectF boundingRect() const;
QRectF clipRect() const;
+#ifndef QT_NO_IM
bool isInputMethodComposing() const;
+#endif
RenderType renderType() const;
void setRenderType(RenderType renderType);
void canPasteChanged();
void canUndoChanged();
void canRedoChanged();
+#ifndef QT_NO_IM
void inputMethodComposingChanged();
+#endif
void effectiveHorizontalAlignmentChanged();
void baseUrlChanged();
+#ifndef QT_NO_IM
void inputMethodHintsChanged();
+#endif
void renderTypeChanged();
public Q_SLOTS:
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
+#ifndef QT_NO_IM
void inputMethodEvent(QInputMethodEvent *e);
+#endif
virtual void itemChange(ItemChange, const ItemChangeData &);
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
, format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
, renderType(QQuickTextEdit::QtRendering)
, contentDirection(Qt::LayoutDirectionAuto)
- , mouseSelectionMode(QQuickTextEdit::SelectCharacters), inputMethodHints(Qt::ImhNone)
+ , mouseSelectionMode(QQuickTextEdit::SelectCharacters)
+#ifndef QT_NO_IM
+ , inputMethodHints(Qt::ImhNone)
+#endif
, updateType(UpdatePaintNode)
, documentDirty(true), dirty(false), richText(false), cursorVisible(false), cursorPending(false)
, focusOnPress(true), persistentSelection(false), requireImplicitWidth(false)
QQuickTextEdit::RenderType renderType;
Qt::LayoutDirection contentDirection;
QQuickTextEdit::SelectionMode mouseSelectionMode;
+#ifndef QT_NO_IM
Qt::InputMethodHints inputMethodHints;
+#endif
UpdateType updateType;
bool documentDirty : 1;
if (s == text())
return;
+#ifndef QT_NO_IM
d->cancelPreedit();
+#endif
d->internalSetText(s, -1, false);
}
if (oldFont != d->font) {
d->updateLayout();
updateCursorRectangle();
+#ifndef QT_NO_IM
updateInputMethod(Qt::ImCursorRectangle | Qt::ImFont);
+#endif
}
emit fontChanged(d->sourceFont);
}
Qt::LayoutDirection QQuickTextInputPrivate::textDirection() const
{
QString text = m_text;
+#ifndef QT_NO_IM
if (text.isEmpty())
text = m_textLayout.preeditAreaText();
+#endif
const QChar *character = text.constData();
while (!character->isNull()) {
Qt::LayoutDirection direction = m_layoutDirection;
if (direction == Qt::LayoutDirectionAuto) {
direction = textDirection();
+#ifndef QT_NO_IM
if (direction == Qt::LayoutDirectionAuto)
direction = qApp->inputMethod()->inputDirection();
+#endif
}
return (direction == Qt::LayoutDirectionAuto) ? Qt::LeftToRight : direction;
}
if (hAlignImplicit) {
// if no explicit alignment has been set, follow the natural layout direction of the text
Qt::LayoutDirection direction = textDirection();
+#ifndef QT_NO_IM
if (direction == Qt::LayoutDirectionAuto)
direction = qApp->inputMethod()->inputDirection();
+#endif
return setHAlign(direction == Qt::RightToLeft ? QQuickTextInput::AlignRight : QQuickTextInput::AlignLeft);
}
return false;
if (d->m_readOnly == ro)
return;
+#ifndef QT_NO_IM
setFlag(QQuickItem::ItemAcceptsInputMethod, !ro);
+#endif
d->m_readOnly = ro;
if (!ro)
d->setCursorPosition(d->end());
+#ifndef QT_NO_IM
updateInputMethod(Qt::ImEnabled);
+#endif
q_canPasteChanged();
d->emitUndoRedoChanged();
emit readOnlyChanged(ro);
{
Q_D(const QQuickTextInput);
- int c = d->m_cursor + d->m_preeditCursor;
+ int c = d->m_cursor;
+#ifndef QT_NO_IM
+ c += d->m_preeditCursor;
+#endif
if (d->m_echoMode == NoEcho)
c = 0;
QTextLine l = d->m_textLayout.lineForTextPosition(c);
state.
*/
+#ifndef QT_NO_IM
Qt::InputMethodHints QQuickTextInputPrivate::effectiveInputMethodHints() const
{
Qt::InputMethodHints hints = inputMethodHints;
hints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
return hints;
}
+#endif
+
/*!
\qmlproperty enumeration QtQuick2::TextInput::echoMode
d->cancelPasswordEchoTimer();
d->m_echoMode = echo;
d->m_passwordEchoEditing = false;
+#ifndef QT_NO_IM
updateInputMethod(Qt::ImHints);
+#endif
d->updateDisplayText();
updateCursorRectangle();
emit echoModeChanged(echoMode());
}
+#ifndef QT_NO_IM
/*!
\qmlproperty enumeration QtQuick2::TextInput::inputMethodHints
updateInputMethod(Qt::ImHints);
emit inputMethodHintsChanged();
}
+#endif // QT_NO_IM
/*!
\qmlproperty Component QtQuick2::TextInput::cursorDelegate
Q_D(const QQuickTextInput);
if (d->m_echoMode == NoEcho)
pos = 0;
+#ifndef QT_NO_IM
else if (pos > d->m_cursor)
pos += d->preeditAreaText().length();
+#endif
QTextLine l = d->m_textLayout.lineForTextPosition(pos);
return l.isValid()
? QRectF(l.cursorToX(pos) - d->hscroll, l.y() - d->vscroll, 1, l.height())
int pos = d->positionAt(x, y, position);
const int cursor = d->m_cursor;
if (pos > cursor) {
+#ifndef QT_NO_IM
const int preeditLength = d->preeditAreaText().length();
pos = pos > cursor + preeditLength
? pos - preeditLength
: cursor;
+#else
+ pos = cursor;
+#endif
}
args->returnValue(v8::Int32::New(pos));
}
QQuickImplicitSizeItem::keyPressEvent(ev);
}
+#ifndef QT_NO_IM
void QQuickTextInput::inputMethodEvent(QInputMethodEvent *ev)
{
Q_D(QQuickTextInput);
if (wasComposing != d->hasImState)
emit inputMethodComposingChanged();
}
+#endif
void QQuickTextInput::mouseDoubleClickEvent(QMouseEvent *event)
{
Q_D(QQuickTextInput);
if (d->selectByMouse && event->button() == Qt::LeftButton) {
+#ifndef QT_NO_IM
d->commitPreedit();
+#endif
int cursor = d->positionAt(event->localPos());
d->selectWordAtPos(cursor);
event->setAccepted(true);
if (d->focusOnPress) {
bool hadActiveFocus = hasActiveFocus();
forceActiveFocus();
+#ifndef QT_NO_IM
// re-open input panel on press if already focused
if (hasActiveFocus() && hadActiveFocus && !d->m_readOnly)
qGuiApp->inputMethod()->show();
+#endif
}
event->setAccepted(true);
if (qAbs(int(event->localPos().x() - d->pressPos.x())) > qApp->styleHints()->startDragDistance())
setKeepMouseGrab(true);
+#ifndef QT_NO_IM
if (d->composeMode()) {
// start selection
int startPos = d->positionAt(d->pressPos);
int currentPos = d->positionAt(event->localPos());
if (startPos != currentPos)
d->setSelection(startPos, currentPos - startPos);
- } else {
+ } else
+#endif
+ {
moveCursorSelection(d->positionAt(event->localPos()), d->mouseSelectionMode);
}
event->setAccepted(true);
}
#else
Q_UNUSED(event);
- Q_UNUSED(eventType)
#endif
return false;
void QQuickTextInputPrivate::updateHorizontalScroll()
{
Q_Q(QQuickTextInput);
+#ifndef QT_NO_IM
QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + m_preeditCursor);
const int preeditLength = m_textLayout.preeditAreaText().length();
+#else
+ QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor);
+#endif
const qreal width = qMax<qreal>(0, q->width());
qreal cix = 0;
qreal widthUsed = 0;
if (currentLine.isValid()) {
+#ifndef QT_NO_IM
cix = currentLine.cursorToX(m_cursor + preeditLength);
+#else
+ cix = currentLine.cursorToX(m_cursor);
+#endif
const qreal cursorWidth = cix >= 0 ? cix : width - cix;
widthUsed = qMax(currentLine.naturalTextWidth(), cursorWidth);
}
// left
hscroll = width - widthUsed;
}
+#ifndef QT_NO_IM
if (preeditLength > 0) {
// check to ensure long pre-edit text doesn't push the cursor
// off to the left
if (cix < hscroll)
hscroll = cix;
}
+#endif
}
if (previousScroll != hscroll)
textLayoutDirty = true;
void QQuickTextInputPrivate::updateVerticalScroll()
{
Q_Q(QQuickTextInput);
+#ifndef QT_NO_IM
const int preeditLength = m_textLayout.preeditAreaText().length();
+#endif
const qreal height = qMax<qreal>(0, q->height());
qreal heightUsed = contentSize.height();
qreal previousScroll = vscroll;
vscroll = -QQuickTextUtil::alignedY(
heightUsed, height, vAlign & ~(Qt::AlignAbsolute|Qt::AlignHorizontal_Mask));
} else {
+#ifndef QT_NO_IM
QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + preeditLength);
+#else
+ QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor);
+#endif
QRectF r = currentLine.isValid() ? currentLine.rect() : QRectF();
qreal top = r.top();
int bottom = r.bottom();
// right
vscroll = heightUsed - height;
}
+#ifndef QT_NO_IM
if (preeditLength > 0) {
// check to ensure long pre-edit text doesn't push the cursor
// off the top
if (top < vscroll)
vscroll = top;
}
+#endif
}
if (previousScroll != vscroll)
textLayoutDirty = true;
offset = -QPoint(d->hscroll, d->vscroll);
}
- if (!d->m_textLayout.text().isEmpty() || !d->m_textLayout.preeditAreaText().isEmpty()) {
+ if (!d->m_textLayout.text().isEmpty()
+#ifndef QT_NO_IM
+ || !d->m_textLayout.preeditAreaText().isEmpty()
+#endif
+ ) {
node->addTextLayout(offset, &d->m_textLayout, d->color,
QQuickText::Normal, QColor(), QColor(),
d->selectionColor, d->selectedTextColor,
return node;
}
+#ifndef QT_NO_IM
QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const
{
Q_D(const QQuickTextInput);
return QVariant();
}
}
+#endif // QT_NO_IM
/*!
\qmlmethod QtQuick2::TextInput::deselect()
void QQuickTextInput::focusInEvent(QFocusEvent *event)
{
Q_D(const QQuickTextInput);
+#ifndef QT_NO_IM
if (d->focusOnPress && !d->m_readOnly)
qGuiApp->inputMethod()->show();
+#endif
QQuickImplicitSizeItem::focusInEvent(event);
}
if (!hasFocus) {
if (!d->persistentSelection)
d->deselect();
+#ifndef QT_NO_IM
disconnect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
this, SLOT(q_updateAlignment()));
+#endif
} else {
q_updateAlignment();
+#ifndef QT_NO_IM
connect(qApp->inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)),
this, SLOT(q_updateAlignment()));
+#endif
}
}
QQuickItem::itemChange(change, value);
}
+#ifndef QT_NO_IM
/*!
\qmlproperty bool QtQuick2::TextInput::inputMethodComposing
Q_D(const QQuickTextInput);
return d->hasImState;
}
+#endif
void QQuickTextInputPrivate::init()
{
#endif
q->setAcceptedMouseButtons(Qt::LeftButton);
+#ifndef QT_NO_IM
q->setFlag(QQuickItem::ItemAcceptsInputMethod);
+#endif
q->setFlag(QQuickItem::ItemHasContents);
#ifndef QT_NO_CLIPBOARD
q->connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()),
d->cursorItem->setPos(r.topLeft());
d->cursorItem->setHeight(r.height());
}
+#ifndef QT_NO_IM
updateInputMethod(Qt::ImCursorRectangle);
+#endif
}
void QQuickTextInput::selectionChanged()
option.setAlignment(Qt::Alignment(q->effectiveHAlign()));
layout.setTextOption(option);
layout.setFont(font);
+#ifndef QT_NO_IM
layout.setPreeditArea(m_textLayout.preeditAreaPosition(), m_textLayout.preeditAreaText());
+#endif
layout.beginLayout();
QTextLine line = layout.createLine();
#endif // !QT_NO_CLIPBOARD
+#ifndef QT_NO_IM
/*!
\internal
*/
QInputMethodEvent ev;
QCoreApplication::sendEvent(q, &ev);
}
+#endif // QT_NO_IM
/*!
\internal
void QQuickTextInputPrivate::setSelection(int start, int length)
{
Q_Q(QQuickTextInput);
+#ifndef QT_NO_IM
commitPreedit();
+#endif
if (start < 0 || start > (int)m_text.length()){
qWarning("QQuickTextInputPrivate::setSelection: Invalid start position");
}
emit q->selectionChanged();
emitCursorPositionChanged();
+#ifndef QT_NO_IM
q->updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorPosition
| Qt::ImCursorPosition | Qt::ImCurrentSelection);
+#endif
}
/*!
void QQuickTextInputPrivate::moveCursor(int pos, bool mark)
{
Q_Q(QQuickTextInput);
+#ifndef QT_NO_IM
commitPreedit();
+#endif
if (pos != m_cursor) {
separate();
emit q->selectionChanged();
}
emitCursorPositionChanged();
+#ifndef QT_NO_IM
q->updateInputMethod();
+#endif
}
+#ifndef QT_NO_IM
/*!
\internal
cursorPositionChanged = true;
}
}
-#ifndef QT_NO_IM
m_textLayout.setPreeditArea(m_cursor, event->preeditString());
-#endif //QT_NO_IM
const int oldPreeditCursor = m_preeditCursor;
m_preeditCursor = event->preeditString().length();
hasImState = !event->preeditString().isEmpty();
| Qt::ImCursorPosition | Qt::ImCurrentSelection);
}
}
+#endif // QT_NO_IM
/*!
\internal
Q_Q(QQuickTextInput);
Q_UNUSED(update)
+#ifndef QT_NO_IM
bool inputMethodAttributesChanged = m_textDirty || m_selDirty;
+#endif
bool alignmentChanged = false;
if (m_textDirty) {
if (m_textDirty) {
m_textDirty = false;
+#ifndef QT_NO_IM
m_preeditDirty = false;
+#endif
alignmentChanged = determineHorizontalAlignment();
emit q->textChanged();
}
if (m_acceptableInput != wasAcceptable)
emit q->acceptableInputChanged();
}
+#ifndef QT_NO_IM
if (m_preeditDirty) {
m_preeditDirty = false;
if (determineHorizontalAlignment()) {
updateLayout();
}
}
+#endif
if (m_selDirty) {
m_selDirty = false;
emit q->selectionChanged();
}
+#ifndef QT_NO_IM
inputMethodAttributesChanged |= (m_cursor != m_lastCursorPos);
if (inputMethodAttributesChanged)
q->updateInputMethod();
+#endif
emitUndoRedoChanged();
if (!emitCursorPositionChanged() && alignmentChanged)
Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged)
#endif
Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
+#ifndef QT_NO_IM
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
+#endif
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
#endif
Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
+#ifndef QT_NO_IM
Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
+#endif
Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
Q_PROPERTY(RenderType renderType READ renderType WRITE setRenderType NOTIFY renderTypeChanged)
bool hasAcceptableInput() const;
+#ifndef QT_NO_IM
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+#endif
QRectF boundingRect() const;
QRectF clipRect() const;
bool canUndo() const;
bool canRedo() const;
+#ifndef QT_NO_IM
bool isInputMethodComposing() const;
Qt::InputMethodHints inputMethodHints() const;
void setInputMethodHints(Qt::InputMethodHints hints);
+#endif
Q_INVOKABLE QString getText(int start, int end) const;
void canPasteChanged();
void canUndoChanged();
void canRedoChanged();
+#ifndef QT_NO_IM
void inputMethodComposingChanged();
+#endif
void effectiveHorizontalAlignmentChanged();
void contentSizeChanged();
+#ifndef QT_NO_IM
void inputMethodHintsChanged();
+#endif
void renderTypeChanged();
protected:
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent* ev);
+#ifndef QT_NO_IM
void inputMethodEvent(QInputMethodEvent *);
+#endif
void mouseUngrabEvent();
bool event(QEvent *e);
void focusInEvent(QFocusEvent *event);
, selectionColor(QRgb(0xFF000080))
, selectedTextColor(QRgb(0xFFFFFFFF))
, m_cursor(0)
+#ifndef QT_NO_IM
, m_preeditCursor(0)
+#endif
, m_blinkPeriod(0)
, m_blinkTimer(0)
, m_maxLength(32767)
, m_undoState(0)
, m_selstart(0)
, m_selend(0)
+#ifndef QT_NO_IM
, inputMethodHints(Qt::ImhNone)
+#endif
, hAlign(QQuickTextInput::AlignLeft)
, vAlign(QQuickTextInput::AlignTop)
, wrapMode(QQuickTextInput::NoWrap)
, m_separator(0)
, m_readOnly(0)
, m_textDirty(0)
+#ifndef QT_NO_IM
, m_preeditDirty(0)
+#endif
, m_selDirty(0)
, m_validInput(1)
, m_acceptableInput(1)
bool setHAlign(QQuickTextInput::HAlignment, bool forceAlign = false);
void mirrorChange();
bool sendMouseEventToInputContext(QMouseEvent *event);
+#ifndef QT_NO_IM
Qt::InputMethodHints effectiveInputMethodHints() const;
+#endif
void hideCursor();
void showCursor();
int lastSelectionStart;
int lastSelectionEnd;
int m_cursor;
+#ifndef QT_NO_IM
int m_preeditCursor;
+#endif
int m_blinkPeriod; // 0 for non-blinking cursor
int m_blinkTimer;
int m_maxLength;
UpdatePaintNode
};
+#ifndef QT_NO_IM
Qt::InputMethodHints inputMethodHints;
+#endif
QQuickTextInput::HAlignment hAlign;
QQuickTextInput::VAlignment vAlign;
QQuickTextInput::WrapMode wrapMode;
bool m_separator : 1;
bool m_readOnly : 1;
bool m_textDirty : 1;
+#ifndef QT_NO_IM
bool m_preeditDirty : 1;
+#endif
bool m_selDirty : 1;
bool m_validInput : 1;
bool m_acceptableInput : 1;
void paste(QClipboard::Mode mode = QClipboard::Clipboard);
#endif
+#ifndef QT_NO_IM
void commitPreedit();
void cancelPreedit();
+#endif
Qt::CursorMoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
void setCursorMoveStyle(Qt::CursorMoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
// input methods
#ifndef QT_NO_IM
bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); }
-#endif
QString preeditAreaText() const { return m_textLayout.preeditAreaText(); }
+#endif
void updatePasswordEchoEditing(bool editing);
}
}
+#ifndef QT_NO_IM
void processInputMethodEvent(QInputMethodEvent *event);
+#endif
void processKeyEvent(QKeyEvent* ev);
void setCursorBlinkPeriod(int msec);
Q_ASSERT(!engine.currentLine().isValid());
QTextBlock block = it.currentBlock();
+#ifndef QT_NO_IM
int preeditLength = block.isValid() ? block.layout()->preeditAreaText().length() : 0;
int preeditPosition = block.isValid() ? block.layout()->preeditAreaPosition() : -1;
+#endif
QVarLengthArray<QTextLayout::FormatRange> colorChanges;
mergeFormats(block.layout(), &colorChanges);
engine.setTextColor(textColor);
int fragmentEnd = textPos + fragment.length();
+#ifndef QT_NO_IM
if (preeditPosition >= 0
&& preeditPosition >= textPos
&& preeditPosition <= fragmentEnd) {
fragmentEnd += preeditLength;
}
+#endif
textPos = engine.addText(block, charFormat, textColor, colorChanges, textPos, fragmentEnd,
selectionStart, selectionEnd);
++blockIterator;
}
+#ifndef QT_NO_IM
if (preeditLength >= 0 && textPos <= block.position() + preeditPosition) {
engine.setPosition(blockPosition);
textPos = block.position() + preeditPosition;
textPos, textPos + preeditLength,
selectionStart, selectionEnd);
}
+#endif
engine.setCurrentLine(QTextLine()); // Reset current line because the text layout changed
++it;
engine.setAnchorColor(anchorColor);
engine.setPosition(position);
+#ifndef QT_NO_IM
int preeditLength = textLayout->preeditAreaText().length();
int preeditPosition = textLayout->preeditAreaPosition();
+#endif
QVarLengthArray<QTextLayout::FormatRange> colorChanges;
mergeFormats(textLayout, &colorChanges);
int length = line.textLength();
int end = start + length;
+#ifndef QT_NO_IM
if (preeditPosition >= 0
&& preeditPosition >= start
&& preeditPosition < end) {
end += preeditLength;
}
+#endif
engine.setCurrentLine(line);
engine.addGlyphsForRanges(colorChanges, start, end, selectionStart, selectionEnd);
void QQuickWindowPrivate::updateFocusItemTransform()
{
Q_Q(QQuickWindow);
+#ifndef QT_NO_IM
QQuickItem *focus = q->activeFocusItem();
if (focus && qApp->focusObject() == focus)
qApp->inputMethod()->setInputItemTransform(QQuickItemPrivate::get(focus)->itemToWindowTransform());
+#endif
}
contentItem()->windowDeactivateEvent();
break;
case QEvent::FocusAboutToChange:
+#ifndef QT_NO_IM
if (d->activeFocusItem)
qGuiApp->inputMethod()->commit();
+#endif
break;
default:
break;
return new QQuickApplication(parent);
}
+#ifndef QT_NO_IM
QInputMethod *inputMethod()
{
return qGuiApp->inputMethod();
}
+#endif
QStringList fontFamilies()
{
void QQuickUtilModule::defineModule()
{
+#ifndef QT_NO_IM
qmlRegisterUncreatableType<QInputMethod>("QtQuick",2,0,"InputMethod",
QInputMethod::tr("InputMethod is an abstract class"));
+#endif
qmlRegisterUncreatableType<QQuickAbstractAnimation>("QtQuick",2,0,"Animation",QQuickAbstractAnimation::tr("Animation is an abstract class"));
qmlRegisterType<QQuickBehavior>("QtQuick",2,0,"Behavior");