-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 4f4f25f..7ddfd3e 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,1710 +1,1710 @@ | |||
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 | 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 <qdir.h> | 34 | #include <qdir.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 | using namespace MultiKey; | 40 | using namespace MultiKey; |
41 | 41 | ||
42 | static const char * const kb_config_xpm[] = { | 42 | static const char * const kb_config_xpm[] = { |
43 | "13 7 2 1", | 43 | "13 7 2 1", |
44 | " c None", | 44 | " c None", |
45 | ". c #000000", | 45 | ". c #000000", |
46 | " ", | 46 | " ", |
47 | " . ", | 47 | " . ", |
48 | " ... ", | 48 | " ... ", |
49 | " ..... ", | 49 | " ..... ", |
50 | " . ", | 50 | " . ", |
51 | " . ", | 51 | " . ", |
52 | " "}; | 52 | " "}; |
53 | 53 | ||
54 | /* Keyboard::Keyboard {{{1 */ | 54 | /* Keyboard::Keyboard {{{1 */ |
55 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 55 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
56 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), | 56 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), |
57 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), | 57 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), |
58 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), | 58 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), |
59 | pressedKeyRow(-1), pressedKeyCol(-1), | 59 | pressedKeyRow(-1), pressedKeyCol(-1), |
60 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 60 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
61 | configdlg(0) | 61 | configdlg(0) |
62 | 62 | ||
63 | { | 63 | { |
64 | 64 | ||
65 | // get the default font | 65 | // get the default font |
66 | Config *config = new Config( "qpe" ); | 66 | Config *config = new Config( "qpe" ); |
67 | config->setGroup( "Appearance" ); | 67 | config->setGroup( "Appearance" ); |
68 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); | 68 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); |
69 | delete config; | 69 | delete config; |
70 | 70 | ||
71 | config = new Config("multikey"); | 71 | config = new Config("multikey"); |
72 | config->setGroup ("general"); | 72 | config->setGroup ("general"); |
73 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed | 73 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed |
74 | useRepeat = config->readBoolEntry ("useRepeat", 1); | 74 | useRepeat = config->readBoolEntry ("useRepeat", 1); |
75 | delete config; | 75 | delete config; |
76 | 76 | ||
77 | 77 | ||
78 | setFont( QFont( familyStr, 10 ) ); | 78 | setFont( QFont( familyStr, 10 ) ); |
79 | 79 | ||
80 | picks = new KeyboardPicks( this ); | 80 | picks = new KeyboardPicks( this ); |
81 | picks->setFont( QFont( familyStr, 10 ) ); | 81 | picks->setFont( QFont( familyStr, 10 ) ); |
82 | picks->initialise(); | 82 | picks->initialise(); |
83 | if (usePicks) { | 83 | if (usePicks) { |
84 | 84 | ||
85 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 85 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
86 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 86 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
87 | 87 | ||
88 | } else picks->hide(); | 88 | } else picks->hide(); |
89 | 89 | ||
90 | loadKeyboardColors(); | 90 | loadKeyboardColors(); |
91 | 91 | ||
92 | keys = new Keys(); | 92 | keys = new Keys(); |
93 | 93 | ||
94 | repeatTimer = new QTimer( this ); | 94 | repeatTimer = new QTimer( this ); |
95 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 95 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
96 | 96 | ||
97 | QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this); | 97 | QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this); |
98 | connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 98 | connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
99 | this, SLOT(receive(const QCString&,const QByteArray&))); | 99 | this, SLOT(receive(const QCString&,const QByteArray&))); |
100 | } | 100 | } |
101 | 101 | ||
102 | Keyboard::~Keyboard() { | 102 | Keyboard::~Keyboard() { |
103 | 103 | ||
104 | if ( configdlg ) { | 104 | if ( configdlg ) { |
105 | delete configdlg; | 105 | delete configdlg; |
106 | configdlg = 0; | 106 | configdlg = 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | /* Keyboard::resizeEvent {{{1 */ | 111 | /* Keyboard::resizeEvent {{{1 */ |
112 | void Keyboard::resizeEvent(QResizeEvent*) | 112 | void Keyboard::resizeEvent(QResizeEvent*) |
113 | { | 113 | { |
114 | int ph = picks->sizeHint().height(); | 114 | int ph = picks->sizeHint().height(); |
115 | picks->setGeometry( 0, 0, width(), ph ); | 115 | picks->setGeometry( 0, 0, width(), ph ); |
116 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); | 116 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); |
117 | 117 | ||
118 | int nk; // number of keys? | 118 | int nk; // number of keys? |
119 | if ( useLargeKeys ) { | 119 | if ( useLargeKeys ) { |
120 | nk = 15; | 120 | nk = 15; |
121 | } else { | 121 | } else { |
122 | nk = 19; | 122 | nk = 19; |
123 | } | 123 | } |
124 | defaultKeyWidth = (width()/nk)/2; | 124 | defaultKeyWidth = (width()/nk)/2; |
125 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 125 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
126 | 126 | ||
127 | } | 127 | } |
128 | 128 | ||
129 | /* KeyboardPicks::initialize {{{1 */ | 129 | /* KeyboardPicks::initialize {{{1 */ |
130 | void KeyboardPicks::initialise() | 130 | void KeyboardPicks::initialise() |
131 | { | 131 | { |
132 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 132 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
133 | mode = 0; | 133 | mode = 0; |
134 | dc = new KeyboardConfig(this); | 134 | dc = new KeyboardConfig(this); |
135 | configs.append(dc); | 135 | configs.append(dc); |
136 | } | 136 | } |
137 | 137 | ||
138 | /* KeyboardPicks::sizeHint {{{1 */ | 138 | /* KeyboardPicks::sizeHint {{{1 */ |
139 | QSize KeyboardPicks::sizeHint() const | 139 | QSize KeyboardPicks::sizeHint() const |
140 | { | 140 | { |
141 | return QSize(240,fontMetrics().lineSpacing()); | 141 | return QSize(240,fontMetrics().lineSpacing()); |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | /* KeyboardConfig::generateText {{{1 */ | 145 | /* KeyboardConfig::generateText {{{1 */ |
146 | void KeyboardConfig::generateText(const QString &s) | 146 | void KeyboardConfig::generateText(const QString &s) |
147 | { | 147 | { |
148 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 148 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
149 | for (int i=0; i<(int)backspaces; i++) { | 149 | for (int i=0; i<(int)backspaces; i++) { |
150 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 150 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false ); |
151 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 151 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false ); |
152 | } | 152 | } |
153 | for (int i=0; i<(int)s.length(); i++) { | 153 | for (int i=0; i<(int)s.length(); i++) { |
154 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 154 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
155 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 155 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
156 | } | 156 | } |
157 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 157 | parent->emitKey( 0, ::Qt::Key_Space, 0, true, false ); |
158 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 158 | parent->emitKey( 0, ::Qt::Key_Space, 0, false, false ); |
159 | backspaces = 0; | 159 | backspaces = 0; |
160 | #endif | 160 | #endif |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | 165 | ||
166 | /* Keyboard::paintEvent {{{1 */ | 166 | /* Keyboard::paintEvent {{{1 */ |
167 | void Keyboard::paintEvent(QPaintEvent* e) | 167 | void Keyboard::paintEvent(QPaintEvent* e) |
168 | { | 168 | { |
169 | QPainter painter(this); | 169 | QPainter painter(this); |
170 | painter.setClipRect(e->rect()); | 170 | painter.setClipRect(e->rect()); |
171 | drawKeyboard( painter ); | 171 | drawKeyboard( painter ); |
172 | picks->dc->draw( &painter ); | 172 | picks->dc->draw( &painter ); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | /* Keyboard::drawKeyboard {{{1 */ | 176 | /* Keyboard::drawKeyboard {{{1 */ |
177 | 177 | ||
178 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 178 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
179 | { | 179 | { |
180 | 180 | ||
181 | 181 | ||
182 | if (row != -1 && col != -1) { //just redraw one key | 182 | if (row != -1 && col != -1) { //just redraw one key |
183 | 183 | ||
184 | int x = 0; | 184 | int x = 0; |
185 | for (int i = 0; i < col; i++) { | 185 | for (int i = 0; i < col; i++) { |
186 | 186 | ||
187 | x += keys->width(row, i) * defaultKeyWidth; | 187 | x += keys->width(row, i) * defaultKeyWidth; |
188 | } | 188 | } |
189 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 189 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
190 | 190 | ||
191 | int keyWidth = keys->width(row, col); | 191 | int keyWidth = keys->width(row, col); |
192 | 192 | ||
193 | p.fillRect(x + 1, y + 1, | 193 | p.fillRect(x + 1, y + 1, |
194 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 194 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
195 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 195 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
196 | 196 | ||
197 | QImage *pix = keys->pix(row,col); | 197 | QImage *pix = keys->pix(row,col); |
198 | 198 | ||
199 | ushort c = keys->uni(row, col); | 199 | ushort c = keys->uni(row, col); |
200 | 200 | ||
201 | p.setPen(textcolor); | 201 | p.setPen(textcolor); |
202 | if (!pix) { | 202 | if (!pix) { |
203 | if ((shift || lock) && keys->shift(c)) | 203 | if ((shift || lock) && keys->shift(c)) |
204 | 204 | ||
205 | if (circumflex && keys->circumflex(keys->shift(c))) | 205 | if (circumflex && keys->circumflex(keys->shift(c))) |
206 | c = keys->circumflex(keys->shift(c)); | 206 | c = keys->circumflex(keys->shift(c)); |
207 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 207 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
208 | c = keys->diaeresis(keys->shift(c)); | 208 | c = keys->diaeresis(keys->shift(c)); |
209 | else if (baccent && keys->baccent(keys->shift(c))) | 209 | else if (baccent && keys->baccent(keys->shift(c))) |
210 | c = keys->baccent(keys->shift(c)); | 210 | c = keys->baccent(keys->shift(c)); |
211 | else if (accent && keys->accent(keys->shift(c))) | 211 | else if (accent && keys->accent(keys->shift(c))) |
212 | c = keys->accent(keys->shift(c)); | 212 | c = keys->accent(keys->shift(c)); |
213 | else if (meta && keys->meta(keys->shift(c))) | 213 | else if (meta && keys->meta(keys->shift(c))) |
214 | c = keys->meta(keys->shift(c)); | 214 | c = keys->meta(keys->shift(c)); |
215 | else | 215 | else |
216 | c = keys->shift(c); | 216 | c = keys->shift(c); |
217 | 217 | ||
218 | else if (meta && keys->meta(c)) | 218 | else if (meta && keys->meta(c)) |
219 | c = keys->meta(c); | 219 | c = keys->meta(c); |
220 | else if (circumflex && keys->circumflex(c)) | 220 | else if (circumflex && keys->circumflex(c)) |
221 | c = keys->circumflex(c); | 221 | c = keys->circumflex(c); |
222 | else if (baccent && keys->baccent(c)) | 222 | else if (baccent && keys->baccent(c)) |
223 | c = keys->baccent(c); | 223 | c = keys->baccent(c); |
224 | else if (accent && keys->accent(c)) | 224 | else if (accent && keys->accent(c)) |
225 | c = keys->accent(c); | 225 | c = keys->accent(c); |
226 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 226 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
227 | 227 | ||
228 | // the diaeresis key itself has to be in the diaeresisMap, | 228 | // the diaeresis key itself has to be in the diaeresisMap, |
229 | // or just do this to make it display the diaeresis char. | 229 | // or just do this to make it display the diaeresis char. |
230 | 230 | ||
231 | if (c == 0x2c6) | 231 | if (c == 0x2c6) |
232 | c = 0xa8; | 232 | c = 0xa8; |
233 | else | 233 | else |
234 | c = keys->diaeresis(c); | 234 | c = keys->diaeresis(c); |
235 | } | 235 | } |
236 | 236 | ||
237 | p.drawText(x, y, | 237 | p.drawText(x, y, |
238 | defaultKeyWidth * keyWidth + 3, keyHeight, | 238 | defaultKeyWidth * keyWidth + 3, keyHeight, |
239 | AlignCenter, (QChar)c); | 239 | AlignCenter, (QChar)c); |
240 | } | 240 | } |
241 | else | 241 | else |
242 | // center the image in the middle of the key | 242 | // center the image in the middle of the key |
243 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, | 243 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, |
244 | y + (keyHeight - pix->height())/2 + 1, | 244 | y + (keyHeight - pix->height())/2 + 1, |
245 | *pix ); | 245 | *pix ); |
246 | 246 | ||
247 | // this fixes the problem that the very right end of the board's vertical line | 247 | // this fixes the problem that the very right end of the board's vertical line |
248 | // gets painted over, because it's one pixel shorter than all other keys | 248 | // gets painted over, because it's one pixel shorter than all other keys |
249 | p.setPen(keycolor_lines); | 249 | p.setPen(keycolor_lines); |
250 | p.drawLine(width() - 1, 0, width() - 1, height()); | 250 | p.drawLine(width() - 1, 0, width() - 1, height()); |
251 | 251 | ||
252 | } else { | 252 | } else { |
253 | 253 | ||
254 | 254 | ||
255 | p.fillRect(0, 0, width(), height(), keycolor); | 255 | p.fillRect(0, 0, width(), height(), keycolor); |
256 | 256 | ||
257 | for (row = 1; row <= keys->rows(); row++) { | 257 | for (row = 1; row <= keys->rows(); row++) { |
258 | 258 | ||
259 | int x = 0; | 259 | int x = 0; |
260 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 260 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
261 | 261 | ||
262 | p.setPen(keycolor_lines); | 262 | p.setPen(keycolor_lines); |
263 | p.drawLine(x, y, x + width(), y); | 263 | p.drawLine(x, y, x + width(), y); |
264 | 264 | ||
265 | for (int col = 0; col < keys->numKeys(row); col++) { | 265 | for (int col = 0; col < keys->numKeys(row); col++) { |
266 | 266 | ||
267 | QImage *pix = keys->pix(row, col); | 267 | QImage *pix = keys->pix(row, col); |
268 | int keyWidth = keys->width(row, col); | 268 | int keyWidth = keys->width(row, col); |
269 | 269 | ||
270 | 270 | ||
271 | int keyWidthPix = defaultKeyWidth * keyWidth; | 271 | int keyWidthPix = defaultKeyWidth * keyWidth; |
272 | 272 | ||
273 | if (keys->pressed(row, col)) | 273 | if (keys->pressed(row, col)) |
274 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 274 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
275 | keyHeight - 1, keycolor_pressed); | 275 | keyHeight - 1, keycolor_pressed); |
276 | 276 | ||
277 | ushort c = keys->uni(row, col); | 277 | ushort c = keys->uni(row, col); |
278 | 278 | ||
279 | p.setPen(textcolor); | 279 | p.setPen(textcolor); |
280 | if (!pix) { | 280 | if (!pix) { |
281 | if ((shift || lock) && keys->shift(c)) | 281 | if ((shift || lock) && keys->shift(c)) |
282 | 282 | ||
283 | if (circumflex && keys->circumflex(keys->shift(c))) | 283 | if (circumflex && keys->circumflex(keys->shift(c))) |
284 | c = keys->circumflex(keys->shift(c)); | 284 | c = keys->circumflex(keys->shift(c)); |
285 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 285 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
286 | c = keys->diaeresis(keys->shift(c)); | 286 | c = keys->diaeresis(keys->shift(c)); |
287 | else if (baccent && keys->baccent(keys->shift(c))) | 287 | else if (baccent && keys->baccent(keys->shift(c))) |
288 | c = keys->baccent(keys->shift(c)); | 288 | c = keys->baccent(keys->shift(c)); |
289 | else if (accent && keys->accent(keys->shift(c))) | 289 | else if (accent && keys->accent(keys->shift(c))) |
290 | c = keys->accent(keys->shift(c)); | 290 | c = keys->accent(keys->shift(c)); |
291 | else if (meta && keys->meta(keys->shift(c))) | 291 | else if (meta && keys->meta(keys->shift(c))) |
292 | c = keys->meta(keys->shift(c)); | 292 | c = keys->meta(keys->shift(c)); |
293 | else | 293 | else |
294 | c = keys->shift(c); | 294 | c = keys->shift(c); |
295 | 295 | ||
296 | else if (meta && keys->meta(c)) | 296 | else if (meta && keys->meta(c)) |
297 | c = keys->meta(c); | 297 | c = keys->meta(c); |
298 | else if (circumflex && keys->circumflex(c)) | 298 | else if (circumflex && keys->circumflex(c)) |
299 | c = keys->circumflex(c); | 299 | c = keys->circumflex(c); |
300 | else if (baccent && keys->baccent(c)) | 300 | else if (baccent && keys->baccent(c)) |
301 | c = keys->baccent(c); | 301 | c = keys->baccent(c); |
302 | else if (accent && keys->accent(c)) | 302 | else if (accent && keys->accent(c)) |
303 | c = keys->accent(c); | 303 | c = keys->accent(c); |
304 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 304 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
305 | 305 | ||
306 | if (c == 0x2c6) | 306 | if (c == 0x2c6) |
307 | c = 0xa8; | 307 | c = 0xa8; |
308 | else | 308 | else |
309 | c = keys->diaeresis(c); | 309 | c = keys->diaeresis(c); |
310 | } | 310 | } |
311 | 311 | ||
312 | p.drawText(x, y, | 312 | p.drawText(x, y, |
313 | keyWidthPix + 3, keyHeight, | 313 | keyWidthPix + 3, keyHeight, |
314 | AlignCenter, (QChar)c); | 314 | AlignCenter, (QChar)c); |
315 | } | 315 | } |
316 | else { | 316 | else { |
317 | // center the image in the middle of the key | 317 | // center the image in the middle of the key |
318 | pix->setColor(1, textcolor.rgb()); | 318 | pix->setColor(1, textcolor.rgb()); |
319 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, | 319 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, |
320 | y + (keyHeight - pix->height())/2 + 1, | 320 | y + (keyHeight - pix->height())/2 + 1, |
321 | QImage(*pix) ); | 321 | QImage(*pix) ); |
322 | } | 322 | } |
323 | 323 | ||
324 | p.setPen(keycolor_lines); | 324 | p.setPen(keycolor_lines); |
325 | p.drawLine(x, y, x, y + keyHeight); | 325 | p.drawLine(x, y, x, y + keyHeight); |
326 | 326 | ||
327 | x += keyWidthPix; | 327 | x += keyWidthPix; |
328 | } | 328 | } |
329 | 329 | ||
330 | 330 | ||
331 | } | 331 | } |
332 | p.setPen(keycolor_lines); | 332 | p.setPen(keycolor_lines); |
333 | p.drawLine(0, height() - 1, width(), height() - 1); | 333 | p.drawLine(0, height() - 1, width(), height() - 1); |
334 | p.drawLine(width() - 1, 0, width() - 1, height()); | 334 | p.drawLine(width() - 1, 0, width() - 1, height()); |
335 | } | 335 | } |
336 | 336 | ||
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | /* Keyboard::mousePressEvent {{{1 */ | 340 | /* Keyboard::mousePressEvent {{{1 */ |
341 | void Keyboard::mousePressEvent(QMouseEvent *e) | 341 | void Keyboard::mousePressEvent(QMouseEvent *e) |
342 | { | 342 | { |
343 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 343 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
344 | if (row > 5) row = 5; | 344 | if (row > 5) row = 5; |
345 | 345 | ||
346 | // figure out the column | 346 | // figure out the column |
347 | int col = 0; | 347 | int col = 0; |
348 | for (int w = 0; e->x() >= w; col++) | 348 | for (int w = 0; e->x() >= w; col++) |
349 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 349 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
350 | w += keys->width(row,col) * defaultKeyWidth; | 350 | w += keys->width(row,col) * defaultKeyWidth; |
351 | else break; | 351 | else break; |
352 | 352 | ||
353 | if (col <= 0) return; | 353 | if (col <= 0) return; |
354 | 354 | ||
355 | col --; // rewind one... | 355 | col --; // rewind one... |
356 | 356 | ||
357 | qkeycode = keys->qcode(row, col); | 357 | qkeycode = keys->qcode(row, col); |
358 | unicode = keys->uni(row, col); | 358 | unicode = keys->uni(row, col); |
359 | 359 | ||
360 | // might need to repaint if two or more of the same keys. | 360 | // might need to repaint if two or more of the same keys. |
361 | // should be faster if just paint one key even though multiple keys exist. | 361 | // should be faster if just paint one key even though multiple keys exist. |
362 | bool need_repaint = FALSE; | 362 | bool need_repaint = FALSE; |
363 | 363 | ||
364 | // circumflex and diaeresis support | 364 | // circumflex and diaeresis support |
365 | // messy to have this here, but too hard to implement any other method | 365 | // messy to have this here, but too hard to implement any other method |
366 | if (unicode == 0x2c6) { | 366 | if (unicode == 0x2c6) { |
367 | 367 | ||
368 | unicode = 0; | 368 | unicode = 0; |
369 | if (shift || lock) { | 369 | if (shift || lock) { |
370 | 370 | ||
371 | // diaeresis | 371 | // diaeresis |
372 | qkeycode = 0x2001; | 372 | qkeycode = 0x2001; |
373 | } | 373 | } |
374 | else { | 374 | else { |
375 | 375 | ||
376 | // circumflex | 376 | // circumflex |
377 | qkeycode = 0x2000; | 377 | qkeycode = 0x2000; |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | // Back accent character support | 381 | // Back accent character support |
382 | 382 | ||
383 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one | 383 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one |
384 | if (unicode == 0x2cb) { | 384 | if (unicode == 0x2cb) { |
385 | 385 | ||
386 | unicode = 0; | 386 | unicode = 0; |
387 | if (shift || lock) { | 387 | if (shift || lock) { |
388 | 388 | ||
389 | // circumblex | 389 | // circumblex |
390 | qkeycode = 0x2000; | 390 | qkeycode = 0x2000; |
391 | } | 391 | } |
392 | else { | 392 | else { |
393 | 393 | ||
394 | // back accent | 394 | // back accent |
395 | qkeycode = 0x2002; | 395 | qkeycode = 0x2002; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | // Accent character support | 399 | // Accent character support |
400 | 400 | ||
401 | if (unicode == 0x2ca) { | 401 | if (unicode == 0x2ca) { |
402 | 402 | ||
403 | unicode = 0; | 403 | unicode = 0; |
404 | if (shift || lock) { | 404 | if (shift || lock) { |
405 | 405 | ||
406 | // diaeresis | 406 | // diaeresis |
407 | qkeycode = 0x2001; | 407 | qkeycode = 0x2001; |
408 | } | 408 | } |
409 | else { | 409 | else { |
410 | 410 | ||
411 | // accent | 411 | // accent |
412 | qkeycode = 0x2003; | 412 | qkeycode = 0x2003; |
413 | } | 413 | } |
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | if (unicode == 0) { // either Qt char, or nothing | 417 | if (unicode == 0) { // either Qt char, or nothing |
418 | 418 | ||
419 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 419 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
420 | 420 | ||
421 | if ( configdlg ) { | 421 | if ( configdlg ) { |
422 | 422 | ||
423 | delete configdlg; | 423 | delete configdlg; |
424 | configdlg = 0; | 424 | configdlg = 0; |
425 | } | 425 | } |
426 | else { | 426 | else { |
427 | configdlg = new ConfigDlg (); | 427 | configdlg = new ConfigDlg (); |
428 | connect(configdlg, SIGNAL(setMapToDefault()), | 428 | connect(configdlg, SIGNAL(setMapToDefault()), |
429 | this, SLOT(setMapToDefault())); | 429 | this, SLOT(setMapToDefault())); |
430 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 430 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
431 | this, SLOT(setMapToFile(QString))); | 431 | this, SLOT(setMapToFile(QString))); |
432 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 432 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
433 | this, SLOT(togglePickboard(bool))); | 433 | this, SLOT(togglePickboard(bool))); |
434 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 434 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
435 | this, SLOT(toggleRepeat(bool))); | 435 | this, SLOT(toggleRepeat(bool))); |
436 | connect(configdlg, SIGNAL(reloadKeyboard()), | 436 | connect(configdlg, SIGNAL(reloadKeyboard()), |
437 | this, SLOT(reloadKeyboard())); | 437 | this, SLOT(reloadKeyboard())); |
438 | connect(configdlg, SIGNAL(configDlgClosed()), | 438 | connect(configdlg, SIGNAL(configDlgClosed()), |
439 | this, SLOT(cleanupConfigDlg())); | 439 | this, SLOT(cleanupConfigDlg())); |
440 | connect(configdlg, SIGNAL(reloadSw()), | 440 | connect(configdlg, SIGNAL(reloadSw()), |
441 | this, SLOT(reloadSw())); | 441 | this, SLOT(reloadSw())); |
442 | configdlg->showMaximized(); | 442 | configdlg->showMaximized(); |
443 | configdlg->show(); | 443 | configdlg->show(); |
444 | configdlg->raise(); | 444 | configdlg->raise(); |
445 | } | 445 | } |
446 | 446 | ||
447 | } else if (qkeycode == Qt::Key_Control) { | 447 | } else if (qkeycode == Qt::Key_Control) { |
448 | need_repaint = TRUE; | 448 | need_repaint = TRUE; |
449 | 449 | ||
450 | if (ctrl) { | 450 | if (ctrl) { |
451 | 451 | ||
452 | *ctrl = 0; | 452 | *ctrl = 0; |
453 | ctrl = 0; | 453 | ctrl = 0; |
454 | 454 | ||
455 | } else { | 455 | } else { |
456 | 456 | ||
457 | ctrl = keys->pressedPtr(row, col); | 457 | ctrl = keys->pressedPtr(row, col); |
458 | need_repaint = TRUE; | 458 | need_repaint = TRUE; |
459 | *ctrl = !keys->pressed(row, col); | 459 | *ctrl = !keys->pressed(row, col); |
460 | 460 | ||
461 | } | 461 | } |
462 | 462 | ||
463 | } else if (qkeycode == Qt::Key_Alt) { | 463 | } else if (qkeycode == Qt::Key_Alt) { |
464 | need_repaint = TRUE; | 464 | need_repaint = TRUE; |
465 | 465 | ||
466 | if (alt) { | 466 | if (alt) { |
467 | *alt = 0; | 467 | *alt = 0; |
468 | alt = 0; | 468 | alt = 0; |
469 | 469 | ||
470 | } else { | 470 | } else { |
471 | 471 | ||
472 | alt = keys->pressedPtr(row, col); | 472 | alt = keys->pressedPtr(row, col); |
473 | need_repaint = TRUE; | 473 | need_repaint = TRUE; |
474 | *alt = !keys->pressed(row, col); | 474 | *alt = !keys->pressed(row, col); |
475 | } | 475 | } |
476 | 476 | ||
477 | } else if (qkeycode == Qt::Key_Shift) { | 477 | } else if (qkeycode == Qt::Key_Shift) { |
478 | need_repaint = TRUE; | 478 | need_repaint = TRUE; |
479 | 479 | ||
480 | if (shift) { | 480 | if (shift) { |
481 | *shift = 0; | 481 | *shift = 0; |
482 | shift = 0; | 482 | shift = 0; |
483 | } | 483 | } |
484 | else { | 484 | else { |
485 | shift = keys->pressedPtr(row, col); | 485 | shift = keys->pressedPtr(row, col); |
486 | *shift = 1; | 486 | *shift = 1; |
487 | if (lock) { | 487 | if (lock) { |
488 | *lock = 0; | 488 | *lock = 0; |
489 | lock = 0; | 489 | lock = 0; |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | 493 | ||
494 | /* | 494 | /* |
495 | * want to be able to hit circumflex/diaeresis -> shift | 495 | * want to be able to hit circumflex/diaeresis -> shift |
496 | * to type in shifted circumflex/diaeresis chars. | 496 | * to type in shifted circumflex/diaeresis chars. |
497 | * same thing with meta | 497 | * same thing with meta |
498 | 498 | ||
499 | if (meta) { *meta = 0; meta = 0; } | 499 | if (meta) { *meta = 0; meta = 0; } |
500 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 500 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
501 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 501 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
502 | 502 | ||
503 | */ | 503 | */ |
504 | 504 | ||
505 | } else if (qkeycode == Qt::Key_CapsLock) { | 505 | } else if (qkeycode == Qt::Key_CapsLock) { |
506 | need_repaint = TRUE; | 506 | need_repaint = TRUE; |
507 | 507 | ||
508 | if (lock) { | 508 | if (lock) { |
509 | *lock = 0; | 509 | *lock = 0; |
510 | lock = 0; | 510 | lock = 0; |
511 | } | 511 | } |
512 | else { | 512 | else { |
513 | lock = keys->pressedPtr(row, col);; | 513 | lock = keys->pressedPtr(row, col);; |
514 | *lock = true;; | 514 | *lock = true;; |
515 | if (shift) { | 515 | if (shift) { |
516 | *shift = 0; | 516 | *shift = 0; |
517 | shift = 0; | 517 | shift = 0; |
518 | } | 518 | } |
519 | } | 519 | } |
520 | 520 | ||
521 | /* | 521 | /* |
522 | if (meta) { *meta = 0; meta = 0; } | 522 | if (meta) { *meta = 0; meta = 0; } |
523 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 523 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
524 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 524 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
525 | */ | 525 | */ |
526 | 526 | ||
527 | } else if (qkeycode == Qt::Key_Meta) { | 527 | } else if (qkeycode == Qt::Key_Meta) { |
528 | need_repaint = TRUE; | 528 | need_repaint = TRUE; |
529 | 529 | ||
530 | if (meta) { | 530 | if (meta) { |
531 | *meta = 0; | 531 | *meta = 0; |
532 | meta = 0; | 532 | meta = 0; |
533 | 533 | ||
534 | } else { | 534 | } else { |
535 | 535 | ||
536 | meta = keys->pressedPtr(row, col); | 536 | meta = keys->pressedPtr(row, col); |
537 | *meta = true; | 537 | *meta = true; |
538 | } | 538 | } |
539 | 539 | ||
540 | // reset all the other keys | 540 | // reset all the other keys |
541 | if (shift) { *shift = 0; shift = 0; } | 541 | if (shift) { *shift = 0; shift = 0; } |
542 | if (lock) { *lock = 0; lock = 0; } | 542 | if (lock) { *lock = 0; lock = 0; } |
543 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 543 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
544 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 544 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
545 | if (baccent) { *baccent = 0; baccent = 0; } | 545 | if (baccent) { *baccent = 0; baccent = 0; } |
546 | if (accent) { *accent = 0; accent = 0; } | 546 | if (accent) { *accent = 0; accent = 0; } |
547 | 547 | ||
548 | // dont need to emit this key... acts same as alt | 548 | // dont need to emit this key... acts same as alt |
549 | qkeycode = 0; | 549 | qkeycode = 0; |
550 | 550 | ||
551 | // circumflex | 551 | // circumflex |
552 | } else if (qkeycode == 0x2000) { | 552 | } else if (qkeycode == 0x2000) { |
553 | need_repaint = TRUE; | 553 | need_repaint = TRUE; |
554 | 554 | ||
555 | if (circumflex) { | 555 | if (circumflex) { |
556 | 556 | ||
557 | *circumflex = 0; | 557 | *circumflex = 0; |
558 | circumflex = 0; | 558 | circumflex = 0; |
559 | 559 | ||
560 | } else { | 560 | } else { |
561 | 561 | ||
562 | circumflex = keys->pressedPtr(row, col); | 562 | circumflex = keys->pressedPtr(row, col); |
563 | *circumflex = true; | 563 | *circumflex = true; |
564 | } | 564 | } |
565 | 565 | ||
566 | /* no need to turn off shift or lock if circumflex | 566 | /* no need to turn off shift or lock if circumflex |
567 | * keys are pressed | 567 | * keys are pressed |
568 | 568 | ||
569 | if (shift) { *shift = 0; shift = 0; } | 569 | if (shift) { *shift = 0; shift = 0; } |
570 | if (lock) { *lock = 0; lock = 0; } | 570 | if (lock) { *lock = 0; lock = 0; } |
571 | 571 | ||
572 | */ | 572 | */ |
573 | 573 | ||
574 | // have to reset all the other keys | 574 | // have to reset all the other keys |
575 | if (meta) { *meta = 0; meta = 0; } | 575 | if (meta) { *meta = 0; meta = 0; } |
576 | if (diaeresis) { | 576 | if (diaeresis) { |
577 | 577 | ||
578 | // *diaeresis and *circumflex point to the same thing | 578 | // *diaeresis and *circumflex point to the same thing |
579 | // when diaeresis is enabled and you hit the circumflex | 579 | // when diaeresis is enabled and you hit the circumflex |
580 | // since they are the same key, it should turn off the | 580 | // since they are the same key, it should turn off the |
581 | // key | 581 | // key |
582 | 582 | ||
583 | *diaeresis = 0; | 583 | *diaeresis = 0; |
584 | diaeresis = 0; | 584 | diaeresis = 0; |
585 | circumflex = 0; | 585 | circumflex = 0; |
586 | } | 586 | } |
587 | 587 | ||
588 | qkeycode = 0; | 588 | qkeycode = 0; |
589 | 589 | ||
590 | // diaeresis | 590 | // diaeresis |
591 | } else if (qkeycode == 0x2001) { | 591 | } else if (qkeycode == 0x2001) { |
592 | need_repaint = TRUE; | 592 | need_repaint = TRUE; |
593 | 593 | ||
594 | if (diaeresis) { | 594 | if (diaeresis) { |
595 | 595 | ||
596 | *diaeresis = 0; | 596 | *diaeresis = 0; |
597 | diaeresis = 0; | 597 | diaeresis = 0; |
598 | 598 | ||
599 | } else { | 599 | } else { |
600 | 600 | ||
601 | diaeresis = keys->pressedPtr(row, col); | 601 | diaeresis = keys->pressedPtr(row, col); |
602 | *diaeresis = true; | 602 | *diaeresis = true; |
603 | } | 603 | } |
604 | 604 | ||
605 | 605 | ||
606 | if (shift) { *shift = 0; shift = 0; } | 606 | if (shift) { *shift = 0; shift = 0; } |
607 | 607 | ||
608 | /* | 608 | /* |
609 | * | 609 | * |
610 | if (lock) { *lock = 0; lock = 0; } | 610 | if (lock) { *lock = 0; lock = 0; } |
611 | * | 611 | * |
612 | */ | 612 | */ |
613 | 613 | ||
614 | if (meta) { *meta = 0; meta = 0; } | 614 | if (meta) { *meta = 0; meta = 0; } |
615 | if (circumflex) { | 615 | if (circumflex) { |
616 | 616 | ||
617 | // *circumflex = 0; | 617 | // *circumflex = 0; |
618 | // | 618 | // |
619 | // same thing the diaeresis pointer points too | 619 | // same thing the diaeresis pointer points too |
620 | 620 | ||
621 | circumflex = 0; | 621 | circumflex = 0; |
622 | } | 622 | } |
623 | 623 | ||
624 | 624 | ||
625 | qkeycode = 0; | 625 | qkeycode = 0; |
626 | 626 | ||
627 | // Back accent | 627 | // Back accent |
628 | } else if (qkeycode == 0x2002) { | 628 | } else if (qkeycode == 0x2002) { |
629 | need_repaint = TRUE; | 629 | need_repaint = TRUE; |
630 | 630 | ||
631 | if (baccent) { | 631 | if (baccent) { |
632 | 632 | ||
633 | *baccent = 0; | 633 | *baccent = 0; |
634 | baccent = 0; | 634 | baccent = 0; |
635 | 635 | ||
636 | } else { | 636 | } else { |
637 | 637 | ||
638 | baccent = keys->pressedPtr(row, col); | 638 | baccent = keys->pressedPtr(row, col); |
639 | *baccent = true; | 639 | *baccent = true; |
640 | } | 640 | } |
641 | 641 | ||
642 | 642 | ||
643 | if (shift) { *shift = 0; shift = 0; } | 643 | if (shift) { *shift = 0; shift = 0; } |
644 | if (meta) { *meta = 0; meta = 0; } | 644 | if (meta) { *meta = 0; meta = 0; } |
645 | if (accent) { *accent = 0; accent = 0; } | 645 | if (accent) { *accent = 0; accent = 0; } |
646 | 646 | ||
647 | qkeycode = 0; | 647 | qkeycode = 0; |
648 | 648 | ||
649 | // Accent | 649 | // Accent |
650 | } else if (qkeycode == 0x2003) { | 650 | } else if (qkeycode == 0x2003) { |
651 | need_repaint = TRUE; | 651 | need_repaint = TRUE; |
652 | 652 | ||
653 | if (accent) { | 653 | if (accent) { |
654 | 654 | ||
655 | *accent = 0; | 655 | *accent = 0; |
656 | accent = 0; | 656 | accent = 0; |
657 | 657 | ||
658 | } else { | 658 | } else { |
659 | 659 | ||
660 | accent = keys->pressedPtr(row, col); | 660 | accent = keys->pressedPtr(row, col); |
661 | *accent = true; | 661 | *accent = true; |
662 | } | 662 | } |
663 | 663 | ||
664 | 664 | ||
665 | if (shift) { *shift = 0; shift = 0; } | 665 | if (shift) { *shift = 0; shift = 0; } |
666 | if (meta) { *meta = 0; meta = 0; } | 666 | if (meta) { *meta = 0; meta = 0; } |
667 | if (baccent) { *baccent = 0; } | 667 | if (baccent) { *baccent = 0; } |
668 | 668 | ||
669 | qkeycode = 0; | 669 | qkeycode = 0; |
670 | } | 670 | } |
671 | 671 | ||
672 | } | 672 | } |
673 | else { // normal char | 673 | else { // normal char |
674 | if ((shift || lock) && keys->shift(unicode)) { | 674 | if ((shift || lock) && keys->shift(unicode)) { |
675 | 675 | ||
676 | // make diaeresis/circumflex -> shift input shifted | 676 | // make diaeresis/circumflex -> shift input shifted |
677 | // diaeresis/circumflex chars | 677 | // diaeresis/circumflex chars |
678 | 678 | ||
679 | if (circumflex && keys->circumflex(keys->shift(unicode))) | 679 | if (circumflex && keys->circumflex(keys->shift(unicode))) |
680 | unicode = keys->circumflex(keys->shift(unicode)); | 680 | unicode = keys->circumflex(keys->shift(unicode)); |
681 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) | 681 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) |
682 | unicode = keys->diaeresis(keys->shift(unicode)); | 682 | unicode = keys->diaeresis(keys->shift(unicode)); |
683 | else if (baccent && keys->baccent(keys->shift(unicode))) | 683 | else if (baccent && keys->baccent(keys->shift(unicode))) |
684 | unicode = keys->baccent(keys->shift(unicode)); | 684 | unicode = keys->baccent(keys->shift(unicode)); |
685 | else if (accent && keys->accent(keys->shift(unicode))) | 685 | else if (accent && keys->accent(keys->shift(unicode))) |
686 | unicode = keys->accent(keys->shift(unicode)); | 686 | unicode = keys->accent(keys->shift(unicode)); |
687 | else if (meta && keys->meta(keys->shift(unicode))) | 687 | else if (meta && keys->meta(keys->shift(unicode))) |
688 | unicode = keys->meta(keys->shift(unicode)); | 688 | unicode = keys->meta(keys->shift(unicode)); |
689 | else | 689 | else |
690 | unicode = keys->shift(unicode); | 690 | unicode = keys->shift(unicode); |
691 | } | 691 | } |
692 | else if (meta && keys->meta(unicode)) { | 692 | else if (meta && keys->meta(unicode)) { |
693 | unicode = keys->meta(unicode); | 693 | unicode = keys->meta(unicode); |
694 | } | 694 | } |
695 | else if (circumflex && keys->circumflex(unicode)) { | 695 | else if (circumflex && keys->circumflex(unicode)) { |
696 | unicode = keys->circumflex(unicode); | 696 | unicode = keys->circumflex(unicode); |
697 | } | 697 | } |
698 | else if (diaeresis && keys->diaeresis(unicode)) { | 698 | else if (diaeresis && keys->diaeresis(unicode)) { |
699 | 699 | ||
700 | unicode = keys->diaeresis(unicode); | 700 | unicode = keys->diaeresis(unicode); |
701 | } | 701 | } |
702 | else if (baccent && keys->baccent(unicode)) { | 702 | else if (baccent && keys->baccent(unicode)) { |
703 | unicode = keys->baccent(unicode); | 703 | unicode = keys->baccent(unicode); |
704 | } | 704 | } |
705 | else if (accent && keys->accent(unicode)) { | 705 | else if (accent && keys->accent(unicode)) { |
706 | unicode = keys->accent(unicode); | 706 | unicode = keys->accent(unicode); |
707 | } | 707 | } |
708 | } | 708 | } |
709 | 709 | ||
710 | // korean parsing | 710 | // korean parsing |
711 | if (keys->lang == "ko") { | 711 | if (keys->lang == "ko") { |
712 | 712 | ||
713 | unicode = parseKoreanInput(unicode); | 713 | unicode = parseKoreanInput(unicode); |
714 | } | 714 | } |
715 | 715 | ||
716 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 716 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
717 | 717 | ||
718 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 718 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
719 | 719 | ||
720 | qkeycode = QChar(unicode).upper(); | 720 | qkeycode = QChar(unicode).upper(); |
721 | unicode = qkeycode - '@'; | 721 | unicode = qkeycode - '@'; |
722 | } | 722 | } |
723 | 723 | ||
724 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 724 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
725 | 725 | ||
726 | // pickboard stuff | 726 | // pickboard stuff |
727 | if (usePicks) { | 727 | if (usePicks) { |
728 | 728 | ||
729 | KeyboardConfig *dc = picks->dc; | 729 | KeyboardConfig *dc = picks->dc; |
730 | 730 | ||
731 | if (dc) { | 731 | if (dc) { |
732 | if (qkeycode == Qt::Key_Backspace) { | 732 | if (qkeycode == Qt::Key_Backspace) { |
733 | dc->input.remove(dc->input.last()); // remove last input | 733 | dc->input.remove(dc->input.last()); // remove last input |
734 | dc->decBackspaces(); | 734 | dc->decBackspaces(); |
735 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 735 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
736 | dc->input.clear(); | 736 | dc->input.clear(); |
737 | dc->resetBackspaces(); | 737 | dc->resetBackspaces(); |
738 | } else { | 738 | } else { |
739 | dc->add(QString(QChar(unicode))); | 739 | dc->add(QString(QChar(unicode))); |
740 | dc->incBackspaces(); | 740 | dc->incBackspaces(); |
741 | } | 741 | } |
742 | } | 742 | } |
743 | picks->repaint(); | 743 | picks->repaint(); |
744 | } | 744 | } |
745 | 745 | ||
746 | 746 | ||
747 | // painting | 747 | // painting |
748 | pressed = TRUE; | 748 | pressed = TRUE; |
749 | 749 | ||
750 | pressedKeyRow = row; | 750 | pressedKeyRow = row; |
751 | pressedKeyCol = col; | 751 | pressedKeyCol = col; |
752 | 752 | ||
753 | if (need_repaint) repaint(FALSE); | 753 | if (need_repaint) repaint(FALSE); |
754 | else { // just paint the one key pressed | 754 | else { // just paint the one key pressed |
755 | 755 | ||
756 | 756 | ||
757 | 757 | ||
758 | QPainter p(this); | 758 | QPainter p(this); |
759 | drawKeyboard(p, row, col); | 759 | drawKeyboard(p, row, col); |
760 | 760 | ||
761 | } | 761 | } |
762 | 762 | ||
763 | if (useRepeat) repeatTimer->start( 800 ); | 763 | if (useRepeat) repeatTimer->start( 800 ); |
764 | //pressTid = startTimer(80); | 764 | //pressTid = startTimer(80); |
765 | 765 | ||
766 | } | 766 | } |
767 | 767 | ||
768 | void Keyboard::receive(const QCString &msg, const QByteArray &data) | 768 | void Keyboard::receive(const QCString &msg, const QByteArray &data) |
769 | { | 769 | { |
770 | if (msg == "setmultikey(QString)") { | 770 | if (msg == "setmultikey(QString)") { |
771 | QDataStream stream(data, IO_ReadOnly); | 771 | QDataStream stream(data, IO_ReadOnly); |
772 | QString map; | 772 | QString map; |
773 | stream >> map; | 773 | stream >> map; |
774 | setMapToFile(map); | 774 | setMapToFile(map); |
775 | } else if (msg == "getmultikey()") { | 775 | } else if (msg == "getmultikey()") { |
776 | reloadSw(); | 776 | reloadSw(); |
777 | } | 777 | } |
778 | } | 778 | } |
779 | 779 | ||
780 | /* Keyboard::mouseReleaseEvent {{{1 */ | 780 | /* Keyboard::mouseReleaseEvent {{{1 */ |
781 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 781 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
782 | { | 782 | { |
783 | pressed = FALSE; | 783 | pressed = FALSE; |
784 | //if ( pressTid == 0 ) | 784 | //if ( pressTid == 0 ) |
785 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 785 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
786 | if ( unicode != -1 ) { | 786 | if ( unicode != -1 ) { |
787 | emit key( unicode, qkeycode, modifiers, false, false ); | 787 | emit key( unicode, qkeycode, modifiers, false, false ); |
788 | repeatTimer->stop(); | 788 | repeatTimer->stop(); |
789 | } | 789 | } |
790 | #endif | 790 | #endif |
791 | if (shift && unicode != 0) { | 791 | if (shift && unicode != 0) { |
792 | 792 | ||
793 | 793 | ||
794 | *shift = 0; // unpress shift key | 794 | *shift = 0; // unpress shift key |
795 | shift = 0; // reset the shift pointer | 795 | shift = 0; // reset the shift pointer |
796 | repaint(FALSE); | 796 | repaint(FALSE); |
797 | 797 | ||
798 | } | 798 | } |
799 | if (ctrl && unicode != 0) { | 799 | if (ctrl && unicode != 0) { |
800 | 800 | ||
801 | *ctrl = 0; | 801 | *ctrl = 0; |
802 | ctrl = 0; | 802 | ctrl = 0; |
803 | repaint(FALSE); | 803 | repaint(FALSE); |
804 | 804 | ||
805 | } | 805 | } |
806 | if (alt && alt != 0) { | 806 | if (alt && alt != 0) { |
807 | 807 | ||
808 | *alt = 0; | 808 | *alt = 0; |
809 | alt = 0; | 809 | alt = 0; |
810 | repaint(FALSE); | 810 | repaint(FALSE); |
811 | 811 | ||
812 | } | 812 | } |
813 | 813 | ||
814 | /* | 814 | /* |
815 | * do not make the meta key release after being pressed | 815 | * do not make the meta key release after being pressed |
816 | * | 816 | * |
817 | 817 | ||
818 | else if (meta && unicode != 0) { | 818 | else if (meta && unicode != 0) { |
819 | 819 | ||
820 | *meta = 0; | 820 | *meta = 0; |
821 | meta = 0; | 821 | meta = 0; |
822 | repaint(FALSE); | 822 | repaint(FALSE); |
823 | } | 823 | } |
824 | 824 | ||
825 | */ | 825 | */ |
826 | 826 | ||
827 | else clearHighlight(); | 827 | else clearHighlight(); |
828 | } | 828 | } |
829 | 829 | ||
830 | /* Keyboard::timerEvent {{{1 */ | 830 | /* Keyboard::timerEvent {{{1 */ |
831 | 831 | ||
832 | /* dont know what this does, but i think it is here so that if your screen | 832 | /* dont know what this does, but i think it is here so that if your screen |
833 | * sticks (like on an ipaq) then it will stop repeating if you click another | 833 | * sticks (like on an ipaq) then it will stop repeating if you click another |
834 | * key... but who knows what anything does in this thing anyway? | 834 | * key... but who knows what anything does in this thing anyway? |
835 | 835 | ||
836 | void Keyboard::timerEvent(QTimerEvent* e) | 836 | void Keyboard::timerEvent(QTimerEvent* e) |
837 | { | 837 | { |
838 | if ( e->timerId() == pressTid ) { | 838 | if ( e->timerId() == pressTid ) { |
839 | killTimer(pressTid); | 839 | killTimer(pressTid); |
840 | pressTid = 0; | 840 | pressTid = 0; |
841 | if ( !pressed ) | 841 | if ( !pressed ) |
842 | cout << "calling clearHighlight from timerEvent\n"; | 842 | cout << "calling clearHighlight from timerEvent\n"; |
843 | //clearHighlight(); | 843 | //clearHighlight(); |
844 | } | 844 | } |
845 | } | 845 | } |
846 | */ | 846 | */ |
847 | 847 | ||
848 | void Keyboard::repeat() | 848 | void Keyboard::repeat() |
849 | { | 849 | { |
850 | 850 | ||
851 | repeatTimer->start( 200 ); | 851 | repeatTimer->start( 200 ); |
852 | emit key( unicode, qkeycode, modifiers, true, true ); | 852 | emit key( unicode, qkeycode, modifiers, true, true ); |
853 | } | 853 | } |
854 | 854 | ||
855 | void Keyboard::clearHighlight() | 855 | void Keyboard::clearHighlight() |
856 | { | 856 | { |
857 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 857 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
858 | int tmpRow = pressedKeyRow; | 858 | int tmpRow = pressedKeyRow; |
859 | int tmpCol = pressedKeyCol; | 859 | int tmpCol = pressedKeyCol; |
860 | 860 | ||
861 | pressedKeyRow = -1; | 861 | pressedKeyRow = -1; |
862 | pressedKeyCol = -1; | 862 | pressedKeyCol = -1; |
863 | 863 | ||
864 | QPainter p(this); | 864 | QPainter p(this); |
865 | drawKeyboard(p, tmpRow, tmpCol); | 865 | drawKeyboard(p, tmpRow, tmpCol); |
866 | } | 866 | } |
867 | } | 867 | } |
868 | 868 | ||
869 | 869 | ||
870 | /* Keyboard::sizeHint {{{1 */ | 870 | /* Keyboard::sizeHint {{{1 */ |
871 | QSize Keyboard::sizeHint() const | 871 | QSize Keyboard::sizeHint() const |
872 | { | 872 | { |
873 | QFontMetrics fm=fontMetrics(); | 873 | QFontMetrics fm=fontMetrics(); |
874 | int keyHeight = fm.lineSpacing() + 2; | 874 | int keyHeight = fm.lineSpacing() + 2; |
875 | 875 | ||
876 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); | 876 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); |
877 | } | 877 | } |
878 | 878 | ||
879 | 879 | ||
880 | void Keyboard::resetState() | 880 | void Keyboard::resetState() |
881 | { | 881 | { |
882 | if (shift) { *shift = 0; shift = 0; } | 882 | if (shift) { *shift = 0; shift = 0; } |
883 | if (lock) {*lock = 0; lock = 0; } | 883 | if (lock) {*lock = 0; lock = 0; } |
884 | if (meta) { *meta = 0; meta = 0; } | 884 | if (meta) { *meta = 0; meta = 0; } |
885 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 885 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
886 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 886 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
887 | if (baccent) { *baccent = 0; baccent = 0; } | 887 | if (baccent) { *baccent = 0; baccent = 0; } |
888 | if (accent) { *accent = 0; accent = 0; } | 888 | if (accent) { *accent = 0; accent = 0; } |
889 | 889 | ||
890 | schar = mchar = echar = 0; | 890 | schar = mchar = echar = 0; |
891 | picks->resetState(); | 891 | picks->resetState(); |
892 | } | 892 | } |
893 | 893 | ||
894 | /* Keyboard::togglePickboard {{{1 */ | 894 | /* Keyboard::togglePickboard {{{1 */ |
895 | void Keyboard::togglePickboard(bool on_off) | 895 | void Keyboard::togglePickboard(bool on_off) |
896 | { | 896 | { |
897 | usePicks = on_off; | 897 | usePicks = on_off; |
898 | if (usePicks) { | 898 | if (usePicks) { |
899 | picks->show(); | 899 | picks->show(); |
900 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 900 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
901 | //adjustSize(); | 901 | //adjustSize(); |
902 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 902 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
903 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 903 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
904 | } else { | 904 | } else { |
905 | 905 | ||
906 | picks->hide(); | 906 | picks->hide(); |
907 | picks->resetState(); | 907 | picks->resetState(); |
908 | //move(x(), y() + picks->height()); | 908 | //move(x(), y() + picks->height()); |
909 | //adjustSize(); | 909 | //adjustSize(); |
910 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 910 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
911 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 911 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
912 | 912 | ||
913 | } | 913 | } |
914 | /* | 914 | /* |
915 | * this closes && opens the input method | 915 | * this closes && opens the input method |
916 | */ | 916 | */ |
917 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 917 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
918 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 918 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
919 | } | 919 | } |
920 | 920 | ||
921 | void Keyboard::toggleRepeat(bool on) { | 921 | void Keyboard::toggleRepeat(bool on) { |
922 | 922 | ||
923 | useRepeat = on; | 923 | useRepeat = on; |
924 | //cout << "setting useRepeat to: " << useRepeat << "\n"; | 924 | //cout << "setting useRepeat to: " << useRepeat << "\n"; |
925 | } | 925 | } |
926 | 926 | ||
927 | void Keyboard::cleanupConfigDlg() { | 927 | void Keyboard::cleanupConfigDlg() { |
928 | 928 | ||
929 | if ( configdlg ) { | 929 | if ( configdlg ) { |
930 | delete configdlg; | 930 | delete configdlg; |
931 | configdlg = 0; | 931 | configdlg = 0; |
932 | } | 932 | } |
933 | } | 933 | } |
934 | 934 | ||
935 | void Keyboard::reloadSw() { | 935 | void Keyboard::reloadSw() { |
936 | QCopEnvelope e("MultiKey/Switcher", "setsw(QString,QString)"); | 936 | QCopEnvelope e("MultiKey/Switcher", "setsw(QString,QString)"); |
937 | 937 | ||
938 | Config* config = new Config("multikey"); | 938 | Config* config = new Config("multikey"); |
939 | config->setGroup("keymaps"); | 939 | config->setGroup("keymaps"); |
940 | QString current_map = config->readEntry("current", "en.keymap"); | 940 | QString current_map = config->readEntry("current", "en.keymap"); |
941 | delete config; | 941 | delete config; |
942 | 942 | ||
943 | e << ConfigDlg::loadSw().join("|") << current_map; | 943 | e << ConfigDlg::loadSw().join("|") << current_map; |
944 | } | 944 | } |
945 | 945 | ||
946 | /* Keyboard::setMapTo ... {{{1 */ | 946 | /* Keyboard::setMapTo ... {{{1 */ |
947 | void Keyboard::setMapToDefault() { | 947 | void Keyboard::setMapToDefault() { |
948 | 948 | ||
949 | 949 | ||
950 | /* load current locale language map */ | 950 | /* load current locale language map */ |
951 | Config *config = new Config("locale"); | 951 | Config *config = new Config("locale"); |
952 | config->setGroup( "Language" ); | 952 | config->setGroup( "Language" ); |
953 | QString l = config->readEntry( "Language" , "en" ); | 953 | QString l = config->readEntry( "Language" , "en" ); |
954 | delete config; | 954 | delete config; |
955 | 955 | ||
956 | /* if Language represents as en_US, ru_RU, etc... */ | 956 | /* if Language represents as en_US, ru_RU, etc... */ |
957 | int d = l.find('_'); | 957 | int d = l.find('_'); |
958 | if (d != -1) { | 958 | if (d != -1) { |
959 | l.remove(d, l.length()-d); | 959 | l.remove(d, l.length()-d); |
960 | } | 960 | } |
961 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" | 961 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" |
962 | + l + ".keymap"; | 962 | + l + ".keymap"; |
963 | 963 | ||
964 | /* save change to multikey config file */ | 964 | /* save change to multikey config file */ |
965 | config = new Config("multikey"); | 965 | config = new Config("multikey"); |
966 | config->setGroup ("keymaps"); | 966 | config->setGroup ("keymaps"); |
967 | config->writeEntry ("current", key_map); // default closed | 967 | config->writeEntry ("current", key_map); // default closed |
968 | delete config; | 968 | delete config; |
969 | 969 | ||
970 | int prevRows = keys->rows(); | 970 | int prevRows = keys->rows(); |
971 | 971 | ||
972 | delete keys; | 972 | delete keys; |
973 | keys = new Keys(key_map); | 973 | keys = new Keys(key_map); |
974 | 974 | ||
975 | // have to repaint the keyboard | 975 | // have to repaint the keyboard |
976 | if (prevRows != keys->rows()) { | 976 | if (prevRows != keys->rows()) { |
977 | 977 | ||
978 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 978 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
979 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 979 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
980 | 980 | ||
981 | } else repaint(FALSE); | 981 | } else repaint(FALSE); |
982 | 982 | ||
983 | resetState(); | 983 | resetState(); |
984 | } | 984 | } |
985 | 985 | ||
986 | void Keyboard::setMapToFile(QString map) { | 986 | void Keyboard::setMapToFile(QString map) { |
987 | 987 | ||
988 | /* save change to multikey config file */ | 988 | /* save change to multikey config file */ |
989 | Config *config = new Config("multikey"); | 989 | Config *config = new Config("multikey"); |
990 | config->setGroup ("keymaps"); | 990 | config->setGroup ("keymaps"); |
991 | config->writeEntry ("current", map); // default closed | 991 | config->writeEntry ("current", map); // default closed |
992 | 992 | ||
993 | delete config; | 993 | delete config; |
994 | 994 | ||
995 | int prevRows = keys->rows(); | 995 | int prevRows = keys->rows(); |
996 | 996 | ||
997 | delete keys; | 997 | delete keys; |
998 | if (QFile(map).exists()) | 998 | if (QFile(map).exists()) |
999 | keys = new Keys(map); | 999 | keys = new Keys(map); |
1000 | else | 1000 | else |
1001 | keys = new Keys(); | 1001 | keys = new Keys(); |
1002 | 1002 | ||
1003 | if (keys->rows() != prevRows) { | 1003 | if (keys->rows() != prevRows) { |
1004 | 1004 | ||
1005 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 1005 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
1006 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 1006 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
1007 | } | 1007 | } |
1008 | else repaint(FALSE); | 1008 | else repaint(FALSE); |
1009 | 1009 | ||
1010 | resetState(); | 1010 | resetState(); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | /* Keybaord::reloadKeyboard {{{1 */ | 1013 | /* Keybaord::reloadKeyboard {{{1 */ |
1014 | void Keyboard::reloadKeyboard() { | 1014 | void Keyboard::reloadKeyboard() { |
1015 | 1015 | ||
1016 | // reload colors and redraw | 1016 | // reload colors and redraw |
1017 | loadKeyboardColors(); | 1017 | loadKeyboardColors(); |
1018 | repaint(); | 1018 | repaint(); |
1019 | 1019 | ||
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | void Keyboard::loadKeyboardColors() { | 1022 | void Keyboard::loadKeyboardColors() { |
1023 | 1023 | ||
1024 | Config config ("multikey"); | 1024 | Config config ("multikey"); |
1025 | config.setGroup("colors"); | 1025 | config.setGroup("colors"); |
1026 | 1026 | ||
1027 | QStringList color; | 1027 | QStringList color; |
1028 | color = config.readListEntry("keycolor", QChar(',')); | 1028 | color = config.readListEntry("keycolor", QChar(',')); |
1029 | if (color.isEmpty()) { | 1029 | if (color.isEmpty()) { |
1030 | color = QStringList::split(",", "240,240,240"); | 1030 | color = QStringList::split(",", "240,240,240"); |
1031 | config.writeEntry("keycolor", color.join(",")); | 1031 | config.writeEntry("keycolor", color.join(",")); |
1032 | 1032 | ||
1033 | } | 1033 | } |
1034 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1034 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1035 | 1035 | ||
1036 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 1036 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
1037 | if (color.isEmpty()) { | 1037 | if (color.isEmpty()) { |
1038 | color = QStringList::split(",", "171,183,198"); | 1038 | color = QStringList::split(",", "171,183,198"); |
1039 | config.writeEntry("keycolor_pressed", color.join(",")); | 1039 | config.writeEntry("keycolor_pressed", color.join(",")); |
1040 | 1040 | ||
1041 | } | 1041 | } |
1042 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1042 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1043 | 1043 | ||
1044 | color = config.readListEntry("keycolor_lines", QChar(',')); | 1044 | color = config.readListEntry("keycolor_lines", QChar(',')); |
1045 | if (color.isEmpty()) { | 1045 | if (color.isEmpty()) { |
1046 | color = QStringList::split(",", "138,148,160"); | 1046 | color = QStringList::split(",", "138,148,160"); |
1047 | config.writeEntry("keycolor_lines", color.join(",")); | 1047 | config.writeEntry("keycolor_lines", color.join(",")); |
1048 | 1048 | ||
1049 | } | 1049 | } |
1050 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1050 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1051 | 1051 | ||
1052 | color = config.readListEntry("textcolor", QChar(',')); | 1052 | color = config.readListEntry("textcolor", QChar(',')); |
1053 | if (color.isEmpty()) { | 1053 | if (color.isEmpty()) { |
1054 | color = QStringList::split(",", "43,54,68"); | 1054 | color = QStringList::split(",", "43,54,68"); |
1055 | config.writeEntry("textcolor", color.join(",")); | 1055 | config.writeEntry("textcolor", color.join(",")); |
1056 | 1056 | ||
1057 | } | 1057 | } |
1058 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1058 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1059 | 1059 | ||
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | /* korean input functions {{{1 | 1062 | /* korean input functions {{{1 |
1063 | * | 1063 | * |
1064 | * TODO | 1064 | * TODO |
1065 | * one major problem with this implementation is that you can't move the | 1065 | * one major problem with this implementation is that you can't move the |
1066 | * cursor after inputing korean chars, otherwise it will eat up and replace | 1066 | * cursor after inputing korean chars, otherwise it will eat up and replace |
1067 | * the char before the cursor you move to. fix that | 1067 | * the char before the cursor you move to. fix that |
1068 | * | 1068 | * |
1069 | * make backspace delete one single char, not the whole thing if still | 1069 | * make backspace delete one single char, not the whole thing if still |
1070 | * editing. | 1070 | * editing. |
1071 | * | 1071 | * |
1072 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 1072 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
1073 | * | 1073 | * |
1074 | * how korean input works | 1074 | * how korean input works |
1075 | * | 1075 | * |
1076 | * all following chars means unicode char value and are in hex | 1076 | * all following chars means unicode char value and are in hex |
1077 | * | 1077 | * |
1078 | * 초음 = schar (start char) | 1078 | * 초음 = schar (start char) |
1079 | * 중음 = mchar (middle char) | 1079 | * 중음 = mchar (middle char) |
1080 | * 끝음 = echar (end char) | 1080 | * 끝음 = echar (end char) |
1081 | * | 1081 | * |
1082 | * there are 19 schars. unicode position is at 1100 - 1112 | 1082 | * there are 19 schars. unicode position is at 1100 - 1112 |
1083 | * there are 21 mchars. unicode position is at 1161 - 1175 | 1083 | * there are 21 mchars. unicode position is at 1161 - 1175 |
1084 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 1084 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
1085 | * | 1085 | * |
1086 | * the map with everything combined is at ac00 - d7a3 | 1086 | * the map with everything combined is at ac00 - d7a3 |
1087 | * | 1087 | * |
1088 | */ | 1088 | */ |
1089 | 1089 | ||
1090 | ushort Keyboard::parseKoreanInput (ushort c) { | 1090 | ushort Keyboard::parseKoreanInput (ushort c) { |
1091 | 1091 | ||
1092 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 1092 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
1093 | || | 1093 | || |
1094 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 1094 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
1095 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 1095 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
1096 | 1096 | ||
1097 | schar = 0, mchar = 0, echar = 0; | 1097 | schar = 0, mchar = 0, echar = 0; |
1098 | return c; | 1098 | return c; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 1101 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
1102 | 1102 | ||
1103 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 1103 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
1104 | schar = c; mchar = 0; echar = 0; | 1104 | schar = c; mchar = 0; echar = 0; |
1105 | return c; | 1105 | return c; |
1106 | } | 1106 | } |
1107 | else if (mchar != 0) { | 1107 | else if (mchar != 0) { |
1108 | 1108 | ||
1109 | if (echar == 0) { | 1109 | if (echar == 0) { |
1110 | 1110 | ||
1111 | if (!(echar = constoe(c))) { | 1111 | if (!(echar = constoe(c))) { |
1112 | 1112 | ||
1113 | schar = c; mchar = 0; echar = 0; | 1113 | schar = c; mchar = 0; echar = 0; |
1114 | return c; | 1114 | return c; |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | } | 1117 | } |
1118 | else { // must figure out what the echar is | 1118 | else { // must figure out what the echar is |
1119 | 1119 | ||
1120 | if (echar == 0x11a8) { // ㄱ | 1120 | if (echar == 0x11a8) { // ㄱ |
1121 | 1121 | ||
1122 | if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ | 1122 | if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ |
1123 | else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ | 1123 | else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ |
1124 | else { | 1124 | else { |
1125 | schar = c; mchar = 0; echar = 0; | 1125 | schar = c; mchar = 0; echar = 0; |
1126 | return c; | 1126 | return c; |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | } else if (echar == 0x11ab) { // ㄴ | 1129 | } else if (echar == 0x11ab) { // ㄴ |
1130 | 1130 | ||
1131 | if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ | 1131 | if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ |
1132 | else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ | 1132 | else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ |
1133 | else { | 1133 | else { |
1134 | schar = c; mchar = 0; echar = 0; | 1134 | schar = c; mchar = 0; echar = 0; |
1135 | return c; | 1135 | return c; |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | } else if (echar == 0x11af) { // ㄹ | 1138 | } else if (echar == 0x11af) { // ㄹ |
1139 | 1139 | ||
1140 | if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ | 1140 | if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ |
1141 | else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ | 1141 | else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ |
1142 | else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ | 1142 | else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ |
1143 | else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ | 1143 | else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ |
1144 | else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ | 1144 | else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ |
1145 | else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ | 1145 | else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ |
1146 | else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ | 1146 | else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ |
1147 | else { | 1147 | else { |
1148 | schar = c; mchar = 0; echar = 0; | 1148 | schar = c; mchar = 0; echar = 0; |
1149 | return c; | 1149 | return c; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | } else if (echar == 0x11b8) { // ㅂ | 1152 | } else if (echar == 0x11b8) { // ㅂ |
1153 | 1153 | ||
1154 | if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ | 1154 | if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ |
1155 | else { | 1155 | else { |
1156 | schar = c; mchar = 0; echar = 0; | 1156 | schar = c; mchar = 0; echar = 0; |
1157 | return c; | 1157 | return c; |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | } else if (echar == 0x11ba) { // ㅅ | 1160 | } else if (echar == 0x11ba) { // ㅅ |
1161 | 1161 | ||
1162 | if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ | 1162 | if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ |
1163 | else { | 1163 | else { |
1164 | schar = c; mchar = 0; echar = 0; | 1164 | schar = c; mchar = 0; echar = 0; |
1165 | return c; | 1165 | return c; |
1166 | } | 1166 | } |
1167 | 1167 | ||
1168 | } else { // if any other char, cannot combine chars | 1168 | } else { // if any other char, cannot combine chars |
1169 | 1169 | ||
1170 | schar = c; mchar = 0; echar = 0; | 1170 | schar = c; mchar = 0; echar = 0; |
1171 | return c; | 1171 | return c; |
1172 | } | 1172 | } |
1173 | 1173 | ||
1174 | unicode = echar; | 1174 | unicode = echar; |
1175 | } | 1175 | } |
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | } | 1178 | } |
1179 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 1179 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
1180 | 1180 | ||
1181 | if (schar != 0 && mchar == 0) { mchar = c; } | 1181 | if (schar != 0 && mchar == 0) { mchar = c; } |
1182 | 1182 | ||
1183 | else if (schar != 0 && mchar != 0 && echar == 0) { | 1183 | else if (schar != 0 && mchar != 0 && echar == 0) { |
1184 | 1184 | ||
1185 | switch (mchar) { | 1185 | switch (mchar) { |
1186 | case 0x1169: | 1186 | case 0x1169: |
1187 | if (c == 0x1161) mchar = 0x116a; | 1187 | if (c == 0x1161) mchar = 0x116a; |
1188 | else if (c == 0x1162) mchar = 0x116b; | 1188 | else if (c == 0x1162) mchar = 0x116b; |
1189 | else if (c == 0x1175) mchar = 0x116c; | 1189 | else if (c == 0x1175) mchar = 0x116c; |
1190 | else { | 1190 | else { |
1191 | schar = 0; mchar = 0; echar = 0; | 1191 | schar = 0; mchar = 0; echar = 0; |
1192 | return c; | 1192 | return c; |
1193 | } | 1193 | } |
1194 | break; | 1194 | break; |
1195 | case 0x116e: | 1195 | case 0x116e: |
1196 | if (c == 0x1165) mchar = 0x116f; | 1196 | if (c == 0x1165) mchar = 0x116f; |
1197 | else if (c == 0x1166) mchar = 0x1170; | 1197 | else if (c == 0x1166) mchar = 0x1170; |
1198 | else if (c == 0x1175) mchar = 0x1171; | 1198 | else if (c == 0x1175) mchar = 0x1171; |
1199 | else { | 1199 | else { |
1200 | schar = 0; mchar = 0; echar = 0; | 1200 | schar = 0; mchar = 0; echar = 0; |
1201 | return c; | 1201 | return c; |
1202 | } | 1202 | } |
1203 | break; | 1203 | break; |
1204 | case 0x1173: | 1204 | case 0x1173: |
1205 | if (c == 0x1175) mchar = 0x1174; | 1205 | if (c == 0x1175) mchar = 0x1174; |
1206 | else { | 1206 | else { |
1207 | schar = 0; mchar = 0; echar = 0; | 1207 | schar = 0; mchar = 0; echar = 0; |
1208 | return c; | 1208 | return c; |
1209 | } | 1209 | } |
1210 | break; | 1210 | break; |
1211 | default: | 1211 | default: |
1212 | schar = 0; mchar = 0; echar = 0; | 1212 | schar = 0; mchar = 0; echar = 0; |
1213 | return c; | 1213 | return c; |
1214 | } | 1214 | } |
1215 | } | 1215 | } |
1216 | else if (schar != 0 && mchar != 0 && echar != 0) { | 1216 | else if (schar != 0 && mchar != 0 && echar != 0) { |
1217 | 1217 | ||
1218 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1218 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1219 | 1219 | ||
1220 | ushort prev = 0; | 1220 | ushort prev = 0; |
1221 | switch (echar) { | 1221 | switch (echar) { |
1222 | /* | 1222 | /* |
1223 | case 0x11a9: | 1223 | case 0x11a9: |
1224 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1224 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1225 | schar = 0x1100; | 1225 | schar = 0x1100; |
1226 | break; | 1226 | break; |
1227 | */ | 1227 | */ |
1228 | case 0x11aa: | 1228 | case 0x11aa: |
1229 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1229 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1230 | schar = 0x1109; | 1230 | schar = 0x1109; |
1231 | break; | 1231 | break; |
1232 | case 0x11ac: | 1232 | case 0x11ac: |
1233 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1233 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1234 | schar = 0x110c; | 1234 | schar = 0x110c; |
1235 | break; | 1235 | break; |
1236 | case 0x11ad: | 1236 | case 0x11ad: |
1237 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1237 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1238 | schar = 0x1112; | 1238 | schar = 0x1112; |
1239 | break; | 1239 | break; |
1240 | case 0x11b0: | 1240 | case 0x11b0: |
1241 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1241 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1242 | schar = 0x1100; | 1242 | schar = 0x1100; |
1243 | break; | 1243 | break; |
1244 | case 0x11b1: | 1244 | case 0x11b1: |
1245 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1245 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1246 | schar = 0x1106; | 1246 | schar = 0x1106; |
1247 | break; | 1247 | break; |
1248 | case 0x11b2: | 1248 | case 0x11b2: |
1249 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1249 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1250 | schar = 0x1107; | 1250 | schar = 0x1107; |
1251 | break; | 1251 | break; |
1252 | case 0x11b3: | 1252 | case 0x11b3: |
1253 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1253 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1254 | schar = 0x1109; | 1254 | schar = 0x1109; |
1255 | break; | 1255 | break; |
1256 | case 0x11b4: | 1256 | case 0x11b4: |
1257 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1257 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1258 | schar = 0x1110; | 1258 | schar = 0x1110; |
1259 | break; | 1259 | break; |
1260 | case 0x11b9: | 1260 | case 0x11b9: |
1261 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 1261 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
1262 | schar = 0x1109; | 1262 | schar = 0x1109; |
1263 | break; | 1263 | break; |
1264 | /* | 1264 | /* |
1265 | case 0x11bb: | 1265 | case 0x11bb: |
1266 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 1266 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
1267 | schar = 0x1109; | 1267 | schar = 0x1109; |
1268 | break; | 1268 | break; |
1269 | */ | 1269 | */ |
1270 | default: | 1270 | default: |
1271 | 1271 | ||
1272 | if (constoe(echar)) { | 1272 | if (constoe(echar)) { |
1273 | 1273 | ||
1274 | prev = combineKoreanChars(schar, mchar, 0); | 1274 | prev = combineKoreanChars(schar, mchar, 0); |
1275 | schar = constoe(echar); | 1275 | schar = constoe(echar); |
1276 | } | 1276 | } |
1277 | break; | 1277 | break; |
1278 | } | 1278 | } |
1279 | 1279 | ||
1280 | emit key( prev, prev, 0, true, false ); | 1280 | emit key( prev, prev, 0, true, false ); |
1281 | 1281 | ||
1282 | mchar = c; echar = 0; | 1282 | mchar = c; echar = 0; |
1283 | 1283 | ||
1284 | return combineKoreanChars(schar, mchar, 0); | 1284 | return combineKoreanChars(schar, mchar, 0); |
1285 | 1285 | ||
1286 | } | 1286 | } |
1287 | else { | 1287 | else { |
1288 | schar = 0; mchar = 0; echar = 0; | 1288 | schar = 0; mchar = 0; echar = 0; |
1289 | return c; | 1289 | return c; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | } | 1292 | } |
1293 | else /*if (c == ' ')*/ return c; | 1293 | else /*if (c == ' ')*/ return c; |
1294 | 1294 | ||
1295 | 1295 | ||
1296 | // and now... finally delete previous char, and return new char | 1296 | // and now... finally delete previous char, and return new char |
1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | return combineKoreanChars( schar, mchar, echar); | 1300 | return combineKoreanChars( schar, mchar, echar); |
1301 | 1301 | ||
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
1305 | 1305 | ||
1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
1307 | 1307 | ||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | ushort Keyboard::constoe(const ushort c) { | 1310 | ushort Keyboard::constoe(const ushort c) { |
1311 | 1311 | ||
1312 | // converts schars to echars if possible | 1312 | // converts schars to echars if possible |
1313 | 1313 | ||
1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
1315 | 1315 | ||
1316 | switch (c) { | 1316 | switch (c) { |
1317 | case 0x1100: return 0x11a8; | 1317 | case 0x1100: return 0x11a8; |
1318 | case 0x1101: return 0x11a9; | 1318 | case 0x1101: return 0x11a9; |
1319 | case 0x1102: return 0x11ab; | 1319 | case 0x1102: return 0x11ab; |
1320 | case 0x1103: return 0x11ae; | 1320 | case 0x1103: return 0x11ae; |
1321 | case 0x1105: return 0x11af; | 1321 | case 0x1105: return 0x11af; |
1322 | case 0x1106: return 0x11b7; | 1322 | case 0x1106: return 0x11b7; |
1323 | case 0x1107: return 0x11b8; | 1323 | case 0x1107: return 0x11b8; |
1324 | case 0x1109: return 0x11ba; | 1324 | case 0x1109: return 0x11ba; |
1325 | case 0x110a: return 0x11bb; | 1325 | case 0x110a: return 0x11bb; |
1326 | case 0x110b: return 0x11bc; | 1326 | case 0x110b: return 0x11bc; |
1327 | case 0x110c: return 0x11bd; | 1327 | case 0x110c: return 0x11bd; |
1328 | case 0x110e: return 0x11be; | 1328 | case 0x110e: return 0x11be; |
1329 | case 0x110f: return 0x11bf; | 1329 | case 0x110f: return 0x11bf; |
1330 | case 0x1110: return 0x11c0; | 1330 | case 0x1110: return 0x11c0; |
1331 | case 0x1111: return 0x11c1; | 1331 | case 0x1111: return 0x11c1; |
1332 | case 0x1112: return 0x11c2; | 1332 | case 0x1112: return 0x11c2; |
1333 | default: return 0; | 1333 | default: return 0; |
1334 | 1334 | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | } else { //echar to schar | 1337 | } else { //echar to schar |
1338 | 1338 | ||
1339 | switch (c) { | 1339 | switch (c) { |
1340 | case 0x11a8: return 0x1100; | 1340 | case 0x11a8: return 0x1100; |
1341 | case 0x11a9: return 0x1101; | 1341 | case 0x11a9: return 0x1101; |
1342 | case 0x11ab: return 0x1102; | 1342 | case 0x11ab: return 0x1102; |
1343 | case 0x11ae: return 0x1103; | 1343 | case 0x11ae: return 0x1103; |
1344 | case 0x11af: return 0x1105; | 1344 | case 0x11af: return 0x1105; |
1345 | case 0x11b7: return 0x1106; | 1345 | case 0x11b7: return 0x1106; |
1346 | case 0x11b8: return 0x1107; | 1346 | case 0x11b8: return 0x1107; |
1347 | case 0x11ba: return 0x1109; | 1347 | case 0x11ba: return 0x1109; |
1348 | case 0x11bb: return 0x110a; | 1348 | case 0x11bb: return 0x110a; |
1349 | case 0x11bc: return 0x110b; | 1349 | case 0x11bc: return 0x110b; |
1350 | case 0x11bd: return 0x110c; | 1350 | case 0x11bd: return 0x110c; |
1351 | case 0x11be: return 0x110e; | 1351 | case 0x11be: return 0x110e; |
1352 | case 0x11bf: return 0x110f; | 1352 | case 0x11bf: return 0x110f; |
1353 | case 0x11c0: return 0x1110; | 1353 | case 0x11c0: return 0x1110; |
1354 | case 0x11c1: return 0x1111; | 1354 | case 0x11c1: return 0x1111; |
1355 | case 0x11c2: return 0x1112; | 1355 | case 0x11c2: return 0x1112; |
1356 | default: return 0; | 1356 | default: return 0; |
1357 | 1357 | ||
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | 1363 | ||
1364 | // Keys::Keys {{{1 | 1364 | // Keys::Keys {{{1 |
1365 | 1365 | ||
1366 | Keys::Keys() { | 1366 | Keys::Keys() { |
1367 | 1367 | ||
1368 | Config *config = new Config ("multikey"); | 1368 | Config *config = new Config ("multikey"); |
1369 | config->setGroup( "keymaps" ); | 1369 | config->setGroup( "keymaps" ); |
1370 | QString map = config->readEntry( "current" ); | 1370 | QString map = config->readEntry( "current" ); |
1371 | delete config; | 1371 | delete config; |
1372 | 1372 | ||
1373 | if (map.isNull() || !(QFile(map).exists())) { | 1373 | if (map.isNull() || !(QFile(map).exists())) { |
1374 | 1374 | ||
1375 | Config *config = new Config("locale"); | 1375 | Config *config = new Config("locale"); |
1376 | config->setGroup( "Language" ); | 1376 | config->setGroup( "Language" ); |
1377 | QString l = config->readEntry( "Language" , "en" ); | 1377 | QString l = config->readEntry( "Language" , "en" ); |
1378 | delete config; | 1378 | delete config; |
1379 | 1379 | ||
1380 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1380 | map = QPEApplication::qpeDir() + "/share/multikey/" |
1381 | + l + ".keymap"; | 1381 | + l + ".keymap"; |
1382 | 1382 | ||
1383 | } | 1383 | } |
1384 | if (map.isNull() || !(QFile(map).exists())) { | 1384 | if (map.isNull() || !(QFile(map).exists())) { |
1385 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; | 1385 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | setKeysFromFile(map); | 1388 | setKeysFromFile(map); |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | Keys::Keys(const char * filename) { | 1391 | Keys::Keys(const char * filename) { |
1392 | 1392 | ||
1393 | setKeysFromFile(filename); | 1393 | setKeysFromFile(filename); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | // Keys::setKeysFromFile {{{2 | 1396 | // Keys::setKeysFromFile {{{2 |
1397 | void Keys::setKeysFromFile(const char * filename) { | 1397 | void Keys::setKeysFromFile(const char * filename) { |
1398 | 1398 | ||
1399 | QFile f(filename); | 1399 | QFile f(filename); |
1400 | 1400 | ||
1401 | if (f.open(IO_ReadOnly)) { | 1401 | if (f.open(IO_ReadOnly)) { |
1402 | 1402 | ||
1403 | QTextStream t(&f); | 1403 | QTextStream t(&f); |
1404 | int row; | 1404 | int row; |
1405 | int qcode; | 1405 | int qcode; |
1406 | ushort unicode; | 1406 | ushort unicode; |
1407 | int width; | 1407 | int width; |
1408 | QString buf; | 1408 | QString buf; |
1409 | QString comment; | 1409 | QString comment; |
1410 | char * xpm[256]; //couldnt be larger than that... could it? | 1410 | char * xpm[256]; //couldnt be larger than that... could it? |
1411 | QImage *xpm2pix = 0; | 1411 | QImage *xpm2pix = 0; |
1412 | 1412 | ||
1413 | buf = t.readLine(); | 1413 | buf = t.readLine(); |
1414 | while (buf) { | 1414 | while (buf) { |
1415 | 1415 | ||
1416 | // get rid of comments | 1416 | // get rid of comments |
1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1418 | 1418 | ||
1419 | // key definition | 1419 | // key definition |
1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1421 | // no $1 type referencing!!! this implementation of regexp sucks | 1421 | // no $1 type referencing!!! this implementation of regexp sucks |
1422 | 1422 | ||
1423 | // dont know of any sscanf() type funcs in Qt lib | 1423 | // dont know of any sscanf() type funcs in Qt lib |
1424 | QTextStream tmp (buf, IO_ReadOnly); | 1424 | QTextStream tmp (buf, IO_ReadOnly); |
1425 | tmp >> row >> qcode >> unicode >> width >> comment; | 1425 | tmp >> row >> qcode >> unicode >> width >> comment; |
1426 | 1426 | ||
1427 | buf = t.readLine(); | 1427 | buf = t.readLine(); |
1428 | int xpmLineCount = 0; | 1428 | int xpmLineCount = 0; |
1429 | xpm2pix = 0; | 1429 | xpm2pix = 0; |
1430 | 1430 | ||
1431 | // erase blank space | 1431 | // erase blank space |
1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1433 | 1433 | ||
1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1435 | 1435 | ||
1436 | QString xpmBuf = buf.stripWhiteSpace(); | 1436 | QString xpmBuf = buf.stripWhiteSpace(); |
1437 | 1437 | ||
1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1439 | 1439 | ||
1440 | int j = 0; | 1440 | int j = 0; |
1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1442 | if (xpmBuf[i].latin1() != '"') { | 1442 | if (xpmBuf[i].latin1() != '"') { |
1443 | 1443 | ||
1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1445 | j++; | 1445 | j++; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | } | 1448 | } |
1449 | // have to close that facker up | 1449 | // have to close that facker up |
1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1451 | 1451 | ||
1452 | xpmLineCount++; | 1452 | xpmLineCount++; |
1453 | buf = t.readLine(); | 1453 | buf = t.readLine(); |
1454 | } | 1454 | } |
1455 | if (xpmLineCount) { | 1455 | if (xpmLineCount) { |
1456 | 1456 | ||
1457 | xpm2pix = new QImage((const char **)xpm); | 1457 | xpm2pix = new QImage((const char **)xpm); |
1458 | for (int i = 0; i < xpmLineCount; i++) | 1458 | for (int i = 0; i < xpmLineCount; i++) |
1459 | 1459 | ||
1460 | delete [] (xpm[i]); | 1460 | delete [] (xpm[i]); |
1461 | 1461 | ||
1462 | } | 1462 | } |
1463 | setKey(row, qcode, unicode, width, xpm2pix); | 1463 | setKey(row, qcode, unicode, width, xpm2pix); |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | // shift map | 1466 | // shift map |
1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1468 | 1468 | ||
1469 | QTextStream tmp (buf, IO_ReadOnly); | 1469 | QTextStream tmp (buf, IO_ReadOnly); |
1470 | ushort lower, shift; | 1470 | ushort lower, shift; |
1471 | tmp >> lower >> shift; | 1471 | tmp >> lower >> shift; |
1472 | 1472 | ||
1473 | shiftMap.insert(lower, shift); | 1473 | shiftMap.insert(lower, shift); |
1474 | 1474 | ||
1475 | buf = t.readLine(); | 1475 | buf = t.readLine(); |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | // meta key map | 1478 | // meta key map |
1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1480 | 1480 | ||
1481 | QTextStream tmp (buf, IO_ReadOnly); | 1481 | QTextStream tmp (buf, IO_ReadOnly); |
1482 | ushort lower, shift; | 1482 | ushort lower, shift; |
1483 | QChar m; | 1483 | QChar m; |
1484 | tmp >> m >> lower >> shift; | 1484 | tmp >> m >> lower >> shift; |
1485 | 1485 | ||
1486 | metaMap.insert(lower, shift); | 1486 | metaMap.insert(lower, shift); |
1487 | 1487 | ||
1488 | buf = t.readLine(); | 1488 | buf = t.readLine(); |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | // circumflex | 1491 | // circumflex |
1492 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1492 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1493 | 1493 | ||
1494 | QTextStream tmp (buf, IO_ReadOnly); | 1494 | QTextStream tmp (buf, IO_ReadOnly); |
1495 | ushort lower, shift; | 1495 | ushort lower, shift; |
1496 | QChar c; | 1496 | QChar c; |
1497 | tmp >> c >> lower >> shift; | 1497 | tmp >> c >> lower >> shift; |
1498 | 1498 | ||
1499 | circumflexMap.insert(lower, shift); | 1499 | circumflexMap.insert(lower, shift); |
1500 | 1500 | ||
1501 | buf = t.readLine(); | 1501 | buf = t.readLine(); |
1502 | } | 1502 | } |
1503 | // diaeresis | 1503 | // diaeresis |
1504 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1504 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1505 | 1505 | ||
1506 | QTextStream tmp (buf, IO_ReadOnly); | 1506 | QTextStream tmp (buf, IO_ReadOnly); |
1507 | ushort lower, shift; | 1507 | ushort lower, shift; |
1508 | QChar d; | 1508 | QChar d; |
1509 | tmp >> d >> lower >> shift; | 1509 | tmp >> d >> lower >> shift; |
1510 | 1510 | ||
1511 | diaeresisMap.insert(lower, shift); | 1511 | diaeresisMap.insert(lower, shift); |
1512 | 1512 | ||
1513 | buf = t.readLine(); | 1513 | buf = t.readLine(); |
1514 | } | 1514 | } |
1515 | // back accent | 1515 | // back accent |
1516 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1516 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1517 | 1517 | ||
1518 | QTextStream tmp (buf, IO_ReadOnly); | 1518 | QTextStream tmp (buf, IO_ReadOnly); |
1519 | ushort lower, shift; | 1519 | ushort lower, shift; |
1520 | QChar d; | 1520 | QChar d; |
1521 | tmp >> d >> lower >> shift; | 1521 | tmp >> d >> lower >> shift; |
1522 | 1522 | ||
1523 | baccentMap.insert(lower, shift); | 1523 | baccentMap.insert(lower, shift); |
1524 | 1524 | ||
1525 | qDebug ("Estoy aadiendo %i con %i", lower, shift); | 1525 | qDebug ("Estoy aadiendo %i con %i", lower, shift); |
1526 | buf = t.readLine(); | 1526 | buf = t.readLine(); |
1527 | } | 1527 | } |
1528 | // accent | 1528 | // accent |
1529 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1529 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1530 | 1530 | ||
1531 | QTextStream tmp (buf, IO_ReadOnly); | 1531 | QTextStream tmp (buf, IO_ReadOnly); |
1532 | ushort lower, shift; | 1532 | ushort lower, shift; |
1533 | QChar d; | 1533 | QChar d; |
1534 | tmp >> d >> lower >> shift; | 1534 | tmp >> d >> lower >> shift; |
1535 | 1535 | ||
1536 | accentMap.insert(lower, shift); | 1536 | accentMap.insert(lower, shift); |
1537 | 1537 | ||
1538 | buf = t.readLine(); | 1538 | buf = t.readLine(); |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | // other variables like lang & title & sw | 1541 | // other variables like lang & title & sw |
1542 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1542 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1543 | 1543 | ||
1544 | QTextStream tmp (buf, IO_ReadOnly); | 1544 | QTextStream tmp (buf, IO_ReadOnly); |
1545 | QString name, equals, value; | 1545 | QString name, equals, value; |
1546 | 1546 | ||
1547 | tmp >> name >> equals >> value; | 1547 | tmp >> name >> equals >> value; |
1548 | 1548 | ||
1549 | if (name == "lang") { | 1549 | if (name == "lang") { |
1550 | 1550 | ||
1551 | lang = value; | 1551 | lang = value; |
1552 | 1552 | ||
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | buf = t.readLine(); | 1555 | buf = t.readLine(); |
1556 | } | 1556 | } |
1557 | // comments | 1557 | // comments |
1558 | else if (buf.contains(QRegExp("^\\s*#"))) { | 1558 | else if (buf.contains(QRegExp("^\\s*#"))) { |
1559 | 1559 | ||
1560 | buf = t.readLine(); | 1560 | buf = t.readLine(); |
1561 | 1561 | ||
1562 | } else { // blank line, or garbage | 1562 | } else { // blank line, or garbage |
1563 | 1563 | ||
1564 | buf = t.readLine(); | 1564 | buf = t.readLine(); |
1565 | 1565 | ||
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | f.close(); | 1570 | f.close(); |
1571 | } else { | 1571 | } else { |
1572 | // We couldnt find the selected keymap, give them a configure button | 1572 | // We couldnt find the selected keymap, give them a configure button |
1573 | QImage * btn = new QImage((const char ** )kb_config_xpm); | 1573 | QImage * btn = new QImage((const char ** )kb_config_xpm); |
1574 | setKey(1, 0x1030, 0, 2, btn); | 1574 | setKey(1, 0x1030, 0, 2, btn); |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | 1579 | ||
1580 | // Keys::setKey {{{2 | 1580 | // Keys::setKey {{{2 |
1581 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 1581 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
1582 | const int width, QImage *pix) { | 1582 | const int width, QImage *pix) { |
1583 | 1583 | ||
1584 | Key * key; | 1584 | Key * key; |
1585 | key = new Key; | 1585 | key = new Key; |
1586 | key->qcode = qcode; | 1586 | key->qcode = qcode; |
1587 | key->unicode = unicode; | 1587 | key->unicode = unicode; |
1588 | key->width = width; | 1588 | key->width = width; |
1589 | 1589 | ||
1590 | // share key->pressed between same keys | 1590 | // share key->pressed between same keys |
1591 | bool found = 0; | 1591 | bool found = 0; |
1592 | for (int i = 1; i <= 5; i++) { | 1592 | for (int i = 1; i <= 5; i++) { |
1593 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1593 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1594 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1594 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1595 | 1595 | ||
1596 | key->pressed = keys[i].at(j)->pressed; | 1596 | key->pressed = keys[i].at(j)->pressed; |
1597 | found = 1; | 1597 | found = 1; |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | } | 1600 | } |
1601 | if (!found) { | 1601 | if (!found) { |
1602 | 1602 | ||
1603 | key->pressed = new bool; | 1603 | key->pressed = new bool; |
1604 | *(key->pressed) = 0; | 1604 | *(key->pressed) = 0; |
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | key->pix = pix; | 1607 | key->pix = pix; |
1608 | 1608 | ||
1609 | 1609 | ||
1610 | keys[row].append(key); | 1610 | keys[row].append(key); |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | // Keys::~Keys {{{2 | 1613 | // Keys::~Keys {{{2 |
1614 | Keys::~Keys() { | 1614 | Keys::~Keys() { |
1615 | 1615 | ||
1616 | for (int i = 1; i <= 5; i++) | 1616 | for (int i = 1; i <= 5; i++) |
1617 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1617 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1618 | delete keys[i].at(j); | 1618 | delete keys[i].at(j); |
1619 | 1619 | ||
1620 | } | 1620 | } |
1621 | 1621 | ||
1622 | // Keys:: other functions {{{2 | 1622 | // Keys:: other functions {{{2 |
1623 | int Keys::width(const int row, const int col) { | 1623 | int Keys::width(const int row, const int col) { |
1624 | 1624 | ||
1625 | return keys[row].at(col)->width; | 1625 | return keys[row].at(col)->width; |
1626 | 1626 | ||
1627 | } | 1627 | } |
1628 | 1628 | ||
1629 | int Keys::rows() { | 1629 | int Keys::rows() { |
1630 | 1630 | ||
1631 | for (int i = 1; i <= 5; i++) { | 1631 | for (int i = 1; i <= 5; i++) { |
1632 | 1632 | ||
1633 | if (keys[i].count() == 0) | 1633 | if (keys[i].count() == 0) |
1634 | return i - 1; | 1634 | return i - 1; |
1635 | 1635 | ||
1636 | } | 1636 | } |
1637 | return 5; | 1637 | return 5; |
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | ushort Keys::uni(const int row, const int col) { | 1640 | ushort Keys::uni(const int row, const int col) { |
1641 | 1641 | ||
1642 | return keys[row].at(col)->unicode; | 1642 | return keys[row].at(col)->unicode; |
1643 | 1643 | ||
1644 | } | 1644 | } |
1645 | 1645 | ||
1646 | int Keys::qcode(const int row, const int col) { | 1646 | int Keys::qcode(const int row, const int col) { |
1647 | 1647 | ||
1648 | return keys[row].at(col)->qcode; | 1648 | return keys[row].at(col)->qcode; |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | QImage *Keys::pix(const int row, const int col) { | 1651 | QImage *Keys::pix(const int row, const int col) { |
1652 | 1652 | ||
1653 | return keys[row].at(col)->pix; | 1653 | return keys[row].at(col)->pix; |
1654 | 1654 | ||
1655 | } | 1655 | } |
1656 | bool Keys::pressed(const int row, const int col) { | 1656 | bool Keys::pressed(const int row, const int col) { |
1657 | 1657 | ||
1658 | return *(keys[row].at(col)->pressed); | 1658 | return *(keys[row].at(col)->pressed); |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | int Keys::numKeys(const int row) { | 1661 | int Keys::numKeys(const int row) { |
1662 | 1662 | ||
1663 | return keys[row].count(); | 1663 | return keys[row].count(); |
1664 | } | 1664 | } |
1665 | 1665 | ||
1666 | void Keys::setPressed(const int row, const int col, const bool pressed) { | 1666 | void Keys::setPressed(const int row, const int col, const bool pressed) { |
1667 | 1667 | ||
1668 | *(keys[row].at(col)->pressed) = pressed; | 1668 | *(keys[row].at(col)->pressed) = pressed; |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | ushort Keys::shift(const ushort uni) { | 1671 | ushort Keys::shift(const ushort uni) { |
1672 | 1672 | ||
1673 | if (shiftMap[uni]) return shiftMap[uni]; | 1673 | if (shiftMap[uni]) return shiftMap[uni]; |
1674 | else return 0; | 1674 | else return 0; |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | ushort Keys::meta(const ushort uni) { | 1677 | ushort Keys::meta(const ushort uni) { |
1678 | 1678 | ||
1679 | if (metaMap[uni]) return metaMap[uni]; | 1679 | if (metaMap[uni]) return metaMap[uni]; |
1680 | else return 0; | 1680 | else return 0; |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | ushort Keys::circumflex(const ushort uni) { | 1683 | ushort Keys::circumflex(const ushort uni) { |
1684 | 1684 | ||
1685 | if (circumflexMap[uni]) return circumflexMap[uni]; | 1685 | if (circumflexMap[uni]) return circumflexMap[uni]; |
1686 | else return 0; | 1686 | else return 0; |
1687 | } | 1687 | } |
1688 | 1688 | ||
1689 | ushort Keys::diaeresis(const ushort uni) { | 1689 | ushort Keys::diaeresis(const ushort uni) { |
1690 | 1690 | ||
1691 | if(diaeresisMap[uni]) return diaeresisMap[uni]; | 1691 | if(diaeresisMap[uni]) return diaeresisMap[uni]; |
1692 | else return 0; | 1692 | else return 0; |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | ushort Keys::baccent(const ushort uni) { | 1695 | ushort Keys::baccent(const ushort uni) { |
1696 | 1696 | ||
1697 | if(baccentMap[uni]) return baccentMap[uni]; | 1697 | if(baccentMap[uni]) return baccentMap[uni]; |
1698 | else return 0; | 1698 | else return 0; |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | ushort Keys::accent(const ushort uni) { | 1701 | ushort Keys::accent(const ushort uni) { |
1702 | 1702 | ||
1703 | if(accentMap[uni]) return accentMap[uni]; | 1703 | if(accentMap[uni]) return accentMap[uni]; |
1704 | else return 0; | 1704 | else return 0; |
1705 | } | 1705 | } |
1706 | 1706 | ||
1707 | bool *Keys::pressedPtr(const int row, const int col) { | 1707 | bool *Keys::pressedPtr(const int row, const int col) { |
1708 | 1708 | ||
1709 | return keys[row].at(col)->pressed; | 1709 | return keys[row].at(col)->pressed; |
1710 | } | 1710 | } |