summaryrefslogtreecommitdiff
path: root/inputmethods
authorsandman <sandman>2002-10-22 11:38:47 (UTC)
committer sandman <sandman>2002-10-22 11:38:47 (UTC)
commit1ee836bd1bb777dded54810909e508dc0470ada3 (patch) (unidiff)
tree7bba0cd910c49c7f7dc7ca61f80c471b039861af /inputmethods
parentbbb2c5fee87baa345ff5c16404204054442f5c11 (diff)
downloadopie-1ee836bd1bb777dded54810909e508dc0470ada3.zip
opie-1ee836bd1bb777dded54810909e508dc0470ada3.tar.gz
opie-1ee836bd1bb777dded54810909e508dc0470ada3.tar.bz2
- Always try to load the "en" keymap, if a user specified one cannot be
found - Fix the divison by zero error in resizeEvent, in case there is a keymap with 0 rows or no keymap at all.
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp7
-rw-r--r--inputmethods/multikey/keyboardimpl.cpp1
2 files changed, 5 insertions, 3 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 1dd8ca1..de3aa52 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -4,193 +4,193 @@
4** This file is part of Qtopia Environment. 4** This file is part of 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#include "keyboard.h" 21#include "keyboard.h"
22#include "configdlg.h" 22#include "configdlg.h"
23 23
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26 26
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qfontmetrics.h> 29#include <qfontmetrics.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <ctype.h> 33#include <ctype.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41/* Keyboard::Keyboard {{{1 */ 41/* Keyboard::Keyboard {{{1 */
42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 42Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), 43 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
44 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), 44 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
45 useLargeKeys(TRUE), usePicks(0), useRepeat(0), 45 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
46 pressedKeyRow(-1), pressedKeyCol(-1), 46 pressedKeyRow(-1), pressedKeyCol(-1),
47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
48 configdlg(0) 48 configdlg(0)
49 49
50{ 50{
51 51
52 // get the default font 52 // get the default font
53 Config *config = new Config( "qpe" ); 53 Config *config = new Config( "qpe" );
54 config->setGroup( "Appearance" ); 54 config->setGroup( "Appearance" );
55 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 55 QString familyStr = config->readEntry( "FontFamily", "fixed" );
56 delete config; 56 delete config;
57 57
58 config = new Config("multikey"); 58 config = new Config("multikey");
59 config->setGroup ("general"); 59 config->setGroup ("general");
60 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed 60 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
61 useRepeat = config->readBoolEntry ("useRepeat", 1); 61 useRepeat = config->readBoolEntry ("useRepeat", 1);
62 delete config; 62 delete config;
63 63
64 64
65 setFont( QFont( familyStr, 10 ) ); 65 setFont( QFont( familyStr, 10 ) );
66 66
67 picks = new KeyboardPicks( this ); 67 picks = new KeyboardPicks( this );
68 picks->setFont( QFont( familyStr, 10 ) ); 68 picks->setFont( QFont( familyStr, 10 ) );
69 picks->initialise(); 69 picks->initialise();
70 if (usePicks) { 70 if (usePicks) {
71 71
72 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 72 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
73 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 73 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
74 74
75 } else picks->hide(); 75 } else picks->hide();
76 76
77 loadKeyboardColors(); 77 loadKeyboardColors();
78 78
79 keys = new Keys(); 79 keys = new Keys();
80 80
81 repeatTimer = new QTimer( this ); 81 repeatTimer = new QTimer( this );
82 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 82 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
83 83
84} 84}
85 85
86Keyboard::~Keyboard() { 86Keyboard::~Keyboard() {
87 87
88 if ( configdlg ) { 88 if ( configdlg ) {
89 delete (ConfigDlg *) configdlg; 89 delete (ConfigDlg *) configdlg;
90 configdlg = 0; 90 configdlg = 0;
91 } 91 }
92 92
93} 93}
94 94
95/* Keyboard::resizeEvent {{{1 */ 95/* Keyboard::resizeEvent {{{1 */
96void Keyboard::resizeEvent(QResizeEvent*) 96void Keyboard::resizeEvent(QResizeEvent*)
97{ 97{
98 int ph = picks->sizeHint().height(); 98 int ph = picks->sizeHint().height();
99 picks->setGeometry( 0, 0, width(), ph ); 99 picks->setGeometry( 0, 0, width(), ph );
100 keyHeight = (height()-(usePicks ? ph : 0))/keys->rows(); 100 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1);
101 101
102 int nk; // number of keys? 102 int nk; // number of keys?
103 if ( useLargeKeys ) { 103 if ( useLargeKeys ) {
104 nk = 15; 104 nk = 15;
105 } else { 105 } else {
106 nk = 19; 106 nk = 19;
107 } 107 }
108 defaultKeyWidth = (width()/nk)/2; 108 defaultKeyWidth = (width()/nk)/2;
109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 109 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
110 110
111} 111}
112 112
113/* KeyboardPicks::initialize {{{1 */ 113/* KeyboardPicks::initialize {{{1 */
114void KeyboardPicks::initialise() 114void KeyboardPicks::initialise()
115{ 115{
116 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 116 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
117 mode = 0; 117 mode = 0;
118 dc = new KeyboardConfig(this); 118 dc = new KeyboardConfig(this);
119 configs.append(dc); 119 configs.append(dc);
120} 120}
121 121
122/* KeyboardPicks::sizeHint {{{1 */ 122/* KeyboardPicks::sizeHint {{{1 */
123QSize KeyboardPicks::sizeHint() const 123QSize KeyboardPicks::sizeHint() const
124{ 124{
125 return QSize(240,fontMetrics().lineSpacing()); 125 return QSize(240,fontMetrics().lineSpacing());
126} 126}
127 127
128 128
129/* KeyboardConfig::generateText {{{1 */ 129/* KeyboardConfig::generateText {{{1 */
130void KeyboardConfig::generateText(const QString &s) 130void KeyboardConfig::generateText(const QString &s)
131{ 131{
132#if defined(Q_WS_QWS) || defined(_WS_QWS_) 132#if defined(Q_WS_QWS) || defined(_WS_QWS_)
133 for (int i=0; i<(int)backspaces; i++) { 133 for (int i=0; i<(int)backspaces; i++) {
134 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 134 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
135 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 135 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
136 } 136 }
137 for (int i=0; i<(int)s.length(); i++) { 137 for (int i=0; i<(int)s.length(); i++) {
138 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 138 parent->emitKey( s[i].unicode(), 0, 0, true, false );
139 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 139 parent->emitKey( s[i].unicode(), 0, 0, false, false );
140 } 140 }
141 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 141 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
142 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 142 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
143 backspaces = 0; 143 backspaces = 0;
144#endif 144#endif
145} 145}
146 146
147 147
148 148
149 149
150/* Keyboard::paintEvent {{{1 */ 150/* Keyboard::paintEvent {{{1 */
151void Keyboard::paintEvent(QPaintEvent* e) 151void Keyboard::paintEvent(QPaintEvent* e)
152{ 152{
153 QPainter painter(this); 153 QPainter painter(this);
154 painter.setClipRect(e->rect()); 154 painter.setClipRect(e->rect());
155 drawKeyboard( painter ); 155 drawKeyboard( painter );
156 picks->dc->draw( &painter ); 156 picks->dc->draw( &painter );
157} 157}
158 158
159 159
160/* Keyboard::drawKeyboard {{{1 */ 160/* Keyboard::drawKeyboard {{{1 */
161 161
162void Keyboard::drawKeyboard(QPainter &p, int row, int col) 162void Keyboard::drawKeyboard(QPainter &p, int row, int col)
163{ 163{
164 164
165 165
166 if (row != -1 && col != -1) { //just redraw one key 166 if (row != -1 && col != -1) { //just redraw one key
167 167
168 int x = 0; 168 int x = 0;
169 for (int i = 0; i < col; i++) { 169 for (int i = 0; i < col; i++) {
170 170
171 x += keys->width(row, i) * defaultKeyWidth; 171 x += keys->width(row, i) * defaultKeyWidth;
172 } 172 }
173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 173 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
174 174
175 int keyWidth = keys->width(row, col); 175 int keyWidth = keys->width(row, col);
176 176
177 p.fillRect(x + 1, y + 1, 177 p.fillRect(x + 1, y + 1,
178 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 178 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 179 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
180 180
181 QImage *pix = keys->pix(row,col); 181 QImage *pix = keys->pix(row,col);
182 182
183 ushort c = keys->uni(row, col); 183 ushort c = keys->uni(row, col);
184 184
185 p.setPen(textcolor); 185 p.setPen(textcolor);
186 if (!pix) { 186 if (!pix) {
187 if ((shift || lock) && keys->shift(c)) 187 if ((shift || lock) && keys->shift(c))
188 188
189 if (circumflex && keys->circumflex(keys->shift(c))) 189 if (circumflex && keys->circumflex(keys->shift(c)))
190 c = keys->circumflex(keys->shift(c)); 190 c = keys->circumflex(keys->shift(c));
191 else if (diaeresis && keys->diaeresis(keys->shift(c))) 191 else if (diaeresis && keys->diaeresis(keys->shift(c)))
192 c = keys->diaeresis(keys->shift(c)); 192 c = keys->diaeresis(keys->shift(c));
193 else if (baccent && keys->baccent(keys->shift(c))) 193 else if (baccent && keys->baccent(keys->shift(c)))
194 c = keys->baccent(keys->shift(c)); 194 c = keys->baccent(keys->shift(c));
195 else if (accent && keys->accent(keys->shift(c))) 195 else if (accent && keys->accent(keys->shift(c)))
196 c = keys->accent(keys->shift(c)); 196 c = keys->accent(keys->shift(c));
@@ -1228,193 +1228,196 @@ ushort Keyboard::parseKoreanInput (ushort c) {
1228 schar = 0; mchar = 0; echar = 0; 1228 schar = 0; mchar = 0; echar = 0;
1229 return c; 1229 return c;
1230 } 1230 }
1231 1231
1232 } 1232 }
1233 else /*if (c == ' ')*/ return c; 1233 else /*if (c == ' ')*/ return c;
1234 1234
1235 1235
1236 // and now... finally delete previous char, and return new char 1236 // and now... finally delete previous char, and return new char
1237 emit key( 8, Qt::Key_Backspace, 0, true, false ); 1237 emit key( 8, Qt::Key_Backspace, 0, true, false );
1238 1238
1239 1239
1240 return combineKoreanChars( schar, mchar, echar); 1240 return combineKoreanChars( schar, mchar, echar);
1241 1241
1242} 1242}
1243 1243
1244ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 1244ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
1245 1245
1246 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 1246 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
1247 1247
1248} 1248}
1249 1249
1250ushort Keyboard::constoe(const ushort c) { 1250ushort Keyboard::constoe(const ushort c) {
1251 1251
1252 // converts schars to echars if possible 1252 // converts schars to echars if possible
1253 1253
1254 if (0x1100 <= c && c <= 0x1112) { // schar to echar 1254 if (0x1100 <= c && c <= 0x1112) { // schar to echar
1255 1255
1256 switch (c) { 1256 switch (c) {
1257 case 0x1100: return 0x11a8; 1257 case 0x1100: return 0x11a8;
1258 case 0x1101: return 0x11a9; 1258 case 0x1101: return 0x11a9;
1259 case 0x1102: return 0x11ab; 1259 case 0x1102: return 0x11ab;
1260 case 0x1103: return 0x11ae; 1260 case 0x1103: return 0x11ae;
1261 case 0x1105: return 0x11af; 1261 case 0x1105: return 0x11af;
1262 case 0x1106: return 0x11b7; 1262 case 0x1106: return 0x11b7;
1263 case 0x1107: return 0x11b8; 1263 case 0x1107: return 0x11b8;
1264 case 0x1109: return 0x11ba; 1264 case 0x1109: return 0x11ba;
1265 case 0x110a: return 0x11bb; 1265 case 0x110a: return 0x11bb;
1266 case 0x110b: return 0x11bc; 1266 case 0x110b: return 0x11bc;
1267 case 0x110c: return 0x11bd; 1267 case 0x110c: return 0x11bd;
1268 case 0x110e: return 0x11be; 1268 case 0x110e: return 0x11be;
1269 case 0x110f: return 0x11bf; 1269 case 0x110f: return 0x11bf;
1270 case 0x1110: return 0x11c0; 1270 case 0x1110: return 0x11c0;
1271 case 0x1111: return 0x11c1; 1271 case 0x1111: return 0x11c1;
1272 case 0x1112: return 0x11c2; 1272 case 0x1112: return 0x11c2;
1273 default: return 0; 1273 default: return 0;
1274 1274
1275 } 1275 }
1276 1276
1277 } else { //echar to schar 1277 } else { //echar to schar
1278 1278
1279 switch (c) { 1279 switch (c) {
1280 case 0x11a8: return 0x1100; 1280 case 0x11a8: return 0x1100;
1281 case 0x11a9: return 0x1101; 1281 case 0x11a9: return 0x1101;
1282 case 0x11ab: return 0x1102; 1282 case 0x11ab: return 0x1102;
1283 case 0x11ae: return 0x1103; 1283 case 0x11ae: return 0x1103;
1284 case 0x11af: return 0x1105; 1284 case 0x11af: return 0x1105;
1285 case 0x11b7: return 0x1106; 1285 case 0x11b7: return 0x1106;
1286 case 0x11b8: return 0x1107; 1286 case 0x11b8: return 0x1107;
1287 case 0x11ba: return 0x1109; 1287 case 0x11ba: return 0x1109;
1288 case 0x11bb: return 0x110a; 1288 case 0x11bb: return 0x110a;
1289 case 0x11bc: return 0x110b; 1289 case 0x11bc: return 0x110b;
1290 case 0x11bd: return 0x110c; 1290 case 0x11bd: return 0x110c;
1291 case 0x11be: return 0x110e; 1291 case 0x11be: return 0x110e;
1292 case 0x11bf: return 0x110f; 1292 case 0x11bf: return 0x110f;
1293 case 0x11c0: return 0x1110; 1293 case 0x11c0: return 0x1110;
1294 case 0x11c1: return 0x1111; 1294 case 0x11c1: return 0x1111;
1295 case 0x11c2: return 0x1112; 1295 case 0x11c2: return 0x1112;
1296 default: return 0; 1296 default: return 0;
1297 1297
1298 } 1298 }
1299 1299
1300 } 1300 }
1301} 1301}
1302 1302
1303 1303
1304// Keys::Keys {{{1 1304// Keys::Keys {{{1
1305 1305
1306Keys::Keys() { 1306Keys::Keys() {
1307 1307
1308 Config *config = new Config ("multikey"); 1308 Config *config = new Config ("multikey");
1309 config->setGroup( "keymaps" ); 1309 config->setGroup( "keymaps" );
1310 QString map = config->readEntry( "current" ); 1310 QString map = config->readEntry( "current" );
1311 delete config; 1311 delete config;
1312 1312
1313 if (map.isNull() || !(QFile(map).exists())) { 1313 if (map.isNull() || !(QFile(map).exists())) {
1314 1314
1315 Config *config = new Config("locale"); 1315 Config *config = new Config("locale");
1316 config->setGroup( "Language" ); 1316 config->setGroup( "Language" );
1317 QString l = config->readEntry( "Language" , "en" ); 1317 QString l = config->readEntry( "Language" , "en" );
1318 delete config; 1318 delete config;
1319 1319
1320 map = QPEApplication::qpeDir() + "/share/multikey/" 1320 map = QPEApplication::qpeDir() + "/share/multikey/"
1321 + l + ".keymap"; 1321 + l + ".keymap";
1322 1322
1323 } 1323 }
1324 1324 if (map.isNull() || !(QFile(map).exists())) {
1325 map = QPEApplication::qpeDir() + "/share/multikey/en.keymap";
1326 }
1327
1325 setKeysFromFile(map); 1328 setKeysFromFile(map);
1326} 1329}
1327 1330
1328Keys::Keys(const char * filename) { 1331Keys::Keys(const char * filename) {
1329 1332
1330 setKeysFromFile(filename); 1333 setKeysFromFile(filename);
1331} 1334}
1332 1335
1333// Keys::setKeysFromFile {{{2 1336// Keys::setKeysFromFile {{{2
1334void Keys::setKeysFromFile(const char * filename) { 1337void Keys::setKeysFromFile(const char * filename) {
1335 1338
1336 QFile f(filename); 1339 QFile f(filename);
1337 1340
1338 if (f.open(IO_ReadOnly)) { 1341 if (f.open(IO_ReadOnly)) {
1339 1342
1340 QTextStream t(&f); 1343 QTextStream t(&f);
1341 int row; 1344 int row;
1342 int qcode; 1345 int qcode;
1343 ushort unicode; 1346 ushort unicode;
1344 int width; 1347 int width;
1345 QString buf; 1348 QString buf;
1346 QString comment; 1349 QString comment;
1347 char * xpm[256]; //couldnt be larger than that... could it? 1350 char * xpm[256]; //couldnt be larger than that... could it?
1348 QImage *xpm2pix = 0; 1351 QImage *xpm2pix = 0;
1349 1352
1350 buf = t.readLine(); 1353 buf = t.readLine();
1351 while (buf) { 1354 while (buf) {
1352 1355
1353 // get rid of comments 1356 // get rid of comments
1354 buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); 1357 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1355 1358
1356 // key definition 1359 // key definition
1357 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1360 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1358 // no $1 type referencing!!! this implementation of regexp sucks 1361 // no $1 type referencing!!! this implementation of regexp sucks
1359 1362
1360 // dont know of any sscanf() type funcs in Qt lib 1363 // dont know of any sscanf() type funcs in Qt lib
1361 QTextStream tmp (buf, IO_ReadOnly); 1364 QTextStream tmp (buf, IO_ReadOnly);
1362 tmp >> row >> qcode >> unicode >> width >> comment; 1365 tmp >> row >> qcode >> unicode >> width >> comment;
1363 1366
1364 buf = t.readLine(); 1367 buf = t.readLine();
1365 int xpmLineCount = 0; 1368 int xpmLineCount = 0;
1366 xpm2pix = 0; 1369 xpm2pix = 0;
1367 1370
1368 // erase blank space 1371 // erase blank space
1369 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1372 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1370 1373
1371 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1374 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1372 1375
1373 QString xpmBuf = buf.stripWhiteSpace(); 1376 QString xpmBuf = buf.stripWhiteSpace();
1374 1377
1375 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1378 xpm[xpmLineCount] = new char [xpmBuf.length()];
1376 1379
1377 int j = 0; 1380 int j = 0;
1378 for (ushort i = 0; i < xpmBuf.length(); i++) { 1381 for (ushort i = 0; i < xpmBuf.length(); i++) {
1379 if (xpmBuf[i].latin1() != '"') { 1382 if (xpmBuf[i].latin1() != '"') {
1380 1383
1381 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1384 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1382 j++; 1385 j++;
1383 } 1386 }
1384 1387
1385 } 1388 }
1386 // have to close that facker up 1389 // have to close that facker up
1387 ((char *)xpm[xpmLineCount])[j] = '\0'; 1390 ((char *)xpm[xpmLineCount])[j] = '\0';
1388 1391
1389 xpmLineCount++; 1392 xpmLineCount++;
1390 buf = t.readLine(); 1393 buf = t.readLine();
1391 } 1394 }
1392 if (xpmLineCount) { 1395 if (xpmLineCount) {
1393 1396
1394 xpm2pix = new QImage((const char **)xpm); 1397 xpm2pix = new QImage((const char **)xpm);
1395 for (int i = 0; i < xpmLineCount; i++) 1398 for (int i = 0; i < xpmLineCount; i++)
1396 1399
1397 delete [] (xpm[i]); 1400 delete [] (xpm[i]);
1398 1401
1399 } 1402 }
1400 setKey(row, qcode, unicode, width, xpm2pix); 1403 setKey(row, qcode, unicode, width, xpm2pix);
1401 } 1404 }
1402 1405
1403 // shift map 1406 // shift map
1404 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1407 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1405 1408
1406 QTextStream tmp (buf, IO_ReadOnly); 1409 QTextStream tmp (buf, IO_ReadOnly);
1407 ushort lower, shift; 1410 ushort lower, shift;
1408 tmp >> lower >> shift; 1411 tmp >> lower >> shift;
1409 1412
1410 shiftMap.insert(lower, shift); 1413 shiftMap.insert(lower, shift);
1411 1414
1412 buf = t.readLine(); 1415 buf = t.readLine();
1413 } 1416 }
1414 1417
1415 // meta key map 1418 // meta key map
1416 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1419 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1417 1420
1418 QTextStream tmp (buf, IO_ReadOnly); 1421 QTextStream tmp (buf, IO_ReadOnly);
1419 ushort lower, shift; 1422 ushort lower, shift;
1420 QChar m; 1423 QChar m;
diff --git a/inputmethods/multikey/keyboardimpl.cpp b/inputmethods/multikey/keyboardimpl.cpp
index 2bcb0fa..cebd43d 100644
--- a/inputmethods/multikey/keyboardimpl.cpp
+++ b/inputmethods/multikey/keyboardimpl.cpp
@@ -1,108 +1,107 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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#include <qapplication.h> 20#include <qapplication.h>
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include "keyboard.h" 22#include "keyboard.h"
23#include "keyboardimpl.h" 23#include "keyboardimpl.h"
24 24
25/* XPM */ 25/* XPM */
26static const char * kb_xpm[] = { 26static const char * kb_xpm[] = {
27"28 13 4 1", 27"28 13 4 1",
28" c None", 28" c None",
29". c #4C4C4C", 29". c #4C4C4C",
30"+ c #FFF7DD", 30"+ c #FFF7DD",
31"@ c #D6CFBA", 31"@ c #D6CFBA",
32" .......................... ", 32" .......................... ",
33" .+++.+++.+++.+++.+++.++++. ", 33" .+++.+++.+++.+++.+++.++++. ",
34" .+@@.+@@.+@@.+@@.+@@.+@@@. ", 34" .+@@.+@@.+@@.+@@.+@@.+@@@. ",
35" .......................... ", 35" .......................... ",
36" .+++++.+++.+++.+++.++++++. ", 36" .+++++.+++.+++.+++.++++++. ",
37" .+@@@@.+@@.+@@.+@@.+@@@@@. ", 37" .+@@@@.+@@.+@@.+@@.+@@@@@. ",
38" .......................... ", 38" .......................... ",
39" .++++++.+++.+++.+++.+++++. ", 39" .++++++.+++.+++.+++.+++++. ",
40" .+@@@@@.+@@.+@@.+@@.+@@@@. ", 40" .+@@@@@.+@@.+@@.+@@.+@@@@. ",
41" .......................... ", 41" .......................... ",
42" .++++.++++++++++++++.++++. ", 42" .++++.++++++++++++++.++++. ",
43" .+@@@.+@@@@@@@@@@@@@.+@@@. ", 43" .+@@@.+@@@@@@@@@@@@@.+@@@. ",
44" .......................... "}; 44" .......................... "};
45 45
46 46
47KeyboardImpl::KeyboardImpl() 47KeyboardImpl::KeyboardImpl()
48 : input(0), icn(0), ref(0) 48 : input(0), icn(0), ref(0)
49{ 49{
50} 50}
51 51
52KeyboardImpl::~KeyboardImpl() 52KeyboardImpl::~KeyboardImpl()
53{ 53{
54 delete input; 54 delete input;
55 delete icn; 55 delete icn;
56} 56}
57 57
58QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) 58QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
59{ 59{
60 if ( !input ) 60 if ( !input )
61 input = new Keyboard( parent, "Keyboard", f ); 61 input = new Keyboard( parent, "Keyboard", f );
62 return input; 62 return input;
63} 63}
64 64
65void KeyboardImpl::resetState() 65void KeyboardImpl::resetState()
66{ 66{
67 if ( input ) 67 if ( input )
68 input->resetState(); 68 input->resetState();
69} 69}
70 70
71QPixmap *KeyboardImpl::icon() 71QPixmap *KeyboardImpl::icon()
72{ 72{
73 if ( !icn ) 73 if ( !icn )
74 icn = new QPixmap( (const char **)kb_xpm ); 74 icn = new QPixmap( (const char **)kb_xpm );
75 return icn; 75 return icn;
76} 76}
77 77
78QString KeyboardImpl::name() 78QString KeyboardImpl::name()
79{ 79{
80 return qApp->translate( "InputMethods", "Multikey" ); 80 return qApp->translate( "InputMethods", "Multikey" );
81// return qApp->translate( "InputMethods", "Opti" );
82} 81}
83 82
84void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) 83void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot )
85{ 84{
86 if ( input ) 85 if ( input )
87 QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); 86 QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
88} 87}
89 88
90#ifndef QT_NO_COMPONENT 89#ifndef QT_NO_COMPONENT
91QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 90QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
92{ 91{
93 *iface = 0; 92 *iface = 0;
94 if ( uuid == IID_QUnknown ) 93 if ( uuid == IID_QUnknown )
95 *iface = this; 94 *iface = this;
96 else if ( uuid == IID_InputMethod ) 95 else if ( uuid == IID_InputMethod )
97 *iface = this; 96 *iface = this;
98 97
99 if ( *iface ) 98 if ( *iface )
100 (*iface)->addRef(); 99 (*iface)->addRef();
101 return QS_OK; 100 return QS_OK;
102} 101}
103 102
104Q_EXPORT_INTERFACE() 103Q_EXPORT_INTERFACE()
105{ 104{
106 Q_CREATE_INSTANCE( KeyboardImpl ) 105 Q_CREATE_INSTANCE( KeyboardImpl )
107} 106}
108#endif 107#endif