Remove QInputContext

This has only been around as compatibility interface for Qt4
but is now replaced by QPlatformInputContext.

Change-Id: I677dbbea46311bf39f6c5ca9dc3fb5009abe924a
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Pekka Vuorela 2012-02-01 09:43:18 +02:00 committed by Qt by Nokia
parent 0160f58d4b
commit c802a5d272
16 changed files with 10 additions and 864 deletions

2
dist/changes-5.0.0 vendored
View File

@ -264,7 +264,7 @@ QtGui
QtWidgets
---------
* QWidget::setInputContext() and QApplication::setInputContext() are removed.
* QInputContext removed as well as related getters and setters on QWidget and QApplication.
Input contexts are now platform specific.
* QInputDialog::getInteger() has been obsoleted. Use QInputDialog::getInt() instead.

View File

@ -1,224 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example tools/inputpanel
\title Input Panel Example
The Input Panel example shows how to create an input panel that
can be used to input text into widgets using only the pointer and
no keyboard.
\image inputpanel-example.png
The input fields in the main window have no function other than
to accept input. The main focus is on how the extra input panel
can be used to input text without the need for a real keyboard or
keypad.
\section1 Main Form Class Definition
Because the main window has no other function than to accept
input, it has no class definition. Instead, its whole layout is
made in Qt Designer. This emphasizes the point that no widget
specific code is needed to use input panels with Qt.
\section1 MyInputPanelContext Class Definition
\snippet examples/tools/inputpanel/myinputpanelcontext.h 0
The \c MyInputPanelContext class inherits QInputContext, which is
Qt's base class for handling input methods.
\c MyInputPanelContext is responsible for managing the state of
the input panel and sending input method events to the receiving
widgets.
The \c inputPanel member is a pointer to the input panel widget
itself; in other words, the window that will display the buttons
used for input.
The \c identifierName(), \c language(), \c isComposing() and
\c reset() functions are there mainly to fill in the pure virtual
functions in the base class, QInputContext, but they can be
useful in other scenarios. The important functions and slots are
the following:
\list
\o \c filterEvent() is where we receive events telling us to open
or close the input panel.
\o \c sendCharacter() is a slot which is called when we want to
send a character to the focused widget.
\o \c updatePosition() is used to position the input panel
relative to the focused widget, and will be used when opening
the input panel.
\endlist
\section1 MyInputPanelContext Class Implementation
In the constructor we connect to the \c characterGenerated()
signal of the input panel, in order to receive key presses. We'll
see how it works in detail later on.
\snippet examples/tools/inputpanel/myinputpanelcontext.cpp 0
In the \c filterEvent() function, we must look for the two event
types: \c RequestSoftwareInputPanel and \c CloseSoftwareInputPanel.
\snippet examples/tools/inputpanel/myinputpanelcontext.cpp 1
The first type will be sent whenever
an input capable widget wants to ask for an input panel. Qt's
input widgets do this automatically. If we receive that type of
event, we call \c updatePosition() \mdash we'll see later on what it
does \mdash then show the actual input panel widget. If we receive
the \c CloseSoftwareInputPanel event, we do the opposite, and
hide the input panel.
\snippet examples/tools/inputpanel/myinputpanelcontext.cpp 2
We implement the \c sendCharacter() function so that it sends the
supplied character to the focused widget. All QInputContext based
classes are always supposed to send events to the widget returned
by QInputContext::focusWidget(). Note the QPointer guards to make
sure that the widget does not get destroyed in between events.
Also note that we chose to use key press events in this example.
For more complex use cases with composed text it might be more
appropriate to send QInputMethodEvent events.
The \c updatePosition() function is implemented to position the
actual input panel window directly below the focused widget.
\snippet examples/tools/inputpanel/myinputpanelcontext.cpp 3
It performs the positioning by obtaining the coordinates of the
focused widget and translating them to global coordinates.
\section1 MyInputPanel Class Definition
The \c MyInputPanel class inherits QWidget and is used to display
the input panel widget and its buttons.
\snippet examples/tools/inputpanel/myinputpanel.h 0
If we look at the member variables first, we see that there is
\c form, which is made with Qt Designer, that contains the layout
of buttons to click. Note that all the buttons in the layout have
been declared with the \c NoFocus focus policy so that we can
maintain focus on the window receiving input instead of the
window containing buttons.
The \c lastFocusedWidget is a helper variable, which also aids in
maintaining focus.
\c signalMapper is an instance of the QSignalMapper class and is
there to help us tell which button was clicked. Since they are
all very similar this is a better solution than creating a separate
slot for each one.
The functions that we implement in \c MyInputPanel are the
following:
\list
\o \c event() is used to intercept and manipulate focus events,
so we can maintain focus in the main window.
\o \c saveFocusWidget() is a slot which will be called whenever
focus changes, and allows us to store the newly focused widget
in \c lastFocusedWidget, so that its focus can be restored
if it loses it to the input panel.
\o \c buttonClicked() is a slot which will be called by the
\c signalMapper whenever it receives a \c clicked() signal
from any of the buttons.
\endlist
\section1 MyInputPanel Class Implementation
If we look at the constructor first, we have a lot of signals to
connect to!
We connect the QApplication::focusChanged() signal
to the \c saveFocusWidget() signal in order to get focus updates.
Then comes the interesting part with the signal mapper: the
series of \c setMapping() calls sets the mapper up so that each
signal from one of the buttons will result in a
QSignalMapper::mapped() signal, with the given widget as a
parameter. This allows us to do general processing of clicks.
\snippet examples/tools/inputpanel/myinputpanel.cpp 0
The next series of connections then connect each button's
\c clicked() signal to the signal mapper. Finally, we create
a connection from the \c mapped() signal to the
\c buttonClicked() slot, where we will handle it.
\snippet examples/tools/inputpanel/myinputpanel.cpp 3
In the \c buttonClicked() slot, we extract the value of the
"buttonValue" property. This is a custom property which was
created in Qt Designer and set to the character that we wish the
button to produce. Then we emit the \c characterGenerated()
signal, which \c MyInputPanelContext is connected to. This will
in turn cause it to send the input to the focused widget.
In the \c saveFocusWidget() slot, we test whether the newly
focused widget is a child of the input panel or not, using the
QWidget::isAncestorOf() call.
\snippet examples/tools/inputpanel/myinputpanel.cpp 2
If it isn't, it means that the widget is outside the input panel,
and we store a pointer to that widget for later.
In the \c event() function we handle QEvent::WindowActivate
event, which occurs if the focus switches to the input panel.
\snippet examples/tools/inputpanel/myinputpanel.cpp 1
Since we want avoid focus on the input panel, we immediately call
QWidget::activateWindow() on the widget that last had focus, so
that input into that widget can continue. We ignore any other events
that we receive.
\section1 Setting the Input Context
The main function for the example is very similar to those for other
examples. The only real difference is that it creates a
\c MyInputPanelContext and sets it as the application-wide input
context.
\snippet examples/tools/inputpanel/main.cpp main
With the input context in place, we set up and show the user interface
made in Qt Designer before running the event loop.
\section1 Further Reading
This example shows a specific kind of input context that uses interaction
with a widget to provide input for another. Qt's input context system can
also be used to create other kinds of input methods. We recommend starting
with the QInputContext documentation if you want to explore further.
*/

View File

@ -1510,7 +1510,7 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
Cursor attributes and render them as specified.
\endlist
\sa QInputContext
\sa QInputMethod
*/
/*!

View File

@ -678,10 +678,6 @@ QT_CLASS_LIB(QPictureFormatInterface, QtGui, qpictureformatplugin.h)
QT_CLASS_LIB(QPictureFormatPlugin, QtGui, qpictureformatplugin.h)
QT_CLASS_LIB(QPixmap, QtGui, qpixmap.h)
QT_CLASS_LIB(QPixmapCache, QtGui, qpixmapcache.h)
QT_CLASS_LIB(QInputContext, QtWidgets, qinputcontext.h)
QT_CLASS_LIB(QInputContextFactory, QtWidgets, qinputcontextfactory.h)
QT_CLASS_LIB(QInputContextFactoryInterface, QtWidgets, qinputcontextplugin.h)
QT_CLASS_LIB(QInputContextPlugin, QtWidgets, qinputcontextplugin.h)
QT_CLASS_LIB(QAbstractItemDelegate, QtWidgets, qabstractitemdelegate.h)
QT_CLASS_LIB(QAbstractItemView, QtWidgets, qabstractitemview.h)
QT_CLASS_LIB(QAbstractProxyModel, QtWidgets, qabstractproxymodel.h)

View File

@ -7327,7 +7327,7 @@ void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event)
surrounding text and reconversions. \a query specifies which
property is queried.
\sa inputMethodEvent(), QInputMethodEvent, QInputContext
\sa inputMethodEvent(), QInputMethodEvent
*/
QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
{
@ -7354,7 +7354,7 @@ QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
\since 4.6
\sa setInputMethodHints(), inputMethodQuery(), QInputContext
\sa setInputMethodHints(), inputMethodQuery()
*/
Qt::InputMethodHints QGraphicsItem::inputMethodHints() const
{
@ -7367,7 +7367,7 @@ Qt::InputMethodHints QGraphicsItem::inputMethodHints() const
\since 4.6
\sa inputMethodHints(), inputMethodQuery(), QInputContext
\sa inputMethodHints(), inputMethodQuery()
*/
void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
{
@ -7387,7 +7387,7 @@ void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
\since 4.7
\sa QInputContext
\sa QInputMethod
*/
void QGraphicsItem::updateMicroFocus()
{
@ -7695,7 +7695,7 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)
\since 4.7
\sa QInputContext
\sa QInputMethod
*/
void QGraphicsObject::updateMicroFocus()
{

View File

@ -20,7 +20,6 @@ HEADERS += \
kernel/qiconloader_p.h \
kernel/qiconengine.h \
kernel/qiconengineplugin.h \
kernel/qinputcontext.h \
kernel/qlayout.h \
kernel/qlayout_p.h \
kernel/qlayoutengine_p.h \
@ -58,7 +57,6 @@ SOURCES += \
kernel/qiconloader.cpp \
kernel/qiconengine.cpp \
kernel/qiconengineplugin.cpp \
kernel/qinputcontext.cpp \
kernel/qlayout.cpp \
kernel/qlayoutengine.cpp \
kernel/qlayoutitem.cpp \

View File

@ -71,7 +71,6 @@
#include <QtGui/qstylehints.h>
#include <QtGui/qinputmethod.h>
#include "qinputcontext.h"
#include "private/qkeymapper_p.h"
#ifdef Q_WS_X11
@ -141,8 +140,6 @@ Q_CORE_EXPORT void qt_call_post_routines();
QApplicationPrivate *QApplicationPrivate::self = 0;
QInputContext *QApplicationPrivate::inputContext = 0;
#ifdef Q_WS_WINCE
int QApplicationPrivate::autoMaximizeThreshold = -1;
bool QApplicationPrivate::autoSipEnabled = false;
@ -4847,41 +4844,6 @@ int QApplication::keyboardInputInterval()
\sa QCoreApplication::instance()
*/
#ifndef QT_NO_IM
// ************************************************************************
// Input Method support
// ************************************************************************
/*
This function replaces the QInputContext instance used by the application
with \a inputContext.
Qt takes ownership of the given \a inputContext.
*/
void QApplicationPrivate::setInputContext(QInputContext *newInputContext)
{
Q_Q(QApplication);
if (newInputContext == inputContext)
return;
if (!newInputContext) {
qWarning("QApplicationPrivate::setInputContext: called with 0 input context");
return;
}
delete inputContext;
inputContext = newInputContext;
inputContext->setParent(q);
}
/*!
Returns the QInputContext instance used by the application.
*/
QInputContext *QApplication::inputContext() const
{
return QApplicationPrivate::inputContext;
}
#endif // QT_NO_IM
/*!
\since 4.2
\obsolete

View File

@ -62,7 +62,6 @@ class QDesktopWidget;
class QStyle;
class QEventLoop;
class QIcon;
class QInputContext;
template <typename T> class QList;
class QLocale;
class QPlatformNativeInterface;
@ -220,10 +219,6 @@ public:
virtual void saveState(QSessionManager& sm);
#endif
#ifndef QT_NO_IM
QInputContext *inputContext() const;
#endif
QT_DEPRECATED static QLocale keyboardInputLocale();
QT_DEPRECATED static Qt::LayoutDirection keyboardInputDirection();
@ -300,7 +295,6 @@ private:
friend class QAction;
#if defined(Q_WS_QWS)
friend class QInputContext;
friend class QWSDirectPainterSurface;
friend class QDirectPainter;
friend class QDirectPainterPrivate;

View File

@ -79,7 +79,6 @@ QT_BEGIN_NAMESPACE
class QClipboard;
class QGraphicsScene;
class QInputContext;
class QObject;
class QWidget;
class QSocketNotifier;
@ -249,12 +248,6 @@ public:
QPoint toolTipPos, toolTipGlobalPos, hoverGlobalPos;
QPointer<QWidget> toolTipWidget;
#ifndef QT_NO_IM
void setInputContext(QInputContext *);
#endif
static QInputContext *inputContext;
static Qt::MouseButtons mouse_buttons;
static Qt::KeyboardModifiers modifier_buttons;

View File

@ -54,7 +54,6 @@
#include "private/qplatformintegrationfactory_qpa_p.h"
#include <qdesktopwidget.h>
#include <qinputcontext.h>
#include <QPlatformCursor>
#include <qdebug.h>
#include <QWindowSystemInterface>
@ -395,10 +394,6 @@ void qt_init(QApplicationPrivate *priv, int type)
QColormap::initialize();
qApp->setObjectName(appName);
#ifndef QT_NO_QWS_INPUTMETHODS
priv->setInputContext(new QInputContext(qApp));
#endif
}
#ifdef Q_OS_WIN
@ -418,8 +413,6 @@ void qt_cleanup()
{
QPixmapCache::clear();
QColormap::cleanup();
delete QApplicationPrivate::inputContext;
QApplicationPrivate::inputContext = 0;
QApplicationPrivate::active_window = 0; //### this should not be necessary
#ifdef Q_OS_WIN

View File

@ -1,414 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/****************************************************************************
**
** Implementation of QInputContext class
**
** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
**
** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
** license. You may use this file under your Qt license. Following
** description is copied from their original file headers. Contact
** immodule-qt@freedesktop.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
//#define QT_NO_IM_PREEDIT_RELOCATION
#include "qinputcontext.h"
#ifndef QT_NO_IM
#include "qplatformdefs.h"
#include "qapplication.h"
#include "qmenu.h"
#include "qtextformat.h"
#include "qpalette.h"
#include <QtGui/qinputmethod.h>
#include <QtGui/qevent.h>
#include <stdlib.h>
#include <limits.h>
QT_BEGIN_NAMESPACE
/*!
\class QInputContext
\brief The QInputContext class abstracts the input method dependent data and composing state.
\ingroup i18n
\inmodule QtWidgets
An input method is responsible for inputting complex text that cannot
be inputted via simple keymap. It converts a sequence of input
events (typically key events) into a text string through the input
method specific converting process. The class of the processes are
widely ranging from simple finite state machine to complex text
translator that pools a whole paragraph of a text with text
editing capability to perform grammar and semantic analysis.
To abstract such different input method specific intermediate
information, Qt offers the QInputContext as base class. The
concept is well known as 'input context' in the input method
domain. An input context is created for a text widget in response
to a demand. It is ensured that an input context is prepared for
an input method before input to a text widget.
Multiple input contexts that belong to a single input method
may concurrently coexist. Suppose multi-window text editor. Each
text widget of window A and B holds different QInputContext
instance which contains different state information such as
partially composed text.
\section1 Groups of Functions
\table
\header \o Context \o Functions
\row \o Receiving information \o
x11FilterEvent(),
filterEvent(),
mouseHandler()
\row \o Sending back composed text \o
sendEvent()
\row \o State change notification \o
setFocusWidget(),
reset()
\row \o Context information \o
identifierName(),
language(),
font(),
isComposing()
\endtable
\section1 Licensing Information
\legalese
Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
license. You may use this file under your Qt license. Following
description is copied from their original file headers. Contact
immodule-qt@freedesktop.org if any conditions of this licensing are
not clear to you.
\endlegalese
\sa QInputContextPlugin, QInputContextFactory, QApplication::setInputContext()
*/
/*!
Constructs an input context with the given \a parent.
*/
QInputContext::QInputContext(QObject* parent)
: QObject(parent)
{
}
/*!
Destroys the input context.
*/
QInputContext::~QInputContext()
{
}
/*!
Returns the widget that has an input focus for this input
context.
The return value may differ from holderWidget() if the input
context is shared between several text widgets.
\warning To ensure platform independence and support flexible
configuration of widgets, ordinary input methods should not call
this function directly.
\sa setFocusWidget()
*/
QWidget *QInputContext::focusWidget() const
{
bool enabled = false;
if (qApp->focusWidget()) {
QInputMethodQueryEvent query(Qt::ImEnabled);
QGuiApplication::sendEvent(qApp->focusWidget(), &query);
enabled = query.value(Qt::ImEnabled).toBool();
}
return enabled ? qobject_cast<QWidget *>(qApp->focusWidget()) : 0;
}
/*!
Sets the \a widget that has an input focus for this input context.
\warning Ordinary input methods must not call this function
directly.
\sa focusWidget()
*/
void QInputContext::setFocusWidget(QWidget *widget)
{
// not honored
}
/*!
\fn bool QInputContext::isComposing() const
\obsolete
This function indicates whether InputMethodStart event had been
sent to the current focus widget. It is ensured that an input
context can send InputMethodCompose or InputMethodEnd event safely
if this function returned true.
The state is automatically being tracked through sendEvent().
\sa sendEvent()
*/
/*!
Sends an input method event specified by \a event to the current focus
widget. Implementations of QInputContext should call this method to
send the generated input method events and not
QApplication::sendEvent(), as the events might have to get dispatched
to a different application on some platforms.
Some complex input methods route the handling to several child
contexts (e.g. to enable language switching). To account for this,
QInputContext will check if the parent object is a QInputContext. If
yes, it will call the parents sendEvent() implementation instead of
sending the event directly.
\sa QInputMethodEvent
*/
void QInputContext::sendEvent(const QInputMethodEvent &event)
{
QObject *focus = qApp->inputMethod()->inputItem();
if (!focus)
return;
QInputMethodEvent e(event);
QApplication::sendEvent(focus, &e);
}
/*!
This function can be reimplemented in a subclass to handle mouse
press, release, double-click, and move events within the preedit
text. You can use the function to implement mouse-oriented user
interface such as text selection or popup menu for candidate
selection.
The \a x parameter is the offset within the string that was sent
with the InputMethodCompose event. The alteration boundary of \a
x is ensured as character boundary of preedit string accurately.
The \a event parameter is the event that was sent to the editor
widget. The event type is QEvent::MouseButtonPress,
QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick or
QEvent::MouseMove. The event's button and state indicate
the kind of operation that was performed.
*/
void QInputContext::mouseHandler(int x, QMouseEvent *event)
{
if (event->type() == QEvent::MouseButtonRelease)
qApp->inputMethod()->invokeAction(QInputMethod::Click, x);
}
/*!
Returns the font of the current input widget
*/
QFont QInputContext::font() const
{
QWidget *focus = focusWidget();
if (!focus)
return QApplication::font();
return qvariant_cast<QFont>(focus->inputMethodQuery(Qt::ImFont));
}
/*!
This virtual function is called when a state in the focus widget
has changed. QInputContext can then use
QWidget::inputMethodQuery() to query the new state of the widget.
*/
void QInputContext::update()
{
qApp->inputMethod()->update(Qt::ImQueryAll);
}
/*!
This virtual function is called when the specified \a widget is
destroyed. The \a widget is a widget on which this input context
is installed.
*/
void QInputContext::widgetDestroyed(QWidget *widget)
{
Q_UNUSED(widget)
// nothing to be done here, as we use a weak pointer in the input method
}
/*!
\fn void QInputContext::reset()
This function can be reimplemented in a subclass to reset the
state of the input method.
This function is called by several widgets to reset input
state. For example, a text widget call this function before
inserting a text to make widget ready to accept a text.
Default implementation is sufficient for simple input method. You
can override this function to reset external input method engines
in complex input method. In the case, call QInputContext::reset()
to ensure proper termination of inputting.
In a reimplementation of reset(), you must not send any
QInputMethodEvent containing preedit text. You can only commit
string and attributes; otherwise, you risk breaking input state
consistency.
*/
void QInputContext::reset()
{
qApp->inputMethod()->reset();
}
/*!
\fn QString QInputContext::identifierName()
This function must be implemented in any subclasses to return the
identifier name of the input method.
Return value is the name to identify and specify input methods for
the input method switching mechanism and so on. The name has to be
consistent with QInputContextPlugin::keys(). The name has to
consist of ASCII characters only.
There are two different names with different responsibility in the
input method domain. This function returns one of them. Another
name is called 'display name' that stands for the name for
endusers appeared in a menu and so on.
\sa QInputContextPlugin::keys(), QInputContextPlugin::displayName()
*/
QString QInputContext::identifierName()
{
return QLatin1String("qpa");
}
/*!
\fn QString QInputContext::language()
This function must be implemented in any subclasses to return a
language code (e.g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...)
of the input context. If the input context can handle multiple
languages, return the currently used one. The name has to be
consistent with QInputContextPlugin::language().
This information will be used by language tagging feature in
QInputMethodEvent. It is required to distinguish unified han characters
correctly. It enables proper font and character code
handling. Suppose CJK-awared multilingual web browser
(that automatically modifies fonts in CJK-mixed text) and XML editor
(that automatically inserts lang attr).
*/
QString QInputContext::language()
{
return QString();
}
/*!
This is a preliminary interface for Qt 4.
*/
QList<QAction *> QInputContext::actions()
{
return QList<QAction *>();
}
/*!
\enum QInputContext::StandardFormat
\value PreeditFormat The preedit text.
\value SelectionFormat The selection text.
\sa standardFormat()
*/
/*!
Returns a QTextFormat object that specifies the format for
component \a s.
*/
QTextFormat QInputContext::standardFormat(StandardFormat s) const
{
QWidget *focus = focusWidget();
const QPalette &pal = focus ? focus->palette() : QApplication::palette();
QTextCharFormat fmt;
QColor bg;
switch (s) {
case QInputContext::PreeditFormat: {
fmt.setUnderlineStyle(QTextCharFormat::DashUnderline);
break;
}
case QInputContext::SelectionFormat: {
bg = pal.text().color();
fmt.setBackground(QBrush(bg));
fmt.setForeground(pal.background());
break;
}
}
return fmt;
}
QT_END_NAMESPACE
#endif //Q_NO_IM

View File

@ -1,127 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
/****************************************************************************
**
** Definition of QInputContext class
**
** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
**
** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
** license. You may use this file under your Qt license. Following
** description is copied from their original file headers. Contact
** immodule-qt@freedesktop.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifndef QINPUTCONTEXT_H
#define QINPUTCONTEXT_H
#include <QtCore/qobject.h>
#include <QtCore/qglobal.h>
#include <QtGui/qevent.h>
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
#include <QtWidgets/qaction.h>
#ifndef QT_NO_IM
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QWidget;
class QFont;
class QPopupMenu;
class QInputContextPrivate;
class Q_WIDGETS_EXPORT QInputContext : public QObject
{
Q_OBJECT
public:
explicit QInputContext(QObject* parent = 0);
virtual ~QInputContext();
virtual QString identifierName();
virtual QString language();
virtual void reset();
virtual void update();
virtual void mouseHandler( int x, QMouseEvent *event);
virtual QFont font() const;
QWidget *focusWidget() const;
virtual void setFocusWidget( QWidget *w );
virtual void widgetDestroyed(QWidget *w);
virtual QList<QAction *> actions();
void sendEvent(const QInputMethodEvent &event);
virtual bool isComposing() const { return false; }
enum StandardFormat {
PreeditFormat,
SelectionFormat
};
QTextFormat standardFormat(StandardFormat s) const;
private:
friend class QWidget;
friend class QWidgetPrivate;
friend class QInputContextFactory;
friend class QApplication;
private: // Disabled copy constructor and operator=
QInputContext( const QInputContext & );
QInputContext &operator=( const QInputContext & );
};
QT_END_NAMESPACE
QT_END_HEADER
#endif //Q_NO_IM
#endif // QINPUTCONTEXT_H

View File

@ -75,7 +75,6 @@
#include "qdebug.h"
#include "private/qstylesheetstyle_p.h"
#include "private/qstyle_p.h"
#include "qinputcontext.h"
#include "qfileinfo.h"
#include "private/qsoftkeymanager_p.h"
#include <QtGui/qinputmethod.h>
@ -358,24 +357,6 @@ void QWidgetPrivate::updateWidgetTransform()
}
}
/*!
This function returns the QInputContext for this widget. By
default the input context is inherited from the widgets
parent. For toplevels it is inherited from QApplication.
You can override this and set a special input context for this
widget by using the setInputContext() method.
\sa setInputContext()
*/
QInputContext *QWidget::inputContext()
{
if (!testAttribute(Qt::WA_InputMethodEnabled))
return 0;
return qApp->inputContext();
}
#ifdef QT_KEYPAD_NAVIGATION
QPointer<QWidget> QWidgetPrivate::editingWidget;
@ -8752,7 +8733,7 @@ void QWidget::inputMethodEvent(QInputMethodEvent *event)
\a query specifies which property is queried.
\sa inputMethodEvent(), QInputMethodEvent, QInputContext, inputMethodHints
\sa inputMethodEvent(), QInputMethodEven, inputMethodHints
*/
QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
{
@ -8790,7 +8771,7 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
\since 4.6
\sa inputMethodQuery(), QInputContext
\sa inputMethodQuery()
*/
Qt::InputMethodHints QWidget::inputMethodHints() const
{
@ -10507,8 +10488,6 @@ void QWidget::setShortcutAutoRepeat(int id, bool enable)
/*!
Updates the widget's micro focus.
\sa QInputContext
*/
void QWidget::updateMicroFocus()
{

View File

@ -90,7 +90,6 @@ class QDragLeaveEvent;
class QDropEvent;
class QShowEvent;
class QHideEvent;
class QInputContext;
class QIcon;
class QBackingStore;
class QPlatformWindow;
@ -599,8 +598,6 @@ public:
void ensurePolished() const;
QInputContext *inputContext();
bool isAncestorOf(const QWidget *child) const;
#ifdef QT_KEYPAD_NAVIGATION

View File

@ -1594,7 +1594,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value RSIP_OnMouseClick Requests an input panel if the user clicks on the
widget.
\sa QEvent::RequestSoftwareInputPanel, QInputContext
\sa QInputMethod
*/
/*!

View File

@ -56,7 +56,6 @@
#include <QtWidgets/QApplication>
#include <QtWidgets/QMessageBox>
#include <QtWidgets/QInputContext>
#include <QtWidgets/QStyleFactory>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QPushButton>