author | zecke <zecke> | 2004-09-13 14:49:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-13 14:49:52 (UTC) |
commit | 114abd0387d34bb0a160059d7799c4fbece63e78 (patch) (unidiff) | |
tree | 8294e4fd9608cb9110a7d747edcd528713476cfe | |
parent | 2e896a0d3d5b18a160c5cc468bee5ed129a92320 (diff) | |
download | opie-114abd0387d34bb0a160059d7799c4fbece63e78.zip opie-114abd0387d34bb0a160059d7799c4fbece63e78.tar.gz opie-114abd0387d34bb0a160059d7799c4fbece63e78.tar.bz2 |
Try to use the Parent Background as BackgroundOrigin
-rw-r--r-- | core/launcher/inputmethods.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 7e99796..586628b 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -1,477 +1,481 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
30 | 30 | ||
31 | /* QT */ | 31 | /* QT */ |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qtoolbutton.h> | 33 | #include <qtoolbutton.h> |
34 | #include <qwidgetstack.h> | 34 | #include <qwidgetstack.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qtl.h> | 37 | #include <qtl.h> |
38 | #ifdef Q_WS_QWS | 38 | #ifdef Q_WS_QWS |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #include <qwsevent_qws.h> | 40 | #include <qwsevent_qws.h> |
41 | #include <qcopchannel_qws.h> | 41 | #include <qcopchannel_qws.h> |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | 46 | ||
47 | /* XPM */ | 47 | /* XPM */ |
48 | static const char * tri_xpm[]={ | 48 | static const char * tri_xpm[]={ |
49 | "9 9 2 1", | 49 | "9 9 2 1", |
50 | "a c #000000", | 50 | "a c #000000", |
51 | ". c None", | 51 | ". c None", |
52 | ".........", | 52 | ".........", |
53 | ".........", | 53 | ".........", |
54 | ".........", | 54 | ".........", |
55 | "....a....", | 55 | "....a....", |
56 | "...aaa...", | 56 | "...aaa...", |
57 | "..aaaaa..", | 57 | "..aaaaa..", |
58 | ".aaaaaaa.", | 58 | ".aaaaaaa.", |
59 | ".........", | 59 | ".........", |
60 | "........."}; | 60 | "........."}; |
61 | 61 | ||
62 | int InputMethod::operator <(const InputMethod& o) const | 62 | int InputMethod::operator <(const InputMethod& o) const |
63 | { | 63 | { |
64 | return name() < o.name(); | 64 | return name() < o.name(); |
65 | } | 65 | } |
66 | int InputMethod::operator >(const InputMethod& o) const | 66 | int InputMethod::operator >(const InputMethod& o) const |
67 | { | 67 | { |
68 | return name() > o.name(); | 68 | return name() > o.name(); |
69 | } | 69 | } |
70 | int InputMethod::operator <=(const InputMethod& o) const | 70 | int InputMethod::operator <=(const InputMethod& o) const |
71 | { | 71 | { |
72 | return name() <= o.name(); | 72 | return name() <= o.name(); |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | /* | 76 | /* |
77 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget | 77 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget |
78 | belongs to the IM system, so clicking it should not cause a reset". | 78 | belongs to the IM system, so clicking it should not cause a reset". |
79 | */ | 79 | */ |
80 | class IMToolButton : public QToolButton | 80 | class IMToolButton : public QToolButton |
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) | 83 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) |
84 | { setWFlags( WStyle_Tool ); } | 84 | { setWFlags( WStyle_Tool ); |
85 | setBackgroundOrigin( ParentOrigin ); | ||
86 | setBackgroundMode( PaletteBackground ); | ||
87 | } | ||
85 | }; | 88 | }; |
86 | 89 | ||
87 | 90 | ||
88 | InputMethods::InputMethods( QWidget *parent ) : | 91 | InputMethods::InputMethods( QWidget *parent ) : |
89 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), | 92 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), |
90 | mkeyboard(0), imethod(0) | 93 | mkeyboard(0), imethod(0) |
91 | { | 94 | { |
92 | readConfig(); | 95 | readConfig(); |
93 | 96 | ||
97 | setBackgroundOrigin( ParentOrigin ); | ||
94 | setBackgroundMode( PaletteBackground ); | 98 | setBackgroundMode( PaletteBackground ); |
95 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 99 | QHBoxLayout *hbox = new QHBoxLayout( this ); |
96 | 100 | ||
97 | kbdButton = new IMToolButton( this); | 101 | kbdButton = new IMToolButton( this); |
98 | kbdButton->setFocusPolicy(NoFocus); | 102 | kbdButton->setFocusPolicy(NoFocus); |
99 | kbdButton->setToggleButton( TRUE ); | 103 | kbdButton->setToggleButton( TRUE ); |
100 | if (parent->sizeHint().height() > 0) | 104 | if (parent->sizeHint().height() > 0) |
101 | kbdButton->setFixedHeight( parent->sizeHint().height() ); | 105 | kbdButton->setFixedHeight( parent->sizeHint().height() ); |
102 | kbdButton->setFixedWidth( 32 ); | 106 | kbdButton->setFixedWidth( 32 ); |
103 | kbdButton->setAutoRaise( TRUE ); | 107 | kbdButton->setAutoRaise( TRUE ); |
104 | kbdButton->setUsesBigPixmap( TRUE ); | 108 | kbdButton->setUsesBigPixmap( TRUE ); |
105 | hbox->addWidget( kbdButton ); | 109 | hbox->addWidget( kbdButton ); |
106 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); | 110 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); |
107 | 111 | ||
108 | kbdChoice = new IMToolButton( this ); | 112 | kbdChoice = new IMToolButton( this ); |
109 | kbdChoice->setFocusPolicy(NoFocus); | 113 | kbdChoice->setFocusPolicy(NoFocus); |
110 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 114 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
111 | if (parent->sizeHint().height() > 0) | 115 | if (parent->sizeHint().height() > 0) |
112 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); | 116 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); |
113 | kbdChoice->setFixedWidth( 13 ); | 117 | kbdChoice->setFixedWidth( 13 ); |
114 | kbdChoice->setAutoRaise( TRUE ); | 118 | kbdChoice->setAutoRaise( TRUE ); |
115 | hbox->addWidget( kbdChoice ); | 119 | hbox->addWidget( kbdChoice ); |
116 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); | 120 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); |
117 | 121 | ||
118 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), | 122 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), |
119 | this, SLOT(resetStates()) ); | 123 | this, SLOT(resetStates()) ); |
120 | 124 | ||
121 | 125 | ||
122 | imButton = new QWidgetStack( this ); // later a widget stack | 126 | imButton = new QWidgetStack( this ); // later a widget stack |
123 | imButton->setFocusPolicy(NoFocus); | 127 | imButton->setFocusPolicy(NoFocus); |
124 | if (parent->sizeHint().height() > 0) | 128 | if (parent->sizeHint().height() > 0) |
125 | imButton->setFixedHeight( parent->sizeHint().height() ); | 129 | imButton->setFixedHeight( parent->sizeHint().height() ); |
126 | hbox->addWidget(imButton); | 130 | hbox->addWidget(imButton); |
127 | 131 | ||
128 | imChoice = new QToolButton( this ); | 132 | imChoice = new QToolButton( this ); |
129 | imChoice->setFocusPolicy(NoFocus); | 133 | imChoice->setFocusPolicy(NoFocus); |
130 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 134 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
131 | if (parent->sizeHint().height() > 0) | 135 | if (parent->sizeHint().height() > 0) |
132 | imChoice->setFixedHeight( parent->sizeHint().height() ); | 136 | imChoice->setFixedHeight( parent->sizeHint().height() ); |
133 | imChoice->setFixedWidth( 13 ); | 137 | imChoice->setFixedWidth( 13 ); |
134 | imChoice->setAutoRaise( TRUE ); | 138 | imChoice->setAutoRaise( TRUE ); |
135 | hbox->addWidget( imChoice ); | 139 | hbox->addWidget( imChoice ); |
136 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); | 140 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); |
137 | 141 | ||
138 | loadInputMethods(); | 142 | loadInputMethods(); |
139 | 143 | ||
140 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); | 144 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); |
141 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 145 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
142 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); | 146 | this, SLOT(qcopReceive(const QCString&,const QByteArray&)) ); |
143 | } | 147 | } |
144 | 148 | ||
145 | InputMethods::~InputMethods() | 149 | InputMethods::~InputMethods() |
146 | { | 150 | { |
147 | Config cfg("qpe"); | 151 | Config cfg("qpe"); |
148 | cfg.setGroup("InputMethod"); | 152 | cfg.setGroup("InputMethod"); |
149 | if (imethod) | 153 | if (imethod) |
150 | cfg.writeEntry("im", imethod->name() ); | 154 | cfg.writeEntry("im", imethod->name() ); |
151 | if (mkeyboard) | 155 | if (mkeyboard) |
152 | cfg.writeEntry("current", mkeyboard->name() ); | 156 | cfg.writeEntry("current", mkeyboard->name() ); |
153 | 157 | ||
154 | unloadInputMethods(); | 158 | unloadInputMethods(); |
155 | } | 159 | } |
156 | 160 | ||
157 | void InputMethods::hideInputMethod() | 161 | void InputMethods::hideInputMethod() |
158 | { | 162 | { |
159 | kbdButton->setOn( FALSE ); | 163 | kbdButton->setOn( FALSE ); |
160 | } | 164 | } |
161 | 165 | ||
162 | void InputMethods::showInputMethod() | 166 | void InputMethods::showInputMethod() |
163 | { | 167 | { |
164 | kbdButton->setOn( TRUE ); | 168 | kbdButton->setOn( TRUE ); |
165 | } | 169 | } |
166 | 170 | ||
167 | void InputMethods::showInputMethod(const QString& name) | 171 | void InputMethods::showInputMethod(const QString& name) |
168 | { | 172 | { |
169 | int i = 0; | 173 | int i = 0; |
170 | QValueList<InputMethod>::Iterator it; | 174 | QValueList<InputMethod>::Iterator it; |
171 | InputMethod *im = 0; | 175 | InputMethod *im = 0; |
172 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 176 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
173 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); | 177 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); |
174 | if ( (*it).name() == name || lname == name ) { | 178 | if ( (*it).name() == name || lname == name ) { |
175 | im = &(*it); | 179 | im = &(*it); |
176 | break; | 180 | break; |
177 | } | 181 | } |
178 | } | 182 | } |
179 | if ( im ) | 183 | if ( im ) |
180 | chooseKeyboard(im); | 184 | chooseKeyboard(im); |
181 | } | 185 | } |
182 | 186 | ||
183 | void InputMethods::resetStates() | 187 | void InputMethods::resetStates() |
184 | { | 188 | { |
185 | if ( mkeyboard && !mkeyboard->newIM ) | 189 | if ( mkeyboard && !mkeyboard->newIM ) |
186 | mkeyboard->interface->resetState(); | 190 | mkeyboard->interface->resetState(); |
187 | } | 191 | } |
188 | 192 | ||
189 | QRect InputMethods::inputRect() const | 193 | QRect InputMethods::inputRect() const |
190 | { | 194 | { |
191 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) | 195 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) |
192 | return QRect(); | 196 | return QRect(); |
193 | else | 197 | else |
194 | return mkeyboard->widget->geometry(); | 198 | return mkeyboard->widget->geometry(); |
195 | } | 199 | } |
196 | 200 | ||
197 | void InputMethods::unloadInputMethods() | 201 | void InputMethods::unloadInputMethods() |
198 | { | 202 | { |
199 | unloadMethod( inputMethodList ); | 203 | unloadMethod( inputMethodList ); |
200 | unloadMethod( inputModifierList ); | 204 | unloadMethod( inputModifierList ); |
201 | inputMethodList.clear(); | 205 | inputMethodList.clear(); |
202 | inputModifierList.clear(); | 206 | inputModifierList.clear(); |
203 | 207 | ||
204 | } | 208 | } |
205 | 209 | ||
206 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { | 210 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { |
207 | QValueList<InputMethod>::Iterator it; | 211 | QValueList<InputMethod>::Iterator it; |
208 | 212 | ||
209 | for (it = list.begin(); it != list.end(); ++it ) | 213 | for (it = list.begin(); it != list.end(); ++it ) |
210 | (*it).releaseInterface(); | 214 | (*it).releaseInterface(); |
211 | 215 | ||
212 | } | 216 | } |
213 | 217 | ||
214 | 218 | ||
215 | QStringList InputMethods::plugins()const { | 219 | QStringList InputMethods::plugins()const { |
216 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 220 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
217 | #ifdef Q_OS_MACX | 221 | #ifdef Q_OS_MACX |
218 | QDir dir( path, "lib*.dylib" ); | 222 | QDir dir( path, "lib*.dylib" ); |
219 | #else | 223 | #else |
220 | QDir dir( path, "lib*.so" ); | 224 | QDir dir( path, "lib*.so" ); |
221 | #endif /* Q_OS_MACX */ | 225 | #endif /* Q_OS_MACX */ |
222 | return dir.entryList(); | 226 | return dir.entryList(); |
223 | } | 227 | } |
224 | 228 | ||
225 | void InputMethods::installTranslator( const QString& type ) { | 229 | void InputMethods::installTranslator( const QString& type ) { |
226 | QStringList langs = Global::languageList(); | 230 | QStringList langs = Global::languageList(); |
227 | QStringList::ConstIterator lit; | 231 | QStringList::ConstIterator lit; |
228 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { | 232 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { |
229 | QString lang = *lit; | 233 | QString lang = *lit; |
230 | QTranslator * trans = new QTranslator(qApp); | 234 | QTranslator * trans = new QTranslator(qApp); |
231 | 235 | ||
232 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 236 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
233 | 237 | ||
234 | if ( trans->load( tfn )) | 238 | if ( trans->load( tfn )) |
235 | qApp->installTranslator( trans ); | 239 | qApp->installTranslator( trans ); |
236 | else | 240 | else |
237 | delete trans; | 241 | delete trans; |
238 | } | 242 | } |
239 | } | 243 | } |
240 | 244 | ||
241 | void InputMethods::setPreferedHandlers() { | 245 | void InputMethods::setPreferedHandlers() { |
242 | Config cfg("qpe"); | 246 | Config cfg("qpe"); |
243 | cfg.setGroup("InputMethod"); | 247 | cfg.setGroup("InputMethod"); |
244 | QString current = cfg.readEntry("current"); | 248 | QString current = cfg.readEntry("current"); |
245 | QString im = cfg.readEntry("im"); | 249 | QString im = cfg.readEntry("im"); |
246 | 250 | ||
247 | QValueList<InputMethod>::Iterator it; | 251 | QValueList<InputMethod>::Iterator it; |
248 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { | 252 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { |
249 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) | 253 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) |
250 | if ( (*it).name() == im ) { | 254 | if ( (*it).name() == im ) { |
251 | imethod = &(*it); break; | 255 | imethod = &(*it); break; |
252 | } | 256 | } |
253 | 257 | ||
254 | } | 258 | } |
255 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { | 259 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { |
256 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) | 260 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) |
257 | if ( (*it).name() == current ) { | 261 | if ( (*it).name() == current ) { |
258 | owarn << "preferred keyboard is " << current << "" << oendl; | 262 | owarn << "preferred keyboard is " << current << "" << oendl; |
259 | mkeyboard = &(*it); | 263 | mkeyboard = &(*it); |
260 | kbdButton->setPixmap( *mkeyboard->icon() ); | 264 | kbdButton->setPixmap( *mkeyboard->icon() ); |
261 | break; | 265 | break; |
262 | } | 266 | } |
263 | } | 267 | } |
264 | 268 | ||
265 | } | 269 | } |
266 | 270 | ||
267 | void InputMethods::loadInputMethods() | 271 | void InputMethods::loadInputMethods() |
268 | { | 272 | { |
269 | #ifndef QT_NO_COMPONENT | 273 | #ifndef QT_NO_COMPONENT |
270 | hideInputMethod(); | 274 | hideInputMethod(); |
271 | mkeyboard = 0; | 275 | mkeyboard = 0; |
272 | 276 | ||
273 | unloadInputMethods(); | 277 | unloadInputMethods(); |
274 | 278 | ||
275 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 279 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
276 | QStringList list = plugins(); | 280 | QStringList list = plugins(); |
277 | QStringList::Iterator it; | 281 | QStringList::Iterator it; |
278 | for ( it = list.begin(); it != list.end(); ++it ) { | 282 | for ( it = list.begin(); it != list.end(); ++it ) { |
279 | InputMethodInterface *iface = 0; | 283 | InputMethodInterface *iface = 0; |
280 | ExtInputMethodInterface *eface = 0; | 284 | ExtInputMethodInterface *eface = 0; |
281 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 285 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
282 | 286 | ||
283 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { | 287 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { |
284 | InputMethod input; | 288 | InputMethod input; |
285 | input.newIM = FALSE; | 289 | input.newIM = FALSE; |
286 | input.library = lib; | 290 | input.library = lib; |
287 | input.libName = *it; | 291 | input.libName = *it; |
288 | input.interface = iface; | 292 | input.interface = iface; |
289 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); | 293 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); |
290 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); | 294 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); |
291 | inputMethodList.append( input ); | 295 | inputMethodList.append( input ); |
292 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { | 296 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { |
293 | InputMethod input; | 297 | InputMethod input; |
294 | input.newIM = TRUE; | 298 | input.newIM = TRUE; |
295 | input.library = lib; | 299 | input.library = lib; |
296 | input.libName = *it; | 300 | input.libName = *it; |
297 | input.extInterface = eface; | 301 | input.extInterface = eface; |
298 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); | 302 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); |
299 | // may be either a simple, or advanced. | 303 | // may be either a simple, or advanced. |
300 | if (input.widget) { | 304 | if (input.widget) { |
301 | //odebug << "its a keyboard" << oendl; | 305 | //odebug << "its a keyboard" << oendl; |
302 | inputMethodList.append( input ); | 306 | inputMethodList.append( input ); |
303 | } else { | 307 | } else { |
304 | //odebug << "its a real im" << oendl; | 308 | //odebug << "its a real im" << oendl; |
305 | input.widget = input.extInterface->statusWidget( 0, 0 ); | 309 | input.widget = input.extInterface->statusWidget( 0, 0 ); |
306 | if (input.widget) { | 310 | if (input.widget) { |
307 | //odebug << "blah" << oendl; | 311 | //odebug << "blah" << oendl; |
308 | inputModifierList.append( input ); | 312 | inputModifierList.append( input ); |
309 | imButton->addWidget(input.widget, inputModifierList.count()); | 313 | imButton->addWidget(input.widget, inputModifierList.count()); |
310 | } | 314 | } |
311 | } | 315 | } |
312 | }else{ | 316 | }else{ |
313 | delete lib; | 317 | delete lib; |
314 | lib = 0l; | 318 | lib = 0l; |
315 | } | 319 | } |
316 | installTranslator( (*it).left( (*it).find(".") ) ); | 320 | installTranslator( (*it).left( (*it).find(".") ) ); |
317 | } | 321 | } |
318 | qHeapSort( inputMethodList ); | 322 | qHeapSort( inputMethodList ); |
319 | #endif /* killed BUILT in cause they would not compile */ | 323 | #endif /* killed BUILT in cause they would not compile */ |
320 | 324 | ||
321 | QWSServer::setCurrentInputMethod( 0 ); | 325 | QWSServer::setCurrentInputMethod( 0 ); |
322 | 326 | ||
323 | /* set the prefered IM + handler */ | 327 | /* set the prefered IM + handler */ |
324 | setPreferedHandlers(); | 328 | setPreferedHandlers(); |
325 | if ( !inputModifierList.isEmpty() ) { | 329 | if ( !inputModifierList.isEmpty() ) { |
326 | if (!imethod) | 330 | if (!imethod) |
327 | imethod = &inputModifierList[0]; | 331 | imethod = &inputModifierList[0]; |
328 | imButton->raiseWidget(imethod->widget); | 332 | imButton->raiseWidget(imethod->widget); |
329 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 333 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
330 | } else { | 334 | } else { |
331 | imethod = 0; | 335 | imethod = 0; |
332 | } | 336 | } |
333 | 337 | ||
334 | // we need to update keyboards afterwards, as some of them may not be compatible with | 338 | // we need to update keyboards afterwards, as some of them may not be compatible with |
335 | // the current input method | 339 | // the current input method |
336 | updateKeyboards(imethod); | 340 | updateKeyboards(imethod); |
337 | 341 | ||
338 | if ( !inputModifierList.isEmpty() ) | 342 | if ( !inputModifierList.isEmpty() ) |
339 | imButton->show(); | 343 | imButton->show(); |
340 | else | 344 | else |
341 | imButton->hide(); | 345 | imButton->hide(); |
342 | 346 | ||
343 | if ( inputModifierList.count() > 1 ) | 347 | if ( inputModifierList.count() > 1 ) |
344 | imChoice->show(); | 348 | imChoice->show(); |
345 | else | 349 | else |
346 | imChoice->hide(); | 350 | imChoice->hide(); |
347 | } | 351 | } |
348 | 352 | ||
349 | void InputMethods::chooseKbd() | 353 | void InputMethods::chooseKbd() |
350 | { | 354 | { |
351 | QPopupMenu pop( this ); | 355 | QPopupMenu pop( this ); |
352 | pop.setFocusPolicy( NoFocus ); //don't reset IM | 356 | pop.setFocusPolicy( NoFocus ); //don't reset IM |
353 | 357 | ||
354 | QString imname; | 358 | QString imname; |
355 | if (imethod) | 359 | if (imethod) |
356 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); | 360 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); |
357 | 361 | ||
358 | int i = 0; | 362 | int i = 0; |
359 | int firstDepKbd = 0; | 363 | int firstDepKbd = 0; |
360 | 364 | ||
361 | QValueList<InputMethod>::Iterator it; | 365 | QValueList<InputMethod>::Iterator it; |
362 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 366 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
363 | // add empty new items, all old items. | 367 | // add empty new items, all old items. |
364 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { | 368 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { |
365 | pop.insertItem( (*it).name(), i, firstDepKbd); | 369 | pop.insertItem( (*it).name(), i, firstDepKbd); |
366 | if ( mkeyboard == &(*it) ) | 370 | if ( mkeyboard == &(*it) ) |
367 | pop.setItemChecked( i, TRUE ); | 371 | pop.setItemChecked( i, TRUE ); |
368 | 372 | ||
369 | firstDepKbd++; | 373 | firstDepKbd++; |
370 | } else if ( (*it).extInterface->compatible().contains(imname)) { | 374 | } else if ( (*it).extInterface->compatible().contains(imname)) { |
371 | // check if we need to insert a sep. | 375 | // check if we need to insert a sep. |
372 | if (firstDepKbd == i) | 376 | if (firstDepKbd == i) |
373 | pop.insertSeparator(); | 377 | pop.insertSeparator(); |
374 | pop.insertItem( (*it).name(), i, -1); | 378 | pop.insertItem( (*it).name(), i, -1); |
375 | if ( mkeyboard == &(*it) ) | 379 | if ( mkeyboard == &(*it) ) |
376 | pop.setItemChecked( i, TRUE ); | 380 | pop.setItemChecked( i, TRUE ); |
377 | } | 381 | } |
378 | } | 382 | } |
379 | 383 | ||
380 | QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); | 384 | QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); |
381 | QSize s = pop.sizeHint(); | 385 | QSize s = pop.sizeHint(); |
382 | pt.ry() -= s.height(); | 386 | pt.ry() -= s.height(); |
383 | pt.rx() -= s.width(); | 387 | pt.rx() -= s.width(); |
384 | i = pop.exec( pt ); | 388 | i = pop.exec( pt ); |
385 | if ( i == -1 ) | 389 | if ( i == -1 ) |
386 | return; | 390 | return; |
387 | InputMethod *im = &inputMethodList[i]; | 391 | InputMethod *im = &inputMethodList[i]; |
388 | chooseKeyboard(im); | 392 | chooseKeyboard(im); |
389 | } | 393 | } |
390 | 394 | ||
391 | void InputMethods::chooseIm() | 395 | void InputMethods::chooseIm() |
392 | { | 396 | { |
393 | QPopupMenu pop( this ); | 397 | QPopupMenu pop( this ); |
394 | 398 | ||
395 | int i = 0; | 399 | int i = 0; |
396 | QValueList<InputMethod>::Iterator it; | 400 | QValueList<InputMethod>::Iterator it; |
397 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { | 401 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { |
398 | pop.insertItem( (*it).name(), i ); | 402 | pop.insertItem( (*it).name(), i ); |
399 | if ( imethod == &(*it) ) | 403 | if ( imethod == &(*it) ) |
400 | pop.setItemChecked( i, TRUE ); | 404 | pop.setItemChecked( i, TRUE ); |
401 | } | 405 | } |
402 | 406 | ||
403 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); | 407 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); |
404 | QSize s = pop.sizeHint(); | 408 | QSize s = pop.sizeHint(); |
405 | pt.ry() -= s.height(); | 409 | pt.ry() -= s.height(); |
406 | pt.rx() -= s.width(); | 410 | pt.rx() -= s.width(); |
407 | i = pop.exec( pt ); | 411 | i = pop.exec( pt ); |
408 | if ( i == -1 ) | 412 | if ( i == -1 ) |
409 | return; | 413 | return; |
410 | InputMethod *im = &inputModifierList[i]; | 414 | InputMethod *im = &inputModifierList[i]; |
411 | 415 | ||
412 | chooseMethod(im); | 416 | chooseMethod(im); |
413 | } | 417 | } |
414 | 418 | ||
415 | void InputMethods::chooseKeyboard(InputMethod* im) | 419 | void InputMethods::chooseKeyboard(InputMethod* im) |
416 | { | 420 | { |
417 | if ( im != mkeyboard ) { | 421 | if ( im != mkeyboard ) { |
418 | if ( mkeyboard && mkeyboard->widget->isVisible() ) | 422 | if ( mkeyboard && mkeyboard->widget->isVisible() ) |
419 | mkeyboard->widget->hide(); | 423 | mkeyboard->widget->hide(); |
420 | mkeyboard = im; | 424 | mkeyboard = im; |
421 | kbdButton->setPixmap( *mkeyboard->icon() ); | 425 | kbdButton->setPixmap( *mkeyboard->icon() ); |
422 | } | 426 | } |
423 | if ( !kbdButton->isOn() ) | 427 | if ( !kbdButton->isOn() ) |
424 | kbdButton->setOn( TRUE ); | 428 | kbdButton->setOn( TRUE ); |
425 | else | 429 | else |
426 | showKbd( TRUE ); | 430 | showKbd( TRUE ); |
427 | } | 431 | } |
428 | 432 | ||
429 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) | 433 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) |
430 | { | 434 | { |
431 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) | 435 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) |
432 | return TRUE; | 436 | return TRUE; |
433 | 437 | ||
434 | if ( keyb->extInterface->compatible().contains(imname) ) | 438 | if ( keyb->extInterface->compatible().contains(imname) ) |
435 | return TRUE; | 439 | return TRUE; |
436 | 440 | ||
437 | return FALSE; | 441 | return FALSE; |
438 | } | 442 | } |
439 | 443 | ||
440 | // Updates the display of the soft keyboards available to the current input method | 444 | // Updates the display of the soft keyboards available to the current input method |
441 | void InputMethods::updateKeyboards(InputMethod *im ) | 445 | void InputMethods::updateKeyboards(InputMethod *im ) |
442 | { | 446 | { |
443 | uint count; | 447 | uint count; |
444 | 448 | ||
445 | if ( im ) { | 449 | if ( im ) { |
446 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); | 450 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); |
447 | 451 | ||
448 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { | 452 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { |
449 | kbdButton->setOn( FALSE ); | 453 | kbdButton->setOn( FALSE ); |
450 | showKbd( FALSE ); | 454 | showKbd( FALSE ); |
451 | mkeyboard = 0; | 455 | mkeyboard = 0; |
452 | } | 456 | } |
453 | 457 | ||
454 | count = 0; | 458 | count = 0; |
455 | 459 | ||
456 | QValueList<InputMethod>::Iterator it; | 460 | QValueList<InputMethod>::Iterator it; |
457 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { | 461 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { |
458 | if ( keyboardCompatible( &(*it), imname ) ) { | 462 | if ( keyboardCompatible( &(*it), imname ) ) { |
459 | if ( !mkeyboard ) { | 463 | if ( !mkeyboard ) { |
460 | mkeyboard = &(*it); | 464 | mkeyboard = &(*it); |
461 | kbdButton->setPixmap( *mkeyboard->icon() ); | 465 | kbdButton->setPixmap( *mkeyboard->icon() ); |
462 | } | 466 | } |
463 | 467 | ||
464 | count++; | 468 | count++; |
465 | } | 469 | } |
466 | } | 470 | } |
467 | } else { | 471 | } else { |
468 | count = inputMethodList.count(); | 472 | count = inputMethodList.count(); |
469 | if ( count && !mkeyboard ) { | 473 | if ( count && !mkeyboard ) { |
470 | mkeyboard = &inputMethodList[0]; | 474 | mkeyboard = &inputMethodList[0]; |
471 | kbdButton->setPixmap( *mkeyboard->icon() ); | 475 | kbdButton->setPixmap( *mkeyboard->icon() ); |
472 | } else if (!count){ | 476 | } else if (!count){ |
473 | mkeyboard = 0; //might be redundant | 477 | mkeyboard = 0; //might be redundant |
474 | } | 478 | } |
475 | } | 479 | } |
476 | 480 | ||
477 | if ( count > 1 ) | 481 | if ( count > 1 ) |