Permalink
Browse files

Create QUimPlatformInputContext for Qt5.

* configure.ac
  - Change file name from quiminputcontextplugin.pro
    to quimplatforminputcontextplugin.pro
* qt4/immodule/candidatewindowproxy.cpp
* qt4/immodule/candidatewindowproxy.h
* qt4/immodule/plugin.cpp
* qt4/immodule/qhelpermanager.cpp
* qt4/immodule/qtextutil.cpp
* qt4/immodule/qtextutil.h
* qt4/immodule/quiminputcontext_compose.cpp
* qt4/immodule/quiminputcontext_compose.h
* qt4/immodule/quiminputcontext_with_slave.h
  - Use QUimPlatformInputContext for Qt5.
* qt4/immodule/quiminputcontext.cpp
* qt4/immodule/quiminputcontext.h
  - Remove lines for Qt5.
* qt5/immodule/quimplatforminputcontext.cpp
* qt5/immodule/quimplatforminputcontext.h
  - New files.
* qt5/immodule/quiminputcontextplugin.pro.in
  - (HEADERS)
    * Add quimplatforminputcontext.h.
    * Remove quiminputcontext.h.
  - (SOURCES)
    * Add quimplatforminputcontext.cpp.
    * Remove quiminputcontext.cpp.
  - (TARGET): Rename to uimplatforminputcontextplugin.
  • Loading branch information...
1 parent 1051e07 commit 98827163d9f37e9a861368835f8532000842b1b5 @mnogu committed May 3, 2012
View
@@ -2036,7 +2036,7 @@ AC_CONFIG_FILES([Makefile
qt5/chardict/Makefile
qt5/chardict/uim-chardict-qt5.pro
qt5/edittest/Makefile
- qt5/immodule/quiminputcontextplugin.pro
+ qt5/immodule/quimplatforminputcontextplugin.pro
qt5/immodule/Makefile
qt5/pref/uim-pref-qt5.pro
qt5/pref/Makefile
@@ -2144,7 +2144,7 @@ if test x$use_qt5 = xyes; then
fi
if test x$use_qt5_immodule = xyes; then
${QMAKE5} -o ${ac_abs_top_builddir}/qt5/immodule/Makefile.qmake \
- ${ac_abs_top_builddir}/qt5/immodule/quiminputcontextplugin.pro
+ ${ac_abs_top_builddir}/qt5/immodule/quimplatforminputcontextplugin.pro
${QMAKE5} -o ${ac_abs_top_builddir}/qt5/edittest/Makefile.qmake \
${ac_abs_top_srcdir}/qt4/edittest/edittest.pro
fi
@@ -50,7 +50,11 @@
#include <uim-scm.h>
-#include "quiminputcontext.h"
+#if QT_VERSION < 0x050000
+# include "quiminputcontext.h"
+#else
+# include "quimplatforminputcontext.h"
+#endif
CandidateWindowProxy::CandidateWindowProxy()
: ic(0), nrCandidates(0), displayLimit(0), candidateIndex(-1), pageIndex(-1),
@@ -44,7 +44,11 @@ class QProcess;
class QRect;
class QTimer;
+#if QT_VERSION < 0x050000
class QUimInputContext;
+#else
+class QUimPlatformInputContext;
+#endif
class CandidateWindowProxy : public QObject
{
@@ -68,7 +72,12 @@ class CandidateWindowProxy : public QObject
void layoutWindow(int x, int y, int height);
+#if QT_VERSION < 0x050000
void setQUimInputContext(QUimInputContext *m_ic) { ic = m_ic; }
+#else
+ void setQUimPlatformInputContext(QUimPlatformInputContext *m_ic)
+ { ic = m_ic; }
+#endif
void candidateActivate(int nr, int displayLimit);
#ifdef UIM_QT_USE_DELAY
@@ -110,7 +119,11 @@ class CandidateWindowProxy : public QObject
bool eventFilter(QObject *obj, QEvent *event);
QProcess *process;
+#if QT_VERSION < 0x050000
QUimInputContext *ic;
+#else
+ QUimPlatformInputContext *ic;
+#endif
// candidate data
QList<uim_candidate> stores;
@@ -101,7 +101,12 @@ QPlatformInputContext *UimInputContextPlugin::create( const QString & key, const
if ( key == "uim" )
imname = uim_get_default_im_name( setlocale( LC_CTYPE, 0 ) );
+#if QT_VERSION < 0x050000
QUimInputContext *uic = new QUimInputContext( imname.toUtf8().data() );
+#else
+ QUimPlatformInputContext *uic
+ = new QUimPlatformInputContext( imname.toUtf8().data() );
+#endif
return uic;
}
@@ -43,15 +43,27 @@ SUCH DAMAGE.
#include "plugin.h"
#include "quiminfomanager.h"
-#include "quiminputcontext.h"
+#if QT_VERSION < 0x050000
+# include "quiminputcontext.h"
+#else
+# include "quimplatforminputcontext.h"
+#endif
static int im_uim_fd = 0;
static QSocketNotifier *notifier = 0;
+#if QT_VERSION < 0x050000
extern QUimInputContext *focusedInputContext;
+#else
+extern QUimPlatformInputContext *focusedInputContext;
+#endif
extern bool disableFocusedContext;
+#if QT_VERSION < 0x050000
extern QList<QUimInputContext *> contextList;
+#else
+extern QList<QUimPlatformInputContext *> contextList;
+#endif
QUimHelperManager::QUimHelperManager( QObject *parent )
: QObject( parent )
@@ -153,7 +165,11 @@ void QUimHelperManager::parseHelperStr( const QString &str )
if ( !list.isEmpty() && !list[ 0 ].isEmpty() &&
!list[ 1 ].isEmpty() && !list[ 2 ].isEmpty() )
{
+#if QT_VERSION < 0x050000
QList<QUimInputContext *>::iterator it;
+#else
+ QList<QUimPlatformInputContext *>::iterator it;
+#endif
for ( it = contextList.begin(); it != contextList.end(); ++it )
{
uim_prop_update_custom( ( *it )->uimContext(),
@@ -177,7 +193,11 @@ void QUimHelperManager::parseHelperStr( const QString &str )
UimInputContextPlugin::getQUimInfoManager();
infoManager->initUimInfo();
+#if QT_VERSION < 0x050000
QList<QUimInputContext *>::iterator it;
+#else
+ QList<QUimPlatformInputContext *>::iterator it;
+#endif
for ( it = contextList.begin(); it != contextList.end(); ++it ) {
( *it )->updatePosition();
( *it )->updateStyle();
@@ -203,7 +223,11 @@ void QUimHelperManager::parseHelperStrImChange( const QString &str )
}
else if ( str.startsWith( QLatin1String( "im_change_whole_desktop" ) ) )
{
+#if QT_VERSION < 0x050000
QList<QUimInputContext *>::iterator it;
+#else
+ QList<QUimPlatformInputContext *>::iterator it;
+#endif
for ( it = contextList.begin(); it != contextList.end(); ++it )
{
uim_switch_im( ( *it )->uimContext(), im_name.toUtf8().data() );
@@ -218,7 +242,11 @@ void QUimHelperManager::parseHelperStrImChange( const QString &str )
{
if ( focusedInputContext )
{
+#if QT_VERSION < 0x050000
QList<QUimInputContext *>::iterator it;
+#else
+ QList<QUimPlatformInputContext *>::iterator it;
+#endif
for ( it = contextList.begin(); it != contextList.end(); ++it )
{
uim_switch_im( ( *it )->uimContext(), im_name.toUtf8().data() );
@@ -283,7 +311,11 @@ void QUimHelperManager::helper_disconnect_cb()
void QUimHelperManager::update_prop_list_cb( void *ptr, const char *str )
{
+#if QT_VERSION < 0x050000
QUimInputContext *ic = static_cast<QUimInputContext*>( ptr );
+#else
+ QUimPlatformInputContext *ic = static_cast<QUimPlatformInputContext*>( ptr );
+#endif
if ( ic != focusedInputContext || disableFocusedContext )
return;
@@ -298,7 +330,11 @@ void QUimHelperManager::update_prop_list_cb( void *ptr, const char *str )
void QUimHelperManager::update_prop_label_cb( void *ptr, const char *str )
{
+#if QT_VERSION < 0x050000
QUimInputContext *ic = static_cast<QUimInputContext*>( ptr );
+#else
+ QUimPlatformInputContext *ic = static_cast<QUimPlatformInputContext*>( ptr );
+#endif
if ( ic != focusedInputContext || disableFocusedContext )
return;
@@ -49,12 +49,20 @@ SUCH DAMAGE.
# include <QtWidgets/QTextEdit>
#endif
+#if QT_VERSION < 0x050000
#include "quiminputcontext.h"
+#else
+#include "quimplatforminputcontext.h"
+#endif
QUimTextUtil::QUimTextUtil( QObject *parent )
: QObject( parent )
{
+#if QT_VERSION < 0x050000
mIc = static_cast<QUimInputContext *>( parent );
+#else
+ mIc = static_cast<QUimPlatformInputContext *>( parent );
+#endif
mPreeditSaved = false;
}
@@ -69,7 +77,12 @@ QUimTextUtil::acquire_text_cb( void *ptr, enum UTextArea text_id,
char **former, char **latter )
{
int err;
+#if QT_VERSION < 0x050000
QUimInputContext *ic = static_cast<QUimInputContext *>( ptr );
+#else
+ QUimPlatformInputContext *ic
+ = static_cast<QUimPlatformInputContext *>( ptr );
+#endif
QUimTextUtil *tu = ic->textUtil();
switch ( text_id ) {
@@ -99,7 +112,12 @@ QUimTextUtil::delete_text_cb( void *ptr, enum UTextArea text_id,
int former_req_len, int latter_req_len )
{
int err;
+#if QT_VERSION < 0x050000
QUimInputContext *ic = static_cast<QUimInputContext *>( ptr );
+#else
+ QUimPlatformInputContext *ic
+ = static_cast<QUimPlatformInputContext *>( ptr );
+#endif
QUimTextUtil *tu = ic->textUtil();
switch ( text_id ) {
@@ -37,7 +37,11 @@ SUCH DAMAGE.
#include "uim/uim.h"
+#if QT_VERSION < 0x050000
class QUimInputContext;
+#else
+class QUimPlatformInputContext;
+#endif
class QUimTextUtil : QObject
{
@@ -118,7 +122,11 @@ class QUimTextUtil : QObject
void restorePreedit();
QWidget *mWidget;
+#if QT_VERSION < 0x050000
QUimInputContext *mIc;
+#else
+ QUimPlatformInputContext *mIc;
+#endif
bool mPreeditSaved;
};
@@ -37,15 +37,10 @@
#include <cstring>
#include <QtCore/QPoint>
+#include <QtGui/QApplication>
#include <QtGui/QInputMethodEvent>
+#include <QtGui/QLabel>
#include <QtGui/QTextCharFormat>
-#if QT_VERSION < 0x050000
-# include <QtGui/QApplication>
-# include <QtGui/QLabel>
-#else
-# include <QtWidgets/QApplication>
-# include <QtWidgets/QLabel>
-#endif
#include <uim/uim-helper.h>
#include <uim/uim-im-switcher.h>
@@ -374,9 +369,7 @@ void QUimInputContext::setFocusWidget( QWidget *w )
qDebug( "QUimInputContext::setFocusWidget() w = %p", w );
#endif
-#if QT_VERSION < 0x050000
QInputContext::setFocusWidget( w );
-#endif
if ( w )
setFocus();
@@ -630,9 +623,7 @@ void QUimInputContext::commitString( const QString& str )
{
QInputMethodEvent e;
e.setCommitString( str );
-#if QT_VERSION < 0x050000
sendEvent( e );
-#endif
m_isComposing = false;
}
@@ -662,9 +653,7 @@ void QUimInputContext::updatePreedit()
if ( !newString.isEmpty() ) {
QInputMethodEvent e( newString, getPreeditAttrs() );
-#if QT_VERSION < 0x050000
sendEvent( e );
-#endif
// Qt4.3.1 does not call back update() here
update();
} else {
@@ -36,12 +36,7 @@
#define UIM_QT4_IMMODULE_QUIMINPUTCONTEXT_H
#include <QtCore/QtGlobal>
-#if QT_VERSION < 0x050000
-# include <QtGui/QInputContext>
-#else
-# include <QtGui/QInputMethodEvent>
-# include <QtGui/QPlatformInputContext>
-#endif
+#include <QtGui/QInputContext>
#ifdef Q_WS_X11
#define UIM_QT_USE_JAPANESE_KANA_KEYBOARD_HACK 1
@@ -75,11 +70,7 @@ struct PreeditSegment
QString str;
};
-#if QT_VERSION < 0x050000
class QUimInputContext : public QInputContext
-#else
-class QUimInputContext : public QPlatformInputContext
-#endif
{
Q_OBJECT
public:
@@ -57,7 +57,11 @@
#include "uim/uim.h"
+#if QT_VERSION < 0x050000
#include "quiminputcontext.h"
+#else
+#include "quimplatforminputcontext.h"
+#endif
static const char COMPOSE_FILE[] = "Compose";
static const char COMPOSE_DIR_FILE[] = "X11/locale/compose.dir";
@@ -73,7 +77,11 @@ static inline bool iscomment(char ch)
static int parse_line(char *line, char **argv, int argsize);
static unsigned int KeySymToUcs4(KeySym keysym);
+#if QT_VERSION < 0x050000
Compose::Compose(DefTree *top, QUimInputContext *ic)
+#else
+Compose::Compose(DefTree *top, QUimPlatformInputContext *ic)
+#endif
{
m_ic = ic;
m_composed = 0;
@@ -59,16 +59,30 @@ typedef struct _DefTree {
KeySym ks;
} DefTree;
+#include <QtCore/QtGlobal>
+
+#if QT_VERSION < 0x050000
class QUimInputContext;
+#else
+class QUimPlatformInputContext;
+#endif
class Compose {
public:
+#if QT_VERSION < 0x050000
Compose(DefTree *, QUimInputContext *);
+#else
+ Compose(DefTree *, QUimPlatformInputContext *);
+#endif
~Compose();
bool handle_qkey(const QKeyEvent *event);
void reset();
private:
bool handleKey(KeySym xkeysym, int xstate, bool is_push);
+#if QT_VERSION < 0x050000
QUimInputContext *m_ic;
+#else
+ QUimPlatformInputContext *m_ic;
+#endif
DefTree *m_top;
DefTree *m_context;
DefTree *m_composed;
Oops, something went wrong.

0 comments on commit 9882716

Please sign in to comment.