A multilingual input method framework
Revision | 21d033997577184c47c3938e99cab1e466961aa1 (tree) |
---|---|
Time | 2006-06-06 20:12:16 |
Author | ekato <ekato@ff9a...> |
Commiter | ekato |
* qt/immodule-qhelpermanager.{cpp,h}
* qt/immodule-quiminputcontext.{cpp.h}
@@ -168,6 +168,7 @@ void QUimHelperManager::parseHelperStrImChange( const QString &str ) | ||
168 | 168 | QUimInputContext * cc; |
169 | 169 | QStringList list = QStringList::split( "\n", str ); |
170 | 170 | QString im_name = list[ 1 ]; |
171 | + QString im_name_sym = "'" + im_name; | |
171 | 172 | |
172 | 173 | if ( str.startsWith( "im_change_this_text_area_only" ) ) |
173 | 174 | { |
@@ -184,6 +185,9 @@ void QUimHelperManager::parseHelperStrImChange( const QString &str ) | ||
184 | 185 | { |
185 | 186 | uim_switch_im( cc->uimContext(), ( const char* ) im_name ); |
186 | 187 | cc->readIMConf(); |
188 | + uim_prop_update_custom( cc->uimContext(), | |
189 | + "custom-preserved-default-im-name", | |
190 | + ( const char* ) im_name_sym ); | |
187 | 191 | } |
188 | 192 | } |
189 | 193 | else if ( str.startsWith( "im_change_this_application_only" ) ) |
@@ -194,6 +198,9 @@ void QUimHelperManager::parseHelperStrImChange( const QString &str ) | ||
194 | 198 | { |
195 | 199 | uim_switch_im( cc->uimContext(), ( const char* ) im_name ); |
196 | 200 | cc->readIMConf(); |
201 | + uim_prop_update_custom( cc->uimContext(), | |
202 | + "custom-preserved-default-im-name", | |
203 | + ( const char* ) im_name_sym ); | |
197 | 204 | } |
198 | 205 | } |
199 | 206 | } |
@@ -227,6 +234,14 @@ void QUimHelperManager::sendImList() | ||
227 | 234 | uim_helper_send_message( im_uim_fd, ( const char* ) msg.utf8() ); |
228 | 235 | } |
229 | 236 | |
237 | +void QUimHelperManager::send_im_change_whole_desktop( const char *name ) | |
238 | +{ | |
239 | + QString msg; | |
240 | + | |
241 | + msg.sprintf("im_change_whole_desktop\n%s\n", name); | |
242 | + uim_helper_send_message( im_uim_fd, ( const char* ) msg ); | |
243 | +} | |
244 | + | |
230 | 245 | void QUimHelperManager::helper_disconnect_cb() |
231 | 246 | { |
232 | 247 | im_uim_fd = -1; |
@@ -55,6 +55,7 @@ public: | ||
55 | 55 | static void helper_disconnect_cb(); |
56 | 56 | static void update_prop_list_cb( void *ptr, const char *str ); |
57 | 57 | static void update_prop_label_cb( void *ptr, const char *str ); |
58 | + static void send_im_change_whole_desktop( const char *str ); | |
58 | 59 | |
59 | 60 | public slots: |
60 | 61 | void slotStdinActivated( int ); |
@@ -136,6 +136,11 @@ uim_context QUimInputContext::createUimContext( const char *imname ) | ||
136 | 136 | |
137 | 137 | uim_set_prop_list_update_cb( uc, QUimHelperManager::update_prop_list_cb ); |
138 | 138 | uim_set_prop_label_update_cb( uc, QUimHelperManager::update_prop_label_cb ); |
139 | + | |
140 | + uim_set_im_switch_request_cb( uc, | |
141 | + QUimInputContext::switch_app_global_im_cb, | |
142 | + QUimInputContext::switch_system_global_im_cb); | |
143 | + | |
139 | 144 | uim_prop_list_update( uc ); |
140 | 145 | |
141 | 146 | return uc; |
@@ -453,6 +458,18 @@ void QUimInputContext::cand_deactivate_cb( void *ptr ) | ||
453 | 458 | ic->candidateDeactivate(); |
454 | 459 | } |
455 | 460 | |
461 | +void QUimInputContext::switch_app_global_im_cb( void *ptr, const char *name ) | |
462 | +{ | |
463 | + QUimInputContext *ic = ( QUimInputContext* ) ptr; | |
464 | + ic->switch_app_global_im( name ); | |
465 | +} | |
466 | + | |
467 | +void QUimInputContext::switch_system_global_im_cb( void *ptr, const char *name ) | |
468 | +{ | |
469 | + QUimInputContext *ic = ( QUimInputContext* ) ptr; | |
470 | + ic->switch_system_global_im( name ); | |
471 | +} | |
472 | + | |
456 | 473 | void QUimInputContext::commitString( const QString& str ) |
457 | 474 | { |
458 | 475 | if ( !isComposing() ) |
@@ -622,6 +639,29 @@ void QUimInputContext::candidateDeactivate() | ||
622 | 639 | candwinIsActive = false; |
623 | 640 | } |
624 | 641 | |
642 | +void QUimInputContext::switch_app_global_im( const char *name ) | |
643 | +{ | |
644 | + QUimInputContext *cc; | |
645 | + QString im_name_sym; | |
646 | + | |
647 | + im_name_sym.sprintf( "'%s", name); | |
648 | + | |
649 | + for ( cc = contextList.first(); cc; cc = contextList.next() ) | |
650 | + { | |
651 | + if (cc != this) { | |
652 | + uim_switch_im( cc->uimContext(), name ); | |
653 | + cc->readIMConf(); | |
654 | + } | |
655 | + } | |
656 | + uim_prop_update_custom(this->uimContext(), "custom-preserved-default-im-name", ( const char* ) im_name_sym ); | |
657 | +} | |
658 | + | |
659 | +void QUimInputContext::switch_system_global_im( const char *name ) | |
660 | +{ | |
661 | + switch_app_global_im( name ); | |
662 | + QUimHelperManager::send_im_change_whole_desktop( name ); | |
663 | +} | |
664 | + | |
625 | 665 | void QUimInputContext::createUimInfo() |
626 | 666 | { |
627 | 667 | if ( !uimInfo.isEmpty() ) |
@@ -36,9 +36,10 @@ SUCH DAMAGE. | ||
36 | 36 | #include <qinputcontext.h> |
37 | 37 | #include <qptrlist.h> |
38 | 38 | |
39 | -#include <uim/uim.h> | |
40 | -#include <uim/uim-util.h> | |
41 | -#include <uim/uim-helper.h> | |
39 | +#include "uim/uim.h" | |
40 | +#include "uim/uim-util.h" | |
41 | +#include "uim/uim-helper.h" | |
42 | +#include "uim/uim-im-switcher.h" | |
42 | 43 | |
43 | 44 | class CandidateWindow; |
44 | 45 | class QUimHelperManager; |
@@ -104,6 +105,9 @@ private: | ||
104 | 105 | static void cand_select_cb( void *ptr, int index ); |
105 | 106 | static void cand_shift_page_cb( void* ptr, int index ); |
106 | 107 | static void cand_deactivate_cb( void *ptr ); |
108 | + //imsw | |
109 | + static void switch_app_global_im_cb( void *ptr, const char *str ); | |
110 | + static void switch_system_global_im_cb( void *ptr, const char *str ); | |
107 | 111 | /* real functions for callbacks (correspond order) */ |
108 | 112 | //preedit |
109 | 113 | void clearPreedit(); |
@@ -113,6 +117,9 @@ private: | ||
113 | 117 | void candidateActivate( int nr, int displayLimit ); |
114 | 118 | void candidateSelect( int index ); |
115 | 119 | void candidateDeactivate(); |
120 | + //imsw | |
121 | + void switch_app_global_im( const char *str ); | |
122 | + void switch_system_global_im( const char *str ); | |
116 | 123 | |
117 | 124 | protected: |
118 | 125 | QString m_imname; |