author | mickeyl <mickeyl> | 2003-10-19 19:47:13 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-19 19:47:13 (UTC) |
commit | b96ee77f28d8d2e697528290204f15913c3f4c3e (patch) (unidiff) | |
tree | 603b15d584bfcd9ee90b2e95a6852c028d7d5247 | |
parent | 38d72acc2225b88b2f561fa59565d4c66261f1c3 (diff) | |
download | opie-b96ee77f28d8d2e697528290204f15913c3f4c3e.zip opie-b96ee77f28d8d2e697528290204f15913c3f4c3e.tar.gz opie-b96ee77f28d8d2e697528290204f15913c3f4c3e.tar.bz2 |
This patch finish the work on the resizable inputmethods.
- in "floating" mode, input methods now remember their geometry
- if closed via (x), the inputmethod button is toggled accordingly
- eliminated the focus problem
-rw-r--r-- | core/launcher/inputmethods.cpp | 88 | ||||
-rw-r--r-- | core/launcher/inputmethods.h | 1 |
2 files changed, 75 insertions, 14 deletions
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index d89a366..8f3e812 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp | |||
@@ -1,566 +1,626 @@ | |||
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 | #include <qtopia/config.h> | 24 | #include <qtopia/config.h> |
25 | #include <qtopia/qpeapplication.h> | 25 | #include <qtopia/qpeapplication.h> |
26 | #include <qtopia/inputmethodinterface.h> | 26 | #include <qtopia/inputmethodinterface.h> |
27 | #include <qtopia/global.h> | 27 | #include <qtopia/global.h> |
28 | 28 | ||
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qtoolbutton.h> | 31 | #include <qtoolbutton.h> |
32 | #include <qwidgetstack.h> | 32 | #include <qwidgetstack.h> |
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | #include <qtranslator.h> | 38 | #include <qtranslator.h> |
39 | #include <qtl.h> | 39 | #include <qtl.h> |
40 | 40 | ||
41 | #ifdef Q_WS_QWS | 41 | #ifdef Q_WS_QWS |
42 | #include <qwindowsystem_qws.h> | 42 | #include <qwindowsystem_qws.h> |
43 | #include <qwsevent_qws.h> | 43 | #include <qwsevent_qws.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | /* ### SingleFloppy if someone is interested? */ | 47 | /* ### SingleFloppy if someone is interested? */ |
48 | #if 0 | 48 | #if 0 |
49 | #ifdef QT_NO_COMPONENT | 49 | #ifdef QT_NO_COMPONENT |
50 | #include "../plugins/inputmethods/handwriting/handwritingimpl.h" | 50 | #include "../plugins/inputmethods/handwriting/handwritingimpl.h" |
51 | #include "../plugins/inputmethods/keyboard/keyboardimpl.h" | 51 | #include "../plugins/inputmethods/keyboard/keyboardimpl.h" |
52 | #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" | 52 | #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" |
53 | #endif | 53 | #endif |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | /* XPM */ | 56 | /* XPM */ |
57 | static const char * tri_xpm[]={ | 57 | static const char * tri_xpm[]={ |
58 | "9 9 2 1", | 58 | "9 9 2 1", |
59 | "a c #000000", | 59 | "a c #000000", |
60 | ". c None", | 60 | ". c None", |
61 | ".........", | 61 | ".........", |
62 | ".........", | 62 | ".........", |
63 | ".........", | 63 | ".........", |
64 | "....a....", | 64 | "....a....", |
65 | "...aaa...", | 65 | "...aaa...", |
66 | "..aaaaa..", | 66 | "..aaaaa..", |
67 | ".aaaaaaa.", | 67 | ".aaaaaaa.", |
68 | ".........", | 68 | ".........", |
69 | "........."}; | 69 | "........."}; |
70 | 70 | ||
71 | int InputMethod::operator <(const InputMethod& o) const | 71 | int InputMethod::operator <(const InputMethod& o) const |
72 | { | 72 | { |
73 | return name() < o.name(); | 73 | return name() < o.name(); |
74 | } | 74 | } |
75 | int InputMethod::operator >(const InputMethod& o) const | 75 | int InputMethod::operator >(const InputMethod& o) const |
76 | { | 76 | { |
77 | return name() > o.name(); | 77 | return name() > o.name(); |
78 | } | 78 | } |
79 | int InputMethod::operator <=(const InputMethod& o) const | 79 | int InputMethod::operator <=(const InputMethod& o) const |
80 | { | 80 | { |
81 | return name() <= o.name(); | 81 | return name() <= o.name(); |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | /* | 85 | /* |
86 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget | 86 | Slightly hacky: We use WStyle_Tool as a flag to say "this widget |
87 | belongs to the IM system, so clicking it should not cause a reset". | 87 | belongs to the IM system, so clicking it should not cause a reset". |
88 | */ | 88 | */ |
89 | class IMToolButton : public QToolButton | 89 | class IMToolButton : public QToolButton |
90 | { | 90 | { |
91 | public: | 91 | public: |
92 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) | 92 | IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) |
93 | { setWFlags( WStyle_Tool ); } | 93 | { setWFlags( WStyle_Tool ); } |
94 | }; | 94 | }; |
95 | 95 | ||
96 | 96 | ||
97 | InputMethods::InputMethods( QWidget *parent ) : | 97 | InputMethods::InputMethods( QWidget *parent ) : |
98 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), | 98 | QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), |
99 | mkeyboard(0), imethod(0) | 99 | mkeyboard(0), imethod(0) |
100 | { | 100 | { |
101 | Config cfg( "Launcher" ); | 101 | Config cfg( "Launcher" ); |
102 | cfg.setGroup( "InputMethods" ); | 102 | cfg.setGroup( "InputMethods" ); |
103 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader; | 103 | inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; |
104 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : QWidget::WStyle_Tool; | 104 | inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; |
105 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); | 105 | inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); |
106 | 106 | ||
107 | setBackgroundMode( PaletteBackground ); | 107 | setBackgroundMode( PaletteBackground ); |
108 | QHBoxLayout *hbox = new QHBoxLayout( this ); | 108 | QHBoxLayout *hbox = new QHBoxLayout( this ); |
109 | 109 | ||
110 | kbdButton = new IMToolButton( this); | 110 | kbdButton = new IMToolButton( this); |
111 | kbdButton->setFocusPolicy(NoFocus); | 111 | kbdButton->setFocusPolicy(NoFocus); |
112 | kbdButton->setToggleButton( TRUE ); | 112 | kbdButton->setToggleButton( TRUE ); |
113 | if (parent->sizeHint().height() > 0) | 113 | if (parent->sizeHint().height() > 0) |
114 | kbdButton->setFixedHeight( parent->sizeHint().height() ); | 114 | kbdButton->setFixedHeight( parent->sizeHint().height() ); |
115 | kbdButton->setFixedWidth( 32 ); | 115 | kbdButton->setFixedWidth( 32 ); |
116 | kbdButton->setAutoRaise( TRUE ); | 116 | kbdButton->setAutoRaise( TRUE ); |
117 | kbdButton->setUsesBigPixmap( TRUE ); | 117 | kbdButton->setUsesBigPixmap( TRUE ); |
118 | hbox->addWidget( kbdButton ); | 118 | hbox->addWidget( kbdButton ); |
119 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); | 119 | connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); |
120 | 120 | ||
121 | kbdChoice = new IMToolButton( this ); | 121 | kbdChoice = new IMToolButton( this ); |
122 | kbdChoice->setFocusPolicy(NoFocus); | 122 | kbdChoice->setFocusPolicy(NoFocus); |
123 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 123 | kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
124 | if (parent->sizeHint().height() > 0) | 124 | if (parent->sizeHint().height() > 0) |
125 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); | 125 | kbdChoice->setFixedHeight( parent->sizeHint().height() ); |
126 | kbdChoice->setFixedWidth( 13 ); | 126 | kbdChoice->setFixedWidth( 13 ); |
127 | kbdChoice->setAutoRaise( TRUE ); | 127 | kbdChoice->setAutoRaise( TRUE ); |
128 | hbox->addWidget( kbdChoice ); | 128 | hbox->addWidget( kbdChoice ); |
129 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); | 129 | connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); |
130 | 130 | ||
131 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), | 131 | connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), |
132 | this, SLOT(resetStates()) ); | 132 | this, SLOT(resetStates()) ); |
133 | 133 | ||
134 | 134 | ||
135 | imButton = new QWidgetStack( this ); // later a widget stack | 135 | imButton = new QWidgetStack( this ); // later a widget stack |
136 | imButton->setFocusPolicy(NoFocus); | 136 | imButton->setFocusPolicy(NoFocus); |
137 | if (parent->sizeHint().height() > 0) | 137 | if (parent->sizeHint().height() > 0) |
138 | imButton->setFixedHeight( parent->sizeHint().height() ); | 138 | imButton->setFixedHeight( parent->sizeHint().height() ); |
139 | hbox->addWidget(imButton); | 139 | hbox->addWidget(imButton); |
140 | 140 | ||
141 | imChoice = new QToolButton( this ); | 141 | imChoice = new QToolButton( this ); |
142 | imChoice->setFocusPolicy(NoFocus); | 142 | imChoice->setFocusPolicy(NoFocus); |
143 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); | 143 | imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); |
144 | if (parent->sizeHint().height() > 0) | 144 | if (parent->sizeHint().height() > 0) |
145 | imChoice->setFixedHeight( parent->sizeHint().height() ); | 145 | imChoice->setFixedHeight( parent->sizeHint().height() ); |
146 | imChoice->setFixedWidth( 13 ); | 146 | imChoice->setFixedWidth( 13 ); |
147 | imChoice->setAutoRaise( TRUE ); | 147 | imChoice->setAutoRaise( TRUE ); |
148 | hbox->addWidget( imChoice ); | 148 | hbox->addWidget( imChoice ); |
149 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); | 149 | connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); |
150 | 150 | ||
151 | loadInputMethods(); | 151 | loadInputMethods(); |
152 | 152 | ||
153 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); | 153 | QCopChannel *channel = new QCopChannel( "QPE/IME", this ); |
154 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 154 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
155 | this, SLOT(qcopReceive(const QCString&, const QByteArray&)) ); | 155 | this, SLOT(qcopReceive(const QCString&, const QByteArray&)) ); |
156 | } | 156 | } |
157 | 157 | ||
158 | InputMethods::~InputMethods() | 158 | InputMethods::~InputMethods() |
159 | { | 159 | { |
160 | Config cfg("qpe"); | 160 | Config cfg("qpe"); |
161 | cfg.setGroup("InputMethod"); | 161 | cfg.setGroup("InputMethod"); |
162 | if (imethod) | 162 | if (imethod) |
163 | cfg.writeEntry("im", imethod->name() ); | 163 | cfg.writeEntry("im", imethod->name() ); |
164 | if (mkeyboard) | 164 | if (mkeyboard) |
165 | cfg.writeEntry("current", mkeyboard->name() ); | 165 | cfg.writeEntry("current", mkeyboard->name() ); |
166 | 166 | ||
167 | unloadInputMethods(); | 167 | unloadInputMethods(); |
168 | } | 168 | } |
169 | 169 | ||
170 | void InputMethods::hideInputMethod() | 170 | void InputMethods::hideInputMethod() |
171 | { | 171 | { |
172 | kbdButton->setOn( FALSE ); | 172 | kbdButton->setOn( FALSE ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void InputMethods::showInputMethod() | 175 | void InputMethods::showInputMethod() |
176 | { | 176 | { |
177 | kbdButton->setOn( TRUE ); | 177 | kbdButton->setOn( TRUE ); |
178 | } | 178 | } |
179 | 179 | ||
180 | void InputMethods::showInputMethod(const QString& name) | 180 | void InputMethods::showInputMethod(const QString& name) |
181 | { | 181 | { |
182 | int i = 0; | 182 | int i = 0; |
183 | QValueList<InputMethod>::Iterator it; | 183 | QValueList<InputMethod>::Iterator it; |
184 | InputMethod *im = 0; | 184 | InputMethod *im = 0; |
185 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 185 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
186 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); | 186 | QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); |
187 | if ( (*it).name() == name || lname == name ) { | 187 | if ( (*it).name() == name || lname == name ) { |
188 | im = &(*it); | 188 | im = &(*it); |
189 | break; | 189 | break; |
190 | } | 190 | } |
191 | } | 191 | } |
192 | if ( im ) | 192 | if ( im ) |
193 | chooseKeyboard(im); | 193 | chooseKeyboard(im); |
194 | } | 194 | } |
195 | 195 | ||
196 | void InputMethods::resetStates() | 196 | void InputMethods::resetStates() |
197 | { | 197 | { |
198 | if ( mkeyboard && !mkeyboard->newIM ) | 198 | if ( mkeyboard && !mkeyboard->newIM ) |
199 | mkeyboard->interface->resetState(); | 199 | mkeyboard->interface->resetState(); |
200 | } | 200 | } |
201 | 201 | ||
202 | QRect InputMethods::inputRect() const | 202 | QRect InputMethods::inputRect() const |
203 | { | 203 | { |
204 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) | 204 | if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) |
205 | return QRect(); | 205 | return QRect(); |
206 | else | 206 | else |
207 | return mkeyboard->widget->geometry(); | 207 | return mkeyboard->widget->geometry(); |
208 | } | 208 | } |
209 | 209 | ||
210 | void InputMethods::unloadInputMethods() | 210 | void InputMethods::unloadInputMethods() |
211 | { | 211 | { |
212 | unloadMethod( inputMethodList ); | 212 | unloadMethod( inputMethodList ); |
213 | unloadMethod( inputModifierList ); | 213 | unloadMethod( inputModifierList ); |
214 | inputMethodList.clear(); | 214 | inputMethodList.clear(); |
215 | inputModifierList.clear(); | 215 | inputModifierList.clear(); |
216 | 216 | ||
217 | } | 217 | } |
218 | 218 | ||
219 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { | 219 | void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { |
220 | QValueList<InputMethod>::Iterator it; | 220 | QValueList<InputMethod>::Iterator it; |
221 | 221 | ||
222 | for (it = list.begin(); it != list.end(); ++it ) | 222 | for (it = list.begin(); it != list.end(); ++it ) |
223 | (*it).releaseInterface(); | 223 | (*it).releaseInterface(); |
224 | 224 | ||
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | QStringList InputMethods::plugins()const { | 228 | QStringList InputMethods::plugins()const { |
229 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 229 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
230 | QDir dir( path, "lib*.so" ); | 230 | QDir dir( path, "lib*.so" ); |
231 | return dir.entryList(); | 231 | return dir.entryList(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void InputMethods::installTranslator( const QString& type ) { | 234 | void InputMethods::installTranslator( const QString& type ) { |
235 | QStringList langs = Global::languageList(); | 235 | QStringList langs = Global::languageList(); |
236 | QStringList::ConstIterator lit; | 236 | QStringList::ConstIterator lit; |
237 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { | 237 | for ( lit= langs.begin(); lit!=langs.end(); ++lit) { |
238 | QString lang = *lit; | 238 | QString lang = *lit; |
239 | QTranslator * trans = new QTranslator(qApp); | 239 | QTranslator * trans = new QTranslator(qApp); |
240 | 240 | ||
241 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 241 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
242 | 242 | ||
243 | if ( trans->load( tfn )) | 243 | if ( trans->load( tfn )) |
244 | qApp->installTranslator( trans ); | 244 | qApp->installTranslator( trans ); |
245 | else | 245 | else |
246 | delete trans; | 246 | delete trans; |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void InputMethods::setPreferedHandlers() { | 250 | void InputMethods::setPreferedHandlers() { |
251 | Config cfg("qpe"); | 251 | Config cfg("qpe"); |
252 | cfg.setGroup("InputMethod"); | 252 | cfg.setGroup("InputMethod"); |
253 | QString current = cfg.readEntry("current"); | 253 | QString current = cfg.readEntry("current"); |
254 | QString im = cfg.readEntry("im"); | 254 | QString im = cfg.readEntry("im"); |
255 | 255 | ||
256 | QValueList<InputMethod>::Iterator it; | 256 | QValueList<InputMethod>::Iterator it; |
257 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { | 257 | if (!inputModifierList.isEmpty() && !im.isEmpty() ) { |
258 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) | 258 | for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) |
259 | if ( (*it).name() == im ) { | 259 | if ( (*it).name() == im ) { |
260 | imethod = &(*it); break; | 260 | imethod = &(*it); break; |
261 | } | 261 | } |
262 | 262 | ||
263 | } | 263 | } |
264 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { | 264 | if (!inputMethodList.isEmpty() && !current.isEmpty() ) { |
265 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) | 265 | for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) |
266 | if ( (*it).name() == current ) { | 266 | if ( (*it).name() == current ) { |
267 | qWarning("preferred keyboard is %s", current.latin1() ); | 267 | qWarning("preferred keyboard is %s", current.latin1() ); |
268 | mkeyboard = &(*it); | 268 | mkeyboard = &(*it); |
269 | kbdButton->setPixmap( *mkeyboard->icon() ); | 269 | kbdButton->setPixmap( *mkeyboard->icon() ); |
270 | break; | 270 | break; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | } | 274 | } |
275 | 275 | ||
276 | void InputMethods::loadInputMethods() | 276 | void InputMethods::loadInputMethods() |
277 | { | 277 | { |
278 | #ifndef QT_NO_COMPONENT | 278 | #ifndef QT_NO_COMPONENT |
279 | hideInputMethod(); | 279 | hideInputMethod(); |
280 | mkeyboard = 0; | 280 | mkeyboard = 0; |
281 | 281 | ||
282 | unloadInputMethods(); | 282 | unloadInputMethods(); |
283 | 283 | ||
284 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; | 284 | QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; |
285 | QStringList list = plugins(); | 285 | QStringList list = plugins(); |
286 | QStringList::Iterator it; | 286 | QStringList::Iterator it; |
287 | for ( it = list.begin(); it != list.end(); ++it ) { | 287 | for ( it = list.begin(); it != list.end(); ++it ) { |
288 | InputMethodInterface *iface = 0; | 288 | InputMethodInterface *iface = 0; |
289 | ExtInputMethodInterface *eface = 0; | 289 | ExtInputMethodInterface *eface = 0; |
290 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 290 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
291 | 291 | ||
292 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { | 292 | if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { |
293 | InputMethod input; | 293 | InputMethod input; |
294 | input.newIM = FALSE; | 294 | input.newIM = FALSE; |
295 | input.library = lib; | 295 | input.library = lib; |
296 | input.libName = *it; | 296 | input.libName = *it; |
297 | input.interface = iface; | 297 | input.interface = iface; |
298 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); | 298 | input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); |
299 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); | 299 | input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); |
300 | inputMethodList.append( input ); | 300 | inputMethodList.append( input ); |
301 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { | 301 | } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { |
302 | InputMethod input; | 302 | InputMethod input; |
303 | input.newIM = TRUE; | 303 | input.newIM = TRUE; |
304 | input.library = lib; | 304 | input.library = lib; |
305 | input.libName = *it; | 305 | input.libName = *it; |
306 | input.extInterface = eface; | 306 | input.extInterface = eface; |
307 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); | 307 | input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); |
308 | // may be either a simple, or advanced. | 308 | // may be either a simple, or advanced. |
309 | if (input.widget) { | 309 | if (input.widget) { |
310 | //qDebug("its a keyboard"); | 310 | //qDebug("its a keyboard"); |
311 | inputMethodList.append( input ); | 311 | inputMethodList.append( input ); |
312 | } else { | 312 | } else { |
313 | //qDebug("its a real im"); | 313 | //qDebug("its a real im"); |
314 | input.widget = input.extInterface->statusWidget( 0, 0 ); | 314 | input.widget = input.extInterface->statusWidget( 0, 0 ); |
315 | if (input.widget) { | 315 | if (input.widget) { |
316 | //qDebug("blah"); | 316 | //qDebug("blah"); |
317 | inputModifierList.append( input ); | 317 | inputModifierList.append( input ); |
318 | imButton->addWidget(input.widget, inputModifierList.count()); | 318 | imButton->addWidget(input.widget, inputModifierList.count()); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | }else{ | 321 | }else{ |
322 | delete lib; | 322 | delete lib; |
323 | lib = 0l; | 323 | lib = 0l; |
324 | } | 324 | } |
325 | installTranslator( (*it).left( (*it).find(".") ) ); | 325 | installTranslator( (*it).left( (*it).find(".") ) ); |
326 | } | 326 | } |
327 | qHeapSort( inputMethodList ); | 327 | qHeapSort( inputMethodList ); |
328 | #endif /* killed BUILT in cause they would not compile */ | 328 | #endif /* killed BUILT in cause they would not compile */ |
329 | 329 | ||
330 | QWSServer::setCurrentInputMethod( 0 ); | 330 | QWSServer::setCurrentInputMethod( 0 ); |
331 | 331 | ||
332 | /* set the prefered IM + handler */ | 332 | /* set the prefered IM + handler */ |
333 | setPreferedHandlers(); | 333 | setPreferedHandlers(); |
334 | if ( !inputModifierList.isEmpty() ) { | 334 | if ( !inputModifierList.isEmpty() ) { |
335 | if (!imethod) | 335 | if (!imethod) |
336 | imethod = &inputModifierList[0]; | 336 | imethod = &inputModifierList[0]; |
337 | imButton->raiseWidget(imethod->widget); | 337 | imButton->raiseWidget(imethod->widget); |
338 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 338 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
339 | } else { | 339 | } else { |
340 | imethod = 0; | 340 | imethod = 0; |
341 | } | 341 | } |
342 | 342 | ||
343 | // we need to update keyboards afterwards, as some of them may not be compatible with | 343 | // we need to update keyboards afterwards, as some of them may not be compatible with |
344 | // the current input method | 344 | // the current input method |
345 | updateKeyboards(imethod); | 345 | updateKeyboards(imethod); |
346 | 346 | ||
347 | if ( !inputModifierList.isEmpty() ) | 347 | if ( !inputModifierList.isEmpty() ) |
348 | imButton->show(); | 348 | imButton->show(); |
349 | else | 349 | else |
350 | imButton->hide(); | 350 | imButton->hide(); |
351 | 351 | ||
352 | if ( inputModifierList.count() > 1 ) | 352 | if ( inputModifierList.count() > 1 ) |
353 | imChoice->show(); | 353 | imChoice->show(); |
354 | else | 354 | else |
355 | imChoice->hide(); | 355 | imChoice->hide(); |
356 | } | 356 | } |
357 | 357 | ||
358 | void InputMethods::chooseKbd() | 358 | void InputMethods::chooseKbd() |
359 | { | 359 | { |
360 | QPopupMenu pop( this ); | 360 | QPopupMenu pop( this ); |
361 | pop.setFocusPolicy( NoFocus ); //don't reset IM | 361 | pop.setFocusPolicy( NoFocus ); //don't reset IM |
362 | 362 | ||
363 | QString imname; | 363 | QString imname; |
364 | if (imethod) | 364 | if (imethod) |
365 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); | 365 | imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); |
366 | 366 | ||
367 | int i = 0; | 367 | int i = 0; |
368 | int firstDepKbd = 0; | 368 | int firstDepKbd = 0; |
369 | 369 | ||
370 | QValueList<InputMethod>::Iterator it; | 370 | QValueList<InputMethod>::Iterator it; |
371 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { | 371 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { |
372 | // add empty new items, all old items. | 372 | // add empty new items, all old items. |
373 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { | 373 | if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { |
374 | pop.insertItem( (*it).name(), i, firstDepKbd); | 374 | pop.insertItem( (*it).name(), i, firstDepKbd); |
375 | if ( mkeyboard == &(*it) ) | 375 | if ( mkeyboard == &(*it) ) |
376 | pop.setItemChecked( i, TRUE ); | 376 | pop.setItemChecked( i, TRUE ); |
377 | 377 | ||
378 | firstDepKbd++; | 378 | firstDepKbd++; |
379 | } else if ( (*it).extInterface->compatible().contains(imname)) { | 379 | } else if ( (*it).extInterface->compatible().contains(imname)) { |
380 | // check if we need to insert a sep. | 380 | // check if we need to insert a sep. |
381 | if (firstDepKbd == i) | 381 | if (firstDepKbd == i) |
382 | pop.insertSeparator(); | 382 | pop.insertSeparator(); |
383 | pop.insertItem( (*it).name(), i, -1); | 383 | pop.insertItem( (*it).name(), i, -1); |
384 | if ( mkeyboard == &(*it) ) | 384 | if ( mkeyboard == &(*it) ) |
385 | pop.setItemChecked( i, TRUE ); | 385 | pop.setItemChecked( i, TRUE ); |
386 | } | 386 | } |
387 | } | 387 | } |
388 | 388 | ||
389 | QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); | 389 | QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); |
390 | QSize s = pop.sizeHint(); | 390 | QSize s = pop.sizeHint(); |
391 | pt.ry() -= s.height(); | 391 | pt.ry() -= s.height(); |
392 | pt.rx() -= s.width(); | 392 | pt.rx() -= s.width(); |
393 | i = pop.exec( pt ); | 393 | i = pop.exec( pt ); |
394 | if ( i == -1 ) | 394 | if ( i == -1 ) |
395 | return; | 395 | return; |
396 | InputMethod *im = &inputMethodList[i]; | 396 | InputMethod *im = &inputMethodList[i]; |
397 | chooseKeyboard(im); | 397 | chooseKeyboard(im); |
398 | } | 398 | } |
399 | 399 | ||
400 | void InputMethods::chooseIm() | 400 | void InputMethods::chooseIm() |
401 | { | 401 | { |
402 | QPopupMenu pop( this ); | 402 | QPopupMenu pop( this ); |
403 | 403 | ||
404 | int i = 0; | 404 | int i = 0; |
405 | QValueList<InputMethod>::Iterator it; | 405 | QValueList<InputMethod>::Iterator it; |
406 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { | 406 | for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { |
407 | pop.insertItem( (*it).name(), i ); | 407 | pop.insertItem( (*it).name(), i ); |
408 | if ( imethod == &(*it) ) | 408 | if ( imethod == &(*it) ) |
409 | pop.setItemChecked( i, TRUE ); | 409 | pop.setItemChecked( i, TRUE ); |
410 | } | 410 | } |
411 | 411 | ||
412 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); | 412 | QPoint pt = mapToGlobal(imChoice->geometry().topRight()); |
413 | QSize s = pop.sizeHint(); | 413 | QSize s = pop.sizeHint(); |
414 | pt.ry() -= s.height(); | 414 | pt.ry() -= s.height(); |
415 | pt.rx() -= s.width(); | 415 | pt.rx() -= s.width(); |
416 | i = pop.exec( pt ); | 416 | i = pop.exec( pt ); |
417 | if ( i == -1 ) | 417 | if ( i == -1 ) |
418 | return; | 418 | return; |
419 | InputMethod *im = &inputModifierList[i]; | 419 | InputMethod *im = &inputModifierList[i]; |
420 | 420 | ||
421 | chooseMethod(im); | 421 | chooseMethod(im); |
422 | } | 422 | } |
423 | 423 | ||
424 | void InputMethods::chooseKeyboard(InputMethod* im) | 424 | void InputMethods::chooseKeyboard(InputMethod* im) |
425 | { | 425 | { |
426 | if ( im != mkeyboard ) { | 426 | if ( im != mkeyboard ) { |
427 | if ( mkeyboard && mkeyboard->widget->isVisible() ) | 427 | if ( mkeyboard && mkeyboard->widget->isVisible() ) |
428 | mkeyboard->widget->hide(); | 428 | mkeyboard->widget->hide(); |
429 | mkeyboard = im; | 429 | mkeyboard = im; |
430 | kbdButton->setPixmap( *mkeyboard->icon() ); | 430 | kbdButton->setPixmap( *mkeyboard->icon() ); |
431 | } | 431 | } |
432 | if ( !kbdButton->isOn() ) | 432 | if ( !kbdButton->isOn() ) |
433 | kbdButton->setOn( TRUE ); | 433 | kbdButton->setOn( TRUE ); |
434 | else | 434 | else |
435 | showKbd( TRUE ); | 435 | showKbd( TRUE ); |
436 | } | 436 | } |
437 | 437 | ||
438 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) | 438 | static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) |
439 | { | 439 | { |
440 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) | 440 | if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) |
441 | return TRUE; | 441 | return TRUE; |
442 | 442 | ||
443 | if ( keyb->extInterface->compatible().contains(imname) ) | 443 | if ( keyb->extInterface->compatible().contains(imname) ) |
444 | return TRUE; | 444 | return TRUE; |
445 | 445 | ||
446 | return FALSE; | 446 | return FALSE; |
447 | } | 447 | } |
448 | 448 | ||
449 | // Updates the display of the soft keyboards available to the current input method | 449 | // Updates the display of the soft keyboards available to the current input method |
450 | void InputMethods::updateKeyboards(InputMethod *im ) | 450 | void InputMethods::updateKeyboards(InputMethod *im ) |
451 | { | 451 | { |
452 | uint count; | 452 | uint count; |
453 | 453 | ||
454 | if ( im ) { | 454 | if ( im ) { |
455 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); | 455 | QString imname = im->libName.mid(im->libName.findRev('/') + 1); |
456 | 456 | ||
457 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { | 457 | if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { |
458 | kbdButton->setOn( FALSE ); | 458 | kbdButton->setOn( FALSE ); |
459 | showKbd( FALSE ); | 459 | showKbd( FALSE ); |
460 | mkeyboard = 0; | 460 | mkeyboard = 0; |
461 | } | 461 | } |
462 | 462 | ||
463 | count = 0; | 463 | count = 0; |
464 | 464 | ||
465 | QValueList<InputMethod>::Iterator it; | 465 | QValueList<InputMethod>::Iterator it; |
466 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { | 466 | for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { |
467 | if ( keyboardCompatible( &(*it), imname ) ) { | 467 | if ( keyboardCompatible( &(*it), imname ) ) { |
468 | if ( !mkeyboard ) { | 468 | if ( !mkeyboard ) { |
469 | mkeyboard = &(*it); | 469 | mkeyboard = &(*it); |
470 | kbdButton->setPixmap( *mkeyboard->icon() ); | 470 | kbdButton->setPixmap( *mkeyboard->icon() ); |
471 | } | 471 | } |
472 | 472 | ||
473 | count++; | 473 | count++; |
474 | } | 474 | } |
475 | } | 475 | } |
476 | } else { | 476 | } else { |
477 | count = inputMethodList.count(); | 477 | count = inputMethodList.count(); |
478 | if ( count && !mkeyboard ) { | 478 | if ( count && !mkeyboard ) { |
479 | mkeyboard = &inputMethodList[0]; | 479 | mkeyboard = &inputMethodList[0]; |
480 | kbdButton->setPixmap( *mkeyboard->icon() ); | 480 | kbdButton->setPixmap( *mkeyboard->icon() ); |
481 | } else if (!count){ | 481 | } else if (!count){ |
482 | mkeyboard = 0; //might be redundant | 482 | mkeyboard = 0; //might be redundant |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | if ( count > 1 ) | 486 | if ( count > 1 ) |
487 | kbdChoice->show(); | 487 | kbdChoice->show(); |
488 | else | 488 | else |
489 | kbdChoice->hide(); | 489 | kbdChoice->hide(); |
490 | 490 | ||
491 | if ( count ) | 491 | if ( count ) |
492 | kbdButton->show(); | 492 | kbdButton->show(); |
493 | else | 493 | else |
494 | kbdButton->hide(); | 494 | kbdButton->hide(); |
495 | } | 495 | } |
496 | 496 | ||
497 | void InputMethods::chooseMethod(InputMethod* im) | 497 | void InputMethods::chooseMethod(InputMethod* im) |
498 | { | 498 | { |
499 | if ( im != imethod ) { | 499 | if ( im != imethod ) { |
500 | updateKeyboards( im ); | 500 | updateKeyboards( im ); |
501 | 501 | ||
502 | Config cfg("qpe"); | 502 | Config cfg("qpe"); |
503 | cfg.setGroup("InputMethod"); | 503 | cfg.setGroup("InputMethod"); |
504 | if (im ) | 504 | if (im ) |
505 | cfg.writeEntry("im", im->name() ); | 505 | cfg.writeEntry("im", im->name() ); |
506 | if (mkeyboard) | 506 | if (mkeyboard) |
507 | cfg.writeEntry("current", mkeyboard->name() ); | 507 | cfg.writeEntry("current", mkeyboard->name() ); |
508 | 508 | ||
509 | QWSServer::setCurrentInputMethod( 0 ); | 509 | QWSServer::setCurrentInputMethod( 0 ); |
510 | imethod = im; | 510 | imethod = im; |
511 | if ( imethod && imethod->newIM ) | 511 | if ( imethod && imethod->newIM ) |
512 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); | 512 | QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); |
513 | else | 513 | else |
514 | QWSServer::setCurrentInputMethod( 0 ); | 514 | QWSServer::setCurrentInputMethod( 0 ); |
515 | 515 | ||
516 | if ( im ) | 516 | if ( im ) |
517 | imButton->raiseWidget(im->widget); | 517 | imButton->raiseWidget(im->widget); |
518 | else | 518 | else |
519 | imButton->hide(); //### good UI? make sure it is shown again! | 519 | imButton->hide(); //### good UI? make sure it is shown again! |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) | 523 | void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) |
524 | { | 524 | { |
525 | if ( imethod && imethod->newIM ) | 525 | if ( imethod && imethod->newIM ) |
526 | imethod->extInterface->qcopReceive( msg, data ); | 526 | imethod->extInterface->qcopReceive( msg, data ); |
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void InputMethods::showKbd( bool on ) | 530 | void InputMethods::showKbd( bool on ) |
531 | { | 531 | { |
532 | if ( !mkeyboard ) | 532 | if ( !mkeyboard ) |
533 | return; | 533 | return; |
534 | 534 | ||
535 | if ( on ) { | 535 | if ( on ) |
536 | mkeyboard->resetState(); | 536 | { |
537 | // HACK... Make the texteditor fit with all input methods | 537 | mkeyboard->resetState(); |
538 | // Input methods should also never use more than about 40% of the screen | 538 | |
539 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); | 539 | int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); |
540 | mkeyboard->widget->resize( qApp->desktop()->width() * (inputWidgetWidth*0.01), height ); | 540 | int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); |
541 | mkeyboard->widget->move( 0, mapToGlobal( QPoint() ).y() - height ); | 541 | int left = 0; |
542 | mkeyboard->widget->show(); | 542 | int top = mapToGlobal( QPoint() ).y() - height; |
543 | } else { | 543 | |
544 | mkeyboard->widget->hide(); | 544 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) |
545 | { | ||
546 | qDebug( "InputMethods: reading geometry." ); | ||
547 | Config cfg( "Launcher" ); | ||
548 | cfg.setGroup( "InputMethods" ); | ||
549 | int l = cfg.readNumEntry( "absX", -1 ); | ||
550 | int t = cfg.readNumEntry( "absY", -1 ); | ||
551 | int w = cfg.readNumEntry( "absWidth", -1 ); | ||
552 | int h = cfg.readNumEntry( "absHeight", -1 ); | ||
553 | |||
554 | if ( l > -1 && t > -1 && w > -1 && h > -1 ) | ||
555 | { | ||
556 | qDebug( "InputMethods: config values ( %d, %d, %d, %d ) are ok.", l, t, w, h ); | ||
557 | left = l; | ||
558 | top = t; | ||
559 | width = w; | ||
560 | height = h; | ||
561 | } | ||
562 | else | ||
563 | { | ||
564 | qDebug( "InputMethods: config values are new or not ok." ); | ||
565 | } | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | qDebug( "InputMethods: no floating selected." ); | ||
570 | } | ||
571 | mkeyboard->widget->resize( width, height ); | ||
572 | mkeyboard->widget->move( left, top ); | ||
573 | mkeyboard->widget->show(); | ||
574 | mkeyboard->widget->installEventFilter( this ); | ||
575 | } | ||
576 | else | ||
577 | { | ||
578 | if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) | ||
579 | { | ||
580 | QPoint pos = mkeyboard->widget->pos(); | ||
581 | QSize siz = mkeyboard->widget->size(); | ||
582 | qDebug( "InputMethods: saving geometry." ); | ||
583 | Config cfg( "Launcher" ); | ||
584 | cfg.setGroup( "InputMethods" ); | ||
585 | cfg.writeEntry( "absX", pos.x() ); | ||
586 | cfg.writeEntry( "absY", pos.y() ); | ||
587 | cfg.writeEntry( "absWidth", siz.width() ); | ||
588 | cfg.writeEntry( "absHeight", siz.height() ); | ||
589 | cfg.write(); | ||
590 | mkeyboard->widget->hide(); | ||
591 | mkeyboard->widget->removeEventFilter( this ); | ||
592 | } | ||
545 | } | 593 | } |
546 | 594 | ||
547 | emit inputToggled( on ); | 595 | emit inputToggled( on ); |
548 | } | 596 | } |
549 | 597 | ||
550 | bool InputMethods::shown() const | 598 | bool InputMethods::shown() const |
551 | { | 599 | { |
552 | return mkeyboard && mkeyboard->widget->isVisible(); | 600 | return mkeyboard && mkeyboard->widget->isVisible(); |
553 | } | 601 | } |
554 | 602 | ||
555 | QString InputMethods::currentShown() const | 603 | QString InputMethods::currentShown() const |
556 | { | 604 | { |
557 | return mkeyboard && mkeyboard->widget->isVisible() | 605 | return mkeyboard && mkeyboard->widget->isVisible() |
558 | ? mkeyboard->name() : QString::null; | 606 | ? mkeyboard->name() : QString::null; |
559 | } | 607 | } |
560 | 608 | ||
561 | void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) | 609 | void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) |
562 | { | 610 | { |
563 | #if defined(Q_WS_QWS) | 611 | #if defined(Q_WS_QWS) |
564 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); | 612 | QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); |
565 | #endif | 613 | #endif |
566 | } | 614 | } |
615 | |||
616 | bool InputMethods::eventFilter( QObject* o, QEvent* e ) | ||
617 | { | ||
618 | if ( e->type() == QEvent::Close ) | ||
619 | { | ||
620 | ( (QCloseEvent*) e )->ignore(); | ||
621 | showKbd( false ); | ||
622 | kbdButton->setOn( false ); | ||
623 | return true; | ||
624 | } | ||
625 | return false; | ||
626 | } | ||
diff --git a/core/launcher/inputmethods.h b/core/launcher/inputmethods.h index 246661a..55ac020 100644 --- a/core/launcher/inputmethods.h +++ b/core/launcher/inputmethods.h | |||
@@ -1,112 +1,113 @@ | |||
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 | #ifndef __INPUT_METHODS_H__ | 21 | #ifndef __INPUT_METHODS_H__ |
22 | #define __INPUT_METHODS_H__ | 22 | #define __INPUT_METHODS_H__ |
23 | 23 | ||
24 | #include <qtopia/qlibrary.h> | 24 | #include <qtopia/qlibrary.h> |
25 | #include <qtopia/inputmethodinterface.h> | 25 | #include <qtopia/inputmethodinterface.h> |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | class QToolButton; | 30 | class QToolButton; |
31 | class QWidgetStack; | 31 | class QWidgetStack; |
32 | 32 | ||
33 | struct InputMethod | 33 | struct InputMethod |
34 | { | 34 | { |
35 | #ifndef QT_NO_COMPONENT | 35 | #ifndef QT_NO_COMPONENT |
36 | QLibrary *library; | 36 | QLibrary *library; |
37 | #endif | 37 | #endif |
38 | QWidget *widget; | 38 | QWidget *widget; |
39 | QString libName; | 39 | QString libName; |
40 | bool newIM; | 40 | bool newIM; |
41 | union { | 41 | union { |
42 | InputMethodInterface *interface; | 42 | InputMethodInterface *interface; |
43 | ExtInputMethodInterface *extInterface; | 43 | ExtInputMethodInterface *extInterface; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | inline void releaseInterface() { | 46 | inline void releaseInterface() { |
47 | newIM ? (void)extInterface->release() : (void)interface->release(); | 47 | newIM ? (void)extInterface->release() : (void)interface->release(); |
48 | library->unload(); | 48 | library->unload(); |
49 | delete library; library = 0l; | 49 | delete library; library = 0l; |
50 | } | 50 | } |
51 | inline QString name() const { return newIM ? extInterface->name() : interface->name(); } | 51 | inline QString name() const { return newIM ? extInterface->name() : interface->name(); } |
52 | inline QPixmap *icon() const { return newIM ? extInterface->icon() : interface->icon(); } | 52 | inline QPixmap *icon() const { return newIM ? extInterface->icon() : interface->icon(); } |
53 | inline QUnknownInterface *iface() { return newIM ? (QUnknownInterface *)extInterface : (QUnknownInterface *)interface; } | 53 | inline QUnknownInterface *iface() { return newIM ? (QUnknownInterface *)extInterface : (QUnknownInterface *)interface; } |
54 | inline void resetState() { if ( !newIM ) interface->resetState(); } | 54 | inline void resetState() { if ( !newIM ) interface->resetState(); } |
55 | 55 | ||
56 | int operator <(const InputMethod& o) const; | 56 | int operator <(const InputMethod& o) const; |
57 | int operator >(const InputMethod& o) const; | 57 | int operator >(const InputMethod& o) const; |
58 | int operator <=(const InputMethod& o) const; | 58 | int operator <=(const InputMethod& o) const; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class InputMethods : public QWidget | 61 | class InputMethods : public QWidget |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | InputMethods( QWidget * ); | 65 | InputMethods( QWidget * ); |
66 | ~InputMethods(); | 66 | ~InputMethods(); |
67 | 67 | ||
68 | QRect inputRect() const; | 68 | QRect inputRect() const; |
69 | bool shown() const; | 69 | bool shown() const; |
70 | QString currentShown() const; // name of interface | 70 | QString currentShown() const; // name of interface |
71 | void showInputMethod(const QString& id); | 71 | void showInputMethod(const QString& id); |
72 | void showInputMethod(); | 72 | void showInputMethod(); |
73 | void hideInputMethod(); | 73 | void hideInputMethod(); |
74 | void unloadInputMethods(); | 74 | void unloadInputMethods(); |
75 | void loadInputMethods(); | 75 | void loadInputMethods(); |
76 | virtual bool eventFilter( QObject *, QEvent * ); | ||
76 | 77 | ||
77 | signals: | 78 | signals: |
78 | void inputToggled( bool on ); | 79 | void inputToggled( bool on ); |
79 | 80 | ||
80 | private slots: | 81 | private slots: |
81 | void chooseKbd(); | 82 | void chooseKbd(); |
82 | void chooseIm(); | 83 | void chooseIm(); |
83 | void showKbd( bool ); | 84 | void showKbd( bool ); |
84 | void resetStates(); | 85 | void resetStates(); |
85 | void sendKey( ushort unicode, ushort scancode, ushort modifiers, bool, bool ); | 86 | void sendKey( ushort unicode, ushort scancode, ushort modifiers, bool, bool ); |
86 | void qcopReceive( const QCString &msg, const QByteArray &data ); | 87 | void qcopReceive( const QCString &msg, const QByteArray &data ); |
87 | 88 | ||
88 | private: | 89 | private: |
89 | void setPreferedHandlers(); | 90 | void setPreferedHandlers(); |
90 | /*static */QStringList plugins()const; | 91 | /*static */QStringList plugins()const; |
91 | /*static */void installTranslator( const QString& ); | 92 | /*static */void installTranslator( const QString& ); |
92 | void unloadMethod( QValueList<InputMethod>& ); | 93 | void unloadMethod( QValueList<InputMethod>& ); |
93 | void chooseMethod(InputMethod* im); | 94 | void chooseMethod(InputMethod* im); |
94 | void chooseKeyboard(InputMethod* im); | 95 | void chooseKeyboard(InputMethod* im); |
95 | void updateKeyboards(InputMethod *im); | 96 | void updateKeyboards(InputMethod *im); |
96 | 97 | ||
97 | private: | 98 | private: |
98 | QToolButton *kbdButton; | 99 | QToolButton *kbdButton; |
99 | QToolButton *kbdChoice; | 100 | QToolButton *kbdChoice; |
100 | QWidgetStack *imButton; // later will be widget stack | 101 | QWidgetStack *imButton; // later will be widget stack |
101 | QToolButton *imChoice; | 102 | QToolButton *imChoice; |
102 | InputMethod *mkeyboard; | 103 | InputMethod *mkeyboard; |
103 | InputMethod *imethod; | 104 | InputMethod *imethod; |
104 | QValueList<InputMethod> inputMethodList; | 105 | QValueList<InputMethod> inputMethodList; |
105 | QValueList<InputMethod> inputModifierList; | 106 | QValueList<InputMethod> inputModifierList; |
106 | int inputWidgetStyle; | 107 | int inputWidgetStyle; |
107 | int inputWidgetWidth; | 108 | int inputWidgetWidth; |
108 | }; | 109 | }; |
109 | 110 | ||
110 | 111 | ||
111 | #endif // __INPUT_METHODS_H__ | 112 | #endif // __INPUT_METHODS_H__ |
112 | 113 | ||