├── debian ├── compat ├── source │ └── format ├── patches │ ├── series │ └── binutils-gold ├── libibus-qt1.install ├── ibus-qt4.install ├── libibus-qt-dev.install ├── watch ├── clean ├── copyright ├── rules ├── control └── changelog ├── src ├── .gitignore ├── interfaces │ ├── introspect_dbus.py │ ├── introspect_ibus.py │ ├── introspect_config.py │ ├── introspect_engine.py │ ├── introspect_panel.py │ ├── introspect_factory.py │ ├── introspect_inputcontext.py │ ├── org.freedesktop.IBus.EngineFactory.xml │ ├── xml2cpp.sh │ ├── org.freedesktop.IBus.Config.xml │ ├── org.freedesktop.IBus.xml │ ├── org.freedesktop.DBus.xml │ ├── org.freedesktop.IBus.Panel.xml │ ├── org.freedesktop.IBus.InputContext.xml │ └── org.freedesktop.IBus.Engine.xml ├── qibus.h ├── qibusobject.cpp ├── qibusattribute.cpp ├── qibusconfig.h ├── qibusdbusproxy.cpp ├── qibusibusproxy.cpp ├── qibusproplist.h ├── qibusconfigproxy.cpp ├── qibusattrlist.h ├── qibusinputcontextproxy.cpp ├── qibustext.h ├── qibusconfigservice.cpp ├── qibustext.cpp ├── qibusenginefactory.h ├── qibusobject.h ├── qibusattrlist.cpp ├── qibusconfigservice.h ├── qibusproplist.cpp ├── qibusobservedpath.h ├── qibusfactoryadaptor.cpp ├── qibuspointer.h ├── qibusfactoryadaptor.h ├── qibustypes.h ├── qibusconfig.cpp ├── qibusconfigadaptor.cpp ├── qibusattribute.h ├── ibus.cpp ├── qibusproperty.h ├── qibusproperty.cpp ├── qibusbus.h ├── qibuslookuptable.h ├── qibusenginefactory.cpp ├── qibusconfigadaptor.h ├── qibusenginedesc.h ├── qibusconfigproxy.h ├── qibuscomponent.h ├── CMakeLists.txt ├── qibusibusproxy.h ├── qibusserializable.cpp ├── qibusdbusproxy.h ├── qibusinputcontext.h ├── qibusobservedpath.cpp ├── qibusenginedesc.cpp ├── qibusengine.cpp ├── qibusengineadaptor.cpp ├── qibuslookuptable.cpp ├── qibuspaneladaptor.h ├── qibusserializable.h ├── qibusinputcontextproxy.h ├── qibusengineadaptor.h ├── qibuspaneladaptor.cpp ├── qibusinputcontext.cpp └── qibusengine.h ├── test ├── .gitignore ├── qibusdemoengine.h ├── CMakeLists.txt ├── diffdist.sh ├── main.cpp └── qibusdemoengine.cpp ├── docs ├── .gitignore └── CMakeLists.txt ├── AUTHORS ├── README ├── codereview.settings ├── .gitignore ├── INSTALL ├── TODO ├── qtim ├── CMakeLists.txt ├── ibus-input-context.h └── ibus-plugin.cpp ├── .travis.yml ├── cmake └── FindICU.cmake ├── ibus-qt.spec.in └── CMakeLists.txt /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | ibus-test 2 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | demo-engine 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/patches/series: -------------------------------------------------------------------------------- 1 | binutils-gold 2 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | html 2 | man 3 | Doxyfile 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Peng Huang 2 | -------------------------------------------------------------------------------- /debian/libibus-qt1.install: -------------------------------------------------------------------------------- 1 | debian/tmp/usr/lib/libibus-qt.so.1* 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ibus-qt 2 | It includes ibus qt library and ibus qt input method plugin. 3 | -------------------------------------------------------------------------------- /debian/ibus-qt4.install: -------------------------------------------------------------------------------- 1 | debian/tmp/usr/lib/qt4/* 2 | debian/tmp/usr/share/* 3 | -------------------------------------------------------------------------------- /debian/libibus-qt-dev.install: -------------------------------------------------------------------------------- 1 | debian/tmp/usr/include/* 2 | debian/tmp/usr/lib/libibus-qt.so 3 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(docs 2 | COMMAND ${DOXYGEN_EXECUTABLE} 3 | SOURCES Doxyfile 4 | ) 5 | -------------------------------------------------------------------------------- /src/interfaces/introspect_dbus.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import ibus 4 | bus = ibus.Bus() 5 | print bus.introspect_dbus() 6 | -------------------------------------------------------------------------------- /src/interfaces/introspect_ibus.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import ibus 4 | bus = ibus.Bus() 5 | print bus.introspect_ibus() 6 | -------------------------------------------------------------------------------- /codereview.settings: -------------------------------------------------------------------------------- 1 | # This file is used by "git cl" to get code review information. 2 | CODE_REVIEW_SERVER: codereview.appspot.com 3 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | http://code.google.com/p/ibus/downloads/list \ 3 | http://ibus.googlecode.com/files/ibus-qt-([0-9].*)-Source\.tar\.gz 4 | -------------------------------------------------------------------------------- /src/interfaces/introspect_config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import ibus 4 | import dbus 5 | 6 | bus = dbus.SessionBus() 7 | e = ibus.interface.IConfig() 8 | print e.Introspect("/", bus) 9 | 10 | -------------------------------------------------------------------------------- /src/interfaces/introspect_engine.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import ibus 4 | import dbus 5 | 6 | bus = dbus.SessionBus() 7 | e = ibus.interface.IEngine() 8 | print e.Introspect("/", bus) 9 | 10 | -------------------------------------------------------------------------------- /src/interfaces/introspect_panel.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import ibus 4 | import dbus 5 | 6 | bus = dbus.SessionBus() 7 | e = ibus.interface.IPanel() 8 | print e.Introspect("/", bus) 9 | 10 | -------------------------------------------------------------------------------- /src/interfaces/introspect_factory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import ibus 4 | import dbus 5 | 6 | bus = dbus.SessionBus() 7 | e = ibus.interface.IEngineFactory() 8 | print e.Introspect("/", bus) 9 | 10 | -------------------------------------------------------------------------------- /src/interfaces/introspect_inputcontext.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import ibus 4 | bus = ibus.Bus() 5 | ic = bus.create_input_context ("aa") 6 | context = ibus.InputContext (bus, ic) 7 | print context.introspect() 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.cmake 3 | CMakeFiles 4 | _CPack_Packages 5 | install_manifest.txt 6 | CMakeCache.txt 7 | .*.swp 8 | *.so 9 | *.so.* 10 | moc_*.cxx 11 | tags 12 | *.gz 13 | *.rpm 14 | ibus-qt.spec 15 | rpm 16 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | # how to build 2 | mkdir build 3 | cd build 4 | cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-Wall" # -DLIBDIR=lib64 5 | make VERBOSE=1 6 | make install # DESTDIR= 7 | make docs # to create API document 8 | -------------------------------------------------------------------------------- /src/qibus.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_H_ 2 | #define __Q_IBUS_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /debian/clean: -------------------------------------------------------------------------------- 1 | src/libibus-qt.so 2 | qtim/libqtim-ibus.so 3 | CMakeCache.txt 4 | CPackConfig.cmake 5 | CPackSourceConfig.cmake 6 | Makefile 7 | cmake_install.cmake 8 | ibus-qt.spec 9 | install_manifest.txt 10 | qtim/Makefile 11 | qtim/cmake_install.cmake 12 | src/Makefile 13 | src/cmake_install.cmake 14 | docs/Doxyfile 15 | docs/Makefile 16 | docs/cmake_install.cmake 17 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | 2 | 3 | == data struct == 4 | IBusSerializable phuang 100% 5 | IBusText phuang 100% 6 | IBusAttribute liudl 100% 7 | IBusAttrList liudl 100% 8 | IBusProperty luoxs 100% 9 | IBusPropList luoxs 100% 10 | IBusLookupTable luoxs 100% 11 | IBusEngineDesc luoxs 100% 12 | IBusComponent luoxs 100% 13 | IBusEngine luoxs 80% 14 | -------------------------------------------------------------------------------- /src/qibusobject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qibusobject.h" 3 | 4 | namespace IBus { 5 | /** 6 | * @brief Destructor of Object 7 | * 8 | * @return 9 | */ 10 | Object::~Object () 11 | { 12 | if (m_referenced && m_refcount != 0) { 13 | qWarning () << "Object::~Object:" << "Delete an object with refcount != 0"; 14 | } 15 | } 16 | 17 | /** 18 | * @brief Destroy the object 19 | * 20 | * @return 21 | */ 22 | void 23 | Object::destroy () 24 | { 25 | delete this; 26 | } 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /src/interfaces/org.freedesktop.IBus.EngineFactory.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/qibusattribute.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusattribute.h" 2 | 3 | namespace IBus { 4 | 5 | IBUS_DECLARE_SERIALIZABLE(Attribute, IBusAttribute); 6 | 7 | bool 8 | Attribute::serialize (QDBusArgument &argument) 9 | { 10 | if (!Serializable::serialize (argument)) { 11 | return false; 12 | } 13 | 14 | argument << m_type; 15 | argument << m_value; 16 | argument << m_start; 17 | argument << m_end; 18 | 19 | return true; 20 | } 21 | 22 | bool 23 | Attribute::deserialize (const QDBusArgument &argument) 24 | { 25 | if (!Serializable::deserialize (argument)) { 26 | return false; 27 | } 28 | 29 | argument >> m_type; 30 | argument >> m_value; 31 | argument >> m_start; 32 | argument >> m_end; 33 | 34 | return true; 35 | } 36 | 37 | }; 38 | -------------------------------------------------------------------------------- /src/qibusconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_CONFIG_H_ 2 | #define __Q_IBUS_CONFIG_H_ 3 | 4 | #include 5 | #include 6 | #include "qibusobject.h" 7 | 8 | class IBusConfigProxy; 9 | 10 | namespace IBus { 11 | 12 | class Config : public QObject 13 | { 14 | Q_OBJECT 15 | 16 | public : 17 | Config (const QDBusConnection &conn); 18 | virtual ~Config (); 19 | 20 | public : 21 | 22 | bool getValue (const QString §ion, const QString &name); // need to process return value; 23 | bool setValue (const QString §ion, const QString &name, const QDBusVariant &value); 24 | bool unset (const QString §ion, const QString &name); 25 | void destroy (void); 26 | 27 | private : 28 | 29 | QDBusConnection m_conn; 30 | IBusConfigProxy *m_config; 31 | }; 32 | 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/qibusdbusproxy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -p qibusdbusproxy -c DBusProxy -v org.freedesktop.DBus.xml org.freedesktop.DBus 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "qibusdbusproxy.h" 13 | 14 | /* 15 | * Implementation of interface class DBusProxy 16 | */ 17 | 18 | DBusProxy::DBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | DBusProxy::~DBusProxy() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/qibusibusproxy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -p qibusibusproxy -c IBusProxy -v org.freedesktop.IBus.xml org.freedesktop.IBus 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "qibusibusproxy.h" 13 | 14 | /* 15 | * Implementation of interface class IBusProxy 16 | */ 17 | 18 | IBusProxy::IBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | IBusProxy::~IBusProxy() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/interfaces/xml2cpp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | qdbusxml2cpp -p qibusibusproxy -c IBusProxy -v org.freedesktop.IBus.xml org.freedesktop.IBus 4 | qdbusxml2cpp -p qibusdbusproxy -c DBusProxy -v org.freedesktop.DBus.xml org.freedesktop.DBus 5 | qdbusxml2cpp -p qibusinputcontextproxy -c IBusInputContextProxy -v org.freedesktop.IBus.InputContext.xml org.freedesktop.IBus.InputContext 6 | qdbusxml2cpp -a qibusengineadaptor -c IBusEngineAdaptor -v org.freedesktop.IBus.Engine.xml org.freedesktop.IBus.Engine 7 | 8 | qdbusxml2cpp -a qibusconfigadaptor -c IBusConfigAdaptor -v org.freedesktop.IBus.Config.xml org.freedesktop.IBus.Config 9 | qdbusxml2cpp -p qibusconfigproxy -c IBusConfigProxy -v org.freedesktop.IBus.Config.xml org.freedesktop.IBus.Config 10 | 11 | qdbusxml2cpp -a qibuspaneladaptor -c IBusPanelAdaptor -v org.freedesktop.IBus.Panel.xml org.freedesktop.IBus.Panel 12 | -------------------------------------------------------------------------------- /test/qibusdemoengine.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_HANGUL_ENGINE_H_ 2 | #define __Q_IBUS_HANGUL_ENGINE_H_ 3 | 4 | #include 5 | 6 | using namespace IBus; 7 | 8 | class DemoEngine : public Engine 9 | { 10 | Q_OBJECT 11 | 12 | public : 13 | Q_INVOKABLE DemoEngine (const QString &name); 14 | virtual ~DemoEngine (); 15 | 16 | private : 17 | void propertyActivate (const QString &prop_name, int prop_state); 18 | void closeLookupTable (); 19 | 20 | private : 21 | // virtual function 22 | bool processKeyEvent (uint keyval, uint keycode, uint state); 23 | 24 | private : 25 | 26 | QString m_context; // store keyboard input 27 | 28 | LookupTablePointer m_lookupTable; 29 | PropertyPointer m_prop; 30 | PropListPointer m_propList; 31 | TextPointer m_candicate; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/qibusproplist.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_PROP_LIST_H_ 2 | #define __Q_IBUS_PROP_LIST_H_ 3 | 4 | #include "qibusserializable.h" 5 | #include "qibusproperty.h" 6 | #include "qibustext.h" 7 | 8 | namespace IBus { 9 | 10 | class Property; 11 | class PropList; 12 | typedef Pointer PropListPointer; 13 | typedef Pointer PropertyPointer; 14 | 15 | class PropList: public Serializable 16 | { 17 | Q_OBJECT; 18 | 19 | public: 20 | PropList () {} 21 | ~PropList () {} 22 | 23 | public: 24 | virtual bool serialize (QDBusArgument &argument); 25 | virtual bool deserialize (const QDBusArgument &argument); 26 | 27 | public : 28 | bool appendProperty (const PropertyPointer &prop); 29 | bool updateProperty (const PropertyPointer &prop); 30 | 31 | private: 32 | QVector m_props; 33 | 34 | IBUS_SERIALIZABLE 35 | }; 36 | 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/qibusconfigproxy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -p qibusconfigproxy -c IBusConfigProxy -v org.freedesktop.IBus.Config.xml org.freedesktop.IBus.Config 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "qibusconfigproxy.h" 13 | 14 | /* 15 | * Implementation of interface class IBusConfigProxy 16 | */ 17 | 18 | IBusConfigProxy::IBusConfigProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | IBusConfigProxy::~IBusConfigProxy() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | ${QT_QTCORE_INCLUDE_DIR} 3 | ${QT_QTDBUS_INCLUDE_DIR} 4 | ${DBUS_INCLUDE_DIRS} 5 | ${IBUS_INCLUDE_DIRS} 6 | ${CMAKE_CURRENT_SOURCE_DIR}/../src 7 | ) 8 | 9 | link_directories( 10 | ${DBUS_LIBRARY_DIRS} 11 | ${ICU_LIBRARY_DIRS} 12 | ) 13 | 14 | set( 15 | demo_engine_SRCS 16 | qibusdemoengine.cpp 17 | main.cpp 18 | ) 19 | 20 | set( 21 | demo_engine_MOC_HDRS 22 | qibusdemoengine.h 23 | ) 24 | 25 | QT4_AUTOMOC(${demo_engine_SRCS}) 26 | QT4_WRAP_CPP( 27 | demo_engine_MOC_SRCS 28 | ${demo_engine_MOC_HDRS} 29 | ) 30 | 31 | add_executable( 32 | demo-engine 33 | ${demo_engine_SRCS} 34 | ${demo_engine_MOC_SRCS} 35 | ) 36 | 37 | target_link_libraries( 38 | demo-engine 39 | debug ${QT_QTGUI_LIBRARY_DEBUG} 40 | optimized ${QT_QTGUI_LIBRARY_RELEASE} 41 | ${ICU_LIBRARIES} 42 | ibus-qt 43 | ) 44 | -------------------------------------------------------------------------------- /src/qibusattrlist.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_ATTRLIST_H_ 2 | #define __Q_IBUS_ATTRLIST_H_ 3 | 4 | #include "qibusattribute.h" 5 | #include 6 | 7 | namespace IBus { 8 | 9 | class AttrList; 10 | typedef Pointer AttrListPointer; 11 | 12 | class AttrList : public Serializable { 13 | Q_OBJECT 14 | public : 15 | AttrList (): m_attrs (0) {} 16 | virtual ~AttrList (); 17 | 18 | public : 19 | AttributePointer get(int index) const; 20 | void append (const AttributePointer &attr); 21 | void clear (void); 22 | uint size (void) const { return m_attrs.size (); } 23 | 24 | AttributePointer operator[] (int index) const { return get (index); } 25 | 26 | virtual bool serialize (QDBusArgument &argument); 27 | virtual bool deserialize (const QDBusArgument &argument); 28 | 29 | private : 30 | QVector m_attrs; 31 | 32 | IBUS_SERIALIZABLE 33 | }; 34 | 35 | } /* IBUS */ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/qibusinputcontextproxy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -p qibusinputcontextproxy -c IBusInputContextProxy -v org.freedesktop.IBus.InputContext.xml org.freedesktop.IBus.InputContext 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #include "qibusinputcontextproxy.h" 13 | 14 | /* 15 | * Implementation of interface class IBusInputContextProxy 16 | */ 17 | 18 | IBusInputContextProxy::IBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) 20 | { 21 | } 22 | 23 | IBusInputContextProxy::~IBusInputContextProxy() 24 | { 25 | } 26 | 27 | -------------------------------------------------------------------------------- /qtim/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | ${QT_QTCORE_INCLUDE_DIR} 3 | ${QT_QTDBUS_INCLUDE_DIR} 4 | ${X11_INCLUDE_DIRS} 5 | ${DBUS_INCLUDE_DIRS} 6 | ${IBUS_INCLUDE_DIRS} 7 | ${CMAKE_CURRENT_SOURCE_DIR}/../src 8 | ) 9 | 10 | link_directories( 11 | ${X11_LIBRARY_DIRS} 12 | ${DBUS_LIBRARY_DIRS} 13 | ${ICU_LIBRARY_DIRS} 14 | ) 15 | 16 | set( 17 | qtim_ibus_SRCS 18 | ibus-input-context.cpp 19 | ibuskeyuni.cpp 20 | ibus-plugin.cpp 21 | ) 22 | 23 | set( 24 | qtim_ibus_MOC_HDRS 25 | ibus-input-context.h 26 | ) 27 | 28 | QT4_AUTOMOC(${qtim_ibus_SRCS}) 29 | QT4_WRAP_CPP( 30 | qtim_ibus_MOC_SRCS 31 | ${qtim_ibus_MOC_HDRS} 32 | ) 33 | 34 | add_library( 35 | qtim-ibus MODULE 36 | ${qtim_ibus_SRCS} 37 | ${qtim_ibus_MOC_SRCS} 38 | ) 39 | 40 | target_link_libraries( 41 | qtim-ibus 42 | debug ${QT_QTGUI_LIBRARY_DEBUG} 43 | optimized ${QT_QTGUI_LIBRARY_RELEASE} 44 | ${ICU_LIBRARIES} 45 | ibus-qt 46 | ) 47 | 48 | install( 49 | TARGETS qtim-ibus 50 | LIBRARY DESTINATION 51 | ${QT_PLUGINS_DIR}/inputmethods) 52 | -------------------------------------------------------------------------------- /debian/patches/binutils-gold: -------------------------------------------------------------------------------- 1 | Description: fix FTBFS with binutils-gold 2 | Author: LI Daobing 3 | Bug-Debian: http://bugs.debian.org/554862 4 | Forwarded: http://code.google.com/p/ibus/issues/detail?id=853 5 | Last-Update: 2010-04-10 6 | 7 | --- ibus-qt-1.3.0.orig/CMakeLists.txt 8 | +++ ibus-qt-1.3.0/CMakeLists.txt 9 | @@ -67,7 +67,7 @@ configure_file(docs/Doxyfile.in docs/Dox 10 | find_package(X11 REQUIRED) 11 | 12 | # check qt 13 | -find_package(Qt4 4.5 COMPONENTS QtCore QtGui QtDBus REQUIRED) 14 | +find_package(Qt4 4.5 COMPONENTS QtCore QtGui QtDBus QtXml REQUIRED) 15 | include(${QT_USE_FILE}) 16 | 17 | # check dbus 18 | --- ibus-qt-1.3.0.orig/src/CMakeLists.txt 19 | +++ ibus-qt-1.3.0/src/CMakeLists.txt 20 | @@ -93,8 +93,10 @@ target_link_libraries( 21 | ibus-qt 22 | debug ${QT_QTCORE_LIBRARY_DEBUG} 23 | debug ${QT_QTDBUS_LIBRARY_DEBUG} 24 | + debug ${QT_QTXML_LIBRARY_DEBUG} 25 | optimized ${QT_QTCORE_LIBRARY_RELEASE} 26 | optimized ${QT_QTDBUS_LIBRARY_RELEASE} 27 | + optimized ${QT_QTXML_LIBRARY_RELEASE} 28 | ${DBUS_LIBRARIES} 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /src/qibustext.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_TEXT_H_ 2 | #define __Q_IBUS_TEXT_H_ 3 | 4 | #include "qibusserializable.h" 5 | #include "qibusattribute.h" 6 | #include "qibusattrlist.h" 7 | 8 | namespace IBus { 9 | 10 | class Text; 11 | typedef Pointer TextPointer; 12 | 13 | class Text : public Serializable 14 | { 15 | Q_OBJECT; 16 | 17 | protected: 18 | 19 | public: 20 | Text () {} 21 | Text (const QString &text) : m_text (text), m_attrs(0) {} 22 | Text (const QChar &ch) : m_text (ch), m_attrs(0) {} 23 | 24 | public: 25 | virtual bool serialize (QDBusArgument &argument); 26 | virtual bool deserialize (const QDBusArgument &argument); 27 | 28 | const QString &text (void) const { return m_text; } 29 | const AttrListPointer &attrs (void) const { return m_attrs; } 30 | const uint getLength (void) const { return m_text.length(); } 31 | void appendAttribute (uint type, uint value, uint startIndex, int endIndex); 32 | 33 | private: 34 | QString m_text; 35 | AttrListPointer m_attrs; 36 | 37 | IBUS_SERIALIZABLE 38 | }; 39 | 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/qibusconfigservice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qibusconfigservice.h" 3 | #include "qibusconfigadaptor.h" 4 | 5 | namespace IBus { 6 | 7 | ConfigService::ConfigService (const QDBusConnection &conn) : m_conn(conn) 8 | { 9 | m_config = new IBusConfigAdaptor (this); 10 | if ( !m_config ) { 11 | qDebug () << "ConfigService::ConfigService, new IBusConfigAdaptor error!"; 12 | } 13 | } 14 | 15 | ConfigService::~ConfigService () 16 | { 17 | if ( NULL != m_config ) { 18 | delete m_config; 19 | m_config = NULL; 20 | } 21 | } 22 | 23 | const QDBusVariant 24 | ConfigService::GetValue (const QString §ion, const QString &name) 25 | { 26 | return getValue (section, name); 27 | } 28 | 29 | void 30 | ConfigService::SetValue (const QString §ion, const QString &name, const QDBusVariant &value) 31 | { 32 | setValue (section, name, value); 33 | } 34 | 35 | void 36 | ConfigService::Unset (const QString §ion, const QString &name) 37 | { 38 | unset (section, name); 39 | } 40 | 41 | void 42 | ConfigService::Destroy (void) 43 | { 44 | destroy (); 45 | } 46 | 47 | }; 48 | -------------------------------------------------------------------------------- /src/qibustext.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qibustext.h" 3 | 4 | namespace IBus { 5 | 6 | IBUS_DECLARE_SERIALIZABLE(Text, IBusText); 7 | 8 | bool 9 | Text::serialize (QDBusArgument &argument) 10 | { 11 | if (!Serializable::serialize (argument)) 12 | return false; 13 | 14 | argument << m_text; 15 | if ( m_attrs.isNull () ) { 16 | m_attrs = new AttrList (); 17 | } 18 | 19 | argument << m_attrs; 20 | return true; 21 | } 22 | 23 | bool 24 | Text::deserialize (const QDBusArgument &argument) 25 | { 26 | if (!Serializable::deserialize (argument)) 27 | return false; 28 | 29 | argument >> m_text; 30 | argument >> m_attrs; 31 | 32 | return true; 33 | } 34 | 35 | void 36 | Text::appendAttribute (uint type, uint value, uint startIndex, int endIndex) 37 | { 38 | if ( endIndex < 0 ) { 39 | endIndex += getLength() + 1; 40 | } 41 | 42 | if ( endIndex <= 0 ) { 43 | return ; 44 | } 45 | 46 | if ( m_attrs.isNull() ) { 47 | m_attrs = new AttrList(); 48 | } 49 | 50 | AttributePointer attribute = new Attribute (type, value, startIndex, endIndex); 51 | m_attrs->append(attribute); 52 | } 53 | 54 | }; 55 | -------------------------------------------------------------------------------- /src/qibusenginefactory.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_FACTORY_ADAPTOR_H_ 2 | #define __Q_IBUS_FACTORY_ADAPTOR_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "qibusobject.h" 8 | 9 | class IBusFactoryAdaptor; 10 | 11 | namespace IBus { 12 | 13 | class Engine; 14 | typedef Pointer EnginePointer; 15 | 16 | class EngineFactory : public Object 17 | { 18 | Q_OBJECT; 19 | 20 | private : 21 | Q_INVOKABLE EngineFactory (const QDBusConnection &conn, uint id = 0); 22 | ~EngineFactory (); 23 | 24 | public: 25 | void addMetaObject (const QString &name, const QMetaObject *metaObject); 26 | static EngineFactory *getEngineFactory (const QDBusConnection &conn); 27 | 28 | protected: 29 | virtual QString createEngine (const QString &name); 30 | 31 | private Q_SLOTS: 32 | Q_INVOKABLE QDBusObjectPath CreateEngine (const QString &name); 33 | Q_INVOKABLE void Destroy (); 34 | 35 | private : 36 | 37 | uint m_id; 38 | QDBusConnection m_conn; 39 | QMap m_engineMap; 40 | QLinkedList m_engineLList; 41 | IBusFactoryAdaptor *m_factoryAdaptor; 42 | 43 | static EngineFactory *m_factory; 44 | }; 45 | 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/interfaces/org.freedesktop.IBus.Config.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/qibusobject.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_OBJECT_H__ 2 | #define __Q_IBUS_OBJECT_H__ 3 | 4 | #include 5 | #include 6 | #include "qibuspointer.h" 7 | 8 | #ifdef QT_USE_NAMESPACE 9 | # undef QT_USE_NAMESPACE 10 | # define QT_USE_NAMESPACE IBus 11 | #endif 12 | 13 | namespace IBus { 14 | 15 | class Object; 16 | typedef Pointer ObjectPointer; 17 | 18 | class Object : public QObject 19 | { 20 | Q_OBJECT 21 | template friend class Pointer; 22 | 23 | public: 24 | // Q_INVOKABLE Object () : m_referenced (false), m_refcount(1) {} 25 | Object () : m_referenced (false), m_refcount(1) {} 26 | virtual ~Object (); 27 | virtual void destroy (); 28 | 29 | private: 30 | Object * ref () { 31 | if (m_referenced) { 32 | m_refcount.ref (); 33 | } 34 | else { 35 | m_referenced = true; 36 | } 37 | return this; 38 | } 39 | 40 | void unref () { 41 | if (! m_refcount.deref ()) { 42 | delete this; 43 | } 44 | } 45 | 46 | bool is_referenced () const { 47 | return m_referenced; 48 | } 49 | 50 | bool m_referenced; 51 | QAtomicInt m_refcount; 52 | }; 53 | 54 | }; 55 | 56 | Q_DECLARE_METATYPE(IBus::ObjectPointer) 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/interfaces/org.freedesktop.IBus.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: gcc 3 | os: linux 4 | 5 | dist: bionic 6 | 7 | branches: 8 | only: 9 | - main 10 | 11 | arch: 12 | - amd64 13 | #- ppc64le 14 | #- s390x 15 | #- arm64 16 | 17 | addons: 18 | apt: 19 | packages: 20 | # For autogen.sh 21 | - autopoint 22 | # For make from 23 | # https://packages.ubuntu.com/search?searchon=sourcenames&keywords=ibus-qt 24 | - cmake 25 | - doxygen 26 | - libdbus-1-dev 27 | - libibus-1.0-dev 28 | - libicu-dev 29 | # libqt4 is available in bionic(18.04) only 30 | - libqt4-dev 31 | - libx11-dev 32 | - pkg-config 33 | - wget 34 | 35 | jobs: 36 | include: 37 | - name: Build 38 | before_script: 39 | - sudo apt-get -qq update 40 | script: 41 | - set -e 42 | - git config pull.rebase false 43 | - git pull --depth=200 44 | # configure options from 45 | # https://salsa.debian.org/debian/ibus-anthy/-/blob/master/debian/rules 46 | - > 47 | cmake . 48 | # Set the cutom DESTDIR because the default DESTDIR 49 | # /home/travis/bulid/fujiwarat/$PKG/ibus/ibus-$VERSION/_inst seems to be 50 | # too long and failed to set DESTDIR to install bindings/pygobject/IBus.py 51 | - > 52 | make 53 | VERBOSE=1 54 | - > 55 | make 56 | package_source 57 | VERBOSE=1 58 | - bash -x ./test/diffdist.sh 59 | 60 | -------------------------------------------------------------------------------- /cmake/FindICU.cmake: -------------------------------------------------------------------------------- 1 | find_program(ICU_CONFIG_EXECUTABLE NAMES icu-config DOC "icu-config executable") 2 | mark_as_advanced(ICU_CONFIG_EXECUTABLE) 3 | 4 | if(ICU_CONFIG_EXECUTABLE) 5 | set(ICU_FOUND "YES") 6 | else(ICU_CONFIG_EXECUTABLE) 7 | set(ICU_FOUND "NO") 8 | # if(ICU_FIND_REQUIRED) 9 | # message(FATAL_ERROR "Could not find icu") 10 | # endif(ICU_FIND_REQUIRED) 11 | endif(ICU_CONFIG_EXECUTABLE) 12 | 13 | if(ICU_FOUND) 14 | # get include dirs 15 | execute_process( 16 | COMMAND ${ICU_CONFIG_EXECUTABLE} --cppflags-searchpath 17 | COMMAND sed s/^-I// 18 | OUTPUT_VARIABLE ICU_INCLUDE_DIRS 19 | OUTPUT_STRIP_TRAILING_WHITESPACE 20 | COMMAND_ERROR_IS_FATAL ANY 21 | ) 22 | separate_arguments(ICU_INCLUDE_DIRS) 23 | 24 | # get libraries 25 | execute_process( 26 | COMMAND ${ICU_CONFIG_EXECUTABLE} --ldflags-searchpath 27 | OUTPUT_VARIABLE ICU_LIBRARY_DIRS 28 | OUTPUT_STRIP_TRAILING_WHITESPACE 29 | COMMAND_ERROR_IS_FATAL ANY 30 | ) 31 | separate_arguments(ICU_LIBRARY_DIRS) 32 | 33 | execute_process( 34 | COMMAND ${ICU_CONFIG_EXECUTABLE} --ldflags-libsonly 35 | OUTPUT_VARIABLE ICU_LIBRARIES 36 | OUTPUT_STRIP_TRAILING_WHITESPACE 37 | COMMAND_ERROR_IS_FATAL ANY 38 | ) 39 | separate_arguments(ICU_LIBRARIES) 40 | 41 | endif(ICU_FOUND) 42 | 43 | include(FindPackageHandleStandardArgs) 44 | find_package_handle_standard_args(ICU DEFAULT_MSG 45 | ICU_LIBRARIES ICU_LIBRARY_DIRS ICU_INCLUDE_DIRS) 46 | -------------------------------------------------------------------------------- /src/qibusattrlist.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusattrlist.h" 2 | 3 | namespace IBus { 4 | 5 | IBUS_DECLARE_SERIALIZABLE(AttrList, IBusAttrList); 6 | 7 | AttrList::~AttrList () 8 | { 9 | m_attrs.clear(); 10 | } 11 | 12 | AttributePointer AttrList::get (int index) const 13 | { 14 | if (index >= m_attrs.size ()) { 15 | return NULL; 16 | } 17 | 18 | return m_attrs[index]; 19 | } 20 | 21 | void AttrList::append (const AttributePointer &attr) 22 | { 23 | if (attr.isNull ()) 24 | return; 25 | 26 | m_attrs.append (attr); 27 | } 28 | 29 | void AttrList::clear (void) 30 | { 31 | m_attrs.clear (); 32 | } 33 | 34 | bool AttrList::serialize (QDBusArgument &argument) 35 | { 36 | if (!Serializable::serialize (argument)) { 37 | return false; 38 | } 39 | 40 | argument.beginArray (qMetaTypeId()); 41 | for (int i = 0; i < m_attrs.size(); i++) { 42 | argument << m_attrs[i]; 43 | } 44 | argument.endArray (); 45 | 46 | return true; 47 | } 48 | 49 | bool AttrList::deserialize (const QDBusArgument &argument) 50 | { 51 | clear (); 52 | 53 | if (!Serializable::deserialize (argument)) { 54 | return false; 55 | } 56 | 57 | argument.beginArray (); 58 | while (!argument.atEnd ()) { 59 | AttributePointer attr; 60 | argument >> attr; 61 | append (attr); 62 | } 63 | argument.endArray (); 64 | 65 | return true; 66 | } 67 | 68 | } /* IBus */ 69 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by: 2 | 3 | LI Daobing on Tue, 28 Jul 2009 22:32:34 +0800 4 | 5 | It was downloaded from: 6 | 7 | http://code.google.com/p/ibus 8 | 9 | Upstream Author: 10 | 11 | Huang Peng 12 | 13 | Copyright: 14 | 15 | Copyright (C) 2007-2008 Huang Peng 16 | 17 | License: 18 | 19 | This program is free software; you can redistribute it and/or modify 20 | it under the terms of the GNU General Public License as published by 21 | the Free Software Foundation; either version 2 of the License, or 22 | (at your option) any later version. 23 | 24 | This program is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | 29 | You should have received a copy of the GNU General Public License along 30 | with this program; if not, write to the Free Software Foundation, Inc., 31 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 32 | 33 | On Debian systems, the complete text of the GNU General 34 | Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'. 35 | 36 | The Debian packaging is: 37 | 38 | Copyright (C) 2009 LI Daobing 39 | 40 | and is licensed under the same license as ibus-qt. 41 | -------------------------------------------------------------------------------- /src/qibusconfigservice.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_CONFIG_H_ 2 | #define __Q_IBUS_CONFIG_H_ 3 | 4 | #include 5 | #include 6 | #include "qibusobject.h" 7 | 8 | class IBusConfigAdaptor; 9 | 10 | namespace IBus { 11 | 12 | class ConfigService; 13 | typedef Pointer ConfigServicePointer; 14 | 15 | class ConfigService : public QObject 16 | { 17 | Q_OBJECT 18 | 19 | public : 20 | 21 | ConfigService (const QDBusConnection &conn); 22 | virtual ~ConfigService (); 23 | 24 | private : 25 | 26 | // developpers need to implement following functions 27 | virtual const QDBusVariant getValue (const QString §ion, const QString &name) 28 | { 29 | QDBusVariant variant; 30 | return variant; 31 | } 32 | virtual void setValue (const QString §ion, const QString &name, const QDBusVariant &value) {} 33 | virtual void unset (const QString §ion, const QString &name) {} 34 | virtual void destroy (void) {} 35 | 36 | public : 37 | 38 | Q_INVOKABLE const QDBusVariant GetValue (const QString §ion, const QString &name); 39 | Q_INVOKABLE void SetValue (const QString §ion, const QString &name, const QDBusVariant &value); 40 | Q_INVOKABLE void Unset (const QString §ion, const QString &name); 41 | Q_INVOKABLE void Destroy (void); 42 | 43 | private : 44 | 45 | QDBusConnection m_conn; 46 | IBusConfigAdaptor *m_config; 47 | }; 48 | 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/qibusproplist.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusproperty.h" 2 | #include "qibusproplist.h" 3 | 4 | namespace IBus { 5 | 6 | IBUS_DECLARE_SERIALIZABLE(PropList, IBusPropList); 7 | 8 | bool 9 | PropList::serialize (QDBusArgument & argument) 10 | { 11 | if (!Serializable::serialize (argument)) { 12 | return false; 13 | } 14 | 15 | argument.beginArray (qMetaTypeId()); 16 | for (int i = 0; i < m_props.size(); ++i ) { 17 | argument << m_props[i]; 18 | } 19 | argument.endArray (); 20 | 21 | return true; 22 | } 23 | 24 | bool 25 | PropList::deserialize (const QDBusArgument & argument) 26 | { 27 | if (!Serializable::deserialize (argument)) { 28 | return false; 29 | } 30 | 31 | argument.beginArray(); 32 | while ( !argument.atEnd() ) 33 | { 34 | PropertyPointer prop; 35 | argument >> prop; 36 | m_props.append(prop); 37 | } 38 | argument.endArray(); 39 | 40 | return true; 41 | } 42 | 43 | bool PropList::appendProperty (const PropertyPointer &prop) 44 | { 45 | if ( !prop.isNull() ) { 46 | m_props.append(prop); 47 | return true; 48 | } 49 | 50 | return false; 51 | } 52 | 53 | bool 54 | PropList::updateProperty (const PropertyPointer &prop) 55 | { 56 | for ( int i = 0; i < m_props.size(); ++i ) { 57 | if ( m_props[i]->update(prop) ) { 58 | return true; 59 | } 60 | } 61 | 62 | return false; 63 | } 64 | 65 | }; 66 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Uncomment this to turn on verbose mode. 4 | #export DH_VERBOSE=1 5 | 6 | # This has to be exported to make some magic below work. 7 | export DH_OPTIONS 8 | 9 | build: build-stamp 10 | build-stamp: 11 | dh_testdir 12 | cmake -DCMAKE_SKIP_RPATH=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_INSTALL_PREFIX="/usr" . 13 | dh_auto_configure 14 | $(MAKE) 15 | touch $@ 16 | 17 | clean: 18 | dh_testdir 19 | dh_testroot 20 | dh_auto_clean 21 | dh_clean 22 | rm -f build-stamp 23 | [ ! -f Makefile ] || make clean || true 24 | rm -rf CMakeFiles/ src/CMakeFiles/ qtim/CMakeFiles/ test/CMakeFiles docs/CMakeFiles 25 | rm -f Makefile test/Makefile test/cmake_install.cmake 26 | rm -rf obj-*-linux-gnu 27 | 28 | install: build 29 | dh_testdir 30 | dh_testroot 31 | dh_prep 32 | dh_installdirs 33 | $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install 34 | dh_install --list-missing --fail-missing 35 | 36 | binary-indep: install 37 | 38 | # Build architecture independant packages using the common target. 39 | binary-arch: install 40 | dh_testdir -s 41 | dh_testroot -s 42 | dh_installchangelogs -s 43 | dh_installdocs -s 44 | dh_installman -s 45 | dh_link -s 46 | dh_strip -s 47 | dh_compress -s 48 | dh_fixperms -s 49 | dh_makeshlibs -Nibus-qt4 -s 50 | dh_installdeb -s 51 | dh_shlibdeps -s 52 | dh_gencontrol -s 53 | dh_md5sums -s 54 | dh_builddeb -s 55 | 56 | binary: binary-indep binary-arch 57 | 58 | .PHONY: build clean binary-indep binary-arch binary install \ 59 | install-indep install-arch 60 | -------------------------------------------------------------------------------- /src/qibusobservedpath.h: -------------------------------------------------------------------------------- 1 | #ifndef _Q_IBUS_OBSERVED_PATH_H_ 2 | #define _Q_IBUS_OBSERVED_PATH_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "qibusserializable.h" 10 | 11 | namespace IBus { 12 | 13 | class ObservedPath; 14 | typedef Pointer ObservedPathPointer; 15 | 16 | class ObservedPath : public Serializable 17 | { 18 | Q_OBJECT; 19 | 20 | public: 21 | ObservedPath () {} 22 | ObservedPath (QString path): m_path(path) {} 23 | 24 | ~ObservedPath () {} 25 | 26 | public: 27 | virtual bool serialize (QDBusArgument &argument); 28 | virtual bool deserialize (const QDBusArgument &argument); 29 | 30 | public: 31 | bool parseXmlNode (const QDomNode & node); 32 | const QString & path() const { return m_path; } 33 | int mtime() const { return m_mtime; } 34 | 35 | #if 0 36 | bool isObservedPathModified () const; 37 | void setObservedPathStat (); 38 | void traverseObservedPath (QVector & observedPathVec) const; 39 | 40 | 41 | bool isRegularFile() const 42 | { 43 | QFileInfo fi(m_path); 44 | return fi.isFile(); 45 | } 46 | 47 | bool isDirFile() const 48 | { 49 | QFileInfo fi(m_path); 50 | return fi.isDir(); 51 | } 52 | #endif 53 | 54 | private: 55 | QString m_path; 56 | uint m_mtime; 57 | bool m_isDir; 58 | bool m_isExist; 59 | 60 | IBUS_SERIALIZABLE 61 | }; 62 | 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/qibusfactoryadaptor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibusfactoryadaptor -c IBusFactoryAdaptor -v org.freedesktop.IBus.EngineFactory.xml org.freedesktop.IBus.EngineFactory 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #include "qibusfactoryadaptor.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /* 21 | * Implementation of adaptor class IBusFactoryAdaptor 22 | */ 23 | 24 | IBusFactoryAdaptor::IBusFactoryAdaptor(QObject *parent) 25 | : QDBusAbstractAdaptor(parent) 26 | { 27 | // constructor 28 | setAutoRelaySignals(true); 29 | } 30 | 31 | IBusFactoryAdaptor::~IBusFactoryAdaptor() 32 | { 33 | // destructor 34 | } 35 | 36 | QDBusObjectPath IBusFactoryAdaptor::CreateEngine(const QString &engine_name) 37 | { 38 | // handle method call org.freedesktop.IBus.EngineFactory.CreateEngine 39 | QDBusObjectPath out0; 40 | QMetaObject::invokeMethod(parent(), "CreateEngine", Q_RETURN_ARG(QDBusObjectPath, out0), Q_ARG(QString, engine_name)); 41 | return out0; 42 | } 43 | 44 | void IBusFactoryAdaptor::Destroy() 45 | { 46 | // handle method call org.freedesktop.IBus.EngineFactory.Destroy 47 | QMetaObject::invokeMethod(parent(), "Destroy"); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /test/diffdist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #if [ $# -gt 1 ] ; then 4 | # SRCDIR=$1 5 | #else 6 | # SRCDIR="." 7 | #fi 8 | #if [ $# -gt 2 ] ; then 9 | # DSTDIR=$1 10 | #else 11 | # DSTDIR=$SRCDIR 12 | #fi 13 | test $# -gt 1 && SRCDIR=$1 || SRCDIR="." 14 | test $# -gt 2 && DSTDIR=$1 || DSTDIR="$SRCDIR" 15 | 16 | VERSION_MAJOR=$(grep VERSION_MAJOR $SRCDIR/CMakeLists.txt | head -1 | awk -F\" '{print $2}') 17 | VERSION_MINOR=$(grep VERSION_MINOR $SRCDIR/CMakeLists.txt | head -1 | awk -F\" '{print $2}') 18 | VERSION_PATCH=$(grep VERSION_PATCH $SRCDIR/CMakeLists.txt | head -1 | awk -F\" '{print $2}') 19 | VERSION="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH" 20 | PREV_VERSION_PATCH="$(expr $VERSION_PATCH - 1)" 21 | PREV_VERSION="$VERSION_MAJOR.$VERSION_MINOR.$PREV_VERSION_PATCH" 22 | zcat $DSTDIR/ibus-qt-${VERSION}-Source.tar.gz | tar xf - 23 | mv ibus-qt-${VERSION}-Source ibus-qt-${VERSION}-Source-new 24 | mv $DSTDIR/ibus-qt-${VERSION}-Source.tar.gz $DSTDIR/ibus-qt-${VERSION}-Source.tar.gz.new 25 | echo "Get upstream ibus-qt-${VERSION}-Source.tar.gz" 26 | wget https://github.com/ibus/ibus-qt/releases/download/$VERSION/ibus-qt-${VERSION}-Source.tar.gz 27 | if [ $? -ne 0 ] ; then 28 | # This is a bumped commit CI. 29 | echo "Get upstream ibus-qt-${PREV_VERSION}-Source.tar.gz" 30 | wget https://github.com/ibus/ibus-qt/releases/download/$PREV_VERSION/ibus-qt-${PREV_VERSION}-Source.tar.gz 31 | DST_VERSION=$PREV_VERSION 32 | else 33 | DST_VERSION=$VERSION 34 | fi 35 | zcat ibus-qt-${DST_VERSION}-Source.tar.gz | tar xf - 36 | diff -r ibus-qt-${DST_VERSION}-Source ibus-qt-${VERSION}-Source-new || : 37 | 38 | -------------------------------------------------------------------------------- /src/interfaces/org.freedesktop.DBus.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/qibuspointer.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_POINTER_H__ 2 | #define __Q_IBUS_POINTER_H__ 3 | 4 | #include 5 | #include 6 | 7 | namespace IBus { 8 | 9 | template 10 | class Pointer 11 | { 12 | public: 13 | Pointer (T *object = 0) : p (0) { 14 | set (object); 15 | } 16 | 17 | Pointer (const Pointer &src) : p (0) { 18 | set (src.get ()); 19 | } 20 | 21 | template 22 | Pointer (const Pointer &src): p (0) { 23 | set (dynamic_cast (src.get ())); 24 | } 25 | 26 | ~Pointer () { 27 | set (0); 28 | } 29 | 30 | Pointer &operator= (T *object) { 31 | set (object); 32 | return *this; 33 | } 34 | 35 | Pointer &operator= (const Pointer &src) { 36 | set (src.get ()); 37 | return *this; 38 | } 39 | 40 | template 41 | Pointer &operator= (const Pointer &src) { 42 | set (dynamic_cast (src.get ())); 43 | return *this; 44 | } 45 | 46 | T &operator* () const { 47 | return *get (); 48 | } 49 | 50 | T *operator-> () const { 51 | return get (); 52 | } 53 | 54 | operator T* () const { 55 | return get (); 56 | } 57 | 58 | operator bool () const { 59 | return !isNull (); 60 | } 61 | 62 | T *get () const { 63 | return p; 64 | } 65 | 66 | bool isNull () const { 67 | return p == 0; 68 | } 69 | 70 | protected: 71 | T *p; 72 | 73 | void set (T *object) { 74 | if (p) 75 | p->unref (); 76 | if (object) 77 | object->ref (); 78 | p = object; 79 | } 80 | }; 81 | 82 | }; 83 | #endif 84 | -------------------------------------------------------------------------------- /src/qibusfactoryadaptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibusfactoryadaptor -c IBusFactoryAdaptor -v org.freedesktop.IBus.EngineFactory.xml org.freedesktop.IBus.EngineFactory 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #ifndef QIBUSFACTORYADAPTOR_H_1251169083 13 | #define QIBUSFACTORYADAPTOR_H_1251169083 14 | 15 | #include 16 | #include 17 | class QByteArray; 18 | template class QList; 19 | template class QMap; 20 | class QString; 21 | class QStringList; 22 | class QVariant; 23 | 24 | /* 25 | * Adaptor class for interface org.freedesktop.IBus.EngineFactory 26 | */ 27 | class IBusFactoryAdaptor: public QDBusAbstractAdaptor 28 | { 29 | Q_OBJECT 30 | Q_CLASSINFO("D-Bus Interface", "org.freedesktop.IBus.EngineFactory") 31 | Q_CLASSINFO("D-Bus Introspection", "" 32 | " \n" 33 | " \n" 34 | " \n" 35 | " \n" 36 | " \n" 37 | " \n" 38 | " \n" 39 | "") 40 | public: 41 | IBusFactoryAdaptor(QObject *parent); 42 | virtual ~IBusFactoryAdaptor(); 43 | 44 | public: // PROPERTIES 45 | public Q_SLOTS: // METHODS 46 | QDBusObjectPath CreateEngine(const QString &engine_name); 47 | void Destroy(); 48 | Q_SIGNALS: // SIGNALS 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/qibustypes.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_TYPES_H_ 2 | #define __Q_IBUS_TYPES_H_ 3 | 4 | #include 5 | 6 | namespace IBus { 7 | 8 | typedef enum 9 | { 10 | ShiftMask = 1 << 0, 11 | LockMask = 1 << 1, 12 | ControlMask = 1 << 2, 13 | Mod1Mask = 1 << 3, 14 | Mod2Mask = 1 << 4, 15 | Mod3Mask = 1 << 5, 16 | Mod4Mask = 1 << 6, 17 | Mod5Mask = 1 << 7, 18 | Button1Mask = 1 << 8, 19 | Button2Mask = 1 << 9, 20 | Button3Mask = 1 << 10, 21 | Button4Mask = 1 << 11, 22 | Button5Mask = 1 << 12, 23 | 24 | /* The next few modifiers are used by XKB, so we skip to the end. 25 | * Bits 15 - 23 are currently unused. Bit 29 is used internally. 26 | * 27 | **/ 28 | 29 | /* ibus mask */ 30 | HandledMask = 1 << 24, 31 | ForwardMask = 1 << 25, 32 | IgnoredMask = ForwardMask, 33 | 34 | SuperMask = 1 << 26, 35 | HyperMask = 1 << 27, 36 | MetaMask = 1 << 28, 37 | 38 | ReleaseMask = 1 << 30, 39 | 40 | ModifierMask = 0x5c001fff 41 | } ModifierType; 42 | 43 | typedef enum { 44 | CapPreeditText = 1 << 0, 45 | CapAuxiliaryText = 1 << 1, 46 | CapLookupTable = 1 << 2, 47 | CapFocus = 1 << 3, 48 | CapProperty = 1 << 4, 49 | CapSurroundingText = 1 << 5, 50 | } Capabilite; 51 | 52 | typedef enum { 53 | OrientationHorizontal = 0, 54 | OrientationVertical = 1, 55 | OrientationSystem = 2, 56 | } Orientation; 57 | 58 | typedef enum { 59 | EnginePreeditClear = 0, 60 | EnginePreeditCommit = 1, 61 | } PreeditFocusMode; 62 | 63 | typedef struct { 64 | uint x; 65 | uint y; 66 | uint width; 67 | uint height; 68 | } Rectangle; 69 | 70 | }; 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /src/qibusconfig.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qibusconfigproxy.h" 3 | #include "qibusconfig.h" 4 | 5 | namespace IBus { 6 | 7 | Config::Config (const QDBusConnection &conn): m_conn(conn) 8 | { 9 | QString service = "org.freedesktop.IBus.Config"; 10 | QString path = "/org/freedesktop/IBus/Config"; 11 | 12 | m_config = new IBusConfigProxy(service, path, m_conn); 13 | if ( !m_config ) { 14 | qDebug () << "Config::Config, new IBusConfigAdaptor error!"; 15 | } 16 | } 17 | 18 | Config::~Config () 19 | { 20 | if ( m_config ) { 21 | delete m_config; 22 | m_config = NULL; 23 | } 24 | } 25 | 26 | bool 27 | Config::getValue (const QString §ion, const QString &name) 28 | { 29 | QDBusPendingReply<> reply = m_config->GetValue(section, name); 30 | reply.waitForFinished (); 31 | 32 | if (reply.isError ()) { 33 | qDebug () << "Config::getValue:" << reply.error (); 34 | return false; 35 | } 36 | 37 | return true; 38 | } 39 | 40 | bool 41 | Config::setValue (const QString §ion, const QString &name, const QDBusVariant &value) 42 | { 43 | QDBusPendingReply<> reply = m_config->SetValue(section, name, value); 44 | reply.waitForFinished (); 45 | 46 | if (reply.isError ()) { 47 | qDebug () << "Config::setValue:" << reply.error (); 48 | return false; 49 | } 50 | 51 | return true; 52 | } 53 | 54 | bool 55 | Config::unset (const QString §ion, const QString &name) 56 | { 57 | QDBusPendingReply<> reply = m_config->Unset(section, name); 58 | reply.waitForFinished (); 59 | 60 | if (reply.isError ()) { 61 | qDebug () << "Config::unset:" << reply.error (); 62 | return false; 63 | } 64 | 65 | return true; 66 | } 67 | 68 | void 69 | Config::destroy (void) 70 | { 71 | m_config->Destroy(); 72 | } 73 | 74 | }; 75 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: ibus-qt 2 | Section: utils 3 | Priority: optional 4 | Maintainer: LI Daobing 5 | Uploaders: Asias He 6 | Build-Depends: debhelper (>= 7), cmake, pkg-config, libqt4-dev, 7 | libdbus-1-dev, libx11-dev, libicu-dev, libibus-dev, doxygen 8 | Standards-Version: 3.8.4 9 | Homepage: http://code.google.com/p/ibus 10 | Vcs-Bzr: lp:~lidaobing/ibus/ibus-qt 11 | Vcs-Browser: https://code.launchpad.net/~lidaobing/ibus/ibus-qt 12 | 13 | Package: ibus-qt4 14 | Architecture: any 15 | Depends: ${shlibs:Depends}, ${misc:Depends} 16 | Description: qt-immodule for ibus (QT4) 17 | IBus is an Intelligent Input Bus. It is a new input framework for Linux 18 | OS. It provides full featured and user friendly input method user interface. 19 | It also may help developers to develop input method easily. 20 | . 21 | ibus-qt4 is the QT4 client of ibus, it provide a qt-immodule for ibus. 22 | 23 | Package: libibus-qt1 24 | Section: libs 25 | Architecture: any 26 | Depends: ${shlibs:Depends}, ${misc:Depends} 27 | Description: qt-immodule for ibus (QT4) 28 | IBus is an Intelligent Input Bus. It is a new input framework for Linux 29 | OS. It provides full featured and user friendly input method user interface. 30 | It also may help developers to develop input method easily. 31 | . 32 | libibus-qt1 is the library of ibus-qt. 33 | 34 | Package: libibus-qt-dev 35 | Section: libdevel 36 | Architecture: any 37 | Depends: libibus-qt1 (= ${binary:Version}), libqt4-dev, libibus-dev, libdbus-1-dev, ${shlibs:Depends}, ${misc:Depends} 38 | Description: qt-immodule for ibus (QT4) 39 | IBus is an Intelligent Input Bus. It is a new input framework for Linux 40 | OS. It provides full featured and user friendly input method user interface. 41 | It also may help developers to develop input method easily. 42 | . 43 | This package contains the header files which is needed for 44 | developing the ibus-qt applications. 45 | 46 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | ibus-qt (1.3.0-1) unstable; urgency=low 2 | 3 | * build for lucid. 4 | 5 | -- Peng Huang Fri, 16 Apr 2010 14:45:00 +0800 6 | 7 | ibus-qt (1.3.0-1) unstable; urgency=low 8 | 9 | * New upstream release. 10 | * debian/control: bump standards version to 3.8.4. 11 | * debian/source/format: 3.0. 12 | * Fix "FTBFS with binutils-gold" (Closes: #554862) 13 | - debian/patches/binutils-gold: added. 14 | 15 | -- LI Daobing Sat, 10 Apr 2010 16:25:47 +0800 16 | 17 | ibus-qt (1.2.0.20091217-1) unstable; urgency=low 18 | 19 | * New upstream release. 20 | * debian/control: 21 | - build depends on doxygen. 22 | * debian/clean: updated 23 | * debian/rules: update clean section. 24 | 25 | -- LI Daobing Thu, 17 Dec 2009 20:37:40 +0800 26 | 27 | ibus-qt (1.2.0.20091206-1) unstable; urgency=low 28 | 29 | * New upstream release. 30 | 31 | -- LI Daobing Thu, 10 Dec 2009 19:28:40 +0800 32 | 33 | ibus-qt (1.2.0.20091014-1) unstable; urgency=low 34 | 35 | * new upstream release. 36 | * debian/rules: updated. 37 | 38 | -- LI Daobing Wed, 14 Oct 2009 18:48:52 +0800 39 | 40 | ibus-qt (1.2.0.20090822-2) unstable; urgency=low 41 | 42 | * split ibus-qt to libibus-qt, libibus-qt-dev, ibus-qt4 43 | 44 | -- Asias He Fri, 28 Aug 2009 16:21:31 +0800 45 | 46 | ibus-qt (1.2.0.20090822-1) unstable; urgency=low 47 | 48 | * new upstream release. 49 | - Fix "Composite key stops working" (Closes: #541784) 50 | * debian/control: 51 | - bump standards version to 3.8.3. 52 | - add libicu-dev, libibus-dev to build-depends. 53 | - change version of debhelper from 7.0.50 to 7 54 | * debian/rules: 55 | - use debhelper 7. 56 | 57 | -- LI Daobing Mon, 24 Aug 2009 22:30:28 +0800 58 | 59 | ibus-qt (1.2.0.20090728-1) unstable; urgency=low 60 | 61 | * Initial release (Closes: #539022) 62 | 63 | -- LI Daobing Tue, 28 Jul 2009 22:32:34 +0800 64 | -------------------------------------------------------------------------------- /src/qibusconfigadaptor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibusconfigadaptor -c IBusConfigAdaptor -v org.freedesktop.IBus.Config.xml org.freedesktop.IBus.Config 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #include "qibusconfigadaptor.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /* 21 | * Implementation of adaptor class IBusConfigAdaptor 22 | */ 23 | 24 | IBusConfigAdaptor::IBusConfigAdaptor(QObject *parent) 25 | : QDBusAbstractAdaptor(parent) 26 | { 27 | // constructor 28 | setAutoRelaySignals(true); 29 | } 30 | 31 | IBusConfigAdaptor::~IBusConfigAdaptor() 32 | { 33 | // destructor 34 | } 35 | 36 | void IBusConfigAdaptor::Destroy() 37 | { 38 | // handle method call org.freedesktop.IBus.Config.Destroy 39 | QMetaObject::invokeMethod(parent(), "Destroy"); 40 | } 41 | 42 | QDBusVariant IBusConfigAdaptor::GetValue(const QString §ion, const QString &name) 43 | { 44 | // handle method call org.freedesktop.IBus.Config.GetValue 45 | QDBusVariant out0; 46 | QMetaObject::invokeMethod(parent(), "GetValue", Q_RETURN_ARG(QDBusVariant, out0), Q_ARG(QString, section), Q_ARG(QString, name)); 47 | return out0; 48 | } 49 | 50 | void IBusConfigAdaptor::SetValue(const QString §ion, const QString &name, const QDBusVariant &value) 51 | { 52 | // handle method call org.freedesktop.IBus.Config.SetValue 53 | QMetaObject::invokeMethod(parent(), "SetValue", Q_ARG(QString, section), Q_ARG(QString, name), Q_ARG(QDBusVariant, value)); 54 | } 55 | 56 | void IBusConfigAdaptor::Unset(const QString §ion, const QString &name) 57 | { 58 | // handle method call org.freedesktop.IBus.Config.Unset 59 | QMetaObject::invokeMethod(parent(), "Unset", Q_ARG(QString, section), Q_ARG(QString, name)); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/qibusattribute.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_ATTRIBUTE_H_ 2 | #define __Q_IBUS_ATTRIBUTE_H_ 3 | 4 | #include "qibusserializable.h" 5 | 6 | namespace IBus { 7 | 8 | class Attribute; 9 | typedef Pointer AttributePointer; 10 | 11 | 12 | class Attribute : public Serializable 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | /* 18 | * Type enumeration of IBusText attribute. 19 | */ 20 | typedef enum { 21 | TypeUnderline = 1, 22 | TypeForeground = 2, 23 | TypeBackground = 3, 24 | } Type; 25 | 26 | /* 27 | * Type of IBusText attribute. 28 | */ 29 | typedef enum { 30 | UnderlineNone = 0, 31 | UnderlineSingle = 1, 32 | UnderlineDouble = 2, 33 | UnderlineLow = 3, 34 | UnderlineError = 4, 35 | } Underline; 36 | 37 | public: 38 | Attribute (uint type = 0, uint value = 0, uint start = 0, uint end = 0) : 39 | m_type (type), m_value (value),m_start (start), m_end (end) {} 40 | 41 | public: 42 | virtual bool serialize (QDBusArgument &argument); 43 | virtual bool deserialize (const QDBusArgument &argument); 44 | 45 | uint type (void) const { return m_type; } 46 | uint value (void) const { return m_value; } 47 | uint start (void) const { return m_start; } 48 | uint end (void) const { return m_end; } 49 | uint length (void) const { return (m_end - m_start); } 50 | 51 | protected: 52 | uint m_type; 53 | uint m_value; 54 | uint m_start; 55 | uint m_end; 56 | 57 | IBUS_SERIALIZABLE 58 | }; 59 | 60 | class AttributeUnderline : public Attribute 61 | { 62 | public: 63 | AttributeUnderline (uint underlineType = 0, uint start = 0, uint end = 0) 64 | : Attribute (TypeUnderline, underlineType, start, end) {} 65 | }; 66 | 67 | class AttributeForeground: public Attribute 68 | { 69 | public: 70 | AttributeForeground (uint color = 0, uint start = 0, uint end = 0) 71 | : Attribute (TypeForeground, color, start, end) {} 72 | }; 73 | 74 | class AttributeBackground: public Attribute 75 | { 76 | public: 77 | AttributeBackground (uint color = 0, uint start = 0, uint end = 0) 78 | : Attribute (TypeBackground, color, start, end) {} 79 | }; 80 | 81 | }; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/ibus.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "qibusserializable.h" 9 | #include "qibustext.h" 10 | #include "qibusbus.h" 11 | #include "qibusattribute.h" 12 | 13 | #include 14 | 15 | using namespace IBus; 16 | 17 | class App : QCoreApplication { 18 | public: 19 | App (int &argc, char **argv ) : QCoreApplication (argc, argv) { 20 | } 21 | }; 22 | 23 | int main (int argc, char **argv) 24 | { 25 | App app(argc, argv); 26 | Bus bus; 27 | SerializablePointer p = new Serializable (); 28 | p = bus.ping (p); 29 | 30 | bus.createInputContext ("Test"); 31 | QCoreApplication::exec (); 32 | 33 | 34 | #if 0 35 | qDBusRegisterMetaType(); 36 | 37 | QDBusArgument arg; 38 | 39 | { 40 | SerializablePointer p; 41 | p = new Serializable (); 42 | 43 | QVariant v = qVariantFromValue (p); 44 | QDBusVariant dv (v); 45 | SerializablePointer p1 = v.value(); 46 | arg << p; 47 | } 48 | 49 | 50 | App app(argc, argv); 51 | Connection connection (QString ("unix:path=/tmp/ibus-liudl/ibus-unix-0")); 52 | 53 | org::freedesktop::IBus bus (QString ("org.freedesktop.IBus"), 54 | QString ("/org/freedesktop/IBus"), 55 | connection.getConnection ()); 56 | 57 | 58 | SerializablePointer p = /* (Serializable *) */ new Attribute(); 59 | QVariant v = qVariantFromValue (p); 60 | 61 | std::cout << v.toInt(); 62 | 63 | QDBusPendingReply ret = bus.Ping (qDBusVariantFromSerializable (p)); 64 | 65 | SerializablePointer p1 = qDBusVariantToSerializable (ret); 66 | #endif 67 | #if 0 68 | 69 | 70 | 71 | 72 | Serializable *obj1, *obj2; 73 | QDBusArgument arg; 74 | 75 | obj1 = new Serializable (); 76 | 77 | Serializable::serializeObject (obj1, arg); 78 | delete obj1; 79 | 80 | QVariant a = QVariant::fromValue(arg); 81 | 82 | 83 | QDBusArgument argout = ret.argumentAt<0>().variant().value(); 84 | 85 | Serializable::deserializeObject (obj2, argout); 86 | #endif 87 | 88 | return 0; 89 | } 90 | -------------------------------------------------------------------------------- /src/qibusproperty.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_PROPERTY_H_ 2 | #define __Q_IBUS_PROPERTY_H_ 3 | 4 | #include "qibusserializable.h" 5 | #include "qibusproplist.h" 6 | #include "qibustext.h" 7 | 8 | namespace IBus { 9 | 10 | /* type of QIBusProperty */ 11 | typedef enum 12 | { 13 | TypeNormal = 0, 14 | TypeToggle = 1, 15 | TypeRadio = 2, 16 | TypeMenu = 3, 17 | TypeSeparator = 4, 18 | }PropType; 19 | 20 | /* 21 | * State of QIBusProperty. The actual effect 22 | * depends on #QIBusPropType of the QIBusProperty. 23 | */ 24 | typedef enum 25 | { 26 | StateUnchecked = 0, 27 | StateChecked = 1, 28 | StateInconsistent = 2, 29 | } PropState; 30 | 31 | class Property; 32 | class PropList; 33 | typedef Pointer PropListPointer; 34 | typedef Pointer PropertyPointer; 35 | 36 | class Property : public Serializable 37 | { 38 | Q_OBJECT; 39 | 40 | 41 | public: 42 | Property () {} 43 | Property (const QString key, 44 | const QString icon, 45 | const TextPointer &label, 46 | const TextPointer &tooltip, 47 | bool sensitive, 48 | bool visible, 49 | uint type, 50 | uint state, 51 | const PropListPointer &subProps): 52 | m_key(key), 53 | m_icon(icon), 54 | m_label(label), 55 | m_tooltip(tooltip), 56 | m_sensitive(sensitive), 57 | m_visible(visible), 58 | m_type(type), 59 | m_state(state), 60 | m_subProps(subProps) {} 61 | 62 | ~Property () {} 63 | 64 | public: 65 | virtual bool serialize (QDBusArgument &argument); 66 | virtual bool deserialize (const QDBusArgument &argument); 67 | 68 | public: 69 | void setLabel (const TextPointer & lable); 70 | void setVisible (bool visible); 71 | void setSubProps (const PropListPointer & props); 72 | bool update (const PropertyPointer prop); 73 | 74 | private: 75 | 76 | QString m_key; 77 | QString m_icon; 78 | TextPointer m_label; 79 | TextPointer m_tooltip; 80 | bool m_sensitive; 81 | bool m_visible; 82 | uint m_type; 83 | uint m_state; 84 | PropListPointer m_subProps; 85 | 86 | IBUS_SERIALIZABLE 87 | }; 88 | 89 | }; 90 | #endif 91 | -------------------------------------------------------------------------------- /src/qibusproperty.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusproperty.h" 2 | 3 | namespace IBus { 4 | 5 | IBUS_DECLARE_SERIALIZABLE(Property, IBusProperty); 6 | 7 | bool 8 | Property::serialize (QDBusArgument &argument) 9 | { 10 | if (!Serializable::serialize (argument)) { 11 | return false; 12 | } 13 | 14 | argument << m_key; 15 | argument << m_type; 16 | argument << m_label; 17 | argument << m_icon; 18 | argument << m_tooltip; 19 | argument << m_sensitive; 20 | argument << m_visible; 21 | argument << m_state; 22 | 23 | if ( !m_subProps ) { 24 | m_subProps = new PropList(); 25 | } 26 | argument << m_subProps; 27 | 28 | return true; 29 | } 30 | 31 | bool 32 | Property::deserialize (const QDBusArgument &argument) 33 | { 34 | if (!Serializable::deserialize (argument)) { 35 | return false; 36 | } 37 | 38 | argument >> m_key; 39 | argument >> m_type; 40 | argument >> m_label; 41 | argument >> m_icon; 42 | argument >> m_tooltip; 43 | argument >> m_sensitive; 44 | argument >> m_visible; 45 | argument >> m_state; 46 | argument >> m_subProps; 47 | 48 | return true; 49 | } 50 | 51 | void 52 | Property::setLabel (const TextPointer & lable) 53 | { 54 | if ( !lable.isNull() ) { 55 | m_label = new Text; 56 | return ; 57 | } 58 | 59 | m_label = lable; 60 | } 61 | 62 | void 63 | Property::setVisible (bool visible) 64 | { 65 | m_visible = visible; 66 | } 67 | 68 | void 69 | Property::setSubProps(const PropListPointer & props) 70 | { 71 | if ( !props ) { 72 | m_subProps = new PropList; 73 | return ; 74 | } 75 | 76 | m_subProps = props; 77 | } 78 | 79 | bool 80 | Property::update (const PropertyPointer prop) 81 | { 82 | if ( m_key == prop->m_key ) { 83 | m_icon = prop->m_icon; 84 | m_label = prop->m_label; 85 | m_tooltip = prop->m_tooltip; 86 | m_visible = prop->m_visible; 87 | m_sensitive = prop->m_sensitive; 88 | m_state = prop->m_state; 89 | 90 | return true; 91 | } 92 | 93 | if ( !m_subProps.isNull() ) 94 | return m_subProps->updateProperty(prop); 95 | 96 | return false; 97 | } 98 | 99 | }; 100 | -------------------------------------------------------------------------------- /src/qibusbus.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_BUS_H_ 2 | #define __Q_IBUS_BUS_H_ 3 | 4 | #include 5 | #include 6 | #include "qibusobject.h" 7 | #include "qibusserializable.h" 8 | #include "qibusenginedesc.h" 9 | #include "qibuscomponent.h" 10 | #include "qibusengine.h" 11 | 12 | class QDBusConnection; 13 | class IBusProxy; 14 | class DBusProxy; 15 | 16 | namespace IBus { 17 | 18 | class Bus; 19 | typedef Pointer BusPointer; 20 | 21 | class Bus : public Object 22 | { 23 | Q_OBJECT; 24 | 25 | protected: 26 | 27 | public: 28 | Bus (void); 29 | ~Bus (void); 30 | bool isConnected (void); 31 | const QDBusConnection &getConnection (void); 32 | 33 | /* org.freedesktop.DBus methods */ 34 | QString hello (void); 35 | void addMatch (const QString &rule); 36 | void removeMatch (const QString &rule); 37 | QString getId (void); 38 | QString getNameOwner (const QString &name); 39 | QStringList listNames (void); 40 | bool nameHasOwner (const QString &name); 41 | uint requestName (const QString &name, uint flag); 42 | uint releaseName (const QString &name); 43 | 44 | /* org.freedesktop.IBus methods */ 45 | QString createInputContext (const QString &name); 46 | bool registerComponent (const ComponentPointer &component); 47 | bool registerObject (const QString &path, QObject *obj); 48 | 49 | QList listEngines (void); 50 | QList listActiveEngines (void); 51 | bool exit (bool restart = false); 52 | SerializablePointer ping (const SerializablePointer &data); 53 | 54 | private: 55 | bool open (void); 56 | void reset (void); 57 | QString getSocketPath (void); 58 | QString getAddress (void); 59 | 60 | signals: 61 | /** 62 | * @brief Emited when bus is disconnected from ibus daemon. 63 | */ 64 | void disconnected (void); 65 | 66 | /** 67 | * @brief Emited when bus is connected to ibus daemon. 68 | */ 69 | void connected (void); 70 | 71 | private slots: 72 | void slotAddressChanged (const QString &path); 73 | void slotIBusDisconnected (void); 74 | 75 | private: 76 | QFileSystemWatcher m_watcher; 77 | QDBusConnection *m_connection; 78 | DBusProxy *m_dbus; 79 | IBusProxy *m_ibus; 80 | }; 81 | 82 | }; 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /ibus-qt.spec.in: -------------------------------------------------------------------------------- 1 | %define ibus_version 1.3.7 2 | 3 | Name: @CPACK_PACKAGE_NAME@ 4 | Version: @CPACK_PACKAGE_VERSION@ 5 | Release: 1%{?dist} 6 | Summary: Qt IBus library and Qt input method plugin 7 | License: GPLv2+ 8 | Group: System Environment/Libraries 9 | URL: http://code.google.com/p/ibus/ 10 | Source0: http://ibus.googlecode.com/files/%{name}-%{version}-Source.tar.gz 11 | 12 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 13 | 14 | BuildRequires: cmake 15 | BuildRequires: qt-devel >= 4.5 16 | BuildRequires: dbus-devel >= 1.2 17 | BuildRequires: ibus-devel >= %ibus_version 18 | BuildRequires: libicu-devel >= 4.0 19 | BuildRequires: doxygen >= 1.6 20 | Requires: ibus >= %ibus_version 21 | 22 | %description 23 | Qt IBus library and Qt input method plugin. 24 | 25 | %package devel 26 | Summary: Development tools for ibus qt 27 | Group: Development/Libraries 28 | Requires: %{name} = %{version}-%{release} 29 | 30 | %description devel 31 | The ibus-qt-devel package contains the header files for ibus qt library. 32 | 33 | %package docs 34 | Summary: Development documents for ibus qt 35 | Group: Development/Libraries 36 | Requires: %{name} = %{version}-%{release} 37 | 38 | %description docs 39 | The ibus-qt-docs package contains developer documentation for ibus qt library. 40 | 41 | %prep 42 | %setup -q -n %{name}-%{version}-Source 43 | 44 | %build 45 | %cmake \ 46 | -DCMAKE_INSTALL_PREFIX=%{_usr} \ 47 | -DLIBDIR=%{_libdir} 48 | make \ 49 | VERBOSE=1 \ 50 | C_DEFINES="$RPM_OPT_FLAGS" \ 51 | CXX_DEFINES="$RPM_OPT_FLAGS" \ 52 | %{?_smp_mflags} 53 | make docs 54 | 55 | %install 56 | rm -rf $RPM_BUILD_ROOT 57 | make install DESTDIR=$RPM_BUILD_ROOT 58 | # %find_lang %{name} 59 | 60 | %post -p /sbin/ldconfig 61 | 62 | %postun -p /sbin/ldconfig 63 | 64 | %clean 65 | rm -rf $RPM_BUILD_ROOT 66 | 67 | %files 68 | # -f %{name}.lang 69 | %defattr(-,root,root,-) 70 | %doc AUTHORS README INSTALL 71 | %{_libdir}/libibus-qt.so.* 72 | %{_libdir}/qt4/plugins/inputmethods/libqtim-ibus.so 73 | 74 | %files devel 75 | %defattr(-,root,root,-) 76 | %{_includedir}/* 77 | %{_libdir}/libibus-qt.so 78 | 79 | %files docs 80 | %defattr(-,root,root,-) 81 | %doc docs/html 82 | 83 | %changelog 84 | * Mon Jul 27 2009 Peng Huang - @CPACK_PACKAGE_VERSION@-1 85 | - The first version. 86 | -------------------------------------------------------------------------------- /src/qibuslookuptable.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_LOOKUP_TABLE_H_ 2 | #define __Q_IBUS_LOOKUP_TABLE_H_ 3 | 4 | #include "qibusserializable.h" 5 | #include "qibustext.h" 6 | #include "qibustypes.h" 7 | 8 | namespace IBus { 9 | 10 | class LookupTable; 11 | typedef Pointer LookupTablePointer; 12 | 13 | class LookupTable: public Serializable 14 | { 15 | Q_OBJECT; 16 | 17 | public: 18 | LookupTable (uint pageSize = 5, 19 | uint cursorPos = 0, 20 | bool cursorVisible = true, 21 | bool round = true, 22 | int orientation = OrientationSystem 23 | ): 24 | m_pageSize (pageSize), 25 | m_cursorPos (cursorPos), 26 | m_cursorVisible (cursorVisible), 27 | m_round (round), 28 | m_orientation (orientation) {} 29 | 30 | ~LookupTable() {} 31 | 32 | public: 33 | virtual bool serialize (QDBusArgument & argument); 34 | virtual bool deserialize (const QDBusArgument & argument); 35 | void appendCandidate (const TextPointer & e); 36 | void appendLabel (const TextPointer & e); 37 | 38 | TextPointer candidate (uint index) const; 39 | TextPointer label (const uint index) const; 40 | const QVector & candidates () const { return m_candidates; } 41 | const QVector & labels () const { return m_labels; } 42 | uint cursorPos () const { return m_cursorPos; } 43 | uint pageSize () const {return m_pageSize; } 44 | bool isCursorVisible () const { return m_cursorVisible; } 45 | bool isRound () const { return m_round; } 46 | int orientation () const { return m_orientation; } 47 | 48 | void setCursorPos (const uint cursorPos); 49 | void setCursorVisible (bool visible); 50 | void setPageSize (uint pageSize); 51 | void setOrientation (int orientation); 52 | uint cursorPosInPage () const; 53 | void clean (void); 54 | 55 | bool pageUp(); 56 | bool pageDown(); 57 | bool cursorUp(); 58 | bool cursorDown(); 59 | 60 | private: 61 | uint m_pageSize; 62 | uint m_cursorPos; 63 | bool m_cursorVisible; 64 | bool m_round; 65 | int m_orientation; 66 | 67 | QVector m_candidates; 68 | QVector m_labels; 69 | 70 | IBUS_SERIALIZABLE 71 | }; 72 | 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/qibusenginefactory.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusenginefactory.h" 2 | #include "qibusfactoryadaptor.h" 3 | #include "qibusengine.h" 4 | 5 | namespace IBus { 6 | 7 | EngineFactory *EngineFactory::m_factory = NULL; 8 | 9 | EngineFactory::EngineFactory (const QDBusConnection &conn, uint id) 10 | : m_conn (conn) 11 | { 12 | m_id = id; 13 | m_factoryAdaptor = new IBusFactoryAdaptor (this); 14 | } 15 | 16 | EngineFactory::~EngineFactory () 17 | { 18 | if ( m_factoryAdaptor != NULL ) { 19 | delete m_factoryAdaptor; 20 | m_factoryAdaptor = NULL; 21 | } 22 | 23 | if ( m_factory != NULL ) { 24 | delete m_factory; 25 | m_factory = NULL; 26 | } 27 | } 28 | 29 | EngineFactory *EngineFactory::getEngineFactory (const QDBusConnection &conn) 30 | { 31 | if ( m_factory == NULL ) { 32 | m_factory = new EngineFactory(conn); 33 | } 34 | 35 | return m_factory; 36 | } 37 | 38 | QString 39 | EngineFactory::createEngine (const QString &engineName) 40 | { 41 | QString path = "/org/freedesktop/IBus/Engine/" + engineName + "_" + QString::number(++m_id); 42 | 43 | if ( !m_engineMap.contains(engineName) ) { 44 | qDebug () << "EngineFactory::createEngine, can not create engine!"; 45 | return ""; 46 | } 47 | 48 | const QMetaObject *mo = m_engineMap[engineName]; 49 | EnginePointer engine = qobject_cast(mo->newInstance (Q_ARG(QString, engineName))); 50 | if ( engine.isNull() ) { 51 | qDebug () << "EngineFactory::createEngine, newInstance error!"; 52 | return ""; 53 | } 54 | 55 | if ( !m_conn.isConnected() ) { 56 | qDebug () << "EngineFactory::createEngine, connection is not open"; 57 | return ""; 58 | } 59 | 60 | if ( !m_conn.registerObject (path, engine) ) { 61 | qDebug () << "EngineFactory::createEngine, registerObject error!"; 62 | return ""; 63 | } 64 | 65 | m_engineLList.append(engine); 66 | 67 | return path; 68 | } 69 | 70 | QDBusObjectPath 71 | EngineFactory::CreateEngine (const QString &engineName) 72 | { 73 | return QDBusObjectPath (createEngine (engineName)); 74 | } 75 | 76 | void 77 | EngineFactory::Destroy () 78 | { 79 | delete this; 80 | } 81 | 82 | void 83 | EngineFactory::addMetaObject(const QString &name, const QMetaObject *metaObject) 84 | { 85 | Q_ASSERT(metaObject); 86 | m_engineMap[name] = metaObject; 87 | } 88 | 89 | }; 90 | -------------------------------------------------------------------------------- /src/qibusconfigadaptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibusconfigadaptor -c IBusConfigAdaptor -v org.freedesktop.IBus.Config.xml org.freedesktop.IBus.Config 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #ifndef QIBUSCONFIGADAPTOR_H_1268725630 13 | #define QIBUSCONFIGADAPTOR_H_1268725630 14 | 15 | #include 16 | #include 17 | class QByteArray; 18 | template class QList; 19 | template class QMap; 20 | class QString; 21 | class QStringList; 22 | class QVariant; 23 | 24 | /* 25 | * Adaptor class for interface org.freedesktop.IBus.Config 26 | */ 27 | class IBusConfigAdaptor: public QDBusAbstractAdaptor 28 | { 29 | Q_OBJECT 30 | Q_CLASSINFO("D-Bus Interface", "org.freedesktop.IBus.Config") 31 | Q_CLASSINFO("D-Bus Introspection", "" 32 | " \n" 33 | " \n" 34 | " \n" 35 | " \n" 36 | " \n" 37 | " \n" 38 | " \n" 39 | " \n" 40 | " \n" 41 | " \n" 42 | " \n" 43 | " \n" 44 | " \n" 45 | " \n" 46 | " \n" 47 | " \n" 48 | " \n" 49 | " \n" 50 | " \n" 51 | " \n" 52 | " \n" 53 | " \n" 54 | "") 55 | public: 56 | IBusConfigAdaptor(QObject *parent); 57 | virtual ~IBusConfigAdaptor(); 58 | 59 | public: // PROPERTIES 60 | public Q_SLOTS: // METHODS 61 | void Destroy(); 62 | QDBusVariant GetValue(const QString §ion, const QString &name); 63 | void SetValue(const QString §ion, const QString &name, const QDBusVariant &value); 64 | void Unset(const QString §ion, const QString &name); 65 | Q_SIGNALS: // SIGNALS 66 | void ValueChanged(const QString §ion, const QString &name, const QDBusVariant &value); 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/qibusenginedesc.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_ENGINE_DESC_H_ 2 | #define __Q_IBUS_ENGINE_DESC_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "qibusserializable.h" 8 | 9 | namespace IBus { 10 | 11 | class EngineDesc; 12 | typedef Pointer EngineDescPointer; 13 | 14 | class EngineDesc : public Serializable 15 | { 16 | Q_OBJECT; 17 | 18 | public: 19 | EngineDesc () : m_rank (0) 20 | {} 21 | EngineDesc (const QString & name, 22 | const QString & lname, 23 | const QString & desc, 24 | const QString & lang, 25 | const QString & lics, 26 | const QString & auth, 27 | const QString & icon, 28 | const QString & layout, 29 | const QString & hotkeys = "", 30 | uint rank = 0): 31 | m_name(name), 32 | m_longname(lname), 33 | m_description(desc), 34 | m_language(lang), 35 | m_license(lics), 36 | m_author(auth), 37 | m_icon(icon), 38 | m_layout(layout), 39 | m_hotkeys(hotkeys), 40 | m_rank(rank) 41 | { 42 | m_engineInfo.insert ("name", m_name); 43 | m_engineInfo.insert ("longname", m_longname); 44 | m_engineInfo.insert ("description", m_description); 45 | m_engineInfo.insert ("language", m_language); 46 | m_engineInfo.insert ("license", m_license); 47 | m_engineInfo.insert ("author", m_author); 48 | m_engineInfo.insert ("icon", m_icon); 49 | m_engineInfo.insert ("layout", m_layout); 50 | m_engineInfo.insert ("hotkeys", m_hotkeys); 51 | 52 | QString stringRank; 53 | stringRank = stringRank.number (m_rank); 54 | m_engineInfo.insert ("rank", stringRank); 55 | } 56 | 57 | virtual ~EngineDesc () {} 58 | 59 | public : 60 | virtual bool serialize (QDBusArgument & argument); 61 | virtual bool deserialize (const QDBusArgument & argument); 62 | 63 | void output (QString & output) const; 64 | bool parseXmlNode (const QDomNode & node); 65 | 66 | const QMap & getEngineInfo () const 67 | { 68 | return m_engineInfo; 69 | } 70 | 71 | private : 72 | QString m_name; 73 | QString m_longname; 74 | QString m_description; 75 | QString m_language; 76 | QString m_license; 77 | QString m_author; 78 | QString m_icon; 79 | QString m_layout; 80 | QString m_hotkeys; 81 | uint m_rank; 82 | 83 | QMap m_engineInfo; 84 | 85 | IBUS_SERIALIZABLE 86 | }; 87 | 88 | }; 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/qibusconfigproxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -p qibusconfigproxy -c IBusConfigProxy -v org.freedesktop.IBus.Config.xml org.freedesktop.IBus.Config 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #ifndef QIBUSCONFIGPROXY_H_1268725630 12 | #define QIBUSCONFIGPROXY_H_1268725630 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /* 24 | * Proxy class for interface org.freedesktop.IBus.Config 25 | */ 26 | class IBusConfigProxy: public QDBusAbstractInterface 27 | { 28 | Q_OBJECT 29 | public: 30 | static inline const char *staticInterfaceName() 31 | { return "org.freedesktop.IBus.Config"; } 32 | 33 | public: 34 | IBusConfigProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); 35 | 36 | ~IBusConfigProxy(); 37 | 38 | public Q_SLOTS: // METHODS 39 | inline QDBusPendingReply<> Destroy() 40 | { 41 | QList argumentList; 42 | return asyncCallWithArgumentList(QLatin1String("Destroy"), argumentList); 43 | } 44 | 45 | inline QDBusPendingReply GetValue(const QString §ion, const QString &name) 46 | { 47 | QList argumentList; 48 | argumentList << qVariantFromValue(section) << qVariantFromValue(name); 49 | return asyncCallWithArgumentList(QLatin1String("GetValue"), argumentList); 50 | } 51 | 52 | inline QDBusPendingReply<> SetValue(const QString §ion, const QString &name, const QDBusVariant &value) 53 | { 54 | QList argumentList; 55 | argumentList << qVariantFromValue(section) << qVariantFromValue(name) << qVariantFromValue(value); 56 | return asyncCallWithArgumentList(QLatin1String("SetValue"), argumentList); 57 | } 58 | 59 | inline QDBusPendingReply<> Unset(const QString §ion, const QString &name) 60 | { 61 | QList argumentList; 62 | argumentList << qVariantFromValue(section) << qVariantFromValue(name); 63 | return asyncCallWithArgumentList(QLatin1String("Unset"), argumentList); 64 | } 65 | 66 | Q_SIGNALS: // SIGNALS 67 | void ValueChanged(const QString §ion, const QString &name, const QDBusVariant &value); 68 | }; 69 | 70 | namespace org { 71 | namespace freedesktop { 72 | namespace IBus { 73 | typedef ::IBusConfigProxy Config; 74 | } 75 | } 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /src/qibuscomponent.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_COMPONENT_H_ 2 | #define __Q_IBUS_COMPONENT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "qibusserializable.h" 11 | #include "qibusenginedesc.h" 12 | #include "qibusobservedpath.h" 13 | 14 | namespace IBus { 15 | 16 | class Component; 17 | typedef Pointer ComponentPointer; 18 | 19 | class Component : public Serializable 20 | { 21 | Q_OBJECT; 22 | 23 | public: 24 | Component () {} 25 | Component (const QString & name, 26 | const QString & desc, 27 | const QString & vers, 28 | const QString & lics, 29 | const QString & auth, 30 | const QString & hmpg, 31 | const QString & exec, 32 | const QString & textdomain): 33 | m_name(name), 34 | m_description(desc), 35 | m_version(vers), 36 | m_license(lics), 37 | m_author(auth), 38 | m_homepage(hmpg), 39 | m_exec(exec), 40 | m_textdomain(textdomain) {} 41 | 42 | virtual ~Component () {} 43 | 44 | public: 45 | virtual bool serialize (QDBusArgument &argument); 46 | virtual bool deserialize (const QDBusArgument &argument); 47 | 48 | void output (QString &output) const; 49 | bool parseXmlNode (const QDomNode &node); 50 | // bool parseEnginesNode (QDomNode &node); 51 | // bool parseObservedPaths (const QDomNode &node); 52 | 53 | void addObservedPath (const ObservedPathPointer &obsPath); 54 | void addEngine (const EngineDescPointer &edp); 55 | 56 | QVector observedPaths () const; 57 | const QVector & engines () const; 58 | 59 | #if 0 60 | 61 | bool start (bool verbose) const; 62 | bool stop () const; 63 | bool isRunning () const; 64 | bool isComponentModified () const; 65 | const ComponentPointer getComponentFromEngine (EngineDescPointer edp) const; 66 | 67 | 68 | friend bool newComponentFromFile (Component &obj, const QString & filename); 69 | 70 | private: 71 | const QDomDocument * parseXmlFile (const QString & filename) const; 72 | const QDomDocument * parseXmlBuffer (const QByteArray & buf); 73 | 74 | #endif 75 | 76 | private: 77 | QString m_name; 78 | QString m_description; 79 | QString m_version; 80 | QString m_license; 81 | QString m_author; 82 | QString m_homepage; 83 | QString m_exec; 84 | QString m_textdomain; 85 | 86 | QVector m_observedPaths; 87 | QVector m_engines; 88 | 89 | IBUS_SERIALIZABLE 90 | }; 91 | 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /qtim/ibus-input-context.h: -------------------------------------------------------------------------------- 1 | /* vim:set noet ts=4: */ 2 | /* 3 | * ibus - The Input Bus 4 | * 5 | * Copyright (c) 2007-2014 Huang Peng 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this program; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307 USA 21 | */ 22 | #ifndef __IBUS_INPUT_CONTEXT_H_ 23 | #define __IBUS_INPUT_CONTEXT_H_ 24 | #include 25 | #include 26 | #include 27 | 28 | #define IBUS_MAX_COMPOSE_LEN 7 29 | 30 | typedef struct _IBusComposeTableCompact IBusComposeTableCompact; 31 | 32 | using namespace IBus; 33 | 34 | class IBusInputContext : public QInputContext { 35 | Q_OBJECT 36 | public: 37 | IBusInputContext (const BusPointer &bus); 38 | ~IBusInputContext (); 39 | 40 | public: 41 | bool filterEvent (const QEvent *event); 42 | QFont font (void) const; 43 | QString identifierName (void); 44 | bool isComposing (void) const; 45 | QString language (void); 46 | void mouseHandler (int x, QMouseEvent *event); 47 | void reset (void); 48 | void update (void); 49 | void setFocusWidget (QWidget *widget ); 50 | void widgetDestroyed (QWidget *widget); 51 | #ifdef Q_WS_X11 52 | bool x11FilterEvent (QWidget *keywidget, XEvent *event); 53 | #endif 54 | private Q_SLOTS: 55 | void slotCommitText (const TextPointer &text); 56 | void slotUpdatePreeditText (const TextPointer &text, uint cursor_pos, bool visible); 57 | void slotShowPreeditText (void); 58 | void slotHidePreeditText (void); 59 | void slotConnected (void); 60 | void slotDisconnected (void); 61 | void slotDeleteSurroundingText (int offset, uint nchars); 62 | void slotRequireSurroundingText (void); 63 | 64 | private: 65 | void createInputContext (void); 66 | void deleteInputContext (void); 67 | void displayPreeditText (const TextPointer &text, uint cursor_pos, bool visible); 68 | bool processCompose (uint keyval, uint state); 69 | bool checkCompactTable (const IBusComposeTableCompact *table); 70 | bool checkAlgorithmically (void); 71 | 72 | private: 73 | BusPointer m_bus; 74 | InputContextPointer m_context; 75 | TextPointer m_preedit; 76 | bool m_preedit_visible; 77 | uint m_preedit_cursor_pos; 78 | bool m_has_focus; 79 | bool m_password_mode; 80 | uint m_caps; 81 | uint m_compose_buffer[IBUS_MAX_COMPOSE_LEN + 1]; 82 | int m_n_compose; 83 | bool m_needs_surrounding_text; 84 | }; 85 | 86 | #endif //__IBUS_INPUT_CONTEXT_H_ 87 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( 2 | ${QT_QTCORE_INCLUDE_DIR} 3 | ${QT_QTDBUS_INCLUDE_DIR} 4 | ${DBUS_INCLUDE_DIRS} 5 | ) 6 | 7 | link_directories( 8 | ${DBUS_LIBRARY_DIRS} 9 | ) 10 | 11 | set( 12 | ibus_qt_SRCS 13 | qibusobject.cpp 14 | qibusserializable.cpp 15 | qibusattribute.cpp 16 | qibusattrlist.cpp 17 | qibusproperty.cpp 18 | qibusproplist.cpp 19 | qibustext.cpp 20 | qibuslookuptable.cpp 21 | qibusenginedesc.cpp 22 | qibuscomponent.cpp 23 | qibusibusproxy.cpp 24 | qibusdbusproxy.cpp 25 | qibusinputcontextproxy.cpp 26 | qibusbus.cpp 27 | qibusinputcontext.cpp 28 | qibusobservedpath.cpp 29 | qibusengineadaptor.cpp 30 | qibusengine.cpp 31 | qibusfactoryadaptor.cpp 32 | qibusenginefactory.cpp 33 | qibusconfigadaptor.cpp 34 | qibusconfigproxy.cpp 35 | qibusconfigservice.cpp 36 | qibusconfig.cpp 37 | ) 38 | 39 | set( 40 | ibus_qt_HDRS 41 | qibusobject.h 42 | qibusserializable.h 43 | qibusattribute.h 44 | qibusattrlist.h 45 | qibusproperty.h 46 | qibusproplist.h 47 | qibustext.h 48 | qibuslookuptable.h 49 | qibusenginedesc.h 50 | qibuscomponent.h 51 | qibusibusproxy.h 52 | qibusdbusproxy.h 53 | qibusinputcontextproxy.h 54 | qibusbus.h 55 | qibusinputcontext.h 56 | qibusobservedpath.h 57 | qibusengineadaptor.h 58 | qibusengine.h 59 | qibusfactoryadaptor.h 60 | qibusenginefactory.h 61 | qibusconfigadaptor.h 62 | qibusconfigproxy.h 63 | qibusconfigservice.h 64 | qibusconfig.h 65 | ) 66 | 67 | # QT4_ADD_DBUS_INTERFACE( 68 | # ibus_qt_SRCS 69 | # ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/org.freedesktop.IBus.xml 70 | # basename 71 | # ) 72 | # 73 | # QT4_AUTOMOC(${ibus_qt_SRCS}) 74 | QT4_WRAP_CPP( 75 | ibus_qt_MOC_SRCS 76 | ${ibus_qt_HDRS} 77 | ) 78 | 79 | add_library( 80 | ibus-qt 81 | SHARED 82 | ${ibus_qt_SRCS} 83 | ${ibus_qt_MOC_SRCS} 84 | ) 85 | 86 | set_target_properties( 87 | ibus-qt PROPERTIES 88 | VERSION ${LIB_VERSION} 89 | SOVERSION ${LIB_SOVERSION} 90 | ) 91 | 92 | target_link_libraries( 93 | ibus-qt 94 | debug ${QT_QTCORE_LIBRARY_DEBUG} 95 | debug ${QT_QTGUI_LIBRARY_DEBUG} 96 | debug ${QT_QTDBUS_LIBRARY_DEBUG} 97 | debug ${QT_QTXML_LIBRARY_DEBUG} 98 | optimized ${QT_QTCORE_LIBRARY_RELEASE} 99 | optimized ${QT_QTGUI_LIBRARY_RELEASE} 100 | optimized ${QT_QTDBUS_LIBRARY_RELEASE} 101 | optimized ${QT_QTXML_LIBRARY_RELEASE} 102 | ${DBUS_LIBRARIES} 103 | ${X11_LIBRARIES} 104 | ) 105 | 106 | install(TARGETS ibus-qt 107 | LIBRARY DESTINATION ${LIBDIR}) 108 | install(FILES ${ibus_qt_HDRS} 109 | DESTINATION include/ibus-qt COMPONENT Devel) 110 | 111 | add_executable( 112 | ibus-test 113 | ibus.cpp 114 | ) 115 | 116 | target_link_libraries( 117 | ibus-test 118 | ibus-qt 119 | ) 120 | 121 | # install(TARGETS ibus-test 122 | # RUNTIME DESTINATION bin) 123 | -------------------------------------------------------------------------------- /src/qibusibusproxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -p qibusibusproxy -c IBusProxy -v org.freedesktop.IBus.xml org.freedesktop.IBus 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #ifndef QIBUSIBUSPROXY_H_1268725630 12 | #define QIBUSIBUSPROXY_H_1268725630 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /* 24 | * Proxy class for interface org.freedesktop.IBus 25 | */ 26 | class IBusProxy: public QDBusAbstractInterface 27 | { 28 | Q_OBJECT 29 | public: 30 | static inline const char *staticInterfaceName() 31 | { return "org.freedesktop.IBus"; } 32 | 33 | public: 34 | IBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); 35 | 36 | ~IBusProxy(); 37 | 38 | public Q_SLOTS: // METHODS 39 | inline QDBusPendingReply CreateInputContext(const QString &name) 40 | { 41 | QList argumentList; 42 | argumentList << qVariantFromValue(name); 43 | return asyncCallWithArgumentList(QLatin1String("CreateInputContext"), argumentList); 44 | } 45 | 46 | inline QDBusPendingReply<> Exit(bool restart) 47 | { 48 | QList argumentList; 49 | argumentList << qVariantFromValue(restart); 50 | return asyncCallWithArgumentList(QLatin1String("Exit"), argumentList); 51 | } 52 | 53 | inline QDBusPendingReply GetAddress() 54 | { 55 | QList argumentList; 56 | return asyncCallWithArgumentList(QLatin1String("GetAddress"), argumentList); 57 | } 58 | 59 | inline QDBusPendingReply ListActiveEngines() 60 | { 61 | QList argumentList; 62 | return asyncCallWithArgumentList(QLatin1String("ListActiveEngines"), argumentList); 63 | } 64 | 65 | inline QDBusPendingReply ListEngines() 66 | { 67 | QList argumentList; 68 | return asyncCallWithArgumentList(QLatin1String("ListEngines"), argumentList); 69 | } 70 | 71 | inline QDBusPendingReply Ping(const QDBusVariant &data) 72 | { 73 | QList argumentList; 74 | argumentList << qVariantFromValue(data); 75 | return asyncCallWithArgumentList(QLatin1String("Ping"), argumentList); 76 | } 77 | 78 | inline QDBusPendingReply<> RegisterComponent(const QDBusVariant &components) 79 | { 80 | QList argumentList; 81 | argumentList << qVariantFromValue(components); 82 | return asyncCallWithArgumentList(QLatin1String("RegisterComponent"), argumentList); 83 | } 84 | 85 | Q_SIGNALS: // SIGNALS 86 | }; 87 | 88 | namespace org { 89 | namespace freedesktop { 90 | typedef ::IBusProxy IBus; 91 | } 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /src/interfaces/org.freedesktop.IBus.Panel.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /qtim/ibus-plugin.cpp: -------------------------------------------------------------------------------- 1 | /* vim:set et ts=4 sts=4 : */ 2 | /* 3 | * ibus - The Input Bus 4 | * 5 | * Copyright (c) 2007-2008 Huang Peng 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this program; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 | * Boston, MA 02111-1307 USA 21 | */ 22 | #include 23 | #include 24 | #include "ibus-input-context.h" 25 | 26 | #define IBUS_IDENTIFIER_NAME "ibus" 27 | 28 | using namespace IBus; 29 | 30 | /* The class Definition */ 31 | class IBusPlugin: public QInputContextPlugin 32 | { 33 | 34 | private: 35 | /** 36 | * The language list for SCIM. 37 | */ 38 | static QStringList ibus_languages; 39 | 40 | public: 41 | 42 | IBusPlugin (QObject *parent = 0); 43 | 44 | ~IBusPlugin (); 45 | 46 | QStringList keys () const; 47 | 48 | QStringList languages (const QString &key); 49 | 50 | QString description (const QString &key); 51 | 52 | QInputContext *create (const QString &key); 53 | 54 | QString displayName (const QString &key); 55 | 56 | private: 57 | BusPointer m_bus; 58 | 59 | }; 60 | 61 | 62 | /* Implementations */ 63 | QStringList IBusPlugin::ibus_languages; 64 | 65 | 66 | IBusPlugin::IBusPlugin (QObject *parent) 67 | :QInputContextPlugin (parent) 68 | { 69 | } 70 | 71 | 72 | IBusPlugin::~IBusPlugin () 73 | { 74 | } 75 | 76 | QStringList 77 | IBusPlugin::keys () const 78 | { 79 | QStringList identifiers; 80 | identifiers.push_back (IBUS_IDENTIFIER_NAME); 81 | return identifiers; 82 | } 83 | 84 | 85 | QStringList 86 | IBusPlugin::languages (const QString & key) 87 | { 88 | if (key.toLower () != IBUS_IDENTIFIER_NAME) { 89 | return QStringList (); 90 | } 91 | 92 | if (ibus_languages.empty ()) { 93 | ibus_languages.push_back ("zh"); 94 | ibus_languages.push_back ("ja"); 95 | ibus_languages.push_back ("ko"); 96 | } 97 | return ibus_languages; 98 | } 99 | 100 | 101 | QString 102 | IBusPlugin::description (const QString &key) 103 | { 104 | if (key.toLower () != IBUS_IDENTIFIER_NAME) { 105 | return QString (""); 106 | } 107 | 108 | return QString::fromUtf8 ("Qt immodule plugin for IBus"); 109 | } 110 | 111 | 112 | QInputContext * 113 | IBusPlugin::create (const QString &key) 114 | { 115 | if (key.toLower () != IBUS_IDENTIFIER_NAME) { 116 | return NULL; 117 | } 118 | 119 | if (m_bus.isNull ()) { 120 | m_bus = new Bus (); 121 | } 122 | return static_cast (new IBusInputContext (m_bus)); 123 | } 124 | 125 | 126 | QString IBusPlugin::displayName (const QString &key) 127 | { 128 | return key; 129 | } 130 | 131 | Q_EXPORT_PLUGIN2 (IBusPlugin, IBusPlugin) 132 | -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qibusdemoengine.h" 3 | 4 | using namespace IBus; 5 | 6 | int main (int argc, char **argv) 7 | { 8 | QCoreApplication app (argc, argv); 9 | 10 | #if 0 11 | 12 | ComponentPointer cmpt = new Component; 13 | if ( !newComponentFromFile(*cmpt, "component/m17n.xml") ) { 14 | qDebug () << "main::newComponentFromFile error!"; 15 | return -1; 16 | } 17 | 18 | Bus bus; 19 | if ( !bus.isConnected() ) { 20 | qDebug () << "main::bus is not connected!"; 21 | return -1; 22 | } 23 | 24 | EngineFactory *engineFactory = EngineFactory::getEngineFactory(bus.getConnection()); 25 | engineFactory->addMetaObject("kn:inscript", &(DemoEngine::staticMetaObject)); 26 | 27 | if ( !bus.registerObject ("/org/freedesktop/IBus/Factory", engineFactory) ) { 28 | qDebug () << "main::registerObject error!"; 29 | return -1; 30 | } 31 | 32 | if ( !bus.registerComponent(cmpt) ) { 33 | qDebug () << "main::registerComponent error!"; 34 | return -1; 35 | } 36 | 37 | #endif 38 | 39 | #if 0 40 | 41 | ComponentPointer cmpt = new Component; 42 | if ( !newComponentFromFile(*cmpt, "component/hangul.xml") ) { 43 | qDebug () << "main::newComponentFromFile error!"; 44 | return -1; 45 | } 46 | 47 | Bus bus; 48 | if ( !bus.isConnected() ) { 49 | qDebug () << "main::bus is not connected!"; 50 | return -1; 51 | } 52 | 53 | EngineFactory *engineFactory = EngineFactory::getEngineFactory(bus.getConnection()); 54 | engineFactory->addMetaObject("hangul", &(DemoEngine::staticMetaObject)); 55 | 56 | if ( !bus.registerObject ("/org/freedesktop/IBus/Factory", engineFactory) ) { 57 | qDebug () << "main::registerObject error!"; 58 | return -1; 59 | } 60 | 61 | if ( !bus.registerComponent(cmpt) ) { 62 | qDebug () << "main::registerComponent error!"; 63 | return -1; 64 | } 65 | 66 | #endif 67 | 68 | #if 1 69 | ComponentPointer cmpt = new Component("org.freedesktop.IBus.Qt.DemoEngine", 70 | "Qt Demo Engine", 71 | "0.1.0", 72 | "GPL", 73 | "Peng Huang ", 74 | "http://code.google.com/p/ibus/", 75 | "", 76 | "ibus-qt"); 77 | 78 | EngineDescPointer engine = new EngineDesc("qtdemo", 79 | "Qt Demo Input Method", 80 | "Qt Demo Input Method", 81 | "en", 82 | "GPL", 83 | "Peng Huang ", 84 | "ibus", 85 | "us"); 86 | 87 | cmpt->addEngine(engine); 88 | 89 | QString stream; 90 | cmpt->output(stream); 91 | qDebug () << stream; 92 | 93 | Bus bus; 94 | if ( !bus.isConnected() ) { 95 | qDebug () << "bus is not connected!"; 96 | return -1; 97 | } 98 | 99 | EngineFactory *engineFactory = EngineFactory::getEngineFactory(bus.getConnection()); 100 | engineFactory->addMetaObject("qtdemo", &(DemoEngine::staticMetaObject)); 101 | 102 | bus.registerObject ("/org/freedesktop/IBus/Factory", engineFactory); 103 | 104 | if ( !bus.registerComponent(cmpt) ) { 105 | qDebug () << "registerComponent error!"; 106 | return -1; 107 | } 108 | 109 | #endif 110 | 111 | return QCoreApplication::exec (); 112 | } 113 | -------------------------------------------------------------------------------- /src/interfaces/org.freedesktop.IBus.InputContext.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/qibusserializable.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusserializable.h" 2 | #include 3 | 4 | namespace IBus { 5 | 6 | QHash Serializable::type_table INIT_PRIO_HIGH; 7 | 8 | IBUS_DECLARE_SERIALIZABLE(Serializable, IBusSerializable); 9 | 10 | void 11 | Serializable::setAttachment (const QString &key, const SerializablePointer &value) 12 | { 13 | m_attachments[key] = value; 14 | } 15 | 16 | SerializablePointer 17 | Serializable::getAttachment (const QString &key) const 18 | { 19 | SerializablePointer p; 20 | if (m_attachments.contains (key)) 21 | p = m_attachments.value (key); 22 | return p; 23 | } 24 | 25 | SerializablePointer 26 | Serializable::removeAttachment (const QString &key) 27 | { 28 | SerializablePointer p = m_attachments.value (key); 29 | if (p) 30 | m_attachments.remove (key); 31 | return p; 32 | } 33 | 34 | bool 35 | Serializable::serialize (QDBusArgument &argument) 36 | { 37 | QMap::const_iterator i; 38 | 39 | argument.beginMap (QVariant::String, qMetaTypeId()); 40 | for (i = m_attachments.begin (); i != m_attachments.end (); i++) { 41 | argument.beginMapEntry (); 42 | argument << i.key (); 43 | argument << i.value (); 44 | argument.endMapEntry (); 45 | } 46 | argument.endMap (); 47 | return true; 48 | } 49 | 50 | bool 51 | Serializable::deserialize (const QDBusArgument &argument) 52 | { 53 | argument.beginMap (); 54 | while (!argument.atEnd()) { 55 | QString key; 56 | SerializablePointer p; 57 | argument.beginMapEntry (); 58 | argument >> key; 59 | argument >> p; 60 | argument.endMapEntry (); 61 | m_attachments[key] = p; 62 | } 63 | argument.endMap (); 64 | return true; 65 | } 66 | 67 | SerializablePointer 68 | Serializable::createInstance(const QString &name) 69 | { 70 | SerializablePointer p; 71 | 72 | if (type_table.contains (name)) { 73 | p = type_table[name](); 74 | } 75 | else { 76 | qWarning () << "Serializable::createInstance:" << "create" << name << "failed"; 77 | } 78 | return p; 79 | } 80 | 81 | void 82 | Serializable::registerObject (const QString &name, NewInstanceFunc _new) 83 | { 84 | if (type_table.contains (name)) { 85 | qFatal ("registerObject failed! name %s has been registered", (char *)name.data ()); 86 | } 87 | 88 | if (_new == NULL) { 89 | qFatal ("registerObject failed! _new should not be NULL"); 90 | } 91 | 92 | Serializable::type_table[name] = _new; 93 | } 94 | 95 | void 96 | Serializable::unregisterObject (const QString &name) 97 | { 98 | if (!type_table.contains (name)) { 99 | qFatal ("unregisterObject failed! name %s has not been registered", (char *)name.data ()); 100 | } 101 | Serializable::type_table.remove(name); 102 | } 103 | 104 | #if 0 105 | QDBusArgument& 106 | operator<< (QDBusArgument& argument, const SerializablePointer &p) 107 | { 108 | argument.beginStructure (); 109 | argument << p->getMetaInfo ()->getName (); 110 | p->serialize (argument); 111 | argument.endStructure (); 112 | 113 | return argument; 114 | } 115 | 116 | const QDBusArgument& 117 | operator>> (const QDBusArgument& argument, SerializablePointer &p) 118 | { 119 | QString name; 120 | 121 | argument.beginStructure (); 122 | argument >> name; 123 | p = Serializable::createInstance (name); 124 | if (!p->deserialize (argument)) 125 | p = NULL; 126 | argument.endStructure (); 127 | 128 | return argument; 129 | } 130 | #endif 131 | 132 | 133 | 134 | 135 | }; 136 | -------------------------------------------------------------------------------- /src/qibusdbusproxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -p qibusdbusproxy -c DBusProxy -v org.freedesktop.DBus.xml org.freedesktop.DBus 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #ifndef QIBUSDBUSPROXY_H_1268725630 12 | #define QIBUSDBUSPROXY_H_1268725630 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /* 24 | * Proxy class for interface org.freedesktop.DBus 25 | */ 26 | class DBusProxy: public QDBusAbstractInterface 27 | { 28 | Q_OBJECT 29 | public: 30 | static inline const char *staticInterfaceName() 31 | { return "org.freedesktop.DBus"; } 32 | 33 | public: 34 | DBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); 35 | 36 | ~DBusProxy(); 37 | 38 | public Q_SLOTS: // METHODS 39 | inline QDBusPendingReply<> AddMatch(const QString &in0) 40 | { 41 | QList argumentList; 42 | argumentList << qVariantFromValue(in0); 43 | return asyncCallWithArgumentList(QLatin1String("AddMatch"), argumentList); 44 | } 45 | 46 | inline QDBusPendingReply GetId() 47 | { 48 | QList argumentList; 49 | return asyncCallWithArgumentList(QLatin1String("GetId"), argumentList); 50 | } 51 | 52 | inline QDBusPendingReply GetNameOwner(const QString &in0) 53 | { 54 | QList argumentList; 55 | argumentList << qVariantFromValue(in0); 56 | return asyncCallWithArgumentList(QLatin1String("GetNameOwner"), argumentList); 57 | } 58 | 59 | inline QDBusPendingReply Hello() 60 | { 61 | QList argumentList; 62 | return asyncCallWithArgumentList(QLatin1String("Hello"), argumentList); 63 | } 64 | 65 | inline QDBusPendingReply ListNames() 66 | { 67 | QList argumentList; 68 | return asyncCallWithArgumentList(QLatin1String("ListNames"), argumentList); 69 | } 70 | 71 | inline QDBusPendingReply NameHasOwner(const QString &in0) 72 | { 73 | QList argumentList; 74 | argumentList << qVariantFromValue(in0); 75 | return asyncCallWithArgumentList(QLatin1String("NameHasOwner"), argumentList); 76 | } 77 | 78 | inline QDBusPendingReply ReleaseName(const QString &in0) 79 | { 80 | QList argumentList; 81 | argumentList << qVariantFromValue(in0); 82 | return asyncCallWithArgumentList(QLatin1String("ReleaseName"), argumentList); 83 | } 84 | 85 | inline QDBusPendingReply<> RemoveMatch(const QString &in0) 86 | { 87 | QList argumentList; 88 | argumentList << qVariantFromValue(in0); 89 | return asyncCallWithArgumentList(QLatin1String("RemoveMatch"), argumentList); 90 | } 91 | 92 | inline QDBusPendingReply RequestName(const QString &in0, uint in1) 93 | { 94 | QList argumentList; 95 | argumentList << qVariantFromValue(in0) << qVariantFromValue(in1); 96 | return asyncCallWithArgumentList(QLatin1String("RequestName"), argumentList); 97 | } 98 | 99 | Q_SIGNALS: // SIGNALS 100 | void NameOwnerChanged(const QString &in0, const QString &in1, const QString &in2); 101 | }; 102 | 103 | namespace org { 104 | namespace freedesktop { 105 | typedef ::DBusProxy DBus; 106 | } 107 | } 108 | #endif 109 | -------------------------------------------------------------------------------- /src/qibusinputcontext.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_INPUT_CONTEXT_H_ 2 | #define __Q_IBUS_INPUT_CONTEXT_H_ 3 | 4 | #include "qibusbus.h" 5 | #include "qibustext.h" 6 | #include "qibusproperty.h" 7 | #include "qibusproplist.h" 8 | #include "qibuslookuptable.h" 9 | 10 | class IBusInputContextProxy; 11 | 12 | namespace IBus { 13 | 14 | class Bus; 15 | typedef Pointer BusPointer; 16 | 17 | class InputContext; 18 | typedef Pointer InputContextPointer; 19 | 20 | class InputContext : public Object 21 | { 22 | Q_OBJECT; 23 | 24 | public: 25 | InputContext (const BusPointer &bus, const QString &path); 26 | ~InputContext (void); 27 | 28 | void reset (void); 29 | void destroy (void); 30 | void enable (void); 31 | void disable (void); 32 | void focusIn (void); 33 | void focusOut (void); 34 | void getEngine (void); 35 | bool isEnabled (void); 36 | bool processKeyEvent (uint keyval, uint keycode, uint state); 37 | void setCapabilities (uint caps); 38 | void setCursorLocation (int x, int y, int w, int h); 39 | void setEngine (const QString &name); 40 | void setSurroundingText (const TextPointer &text, uint cursor_pos, uint anchor_pos); 41 | 42 | public: 43 | static InputContextPointer create (const BusPointer &bus, const QString &name); 44 | 45 | Q_SIGNALS: 46 | void commitText (const TextPointer &text); 47 | 48 | void updatePreeditText (const TextPointer &text, uint cursor_pos, bool visible); 49 | void showPreeditText (void); 50 | void hidePreeditText (void); 51 | 52 | void updateAuxiliaryText (const TextPointer &text, bool visible); 53 | void showAuxiliaryText (void); 54 | void hideAuxiliaryText (void); 55 | 56 | void updateLookupTable (const LookupTablePointer &table, bool visible); 57 | void showLookupTable (void); 58 | void hideLookupTable (void); 59 | void cursorUpLookupTable (void); 60 | void cursorDownLookupTable (void); 61 | void pageUpLookupTable (void); 62 | void pageDownLookupTable (void); 63 | 64 | void registerProperties (const PropListPointer &props); 65 | void updateProperty (const PropertyPointer &property); 66 | 67 | void enabled (void); 68 | void disabled (void); 69 | 70 | void forwardKeyEvent (uint keyval, uint keycode, uint state); 71 | void deleteSurroundingText (int offset, uint nchars); 72 | void requireSurroundingText (void); 73 | 74 | private Q_SLOTS: 75 | void slotCommitText (const QDBusVariant &text); 76 | 77 | void slotUpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); 78 | void slotHidePreeditText(); 79 | void slotShowPreeditText(); 80 | 81 | void slotUpdateAuxiliaryText(const QDBusVariant &text, bool visible); 82 | void slotShowAuxiliaryText(); 83 | void slotHideAuxiliaryText(); 84 | 85 | void slotUpdateLookupTable(const QDBusVariant &table, bool visible); 86 | void slotShowLookupTable(); 87 | void slotHideLookupTable(); 88 | void slotCursorUpLookupTable(); 89 | void slotCursorDownLookupTable(); 90 | void slotPageUpLookupTable(); 91 | void slotPageDownLookupTable(); 92 | 93 | void slotRegisterProperties(const QDBusVariant &props); 94 | void slotUpdateProperty(const QDBusVariant &prop); 95 | 96 | void slotEnabled(); 97 | void slotDisabled(); 98 | 99 | void slotForwardKeyEvent(uint keyval, uint keycode, uint state); 100 | void slotDeleteSurroundingText(int offset, uint nchars); 101 | void slotRequireSurroundingText(); 102 | 103 | /* 104 | signals: 105 | void disconnected (void); 106 | void connected (void); 107 | 108 | private slots: 109 | void slotAddressChanged (const QString &path); 110 | void slotIBusDisconnected (void); 111 | */ 112 | private: 113 | BusPointer m_bus; 114 | IBusInputContextProxy *m_context; 115 | }; 116 | 117 | }; 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /src/interfaces/org.freedesktop.IBus.Engine.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /src/qibusobservedpath.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusobservedpath.h" 2 | 3 | namespace IBus { 4 | 5 | IBUS_DECLARE_SERIALIZABLE(ObservedPath, IBusObservedPath); 6 | 7 | bool 8 | ObservedPath::serialize (QDBusArgument & argument) 9 | { 10 | if ( !Serializable::serialize(argument) ) { 11 | return false; 12 | } 13 | 14 | argument << m_path; 15 | argument << m_mtime; 16 | 17 | return true; 18 | } 19 | 20 | bool 21 | ObservedPath::deserialize (const QDBusArgument & argument) 22 | { 23 | if ( !Serializable::deserialize(argument) ) { 24 | return false; 25 | } 26 | 27 | argument >> m_path; 28 | argument >> m_mtime; 29 | 30 | return true; 31 | } 32 | 33 | bool 34 | ObservedPath::parseXmlNode (const QDomNode & node) 35 | { 36 | if ( node.nodeName().compare("path") ) { 37 | return false; 38 | } 39 | 40 | // process path 41 | int lstIdx = node.toElement().text().lastIndexOf('/'); 42 | QDir path(node.toElement().text().left(lstIdx)); 43 | 44 | if ( !path.isReadable() ) { 45 | return false; 46 | } 47 | 48 | if ( path.isAbsolute() ) { 49 | m_path = node.toElement().text(); 50 | } 51 | else if ( path.isRelative() ) { 52 | if ( node.toElement().text()[0] == '~' ) { 53 | QString homePath = QDir::homePath(); 54 | m_path += homePath; 55 | m_path += node.toElement().text().right(node.toElement().text().size() - 2); 56 | } 57 | else if ( node.toElement().text()[0] == '.' && node.toElement().text()[1] == '/' ) { 58 | QString curPath = QDir::currentPath(); 59 | m_path += curPath; 60 | m_path += node.toElement().text().right(node.toElement().text().size() - 2); 61 | } 62 | else { 63 | QString curPath = QDir::currentPath(); 64 | m_path += curPath; 65 | m_path += node.toElement().text(); 66 | } 67 | } 68 | else { 69 | qDebug() << "ObservedPath::parseXmlNode: invalid path! \"" << node.toElement().text() << "\""; 70 | return false; 71 | } 72 | 73 | // process mtime 74 | if ( node.hasAttributes() ) { 75 | QDomNamedNodeMap nnMap = node.attributes(); 76 | for ( uint i = 0; i < nnMap.length(); ++i ) { 77 | QDomNode attrNode = nnMap.item(i); 78 | if ( !attrNode.nodeName().compare("mtime") ) { 79 | m_mtime = attrNode.toElement().text().toInt(); 80 | } 81 | } 82 | } 83 | 84 | return true; 85 | } 86 | 87 | #if 0 88 | 89 | bool 90 | ObservedPath::isObservedPathModified () const 91 | { 92 | QFileInfo fi(m_path); 93 | if ( m_mtime == fi.lastModified().toTime_t() ) { 94 | return false; 95 | } 96 | 97 | return true; 98 | } 99 | 100 | void 101 | ObservedPath::setObservedPathStat () 102 | { 103 | QFileInfo fi(m_path); 104 | if ( fi.exists() ) { 105 | m_isExist = true; 106 | m_mtime = fi.lastModified().toTime_t(); 107 | if ( fi.isDir() ) { 108 | m_isDir = true; 109 | } 110 | } 111 | else { 112 | m_isExist = false; 113 | m_isDir = false; 114 | m_mtime = 0; 115 | } 116 | } 117 | 118 | void 119 | ObservedPath::traverseObservedPath (QVector & observedPathVec) const 120 | { 121 | QDir dir(m_path); 122 | dir.setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); 123 | QStringList files = dir.entryList(); 124 | 125 | for ( int i = 0; i < files.size(); ++i ) { 126 | QString file = files.at(i); 127 | // qDebug () << file; 128 | ObservedPathPointer observedPath = new ObservedPath(file); 129 | observedPath->setObservedPathStat(); 130 | observedPathVec.push_back(observedPath); 131 | 132 | if ( observedPath->isDirFile() ) { 133 | observedPath->traverseObservedPath(observedPathVec); 134 | } 135 | } 136 | } 137 | 138 | #endif 139 | 140 | }; 141 | 142 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | if(COMMAND cmake_policy) 3 | cmake_policy(SET CMP0003 NEW) 4 | endif(COMMAND cmake_policy) 5 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") 6 | 7 | # ====== 8 | # Project information 9 | project(ibus-qt) 10 | set(AUTHORS "Peng Huang") 11 | set(MAINTAINER "Peng Huang ") 12 | set(VERSION_MAJOR "1") 13 | set(VERSION_MINOR "3") 14 | set(VERSION_PATCH "4") 15 | set(VERSION_SNAPDATE "") 16 | set(LIB_VERSION "1.3.0") 17 | set(LIB_SOVERSION "1") 18 | 19 | # ====== 20 | # CPack configure 21 | set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) 22 | set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) 23 | if(NOT VERSION_SNAPDATE) 24 | set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) 25 | else(NOT VERSION_SNAPDATE) 26 | set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}.${VERSION_SNAPDATE}) 27 | endif(NOT VERSION_SNAPDATE) 28 | 29 | set(CPACK_SET_DESTDIR "ON") 30 | set(CPACK_INSTALL_PREFIX "/usr") 31 | set(CPACK_GENERATOR "TGZ") 32 | set(CPACK_SOURCE_GENERATOR "TGZ") 33 | set(CPACK_CMAKE_GENERATOR "Unix Makefiles") 34 | set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING) 35 | set(CPACK_SOURCE_IGNORE_FILES 36 | "/\\\\.git/" 37 | "\\\\.gitignore$" 38 | "\\\\.travis\\\\.yml$" 39 | "/CMakeFiles/" 40 | "/_CPack_Packages/" 41 | "cmake_install.cmake" 42 | "CMakeCache.txt$" 43 | "install_manifest.txt$" 44 | "Makefile$" 45 | "Source\\\\.tar\\\\.gz$" 46 | "Linux\\\\.tar\\\\.gz$" 47 | "moc_.*\\\\.cxx$" 48 | "\\\\.back$" 49 | "\\\\.back\\\\/" 50 | "\\\\.diff$" 51 | "\\\\.orig$" 52 | "\\\\.orig\\\\/" 53 | "\\\\.patch$" 54 | "\\\\.so$" 55 | "\\\\.so\\\\.*" 56 | "ibus-test$" 57 | "/rpm/" 58 | "ibus-qt\\\\.spec$" 59 | "CPackSourceConfig\\\\.cmake$" 60 | "CPackConfig\\\\.cmake$" 61 | "docs/Doxyfile$" 62 | "docs/man" 63 | "docs/html" 64 | "ibus-qt-*-Source" 65 | "test/demo-engine" 66 | "test/diffdist.sh" 67 | ) 68 | include(CPack) 69 | 70 | configure_file(ibus-qt.spec.in ibus-qt.spec) 71 | configure_file(docs/Doxyfile.in docs/Doxyfile) 72 | 73 | # ====== 74 | # Requires 75 | # check X11 76 | find_package(X11 REQUIRED) 77 | 78 | # check qt 79 | find_package(Qt4 4.5 COMPONENTS QtCore QtGui QtDBus QtXml REQUIRED) 80 | include(${QT_USE_FILE}) 81 | 82 | # check dbus 83 | find_package(PkgConfig REQUIRED) 84 | find_package(ICU REQUIRED) 85 | pkg_check_modules(DBUS REQUIRED dbus-1) 86 | pkg_check_modules(IBUS REQUIRED ibus-1.0>=1.3.7) 87 | 88 | # check doxygen 89 | find_package(Doxygen REQUIRED) 90 | 91 | # ===== 92 | # Define variables 93 | if(NOT LIBDIR) 94 | if( $ENV{MACHTYPE} MATCHES "64") 95 | set(LIBDIR lib64) 96 | else() 97 | set(LIBDIR lib) 98 | endif() 99 | endif(NOT LIBDIR) 100 | 101 | if(NOT MANDIR) 102 | set(MANDIR "share/man") 103 | endif(NOT MANDIR) 104 | 105 | # ====== 106 | # sub dirs 107 | add_subdirectory(src) 108 | add_subdirectory(qtim) 109 | add_subdirectory(test) 110 | add_subdirectory(docs) 111 | 112 | # ====== 113 | # targets 114 | add_custom_target(version echo ${CPACK_PACKAGE_VERSION}) 115 | add_custom_target(gitclean git clean -f -d -X) 116 | add_custom_target(rpm 117 | COMMAND make package_source 118 | COMMAND rpmbuild -bb 119 | --define "_sourcedir ${CMAKE_CURRENT_BINARY_DIR}" 120 | --define "_builddir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 121 | --define "_srcrpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 122 | --define "_rpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 123 | --define "_specdir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 124 | ibus-qt.spec 125 | SOURCES ibus-qt.spec 126 | ) 127 | add_custom_target(srpm 128 | COMMAND make package_source 129 | COMMAND rpmbuild -bs 130 | --define "_sourcedir ${CMAKE_CURRENT_BINARY_DIR}" 131 | --define "_builddir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 132 | --define "_srcrpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 133 | --define "_rpmdir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 134 | --define "_specdir ${CMAKE_CURRENT_BINARY_DIR}/rpm" 135 | ibus-qt.spec 136 | SOURCES ibus-qt.spec 137 | ) 138 | -------------------------------------------------------------------------------- /src/qibusenginedesc.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusenginedesc.h" 2 | 3 | namespace IBus { 4 | 5 | IBUS_DECLARE_SERIALIZABLE(EngineDesc, IBusEngineDesc); 6 | 7 | bool 8 | EngineDesc::serialize (QDBusArgument &argument) 9 | { 10 | if (!Serializable::serialize (argument)) 11 | return false; 12 | 13 | argument << m_name; 14 | argument << m_longname; 15 | argument << m_description; 16 | argument << m_language; 17 | argument << m_license; 18 | argument << m_author; 19 | argument << m_icon; 20 | argument << m_layout; 21 | argument << m_hotkeys; 22 | argument << m_rank; 23 | 24 | return true; 25 | } 26 | 27 | bool 28 | EngineDesc::deserialize (const QDBusArgument &argument) 29 | { 30 | if (!Serializable::deserialize (argument)) 31 | return false; 32 | 33 | argument >> m_name; 34 | argument >> m_longname; 35 | argument >> m_description; 36 | argument >> m_language; 37 | argument >> m_license; 38 | argument >> m_author; 39 | argument >> m_icon; 40 | argument >> m_layout; 41 | argument >> m_hotkeys; 42 | argument >> m_rank; 43 | 44 | return true; 45 | } 46 | 47 | // generate xml stream via QT-lib 48 | void 49 | EngineDesc::output (QString & output) const 50 | { 51 | QXmlStreamWriter stream(&output); 52 | stream.setAutoFormatting(true); 53 | 54 | stream.writeStartElement("engine"); 55 | 56 | stream.writeTextElement("name", m_name); 57 | stream.writeTextElement("longname", m_longname); 58 | stream.writeTextElement("description", m_description); 59 | stream.writeTextElement("language", m_language); 60 | stream.writeTextElement("license", m_license); 61 | stream.writeTextElement("author", m_author); 62 | stream.writeTextElement("icon", m_icon); 63 | stream.writeTextElement("layout", m_layout); 64 | stream.writeTextElement("hotkeys", m_hotkeys); 65 | 66 | QString stringRank; 67 | stringRank = stringRank.number(m_rank); 68 | stream.writeTextElement("rank", stringRank); 69 | 70 | stream.writeEndElement(); 71 | } 72 | 73 | bool 74 | EngineDesc::parseXmlNode (const QDomNode & node) 75 | { 76 | if ( node.nodeName().compare("engine") ) { 77 | return false; 78 | } 79 | 80 | bool errFlag = false; 81 | 82 | QDomNode child = node.firstChild(); 83 | for ( ; !child.isNull() ; child = child.nextSibling() ) { 84 | if ( !child.nodeName().compare("name") ) { 85 | m_name = child.toElement().text(); 86 | } 87 | else if ( !child.nodeName().compare("longname") ) { 88 | m_longname = child.toElement().text(); 89 | } 90 | else if ( !child.nodeName().compare("description") ) { 91 | m_description = child.toElement().text(); 92 | } 93 | else if ( !child.nodeName().compare("language") ) { 94 | m_language = child.toElement().text(); 95 | } 96 | else if ( !child.nodeName().compare("license") ) { 97 | m_license = child.toElement().text(); 98 | } 99 | else if ( !child.nodeName().compare("author") ) { 100 | m_author = child.toElement().text(); 101 | } 102 | else if ( !child.nodeName().compare("icon") ) { 103 | m_icon = child.toElement().text(); 104 | } 105 | else if ( !child.nodeName().compare("layout") ) { 106 | m_layout = child.toElement().text(); 107 | } 108 | else if ( !child.nodeName().compare("hotkeys") ) { 109 | m_hotkeys = child.toElement().text(); 110 | } 111 | else if ( !child.nodeName().compare("rank") ) { 112 | m_rank = child.toElement().text().toUInt(); 113 | } 114 | else { 115 | QString s; 116 | QXmlStreamWriter stream(&s); 117 | stream.writeTextElement(child.nodeName(), child.toElement().text()); 118 | qDebug() << "EngineDesc::parseXmlNode, Unknown element, \"<" << s << "\""; 119 | 120 | errFlag = true; 121 | break; 122 | } 123 | } 124 | 125 | if ( errFlag ) { 126 | return false; 127 | } 128 | 129 | return true; 130 | } 131 | 132 | }; 133 | -------------------------------------------------------------------------------- /src/qibusengine.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusengine.h" 2 | #include "qibusengineadaptor.h" 3 | 4 | namespace IBus { 5 | 6 | Engine::Engine (const QString &engineName) 7 | : m_engineName(engineName) 8 | { 9 | m_adaptor = new IBusEngineAdaptor (this); 10 | if ( !m_adaptor ) { 11 | qDebug () << "Engine::Engine, new IBusEngineAdaptor error!"; 12 | } 13 | } 14 | 15 | Engine::~Engine () 16 | { 17 | if( NULL != m_adaptor ) { 18 | delete m_adaptor; 19 | m_adaptor = NULL; 20 | } 21 | } 22 | 23 | const QString & 24 | Engine::engineName () const 25 | { 26 | return m_engineName; 27 | } 28 | 29 | void 30 | Engine::updateLookupTableFast (const LookupTablePointer & lookupTablePtr, bool visible) 31 | { 32 | if ( static_cast(lookupTablePtr->candidates().size()) <= (lookupTablePtr->pageSize() << 2) ) { 33 | updateLookupTable(lookupTablePtr, visible); 34 | return ; 35 | } 36 | 37 | LookupTable newLookupTable(lookupTablePtr->pageSize(), 0, lookupTablePtr->isCursorVisible(), lookupTablePtr->isRound()); 38 | uint pageNumBegin = lookupTablePtr->cursorPos() / lookupTablePtr->pageSize(); 39 | 40 | for ( int i = 0; i < (lookupTablePtr->candidates().size()) \ 41 | && i < static_cast(pageNumBegin * lookupTablePtr->pageSize() + lookupTablePtr->pageSize()); ++i ) { 42 | newLookupTable.appendCandidate (lookupTablePtr->candidate (i)); 43 | } 44 | 45 | newLookupTable.setCursorPos (lookupTablePtr->cursorPos ()); 46 | updateLookupTable (static_cast(&newLookupTable), visible); 47 | } 48 | 49 | void 50 | Engine::CandidateClicked (uint index, uint button, uint state) 51 | { 52 | candidateClicked(index, button, state); 53 | } 54 | 55 | void 56 | Engine::CursorDown () 57 | { 58 | cursorDown(); 59 | } 60 | 61 | void 62 | Engine::CursorUp () 63 | { 64 | cursorUp(); 65 | } 66 | 67 | void 68 | Engine::Destroy () 69 | { 70 | destroy(); 71 | } 72 | 73 | void 74 | Engine::Disable () 75 | { 76 | disable(); 77 | } 78 | 79 | void 80 | Engine::Enable () 81 | { 82 | enable(); 83 | } 84 | 85 | void 86 | Engine::FocusIn() 87 | { 88 | focusIn(); 89 | } 90 | 91 | void 92 | Engine::FocusOut() 93 | { 94 | focusOut(); 95 | } 96 | 97 | void 98 | Engine::PageDown() 99 | { 100 | pageDown(); 101 | } 102 | 103 | void 104 | Engine::PageUp() 105 | { 106 | pageUp(); 107 | } 108 | 109 | bool 110 | Engine::ProcessKeyEvent(uint keyval, uint keycode, uint state) 111 | { 112 | return processKeyEvent(keyval, keycode, state); 113 | } 114 | 115 | void 116 | Engine::PropertyActivate(const QString &prop_name, int prop_state) 117 | { 118 | qDebug () << "Engine::PropertyActivate"; 119 | 120 | propertyActivate(prop_name, prop_state); 121 | } 122 | 123 | void 124 | Engine::PropertyHide(const QString &prop_name) 125 | { 126 | propertyHide(prop_name); 127 | } 128 | 129 | void 130 | Engine::PropertyShow(const QString &prop_name) 131 | { 132 | propertyShow(prop_name); 133 | } 134 | 135 | void 136 | Engine::Reset() 137 | { 138 | reset(); 139 | } 140 | 141 | void 142 | Engine::SetCapabilities(uint cap) 143 | { 144 | setCapabilities(cap); 145 | } 146 | 147 | void 148 | Engine::SetCursorLocation(int x, int y, int w, int h) 149 | { 150 | setCursorLocation(x, y, w, h); 151 | } 152 | 153 | // IME developpers need to implement following functions 154 | void 155 | Engine::candidateClicked (uint index, uint button, uint state) 156 | {} 157 | 158 | void 159 | Engine::cursorDown () 160 | {} 161 | 162 | void 163 | Engine::cursorUp () 164 | {} 165 | 166 | void 167 | Engine::destroy () 168 | {} 169 | 170 | void 171 | Engine::disable () 172 | {} 173 | 174 | void 175 | Engine::enable () 176 | {} 177 | 178 | void 179 | Engine::focusIn () 180 | {} 181 | 182 | void 183 | Engine::focusOut () 184 | {} 185 | 186 | void 187 | Engine::pageDown () 188 | {} 189 | 190 | void 191 | Engine::pageUp () 192 | {} 193 | 194 | bool 195 | Engine::processKeyEvent (uint keyval, uint keycode, uint state) 196 | { 197 | return true; 198 | } 199 | 200 | void 201 | Engine::propertyActivate (const QString &prop_name, int prop_state) 202 | { 203 | } 204 | 205 | void 206 | Engine::propertyHide (const QString &prop_name) 207 | { 208 | } 209 | 210 | void 211 | Engine::propertyShow (const QString &prop_name) 212 | { 213 | } 214 | 215 | void 216 | Engine::reset () 217 | { 218 | } 219 | 220 | void 221 | Engine::setCapabilities (uint cap) 222 | { 223 | } 224 | 225 | void 226 | Engine::setCursorLocation (int x, int y, int w, int h) 227 | { 228 | } 229 | 230 | }; 231 | -------------------------------------------------------------------------------- /src/qibusengineadaptor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibusengineadaptor -c IBusEngineAdaptor -v org.freedesktop.IBus.Engine.xml org.freedesktop.IBus.Engine 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #include "qibusengineadaptor.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /* 21 | * Implementation of adaptor class IBusEngineAdaptor 22 | */ 23 | 24 | IBusEngineAdaptor::IBusEngineAdaptor(QObject *parent) 25 | : QDBusAbstractAdaptor(parent) 26 | { 27 | // constructor 28 | setAutoRelaySignals(true); 29 | } 30 | 31 | IBusEngineAdaptor::~IBusEngineAdaptor() 32 | { 33 | // destructor 34 | } 35 | 36 | void IBusEngineAdaptor::CandidateClicked(uint index, uint button, uint state) 37 | { 38 | // handle method call org.freedesktop.IBus.Engine.CandidateClicked 39 | QMetaObject::invokeMethod(parent(), "CandidateClicked", Q_ARG(uint, index), Q_ARG(uint, button), Q_ARG(uint, state)); 40 | } 41 | 42 | void IBusEngineAdaptor::CursorDown() 43 | { 44 | // handle method call org.freedesktop.IBus.Engine.CursorDown 45 | QMetaObject::invokeMethod(parent(), "CursorDown"); 46 | } 47 | 48 | void IBusEngineAdaptor::CursorUp() 49 | { 50 | // handle method call org.freedesktop.IBus.Engine.CursorUp 51 | QMetaObject::invokeMethod(parent(), "CursorUp"); 52 | } 53 | 54 | void IBusEngineAdaptor::Destroy() 55 | { 56 | // handle method call org.freedesktop.IBus.Engine.Destroy 57 | QMetaObject::invokeMethod(parent(), "Destroy"); 58 | } 59 | 60 | void IBusEngineAdaptor::Disable() 61 | { 62 | // handle method call org.freedesktop.IBus.Engine.Disable 63 | QMetaObject::invokeMethod(parent(), "Disable"); 64 | } 65 | 66 | void IBusEngineAdaptor::Enable() 67 | { 68 | // handle method call org.freedesktop.IBus.Engine.Enable 69 | QMetaObject::invokeMethod(parent(), "Enable"); 70 | } 71 | 72 | void IBusEngineAdaptor::FocusIn() 73 | { 74 | // handle method call org.freedesktop.IBus.Engine.FocusIn 75 | QMetaObject::invokeMethod(parent(), "FocusIn"); 76 | } 77 | 78 | void IBusEngineAdaptor::FocusOut() 79 | { 80 | // handle method call org.freedesktop.IBus.Engine.FocusOut 81 | QMetaObject::invokeMethod(parent(), "FocusOut"); 82 | } 83 | 84 | void IBusEngineAdaptor::PageDown() 85 | { 86 | // handle method call org.freedesktop.IBus.Engine.PageDown 87 | QMetaObject::invokeMethod(parent(), "PageDown"); 88 | } 89 | 90 | void IBusEngineAdaptor::PageUp() 91 | { 92 | // handle method call org.freedesktop.IBus.Engine.PageUp 93 | QMetaObject::invokeMethod(parent(), "PageUp"); 94 | } 95 | 96 | bool IBusEngineAdaptor::ProcessKeyEvent(uint keyval, uint keycode, uint state) 97 | { 98 | // handle method call org.freedesktop.IBus.Engine.ProcessKeyEvent 99 | bool out0; 100 | QMetaObject::invokeMethod(parent(), "ProcessKeyEvent", Q_RETURN_ARG(bool, out0), Q_ARG(uint, keyval), Q_ARG(uint, keycode), Q_ARG(uint, state)); 101 | return out0; 102 | } 103 | 104 | void IBusEngineAdaptor::PropertyActivate(const QString &prop_name, int prop_state) 105 | { 106 | // handle method call org.freedesktop.IBus.Engine.PropertyActivate 107 | QMetaObject::invokeMethod(parent(), "PropertyActivate", Q_ARG(QString, prop_name), Q_ARG(int, prop_state)); 108 | } 109 | 110 | void IBusEngineAdaptor::PropertyHide(const QString &prop_name) 111 | { 112 | // handle method call org.freedesktop.IBus.Engine.PropertyHide 113 | QMetaObject::invokeMethod(parent(), "PropertyHide", Q_ARG(QString, prop_name)); 114 | } 115 | 116 | void IBusEngineAdaptor::PropertyShow(const QString &prop_name) 117 | { 118 | // handle method call org.freedesktop.IBus.Engine.PropertyShow 119 | QMetaObject::invokeMethod(parent(), "PropertyShow", Q_ARG(QString, prop_name)); 120 | } 121 | 122 | void IBusEngineAdaptor::Reset() 123 | { 124 | // handle method call org.freedesktop.IBus.Engine.Reset 125 | QMetaObject::invokeMethod(parent(), "Reset"); 126 | } 127 | 128 | void IBusEngineAdaptor::SetCapabilities(uint cap) 129 | { 130 | // handle method call org.freedesktop.IBus.Engine.SetCapabilities 131 | QMetaObject::invokeMethod(parent(), "SetCapabilities", Q_ARG(uint, cap)); 132 | } 133 | 134 | void IBusEngineAdaptor::SetCursorLocation(int x, int y, int w, int h) 135 | { 136 | // handle method call org.freedesktop.IBus.Engine.SetCursorLocation 137 | QMetaObject::invokeMethod(parent(), "SetCursorLocation", Q_ARG(int, x), Q_ARG(int, y), Q_ARG(int, w), Q_ARG(int, h)); 138 | } 139 | 140 | -------------------------------------------------------------------------------- /src/qibuslookuptable.cpp: -------------------------------------------------------------------------------- 1 | #include "qibuslookuptable.h" 2 | 3 | namespace IBus { 4 | 5 | IBUS_DECLARE_SERIALIZABLE(LookupTable, IBusLookupTable); 6 | 7 | bool 8 | LookupTable::serialize (QDBusArgument & argument) 9 | { 10 | if ( !Serializable::serialize(argument) ) 11 | return false; 12 | 13 | // read variables of basic type into argument 14 | argument << m_pageSize; 15 | argument << m_cursorPos; 16 | argument << m_cursorVisible; 17 | argument << m_round; 18 | argument << m_orientation; 19 | 20 | argument.beginArray (qMetaTypeId()); 21 | for ( int i = 0; i < m_candidates.size(); ++i ) { 22 | argument << m_candidates[i]; 23 | } 24 | argument.endArray(); 25 | 26 | argument.beginArray (qMetaTypeId()); 27 | for ( int i = 0; i < m_labels.size(); ++i ) { 28 | argument << m_labels[i]; 29 | } 30 | argument.endArray(); 31 | 32 | return true; 33 | } 34 | 35 | bool 36 | LookupTable::deserialize (const QDBusArgument & argument) 37 | { 38 | if ( !Serializable::deserialize(argument) ) 39 | return false; 40 | 41 | // clear vector 42 | m_candidates.clear(); 43 | m_labels.clear(); 44 | 45 | argument >> m_pageSize; 46 | argument >> m_cursorPos; 47 | argument >> m_cursorVisible; 48 | argument >> m_round; 49 | argument >> m_orientation; 50 | 51 | argument.beginArray(); 52 | while ( !argument.atEnd() ); 53 | { 54 | TextPointer tp; 55 | argument >> tp; 56 | m_candidates.append(tp); 57 | } 58 | argument.endArray(); 59 | 60 | argument.beginArray(); 61 | while ( !argument.atEnd() ); 62 | { 63 | TextPointer tp; 64 | argument >> tp; 65 | m_labels.append(tp); 66 | } 67 | argument.endArray(); 68 | 69 | return true; 70 | } 71 | 72 | void 73 | LookupTable::appendCandidate(const TextPointer & e) 74 | { 75 | m_candidates.append(e); 76 | } 77 | 78 | void 79 | LookupTable::appendLabel(const TextPointer & e) 80 | { 81 | m_labels.append(e); 82 | } 83 | 84 | TextPointer 85 | LookupTable::candidate(uint index) const 86 | { 87 | if ( index >= static_cast(m_candidates.size()) ) 88 | return NULL; 89 | 90 | // pageNum: which page is cursor located in ? 91 | uint pageNum = m_cursorPos / m_pageSize; 92 | index = pageNum * m_pageSize + index; 93 | return m_candidates[index]; 94 | } 95 | 96 | TextPointer 97 | LookupTable::label(const uint index) const 98 | { 99 | if ( index >= static_cast(m_labels.size()) ) 100 | return NULL; 101 | 102 | return m_labels[index]; 103 | } 104 | 105 | void 106 | LookupTable::setCursorPos(const uint cursorPos) 107 | { 108 | m_cursorPos = cursorPos; 109 | } 110 | 111 | uint 112 | LookupTable::cursorPosInPage() const 113 | { 114 | return (m_cursorPos % m_pageSize); 115 | } 116 | 117 | void 118 | LookupTable::setCursorVisible(bool visible) 119 | { 120 | m_cursorVisible = visible; 121 | } 122 | 123 | void 124 | LookupTable::setPageSize(const uint pageSize) 125 | { 126 | m_pageSize = pageSize; 127 | } 128 | 129 | void 130 | LookupTable::setOrientation (int orientation) 131 | { 132 | m_orientation = orientation; 133 | } 134 | 135 | void 136 | LookupTable::clean (void) 137 | { 138 | m_candidates.clear (); 139 | } 140 | 141 | bool 142 | LookupTable::pageUp() 143 | { 144 | if ( m_cursorPos >= m_pageSize ) { 145 | m_cursorPos -= m_pageSize; 146 | return true; 147 | } 148 | 149 | // here, cursor points to first page 150 | if ( !m_round ) { 151 | return false; 152 | } 153 | 154 | // set the right position of cursor 155 | uint tmpCursorPos = (m_candidates.size() / m_pageSize) * m_pageSize + cursorPosInPage(); 156 | if ( tmpCursorPos >= static_cast(m_candidates.size()) ) 157 | m_cursorPos = m_candidates.size() - 1; 158 | else 159 | m_cursorPos = tmpCursorPos; 160 | 161 | return true; 162 | } 163 | 164 | bool 165 | LookupTable::pageDown() 166 | { 167 | if ( (m_candidates.size() / m_pageSize) > (m_cursorPos / m_pageSize) ) { 168 | if ( (m_cursorPos + m_pageSize) < static_cast(m_candidates.size()) ) 169 | m_cursorPos = m_cursorPos + m_pageSize; 170 | else 171 | m_cursorPos = ((m_cursorPos / m_pageSize) * m_pageSize) + cursorPosInPage(); 172 | 173 | return true; 174 | } 175 | 176 | // curosr points to last page 177 | if ( !m_round ) 178 | return false; 179 | 180 | m_cursorPos = m_cursorPos % m_pageSize; 181 | return true; 182 | } 183 | 184 | bool 185 | LookupTable::cursorUp() 186 | { 187 | if ( m_cursorPos == 0 ) { 188 | // cursor points to the first candidate of first page 189 | if ( !m_round ) { 190 | return false; 191 | } 192 | 193 | m_cursorPos = m_candidates.size() - 1; 194 | return true; 195 | } 196 | 197 | --m_cursorPos; 198 | return true; 199 | } 200 | 201 | bool 202 | LookupTable::cursorDown() 203 | { 204 | if ( ++m_cursorPos < static_cast(m_candidates.size()) ) { 205 | return true; 206 | } 207 | 208 | if ( m_round ) { 209 | m_cursorPos = 0; 210 | return true; 211 | } 212 | 213 | return false; 214 | } 215 | 216 | }; 217 | -------------------------------------------------------------------------------- /src/qibuspaneladaptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibuspaneladaptor -c IBusPanelAdaptor -v org.freedesktop.IBus.Panel.xml org.freedesktop.IBus.Panel 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #ifndef QIBUSPANELADAPTOR_H_1268725630 13 | #define QIBUSPANELADAPTOR_H_1268725630 14 | 15 | #include 16 | #include 17 | class QByteArray; 18 | template class QList; 19 | template class QMap; 20 | class QString; 21 | class QStringList; 22 | class QVariant; 23 | 24 | /* 25 | * Adaptor class for interface org.freedesktop.IBus.Panel 26 | */ 27 | class IBusPanelAdaptor: public QDBusAbstractAdaptor 28 | { 29 | Q_OBJECT 30 | Q_CLASSINFO("D-Bus Interface", "org.freedesktop.IBus.Panel") 31 | Q_CLASSINFO("D-Bus Introspection", "" 32 | " \n" 33 | " \n" 34 | " \n" 35 | " \n" 36 | " \n" 37 | " \n" 38 | " \n" 39 | " \n" 40 | " \n" 41 | " \n" 42 | " \n" 43 | " \n" 44 | " \n" 45 | " \n" 46 | " \n" 47 | " \n" 48 | " \n" 49 | " \n" 50 | " \n" 51 | " \n" 52 | " \n" 53 | " \n" 54 | " \n" 55 | " \n" 56 | " \n" 57 | " \n" 58 | " \n" 59 | " \n" 60 | " \n" 61 | " \n" 62 | " \n" 63 | " \n" 64 | " \n" 65 | " \n" 66 | " \n" 67 | " \n" 68 | " \n" 69 | " \n" 70 | " \n" 71 | " \n" 72 | " \n" 73 | " \n" 74 | " \n" 75 | " \n" 76 | " \n" 77 | " \n" 78 | " \n" 79 | " \n" 80 | " \n" 81 | " \n" 82 | " \n" 83 | " \n" 84 | " \n" 85 | " \n" 86 | " \n" 87 | " \n" 88 | " \n" 89 | " \n" 90 | " \n" 91 | " \n" 92 | " \n" 93 | " \n" 94 | " \n" 95 | " \n" 96 | " \n" 97 | " \n" 98 | " \n" 99 | " \n" 100 | "") 101 | public: 102 | IBusPanelAdaptor(QObject *parent); 103 | virtual ~IBusPanelAdaptor(); 104 | 105 | public: // PROPERTIES 106 | public Q_SLOTS: // METHODS 107 | void CursorDownLookupTable(); 108 | void CursorUpLookupTable(); 109 | void Destroy(); 110 | void FocusIn(const QDBusObjectPath &ic); 111 | void FocusOut(const QDBusObjectPath &ic); 112 | void HideAuxiliaryText(); 113 | void HideLanguageBar(); 114 | void HideLookupTable(); 115 | void HidePreeditText(); 116 | void PageDownLookupTable(); 117 | void PageUpLookupTable(); 118 | void RegisterProperties(const QDBusVariant &props); 119 | void Reset(); 120 | void SetCursorLocation(int x, int y, int w, int h); 121 | void ShowAuxiliaryText(); 122 | void ShowLanguageBar(); 123 | void ShowLookupTable(); 124 | void ShowPreeditText(); 125 | void StartSetup(); 126 | void StateChanged(); 127 | void UpdateAuxiliaryText(const QDBusVariant &text, bool visible); 128 | void UpdateLookupTable(const QDBusVariant &lookup_table, bool visible); 129 | void UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); 130 | void UpdateProperty(const QDBusVariant &prop); 131 | Q_SIGNALS: // SIGNALS 132 | void CandidateClicked(uint index, uint button, uint state); 133 | void CursorDown(); 134 | void CursorUp(); 135 | void PageDown(); 136 | void PageUp(); 137 | void PropertyActivate(const QString &prop_name, int prop_state); 138 | void PropertyHide(const QString &prop_name); 139 | void PropertyShow(const QString &prop_name); 140 | }; 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /src/qibusserializable.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_SERIALIZABLE_H_ 2 | #define __Q_IBUS_SERIALIZABLE_H_ 3 | 4 | #include 5 | #include "qibusobject.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define INIT_PRIO_HIGH __attribute__((init_priority(1000))) 12 | // #define INIT_PRIO_LOW __attribute__((init_priority(2000))) 13 | #define INIT_PRIO_LOW 14 | 15 | #define IBUS_SERIALIZABLE \ 16 | public: \ 17 | static Serializable *newInstance (void); \ 18 | static MetaTypeInfo staticMetaTypeInfo; \ 19 | virtual const MetaTypeInfo *metaTypeInfo (void) const; 20 | 21 | #define IBUS_DECLARE_SERIALIZABLE(classname, name) \ 22 | Serializable * \ 23 | classname::newInstance (void) \ 24 | { \ 25 | return (Serializable *) new classname (); \ 26 | } \ 27 | const Serializable::MetaTypeInfo * \ 28 | classname::metaTypeInfo (void) const \ 29 | { \ 30 | return & (classname::staticMetaTypeInfo); \ 31 | } \ 32 | Serializable::MetaTypeInfo \ 33 | classname::staticMetaTypeInfo INIT_PRIO_LOW (QString(#name), classname::newInstance); 34 | 35 | namespace IBus { 36 | 37 | class Serializable; 38 | typedef Pointer SerializablePointer; 39 | 40 | class Serializable : public Object 41 | { 42 | Q_OBJECT; 43 | 44 | template friend QDBusVariant & qDBusVariantFromSerializable (const Pointer &p, QDBusVariant & dbus_variant); 45 | template friend QDBusVariant qDBusVariantFromSerializable (const Pointer &p); 46 | template friend Pointer qDBusVariantToSerializable (const QDBusVariant &variant); 47 | 48 | typedef Serializable * (NewInstanceFunc) (void); 49 | 50 | protected: 51 | class MetaTypeInfo 52 | { 53 | public: 54 | MetaTypeInfo(const QString &name, NewInstanceFunc _new) : m_className (name) { 55 | Serializable::registerObject (m_className, _new); 56 | } 57 | ~MetaTypeInfo (void) { 58 | Serializable::unregisterObject (m_className); 59 | } 60 | const QString &className (void) const { 61 | return m_className; 62 | } 63 | private: 64 | QString m_className; 65 | }; 66 | 67 | public: 68 | Serializable () {} 69 | void setAttachment (const QString &key, const SerializablePointer &value); 70 | SerializablePointer getAttachment (const QString &key) const; 71 | SerializablePointer removeAttachment (const QString &key); 72 | 73 | protected: 74 | virtual bool serialize (QDBusArgument &argument); 75 | virtual bool deserialize (const QDBusArgument &argument); 76 | 77 | private: 78 | QMap m_attachments; 79 | 80 | /* static */ 81 | protected: 82 | static void registerObject (const QString &name, NewInstanceFunc _new); 83 | static void unregisterObject (const QString &name); 84 | 85 | private: 86 | static SerializablePointer createInstance (const QString &name); 87 | static QHash type_table; 88 | 89 | IBUS_SERIALIZABLE 90 | }; 91 | 92 | template 93 | QVariant & 94 | qVariantFromSerializable (const Pointer &p, QVariant & variant) 95 | { 96 | QDBusArgument argument; 97 | 98 | argument.beginStructure (); 99 | argument << p->metaTypeInfo ()->className (); 100 | p->serialize (argument); 101 | argument.endStructure (); 102 | 103 | variant.setValue (argument); 104 | return variant; 105 | } 106 | 107 | template 108 | QDBusVariant & 109 | qDBusVariantFromSerializable (const Pointer &p, QDBusVariant &dbus_variant) 110 | { 111 | QVariant variant; 112 | QDBusArgument argument; 113 | 114 | argument.beginStructure (); 115 | argument << p->metaTypeInfo ()->className (); 116 | p->serialize (argument); 117 | argument.endStructure (); 118 | variant.setValue (argument); 119 | dbus_variant.setVariant (variant); 120 | 121 | return dbus_variant; 122 | } 123 | 124 | template 125 | QDBusVariant 126 | qDBusVariantFromSerializable (const Pointer &p) 127 | { 128 | QDBusVariant variant; 129 | return qDBusVariantFromSerializable (p, variant); 130 | } 131 | 132 | template 133 | Pointer 134 | qDBusVariantToSerializable (const QDBusVariant &variant) 135 | { 136 | 137 | Pointer p; 138 | QString name; 139 | 140 | const QDBusArgument argument = variant.variant().value (); 141 | 142 | if (argument.currentType () != QDBusArgument::StructureType) { 143 | return p; 144 | } 145 | 146 | argument.beginStructure (); 147 | argument >> name; 148 | p = Serializable::createInstance (name); 149 | if (!p.isNull () && !p->deserialize (argument)) { 150 | p = NULL; 151 | } 152 | argument.endStructure (); 153 | 154 | return p; 155 | } 156 | 157 | template 158 | QDBusArgument& operator<< (QDBusArgument& argument, const Pointer &p) 159 | { 160 | QDBusVariant variant; 161 | argument << qDBusVariantFromSerializable (p, variant); 162 | return argument; 163 | } 164 | 165 | template 166 | const QDBusArgument& operator>> (const QDBusArgument& argument, Pointer &p) 167 | { 168 | Q_ASSERT ((argument.currentType () == QDBusArgument::VariantType)); 169 | 170 | QDBusVariant variant; 171 | argument >> variant; 172 | 173 | p = qDBusVariantToSerializable (variant); 174 | 175 | return argument; 176 | } 177 | 178 | }; 179 | 180 | Q_DECLARE_METATYPE (IBus::SerializablePointer); 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /src/qibusinputcontextproxy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.8 3 | * Command line was: qdbusxml2cpp -p qibusinputcontextproxy -c IBusInputContextProxy -v org.freedesktop.IBus.InputContext.xml org.freedesktop.IBus.InputContext 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #ifndef QIBUSINPUTCONTEXTPROXY_H_1395517681 12 | #define QIBUSINPUTCONTEXTPROXY_H_1395517681 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | /* 24 | * Proxy class for interface org.freedesktop.IBus.InputContext 25 | */ 26 | class IBusInputContextProxy: public QDBusAbstractInterface 27 | { 28 | Q_OBJECT 29 | public: 30 | static inline const char *staticInterfaceName() 31 | { return "org.freedesktop.IBus.InputContext"; } 32 | 33 | public: 34 | IBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); 35 | 36 | ~IBusInputContextProxy(); 37 | 38 | public Q_SLOTS: // METHODS 39 | inline QDBusPendingReply<> Destroy() 40 | { 41 | QList argumentList; 42 | return asyncCallWithArgumentList(QLatin1String("Destroy"), argumentList); 43 | } 44 | 45 | inline QDBusPendingReply<> Disable() 46 | { 47 | QList argumentList; 48 | return asyncCallWithArgumentList(QLatin1String("Disable"), argumentList); 49 | } 50 | 51 | inline QDBusPendingReply<> Enable() 52 | { 53 | QList argumentList; 54 | return asyncCallWithArgumentList(QLatin1String("Enable"), argumentList); 55 | } 56 | 57 | inline QDBusPendingReply<> FocusIn() 58 | { 59 | QList argumentList; 60 | return asyncCallWithArgumentList(QLatin1String("FocusIn"), argumentList); 61 | } 62 | 63 | inline QDBusPendingReply<> FocusOut() 64 | { 65 | QList argumentList; 66 | return asyncCallWithArgumentList(QLatin1String("FocusOut"), argumentList); 67 | } 68 | 69 | inline QDBusPendingReply GetEngine() 70 | { 71 | QList argumentList; 72 | return asyncCallWithArgumentList(QLatin1String("GetEngine"), argumentList); 73 | } 74 | 75 | inline QDBusPendingReply IsEnabled() 76 | { 77 | QList argumentList; 78 | return asyncCallWithArgumentList(QLatin1String("IsEnabled"), argumentList); 79 | } 80 | 81 | inline QDBusPendingReply ProcessKeyEvent(uint keyval, uint keycode, uint state) 82 | { 83 | QList argumentList; 84 | argumentList << QVariant::fromValue(keyval) << QVariant::fromValue(keycode) << QVariant::fromValue(state); 85 | return asyncCallWithArgumentList(QLatin1String("ProcessKeyEvent"), argumentList); 86 | } 87 | 88 | inline QDBusPendingReply<> PropertyActivate(const QString &name, int state) 89 | { 90 | QList argumentList; 91 | argumentList << QVariant::fromValue(name) << QVariant::fromValue(state); 92 | return asyncCallWithArgumentList(QLatin1String("PropertyActivate"), argumentList); 93 | } 94 | 95 | inline QDBusPendingReply<> Reset() 96 | { 97 | QList argumentList; 98 | return asyncCallWithArgumentList(QLatin1String("Reset"), argumentList); 99 | } 100 | 101 | inline QDBusPendingReply<> SetCapabilities(uint caps) 102 | { 103 | QList argumentList; 104 | argumentList << QVariant::fromValue(caps); 105 | return asyncCallWithArgumentList(QLatin1String("SetCapabilities"), argumentList); 106 | } 107 | 108 | inline QDBusPendingReply<> SetCursorLocation(int x, int y, int w, int h) 109 | { 110 | QList argumentList; 111 | argumentList << QVariant::fromValue(x) << QVariant::fromValue(y) << QVariant::fromValue(w) << QVariant::fromValue(h); 112 | return asyncCallWithArgumentList(QLatin1String("SetCursorLocation"), argumentList); 113 | } 114 | 115 | inline QDBusPendingReply<> SetEngine(const QString &name) 116 | { 117 | QList argumentList; 118 | argumentList << QVariant::fromValue(name); 119 | return asyncCallWithArgumentList(QLatin1String("SetEngine"), argumentList); 120 | } 121 | 122 | inline QDBusPendingReply<> SetSurroundingText(const QDBusVariant &text, uint cursor_pos, uint anchor_pos) 123 | { 124 | QList argumentList; 125 | argumentList << QVariant::fromValue(text) << QVariant::fromValue(cursor_pos) << QVariant::fromValue(anchor_pos); 126 | return asyncCallWithArgumentList(QLatin1String("SetSurroundingText"), argumentList); 127 | } 128 | 129 | Q_SIGNALS: // SIGNALS 130 | void CommitText(const QDBusVariant &text); 131 | void CursorDownLookupTable(); 132 | void CursorUpLookupTable(); 133 | void DeleteSurroundingText(int offset, uint nchars); 134 | void Disabled(); 135 | void Enabled(); 136 | void ForwardKeyEvent(uint keyval, uint keycode, uint state); 137 | void HideAuxiliaryText(); 138 | void HideLookupTable(); 139 | void HidePreeditText(); 140 | void PageDownLookupTable(); 141 | void PageUpLookupTable(); 142 | void RegisterProperties(const QDBusVariant &props); 143 | void RequireSurroundingText(); 144 | void ShowAuxiliaryText(); 145 | void ShowLookupTable(); 146 | void ShowPreeditText(); 147 | void UpdateAuxiliaryText(const QDBusVariant &text, bool visible); 148 | void UpdateLookupTable(const QDBusVariant &table, bool visible); 149 | void UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); 150 | void UpdateProperty(const QDBusVariant &prop); 151 | }; 152 | 153 | namespace org { 154 | namespace freedesktop { 155 | namespace IBus { 156 | typedef ::IBusInputContextProxy InputContext; 157 | } 158 | } 159 | } 160 | #endif 161 | -------------------------------------------------------------------------------- /src/qibusengineadaptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibusengineadaptor -c IBusEngineAdaptor -v org.freedesktop.IBus.Engine.xml org.freedesktop.IBus.Engine 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * This file may have been hand-edited. Look for HAND-EDIT comments 9 | * before re-generating it. 10 | */ 11 | 12 | #ifndef QIBUSENGINEADAPTOR_H_1268725630 13 | #define QIBUSENGINEADAPTOR_H_1268725630 14 | 15 | #include 16 | #include 17 | class QByteArray; 18 | template class QList; 19 | template class QMap; 20 | class QString; 21 | class QStringList; 22 | class QVariant; 23 | 24 | /* 25 | * Adaptor class for interface org.freedesktop.IBus.Engine 26 | */ 27 | class IBusEngineAdaptor: public QDBusAbstractAdaptor 28 | { 29 | Q_OBJECT 30 | Q_CLASSINFO("D-Bus Interface", "org.freedesktop.IBus.Engine") 31 | Q_CLASSINFO("D-Bus Introspection", "" 32 | " \n" 33 | " \n" 34 | " \n" 35 | " \n" 36 | " \n" 37 | " \n" 38 | " \n" 39 | " \n" 40 | " \n" 41 | " \n" 42 | " \n" 43 | " \n" 44 | " \n" 45 | " \n" 46 | " \n" 47 | " \n" 48 | " \n" 49 | " \n" 50 | " \n" 51 | " \n" 52 | " \n" 53 | " \n" 54 | " \n" 55 | " \n" 56 | " \n" 57 | " \n" 58 | " \n" 59 | " \n" 60 | " \n" 61 | " \n" 62 | " \n" 63 | " \n" 64 | " \n" 65 | " \n" 66 | " \n" 67 | " \n" 68 | " \n" 69 | " \n" 70 | " \n" 71 | " \n" 72 | " \n" 73 | " \n" 74 | " \n" 75 | " \n" 76 | " \n" 77 | " \n" 78 | " \n" 79 | " \n" 80 | " \n" 81 | " \n" 82 | " \n" 83 | " \n" 84 | " \n" 85 | " \n" 86 | " \n" 87 | " \n" 88 | " \n" 89 | " \n" 90 | " \n" 91 | " \n" 92 | " \n" 93 | " \n" 94 | " \n" 95 | " \n" 96 | " \n" 97 | " \n" 98 | " \n" 99 | " \n" 100 | " \n" 101 | " \n" 102 | " \n" 103 | " \n" 104 | " \n" 105 | " \n" 106 | " \n" 107 | " \n" 108 | " \n" 109 | " \n" 110 | " \n" 111 | " \n" 112 | "") 113 | public: 114 | IBusEngineAdaptor(QObject *parent); 115 | virtual ~IBusEngineAdaptor(); 116 | 117 | public: // PROPERTIES 118 | public Q_SLOTS: // METHODS 119 | void CandidateClicked(uint index, uint button, uint state); 120 | void CursorDown(); 121 | void CursorUp(); 122 | void Destroy(); 123 | void Disable(); 124 | void Enable(); 125 | void FocusIn(); 126 | void FocusOut(); 127 | void PageDown(); 128 | void PageUp(); 129 | bool ProcessKeyEvent(uint keyval, uint keycode, uint state); 130 | void PropertyActivate(const QString &prop_name, int prop_state); 131 | void PropertyHide(const QString &prop_name); 132 | void PropertyShow(const QString &prop_name); 133 | void Reset(); 134 | void SetCapabilities(uint cap); 135 | void SetCursorLocation(int x, int y, int w, int h); 136 | Q_SIGNALS: // SIGNALS 137 | void CommitText(const QDBusVariant &text); 138 | void CursorDownLookupTable(); 139 | void CursorUpLookupTable(); 140 | void ForwardKeyEvent(uint keyval, uint keycode, uint state); 141 | void HideAuxiliaryText(); 142 | void HideLookupTable(); 143 | void HidePreeditText(); 144 | void PageDownLookupTable(); 145 | void PageUpLookupTable(); 146 | void RegisterProperties(const QDBusVariant &props); 147 | void ShowAuxiliaryText(); 148 | void ShowLookupTable(); 149 | void ShowPreeditText(); 150 | void UpdateAuxiliaryText(const QDBusVariant &text, bool visible); 151 | void UpdateLookupTable(const QDBusVariant &lookup_table, bool visible); 152 | void UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible, uint mode); 153 | void UpdateProperty(const QDBusVariant &prop); 154 | }; 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /src/qibuspaneladaptor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by qdbusxml2cpp version 0.7 3 | * Command line was: qdbusxml2cpp -a qibuspaneladaptor -c IBusPanelAdaptor -v org.freedesktop.IBus.Panel.xml org.freedesktop.IBus.Panel 4 | * 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 6 | * 7 | * This is an auto-generated file. 8 | * Do not edit! All changes made to it will be lost. 9 | */ 10 | 11 | #include "qibuspaneladaptor.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | /* 21 | * Implementation of adaptor class IBusPanelAdaptor 22 | */ 23 | 24 | IBusPanelAdaptor::IBusPanelAdaptor(QObject *parent) 25 | : QDBusAbstractAdaptor(parent) 26 | { 27 | // constructor 28 | setAutoRelaySignals(true); 29 | } 30 | 31 | IBusPanelAdaptor::~IBusPanelAdaptor() 32 | { 33 | // destructor 34 | } 35 | 36 | void IBusPanelAdaptor::CursorDownLookupTable() 37 | { 38 | // handle method call org.freedesktop.IBus.Panel.CursorDownLookupTable 39 | QMetaObject::invokeMethod(parent(), "CursorDownLookupTable"); 40 | } 41 | 42 | void IBusPanelAdaptor::CursorUpLookupTable() 43 | { 44 | // handle method call org.freedesktop.IBus.Panel.CursorUpLookupTable 45 | QMetaObject::invokeMethod(parent(), "CursorUpLookupTable"); 46 | } 47 | 48 | void IBusPanelAdaptor::Destroy() 49 | { 50 | // handle method call org.freedesktop.IBus.Panel.Destroy 51 | QMetaObject::invokeMethod(parent(), "Destroy"); 52 | } 53 | 54 | void IBusPanelAdaptor::FocusIn(const QDBusObjectPath &ic) 55 | { 56 | // handle method call org.freedesktop.IBus.Panel.FocusIn 57 | QMetaObject::invokeMethod(parent(), "FocusIn", Q_ARG(QDBusObjectPath, ic)); 58 | } 59 | 60 | void IBusPanelAdaptor::FocusOut(const QDBusObjectPath &ic) 61 | { 62 | // handle method call org.freedesktop.IBus.Panel.FocusOut 63 | QMetaObject::invokeMethod(parent(), "FocusOut", Q_ARG(QDBusObjectPath, ic)); 64 | } 65 | 66 | void IBusPanelAdaptor::HideAuxiliaryText() 67 | { 68 | // handle method call org.freedesktop.IBus.Panel.HideAuxiliaryText 69 | QMetaObject::invokeMethod(parent(), "HideAuxiliaryText"); 70 | } 71 | 72 | void IBusPanelAdaptor::HideLanguageBar() 73 | { 74 | // handle method call org.freedesktop.IBus.Panel.HideLanguageBar 75 | QMetaObject::invokeMethod(parent(), "HideLanguageBar"); 76 | } 77 | 78 | void IBusPanelAdaptor::HideLookupTable() 79 | { 80 | // handle method call org.freedesktop.IBus.Panel.HideLookupTable 81 | QMetaObject::invokeMethod(parent(), "HideLookupTable"); 82 | } 83 | 84 | void IBusPanelAdaptor::HidePreeditText() 85 | { 86 | // handle method call org.freedesktop.IBus.Panel.HidePreeditText 87 | QMetaObject::invokeMethod(parent(), "HidePreeditText"); 88 | } 89 | 90 | void IBusPanelAdaptor::PageDownLookupTable() 91 | { 92 | // handle method call org.freedesktop.IBus.Panel.PageDownLookupTable 93 | QMetaObject::invokeMethod(parent(), "PageDownLookupTable"); 94 | } 95 | 96 | void IBusPanelAdaptor::PageUpLookupTable() 97 | { 98 | // handle method call org.freedesktop.IBus.Panel.PageUpLookupTable 99 | QMetaObject::invokeMethod(parent(), "PageUpLookupTable"); 100 | } 101 | 102 | void IBusPanelAdaptor::RegisterProperties(const QDBusVariant &props) 103 | { 104 | // handle method call org.freedesktop.IBus.Panel.RegisterProperties 105 | QMetaObject::invokeMethod(parent(), "RegisterProperties", Q_ARG(QDBusVariant, props)); 106 | } 107 | 108 | void IBusPanelAdaptor::Reset() 109 | { 110 | // handle method call org.freedesktop.IBus.Panel.Reset 111 | QMetaObject::invokeMethod(parent(), "Reset"); 112 | } 113 | 114 | void IBusPanelAdaptor::SetCursorLocation(int x, int y, int w, int h) 115 | { 116 | // handle method call org.freedesktop.IBus.Panel.SetCursorLocation 117 | QMetaObject::invokeMethod(parent(), "SetCursorLocation", Q_ARG(int, x), Q_ARG(int, y), Q_ARG(int, w), Q_ARG(int, h)); 118 | } 119 | 120 | void IBusPanelAdaptor::ShowAuxiliaryText() 121 | { 122 | // handle method call org.freedesktop.IBus.Panel.ShowAuxiliaryText 123 | QMetaObject::invokeMethod(parent(), "ShowAuxiliaryText"); 124 | } 125 | 126 | void IBusPanelAdaptor::ShowLanguageBar() 127 | { 128 | // handle method call org.freedesktop.IBus.Panel.ShowLanguageBar 129 | QMetaObject::invokeMethod(parent(), "ShowLanguageBar"); 130 | } 131 | 132 | void IBusPanelAdaptor::ShowLookupTable() 133 | { 134 | // handle method call org.freedesktop.IBus.Panel.ShowLookupTable 135 | QMetaObject::invokeMethod(parent(), "ShowLookupTable"); 136 | } 137 | 138 | void IBusPanelAdaptor::ShowPreeditText() 139 | { 140 | // handle method call org.freedesktop.IBus.Panel.ShowPreeditText 141 | QMetaObject::invokeMethod(parent(), "ShowPreeditText"); 142 | } 143 | 144 | void IBusPanelAdaptor::StartSetup() 145 | { 146 | // handle method call org.freedesktop.IBus.Panel.StartSetup 147 | QMetaObject::invokeMethod(parent(), "StartSetup"); 148 | } 149 | 150 | void IBusPanelAdaptor::StateChanged() 151 | { 152 | // handle method call org.freedesktop.IBus.Panel.StateChanged 153 | QMetaObject::invokeMethod(parent(), "StateChanged"); 154 | } 155 | 156 | void IBusPanelAdaptor::UpdateAuxiliaryText(const QDBusVariant &text, bool visible) 157 | { 158 | // handle method call org.freedesktop.IBus.Panel.UpdateAuxiliaryText 159 | QMetaObject::invokeMethod(parent(), "UpdateAuxiliaryText", Q_ARG(QDBusVariant, text), Q_ARG(bool, visible)); 160 | } 161 | 162 | void IBusPanelAdaptor::UpdateLookupTable(const QDBusVariant &lookup_table, bool visible) 163 | { 164 | // handle method call org.freedesktop.IBus.Panel.UpdateLookupTable 165 | QMetaObject::invokeMethod(parent(), "UpdateLookupTable", Q_ARG(QDBusVariant, lookup_table), Q_ARG(bool, visible)); 166 | } 167 | 168 | void IBusPanelAdaptor::UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible) 169 | { 170 | // handle method call org.freedesktop.IBus.Panel.UpdatePreeditText 171 | QMetaObject::invokeMethod(parent(), "UpdatePreeditText", Q_ARG(QDBusVariant, text), Q_ARG(uint, cursor_pos), Q_ARG(bool, visible)); 172 | } 173 | 174 | void IBusPanelAdaptor::UpdateProperty(const QDBusVariant &prop) 175 | { 176 | // handle method call org.freedesktop.IBus.Panel.UpdateProperty 177 | QMetaObject::invokeMethod(parent(), "UpdateProperty", Q_ARG(QDBusVariant, prop)); 178 | } 179 | 180 | -------------------------------------------------------------------------------- /test/qibusdemoengine.cpp: -------------------------------------------------------------------------------- 1 | #include "qibusdemoengine.h" 2 | #include 3 | 4 | DemoEngine::DemoEngine (const QString &name) 5 | : Engine(name) 6 | { 7 | m_lookupTable = NULL; 8 | m_candicate = NULL; 9 | } 10 | 11 | DemoEngine::~DemoEngine () {} 12 | 13 | void 14 | DemoEngine::closeLookupTable () 15 | { 16 | m_lookupTable->clean (); 17 | hidePreeditText (); 18 | hideAuxiliaryText (); 19 | hideLookupTable (); 20 | } 21 | 22 | // follows are virtual functions 23 | void 24 | DemoEngine::propertyActivate (const QString &prop_name, int prop_state) 25 | { 26 | qDebug () << "Activate"; 27 | TextPointer tooltip = new Text ("toggle to english"); 28 | TextPointer label = new Text ("setup"); 29 | PropertyPointer prop = new Property ("setup", 30 | "/home/doyle/IME/ibus-pinyin/icons/english.svg", 31 | label, 32 | tooltip, 33 | true, 34 | true, 35 | TypeNormal, 36 | 0, 37 | NULL); 38 | 39 | updateProperty (prop); 40 | } 41 | 42 | bool 43 | DemoEngine::processKeyEvent (uint keyval, uint keycode, uint modifiers) 44 | { 45 | if (modifiers & ReleaseMask) { 46 | return false; 47 | } 48 | 49 | uint indexOfcandidate = 0; 50 | 51 | TextPointer tooltip = NULL; 52 | TextPointer label = NULL; 53 | PropListPointer props = NULL; 54 | PropertyPointer prop = NULL; 55 | 56 | TextPointer attributeText = NULL; 57 | 58 | switch (keyval) { 59 | case Key_a : 60 | /* 61 | attributeText = new Text ("Apple"); 62 | attributeText->appendAttribute (Attribute::TypeUnderline, Attribute::UnderlineLow, 0, -1); 63 | attributeText->appendAttribute (Attribute::TypeForeground, 0xff0000, 0, -1); 64 | updatePreeditText (attributeText, 0, TRUE); 65 | break; 66 | */ 67 | 68 | case Key_b : 69 | attributeText = new Text ("Banana"); 70 | attributeText->appendAttribute (Attribute::TypeUnderline, Attribute::UnderlineSingle, 0, -1); 71 | attributeText->appendAttribute (Attribute::TypeBackground, 0xff0000, 0, -1); 72 | updatePreeditText (attributeText, 0, TRUE); 73 | break; 74 | 75 | case Key_c : 76 | updateAuxiliaryText (new Text ("CCCCC"), TRUE); 77 | break; 78 | 79 | case Key_p : 80 | label = new Text ("setup"); 81 | tooltip = new Text ("toggle to english"); 82 | prop = new Property ("setup", 83 | "/home/doyle/IME/ibus-pinyin/icons/chinese.svg", 84 | label, 85 | tooltip, 86 | true, 87 | true, 88 | TypeNormal, 89 | 0, 90 | NULL); 91 | props = new PropList (); 92 | props->appendProperty (prop); 93 | registerProperties (props); 94 | break; 95 | 96 | case Key_d : 97 | { 98 | m_lookupTable = new LookupTable (true, true, 5, 0); 99 | m_lookupTable->appendLabel (new Text ("1")); 100 | m_lookupTable->appendLabel (new Text ("2")); 101 | m_lookupTable->appendLabel (new Text ("3")); 102 | m_lookupTable->appendLabel (new Text ("4")); 103 | m_lookupTable->appendLabel (new Text ("5")); 104 | attributeText = new Text("ibus"); 105 | attributeText->appendAttribute (Attribute::TypeForeground, 0xff0000, 0, -1); 106 | m_lookupTable->appendCandidate (attributeText); 107 | m_lookupTable->appendCandidate (new Text ("wubi")); 108 | m_lookupTable->appendCandidate (new Text ("chewing")); 109 | m_lookupTable->appendCandidate (new Text ("IBM")); 110 | m_lookupTable->appendCandidate (new Text ("Yahoo")); 111 | m_lookupTable->appendCandidate (new Text ("dbus")); 112 | m_lookupTable->appendCandidate (new Text ("redhat")); 113 | m_lookupTable->appendCandidate (new Text ("bupt")); 114 | m_lookupTable->appendCandidate (new Text ("smth")); 115 | m_lookupTable->appendCandidate (new Text ("sogou")); 116 | m_lookupTable->appendCandidate (new Text ("google")); 117 | m_lookupTable->appendCandidate (new Text ("ziguang")); 118 | 119 | updateLookupTable (m_lookupTable, true); 120 | break; 121 | } 122 | 123 | case Key_e : 124 | commitText (new Text("commitText")); 125 | break; 126 | 127 | case Key_j : 128 | PageDownLookupTable (); 129 | break; 130 | 131 | case Key_k : 132 | PageUpLookupTable (); 133 | break; 134 | 135 | case Key_h : 136 | CursorUpLookupTable (); 137 | break; 138 | 139 | case Key_l : 140 | CursorDownLookupTable (); 141 | break; 142 | 143 | case Key_Up : 144 | m_lookupTable->cursorUp(); 145 | updateLookupTable (m_lookupTable, true); 146 | break; 147 | 148 | case Key_Down : 149 | m_lookupTable->cursorDown(); 150 | updateLookupTable (m_lookupTable, true); 151 | break; 152 | 153 | case Key_Left : 154 | m_lookupTable->cursorUp(); 155 | updateLookupTable (m_lookupTable, true); 156 | break; 157 | 158 | case Key_Right : 159 | m_lookupTable->cursorDown(); 160 | updateLookupTable (m_lookupTable, true); 161 | break; 162 | 163 | case Key_Page_Up : 164 | m_lookupTable->pageUp (); 165 | updateLookupTable (m_lookupTable, true); 166 | break; 167 | 168 | case Key_Page_Down : 169 | m_lookupTable->pageDown (); 170 | updateLookupTable (m_lookupTable, true); 171 | break; 172 | 173 | case Key_s : 174 | showLookupTable (); 175 | break; 176 | 177 | case Key_g : 178 | hideLookupTable (); 179 | break; 180 | 181 | case Key_i : 182 | hidePreeditText (); 183 | break; 184 | 185 | case Key_m : 186 | hideAuxiliaryText (); 187 | break; 188 | 189 | case Key_n : 190 | break; 191 | 192 | case Key_Escape : 193 | closeLookupTable (); 194 | 195 | case Key_1 : 196 | case Key_2 : 197 | case Key_3 : 198 | case Key_4 : 199 | case Key_5 : 200 | case Key_6 : 201 | case Key_7 : 202 | case Key_8 : 203 | case Key_9 : 204 | indexOfcandidate = keyval - 49; 205 | if ( m_lookupTable->candidate(0) != NULL ) { 206 | if ( (m_candicate = m_lookupTable->candidate(indexOfcandidate)) != NULL ) { 207 | commitText (m_candicate); 208 | closeLookupTable (); 209 | } 210 | 211 | break; 212 | } 213 | 214 | commitText (new Text (static_cast(keyval))); 215 | break; 216 | 217 | default: 218 | qDebug () << "Unknown key input!"; 219 | return false; 220 | } 221 | 222 | return true; 223 | } 224 | 225 | -------------------------------------------------------------------------------- /src/qibusinputcontext.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "qibusinputcontext.h" 3 | #include "qibusinputcontextproxy.h" 4 | 5 | namespace IBus { 6 | 7 | InputContext::InputContext (const BusPointer &bus, const QString &path) 8 | : m_bus (bus) 9 | { 10 | m_context = new IBusInputContextProxy ("org.freedesktop.IBus", 11 | path, 12 | m_bus->getConnection ()); 13 | 14 | /* commit text */ 15 | QObject::connect (m_context, SIGNAL (CommitText (const QDBusVariant &)), 16 | this, SLOT (slotCommitText (const QDBusVariant &))); 17 | 18 | /* preedit text */ 19 | QObject::connect (m_context, SIGNAL (UpdatePreeditText (const QDBusVariant &, uint, bool)), 20 | this, SLOT (slotUpdatePreeditText (const QDBusVariant &, uint, bool))); 21 | QObject::connect (m_context, SIGNAL (ShowPreeditText (void)), 22 | this, SLOT (slotShowPreeditText (void))); 23 | QObject::connect (m_context, SIGNAL (HidePreeditText (void)), 24 | this, SLOT (slotHidePreeditText (void))); 25 | 26 | /* auxiliary text */ 27 | QObject::connect (m_context, SIGNAL (UpdateAuxiliaryText (const QDBusVariant &, bool)), 28 | this, SLOT (slotUpdateAuxiliaryText (const QDBusVariant &, bool))); 29 | QObject::connect (m_context, SIGNAL (ShowAuxiliaryText (void)), 30 | this, SLOT (slotShowAuxiliaryText (void))); 31 | QObject::connect (m_context, SIGNAL (HideAuxiliaryText (void)), 32 | this, SLOT (slotHideAuxiliaryText (void))); 33 | 34 | /*lookup table */ 35 | QObject::connect (m_context, SIGNAL (UpdateLookupTable (const QDBusVariant &, bool)), 36 | this, SLOT (slotUpdateLookupTable (const QDBusVariant &, bool))); 37 | QObject::connect (m_context, SIGNAL (ShowLookupTable (void)), 38 | this, SLOT (slotShowLookupTable (void))); 39 | QObject::connect (m_context, SIGNAL (HideLookupTable (void)), 40 | this, SLOT (slotHideLookupTable (void))); 41 | QObject::connect (m_context, SIGNAL (CursorUpLookupTable (void)), 42 | this, SLOT (slotCursorUpLookupTable (void))); 43 | QObject::connect (m_context, SIGNAL (CursorDownLookupTable (void)), 44 | this, SLOT (slotCursorDownLookupTable (void))); 45 | QObject::connect (m_context, SIGNAL (PageUpLookupTable (void)), 46 | this, SLOT (slotPageUpLookupTable (void))); 47 | QObject::connect (m_context, SIGNAL (PageDownLookupTable (void)), 48 | this, SLOT (slotPageDownLookupTable (void))); 49 | 50 | /* property */ 51 | QObject::connect (m_context, SIGNAL (RegisterProperties (const QDBusVariant &)), 52 | this, SLOT (slotRegisterProperties (const QDBusVariant &))); 53 | QObject::connect (m_context, SIGNAL (UpdateProperty (const QDBusVariant &)), 54 | this, SLOT (slotUpdateProperty (const QDBusVariant &))); 55 | 56 | /* others */ 57 | QObject::connect (m_context, SIGNAL (DeleteSurroundingText (int, uint)), 58 | this, SLOT (slotDeleteSurroundingText (int, uint))); 59 | QObject::connect (m_context, SIGNAL (RequireSurroundingText (void)), 60 | this, SLOT (slotRequireSurroundingText (void))); 61 | QObject::connect (m_context, SIGNAL (ForwardKeyEvent (uint, uint, uint)), 62 | this, SLOT (slotForwardKeyEvent (uint, uint, uint))); 63 | QObject::connect (m_context, SIGNAL (Enabled (void)), 64 | this, SLOT (slotEnabled (void))); 65 | QObject::connect (m_context, SIGNAL (Disabled (void)), 66 | this, SLOT (slotDisabled (void))); 67 | 68 | } 69 | 70 | InputContext::~InputContext (void) 71 | { 72 | destroy (); 73 | } 74 | 75 | InputContextPointer 76 | InputContext::create (const BusPointer &bus, const QString &name) 77 | { 78 | Q_ASSERT (!bus.isNull ()); 79 | 80 | if (!bus->isConnected ()) { 81 | qWarning () << "InputContext::create:" << "Bus does not connect!"; 82 | return NULL; 83 | } 84 | 85 | QString path = bus->createInputContext (name); 86 | 87 | return new InputContext (bus, path); 88 | } 89 | 90 | 91 | void 92 | InputContext::reset (void) 93 | { 94 | Q_ASSERT (m_context); 95 | m_context->Reset (); 96 | } 97 | 98 | void 99 | InputContext::destroy (void) 100 | { 101 | Q_ASSERT (m_context); 102 | m_context->Destroy (); 103 | delete m_context; 104 | m_context = NULL; 105 | } 106 | 107 | void 108 | InputContext::enable (void) 109 | { 110 | Q_ASSERT (m_context); 111 | m_context->Enable (); 112 | } 113 | 114 | void 115 | InputContext::disable (void) 116 | { 117 | Q_ASSERT (m_context); 118 | m_context->Disable (); 119 | } 120 | 121 | void 122 | InputContext::focusIn (void) 123 | { 124 | Q_ASSERT (m_context); 125 | m_context->FocusIn (); 126 | } 127 | 128 | void 129 | InputContext::focusOut (void) 130 | { 131 | Q_ASSERT (m_context); 132 | m_context->FocusOut (); 133 | } 134 | 135 | void 136 | InputContext::getEngine (void) 137 | { 138 | Q_ASSERT (m_context); 139 | m_context->GetEngine (); 140 | } 141 | 142 | bool 143 | InputContext::isEnabled (void) 144 | { 145 | Q_ASSERT (m_context); 146 | return m_context->IsEnabled (); 147 | } 148 | 149 | bool 150 | InputContext::processKeyEvent (uint keyval, uint keycode, uint state) 151 | { 152 | Q_ASSERT (m_context); 153 | 154 | QDBusPendingReply reply = m_context->ProcessKeyEvent (keyval, keycode, state); 155 | 156 | QEventLoop loop; 157 | QDBusPendingCallWatcher watcher (reply); 158 | 159 | loop.connect (&watcher, SIGNAL(finished(QDBusPendingCallWatcher *)), SLOT(quit())); 160 | loop.exec (QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents); 161 | 162 | if (reply.isError ()) { 163 | qWarning () << "InputContext::processKeyEvent:" << reply.error (); 164 | return false; 165 | } 166 | 167 | return reply; 168 | } 169 | 170 | void 171 | InputContext::setCapabilities (uint caps) 172 | { 173 | Q_ASSERT (m_context); 174 | m_context->SetCapabilities (caps); 175 | } 176 | 177 | void 178 | InputContext::setCursorLocation (int x, int y, int w, int h) 179 | { 180 | Q_ASSERT (m_context); 181 | m_context->SetCursorLocation (x, y, w, h); 182 | } 183 | 184 | void 185 | InputContext::setEngine (const QString &name) 186 | { 187 | Q_ASSERT (m_context); 188 | m_context->SetEngine (name); 189 | } 190 | 191 | void 192 | InputContext::setSurroundingText (const TextPointer &text, uint cursor_pos, uint anchor_pos) 193 | { 194 | QDBusVariant dbus_text = qDBusVariantFromSerializable (text); 195 | m_context->SetSurroundingText (dbus_text, cursor_pos, anchor_pos); 196 | } 197 | 198 | /* slots */ 199 | void 200 | InputContext::slotCommitText (const QDBusVariant &text) 201 | { 202 | commitText (qDBusVariantToSerializable (text)); 203 | } 204 | 205 | /* preedit text */ 206 | void 207 | InputContext::slotUpdatePreeditText (const QDBusVariant &text, uint cursor_pos, bool visible) 208 | { 209 | updatePreeditText (qDBusVariantToSerializable (text), cursor_pos, visible); 210 | } 211 | 212 | void 213 | InputContext::slotShowPreeditText () 214 | { 215 | showPreeditText (); 216 | } 217 | 218 | void 219 | InputContext::slotHidePreeditText () 220 | { 221 | hidePreeditText (); 222 | } 223 | 224 | /* auxiliary text */ 225 | void 226 | InputContext::slotUpdateAuxiliaryText (const QDBusVariant &text, bool visible) 227 | { 228 | updateAuxiliaryText (qDBusVariantToSerializable (text), visible); 229 | } 230 | 231 | void 232 | InputContext::slotShowAuxiliaryText () 233 | { 234 | showAuxiliaryText (); 235 | } 236 | 237 | void 238 | InputContext::slotHideAuxiliaryText () 239 | { 240 | hideAuxiliaryText (); 241 | } 242 | 243 | /* lookup table */ 244 | void 245 | InputContext::slotUpdateLookupTable (const QDBusVariant &table, bool visible) 246 | { 247 | updateLookupTable (qDBusVariantToSerializable (table), visible); 248 | } 249 | 250 | void 251 | InputContext::slotShowLookupTable () 252 | { 253 | showLookupTable (); 254 | } 255 | 256 | void 257 | InputContext::slotHideLookupTable () 258 | { 259 | hideLookupTable (); 260 | } 261 | 262 | void 263 | InputContext::slotPageUpLookupTable () 264 | { 265 | pageUpLookupTable (); 266 | } 267 | 268 | void 269 | InputContext::slotPageDownLookupTable () 270 | { 271 | pageDownLookupTable (); 272 | } 273 | 274 | void 275 | InputContext::slotCursorUpLookupTable () 276 | { 277 | cursorUpLookupTable (); 278 | } 279 | 280 | void 281 | InputContext::slotCursorDownLookupTable () 282 | { 283 | cursorDownLookupTable (); 284 | } 285 | 286 | void 287 | InputContext::slotEnabled () 288 | { 289 | enabled (); 290 | } 291 | 292 | void 293 | InputContext::slotDisabled () 294 | { 295 | disabled (); 296 | } 297 | 298 | void 299 | InputContext::slotForwardKeyEvent (uint keyval, uint keycode, uint state) 300 | { 301 | forwardKeyEvent (keyval, keycode, state); 302 | } 303 | 304 | void 305 | InputContext::slotDeleteSurroundingText (int offset, uint nchars) 306 | { 307 | deleteSurroundingText (offset, nchars); 308 | } 309 | 310 | void 311 | InputContext::slotRequireSurroundingText () 312 | { 313 | requireSurroundingText(); 314 | } 315 | 316 | void 317 | InputContext::slotRegisterProperties (const QDBusVariant &props) 318 | { 319 | registerProperties (qDBusVariantToSerializable (props)); 320 | } 321 | 322 | void 323 | InputContext::slotUpdateProperty (const QDBusVariant &prop) 324 | { 325 | updateProperty (qDBusVariantToSerializable (prop)); 326 | } 327 | 328 | }; 329 | -------------------------------------------------------------------------------- /src/qibusengine.h: -------------------------------------------------------------------------------- 1 | #ifndef __Q_IBUS_ENGINE_H_ 2 | #define __Q_IBUS_ENGINE_H_ 3 | 4 | #include 5 | #include "qibustypes.h" 6 | #include "qibustext.h" 7 | #include "qibusproplist.h" 8 | #include "qibuslookuptable.h" 9 | 10 | class IBusEngineAdaptor; 11 | 12 | namespace IBus { 13 | 14 | class Engine; 15 | typedef Pointer EnginePointer; 16 | 17 | class Engine : public Object 18 | { 19 | Q_OBJECT 20 | 21 | public : 22 | /** 23 | * @brief Constructor of Engine object. 24 | * 25 | * @return 26 | */ 27 | Engine (const QString &engineName); 28 | 29 | /** 30 | * @brief Destructor of Engine object. 31 | * 32 | * @return 33 | */ 34 | virtual ~Engine (); 35 | 36 | public : 37 | /** 38 | * @brief Gets name of the engine object. 39 | * 40 | * @return The name of the engine object. 41 | */ 42 | const QString & engineName () const; 43 | 44 | /** 45 | * @brief Updates the lookup table in fast mode, it only sends candidates in current page. 46 | * 47 | * @param[in] lookupTable A lookup table object. 48 | * @param[in] visible Whether the lookup table is visible. 49 | * @return 50 | */ 51 | void updateLookupTableFast (const LookupTablePointer & lookupTable, bool visible); 52 | 53 | public : 54 | /** 55 | * @brief Commits text to client application. 56 | * 57 | * @param[in] text A text object. 58 | * @return 59 | */ 60 | void commitText (const TextPointer & text) 61 | { 62 | QDBusVariant variant; 63 | CommitText (qDBusVariantFromSerializable (text, variant)); 64 | } 65 | 66 | /** 67 | * @brief Moves down the cursor of lookup table. 68 | * 69 | * @return 70 | */ 71 | void cursorDownLookupTable () 72 | { 73 | CursorDownLookupTable(); 74 | } 75 | 76 | /** 77 | * @brief Moves up the cursor of lookup table. 78 | * 79 | * @return 80 | */ 81 | void cursorUpLookupTable () 82 | { 83 | CursorUpLookupTable(); 84 | } 85 | 86 | /** 87 | * @brief Forwards keyevents to client application. 88 | * 89 | * @param[in] keyval 90 | * @param[in] keycode 91 | * @param[in] state 92 | * @return 93 | */ 94 | void forwardKeyEvent (uint keyval, uint keycode, uint state) 95 | { 96 | ForwardKeyEvent(keyval, keycode, state); 97 | } 98 | 99 | /** 100 | * @brief Hides the auxiliary text in UI. 101 | * 102 | * @return 103 | */ 104 | void hideAuxiliaryText () 105 | { 106 | HideAuxiliaryText(); 107 | } 108 | 109 | /** 110 | * @brief Hides the lookup table in UI. 111 | * 112 | * @return 113 | */ 114 | void hideLookupTable () 115 | { 116 | HideLookupTable(); 117 | } 118 | 119 | /** 120 | * @brief Hides the preedit text in UI. 121 | * 122 | * @return 123 | */ 124 | void hidePreeditText () 125 | { 126 | HidePreeditText(); 127 | } 128 | 129 | /** 130 | * @brief Page down the lookup table. 131 | * 132 | * @return 133 | */ 134 | void pageDownLookupTable () 135 | { 136 | PageDownLookupTable(); 137 | } 138 | 139 | /** 140 | * @brief Page up the lookup table. 141 | * 142 | * @return 143 | */ 144 | void pageUpLookupTable () 145 | { 146 | PageUpLookupTable(); 147 | } 148 | 149 | /** 150 | * @brief Registers properties. 151 | * 152 | * @param[in] props A PropList object contains some properties. 153 | * @return 154 | */ 155 | void registerProperties (const PropListPointer & props) 156 | { 157 | QDBusVariant variant; 158 | RegisterProperties(qDBusVariantFromSerializable (props, variant)); 159 | } 160 | 161 | /** 162 | * @brief Shows the auxiliary text in UI. 163 | * 164 | * @return 165 | */ 166 | void showAuxiliaryText () 167 | { 168 | ShowAuxiliaryText(); 169 | } 170 | 171 | /** 172 | * @brief Shows the lookup table in UI. 173 | * 174 | * @return 175 | */ 176 | void showLookupTable () 177 | { 178 | ShowLookupTable(); 179 | } 180 | 181 | /** 182 | * @brief Shows the preedit text in UI. 183 | * 184 | * @return 185 | */ 186 | void showPreeditText () 187 | { 188 | ShowPreeditText(); 189 | } 190 | 191 | /** 192 | * @brief Updates the auxiliary text. 193 | * 194 | * @param[in] text A text object. 195 | * @param[in] visible Whether the auxiliary text is visible. 196 | * @return 197 | */ 198 | void updateAuxiliaryText (const TextPointer & text, bool visible) 199 | { 200 | QDBusVariant variant; 201 | UpdateAuxiliaryText (qDBusVariantFromSerializable (text, variant), visible); 202 | } 203 | 204 | /** 205 | * @brief Updates the lookup table. 206 | * 207 | * @param[in] lookupTable A lookup table object. 208 | * @param[in] visible Whether the lookup table is visible. 209 | * @return 210 | */ 211 | void updateLookupTable (const LookupTablePointer & lookupTable, bool visible) 212 | { 213 | QDBusVariant variant; 214 | UpdateLookupTable (qDBusVariantFromSerializable (lookupTable, variant), visible); 215 | } 216 | 217 | /** 218 | * @brief Updates the preedit text. 219 | * 220 | * @param[in] text A text object. 221 | * @param[in] cursorPos The cursor position in the given text. 222 | * @param[in] visible Whether the preedit text is visible. 223 | * @param[in] mode preedit focus mode. 224 | * @return 225 | */ 226 | void updatePreeditText (const TextPointer & text, uint cursorPos, bool visible, uint mode = EnginePreeditClear) 227 | { 228 | QDBusVariant variant; 229 | UpdatePreeditText (qDBusVariantFromSerializable (text, variant), cursorPos, visible, mode); 230 | } 231 | 232 | /** 233 | * @brief Updates the property 234 | * 235 | * @param[in] prop A propeerty object 236 | * @return 237 | */ 238 | void updateProperty (const PropertyPointer & prop) 239 | { 240 | QDBusVariant variant; 241 | UpdateProperty (qDBusVariantFromSerializable (prop, variant)); 242 | } 243 | 244 | public: 245 | /** 246 | * @brief Candidate is clicked. 247 | * 248 | * Implement this virtual function to handle candidate clicked event. 249 | * @param[in] index The index of candidate clicked 250 | * @param[in] button The button of the clicked event. 251 | * @param[in] state The current state of keyboard. 252 | * @return 253 | */ 254 | virtual void candidateClicked (uint index, uint button, uint state); 255 | 256 | /** 257 | * @brief Cursor is moved down. 258 | * 259 | * @return 260 | */ 261 | virtual void cursorDown (); 262 | 263 | /** 264 | * @brief Cursor is moved up. 265 | * 266 | * @return 267 | */ 268 | virtual void cursorUp (); 269 | virtual void destroy (); 270 | 271 | /** 272 | * @brief Disables the engine. 273 | * 274 | * @return 275 | */ 276 | virtual void disable (); 277 | 278 | /** 279 | * @brief Enables the engine. 280 | * 281 | * @return 282 | */ 283 | virtual void enable (); 284 | 285 | /** 286 | * @brief Sets the focus of the engine. 287 | * 288 | * @return 289 | */ 290 | virtual void focusIn (); 291 | 292 | /** 293 | * @brief Unsets the focus of the engine. 294 | * 295 | * @return 296 | */ 297 | virtual void focusOut (); 298 | 299 | /** 300 | * @brief Moves cursor of lookup table to next page. 301 | * 302 | * @return 303 | */ 304 | virtual void pageDown (); 305 | 306 | /** 307 | * @brief Moves cursor of lookup tabele to previous page. 308 | * 309 | * @return 310 | */ 311 | virtual void pageUp (); 312 | 313 | /** 314 | * @brief Moves cursor of lookup tabele to previous page. 315 | * 316 | * @param[in] keyval The keyval of the key event. 317 | * @param[in] keycode The keycode of the key event. 318 | * @param[in] state The modifiers of the key event. 319 | * @return If engine returns true, the client application will ignore this key event, 320 | * otherwise client application will continue process this key event. 321 | */ 322 | virtual bool processKeyEvent (uint keyval, uint keycode, uint state); 323 | 324 | /** 325 | * @brief The property with given name is clicked. 326 | * 327 | * @param[in] prop_name The name of the property. 328 | * @param[in] prop_state The state of the property. 329 | * @return 330 | */ 331 | virtual void propertyActivate (const QString &prop_name, int prop_state); 332 | 333 | /** 334 | * @brief Hides the property with given name. 335 | * 336 | * @param[in] prop_name The name of the property. 337 | * @return 338 | */ 339 | virtual void propertyHide (const QString &prop_name); 340 | 341 | /** 342 | * @brief Shows the property with given name. 343 | * 344 | * @param[in] prop_name The name of the property. 345 | * @return 346 | */ 347 | virtual void propertyShow (const QString &prop_name); 348 | 349 | /** 350 | * @brief Resets the engine. 351 | * 352 | * @return 353 | */ 354 | virtual void reset (); 355 | 356 | /** 357 | * @brief Sets the capabilities from client application. 358 | * 359 | * @param[in] cap The capabilities of client application. 360 | * @return 361 | */ 362 | virtual void setCapabilities (uint cap); 363 | 364 | /** 365 | * @brief Sets the cursor location from client applicaion. 366 | * 367 | * @param[in] x 368 | * @param[in] y 369 | * @param[in] w 370 | * @param[in] h 371 | * @return 372 | */ 373 | virtual void setCursorLocation (int x, int y, int w, int h); 374 | 375 | private Q_SLOTS: 376 | Q_INVOKABLE void CandidateClicked (uint index, uint button, uint state); 377 | Q_INVOKABLE void CursorDown (); 378 | Q_INVOKABLE void CursorUp (); 379 | Q_INVOKABLE void Destroy (); 380 | Q_INVOKABLE void Disable (); 381 | Q_INVOKABLE void Enable (); 382 | Q_INVOKABLE void FocusIn (); 383 | Q_INVOKABLE void FocusOut (); 384 | Q_INVOKABLE void PageDown (); 385 | Q_INVOKABLE void PageUp (); 386 | Q_INVOKABLE bool ProcessKeyEvent (uint keyval, uint keycode, uint state); 387 | Q_INVOKABLE void PropertyActivate (const QString &prop_name, int prop_state); 388 | Q_INVOKABLE void PropertyHide (const QString &prop_name); 389 | Q_INVOKABLE void PropertyShow (const QString &prop_name); 390 | Q_INVOKABLE void Reset (); 391 | Q_INVOKABLE void SetCapabilities (uint cap); 392 | Q_INVOKABLE void SetCursorLocation (int x, int y, int w, int h); 393 | 394 | Q_SIGNALS : 395 | /** 396 | * FIXME need hide signals in doxygen 397 | */ 398 | void CommitText (const QDBusVariant &text); 399 | void CursorDownLookupTable (); 400 | void CursorUpLookupTable (); 401 | void ForwardKeyEvent (uint keyval, uint keycode, uint state); 402 | void HideAuxiliaryText (); 403 | void HideLookupTable (); 404 | void HidePreeditText (); 405 | void PageDownLookupTable (); 406 | void PageUpLookupTable (); 407 | void RegisterProperties (const QDBusVariant &props); 408 | void ShowAuxiliaryText (); 409 | void ShowLookupTable (); 410 | void ShowPreeditText (); 411 | void UpdateAuxiliaryText (const QDBusVariant &text, bool visible); 412 | void UpdateLookupTable (const QDBusVariant &lookup_table, bool visible); 413 | void UpdatePreeditText (const QDBusVariant &text, uint cursor_pos, bool visible, uint mode); 414 | void UpdateProperty (const QDBusVariant &prop); 415 | private : 416 | QString m_engineName; 417 | IBusEngineAdaptor *m_adaptor; 418 | }; 419 | 420 | }; 421 | 422 | #endif 423 | --------------------------------------------------------------------------------