author | kergoth <kergoth> | 2003-01-24 04:16:17 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-24 04:16:17 (UTC) |
commit | 067166880b657925d95ddd688099e56b1463fba8 (patch) (unidiff) | |
tree | 616a36f012cc345f7566eb9c5d47df7d0bb22b0e | |
parent | a50448ae6d0ea041abb7c396c9dddf197ca6f125 (diff) | |
download | opie-067166880b657925d95ddd688099e56b1463fba8.zip opie-067166880b657925d95ddd688099e56b1463fba8.tar.gz opie-067166880b657925d95ddd688099e56b1463fba8.tar.bz2 |
I dont know why we were defaulting to fixed... *shudders*.. but we default to smallsmooth now.
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index c22fbb1..bded447 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,824 +1,824 @@ | |||
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 <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | 37 | ||
38 | #include <sys/utsname.h> | 38 | #include <sys/utsname.h> |
39 | 39 | ||
40 | using namespace MultiKey; | 40 | using namespace MultiKey; |
41 | 41 | ||
42 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), |
45 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), | 45 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), |
46 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), | 46 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), |
47 | pressedKeyRow(-1), pressedKeyCol(-1), | 47 | pressedKeyRow(-1), pressedKeyCol(-1), |
48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
49 | configdlg(0) | 49 | configdlg(0) |
50 | 50 | ||
51 | { | 51 | { |
52 | 52 | ||
53 | // get the default font | 53 | // get the default font |
54 | Config *config = new Config( "qpe" ); | 54 | Config *config = new Config( "qpe" ); |
55 | config->setGroup( "Appearance" ); | 55 | config->setGroup( "Appearance" ); |
56 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 56 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); |
57 | delete config; | 57 | delete config; |
58 | 58 | ||
59 | config = new Config("multikey"); | 59 | config = new Config("multikey"); |
60 | config->setGroup ("general"); | 60 | config->setGroup ("general"); |
61 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed | 61 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed |
62 | useRepeat = config->readBoolEntry ("useRepeat", 1); | 62 | useRepeat = config->readBoolEntry ("useRepeat", 1); |
63 | delete config; | 63 | delete config; |
64 | 64 | ||
65 | 65 | ||
66 | setFont( QFont( familyStr, 10 ) ); | 66 | setFont( QFont( familyStr, 10 ) ); |
67 | 67 | ||
68 | picks = new KeyboardPicks( this ); | 68 | picks = new KeyboardPicks( this ); |
69 | picks->setFont( QFont( familyStr, 10 ) ); | 69 | picks->setFont( QFont( familyStr, 10 ) ); |
70 | picks->initialise(); | 70 | picks->initialise(); |
71 | if (usePicks) { | 71 | if (usePicks) { |
72 | 72 | ||
73 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 73 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
74 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 74 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
75 | 75 | ||
76 | } else picks->hide(); | 76 | } else picks->hide(); |
77 | 77 | ||
78 | loadKeyboardColors(); | 78 | loadKeyboardColors(); |
79 | 79 | ||
80 | keys = new Keys(); | 80 | keys = new Keys(); |
81 | 81 | ||
82 | repeatTimer = new QTimer( this ); | 82 | repeatTimer = new QTimer( this ); |
83 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 83 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
84 | 84 | ||
85 | } | 85 | } |
86 | 86 | ||
87 | Keyboard::~Keyboard() { | 87 | Keyboard::~Keyboard() { |
88 | 88 | ||
89 | if ( configdlg ) { | 89 | if ( configdlg ) { |
90 | delete (ConfigDlg *) configdlg; | 90 | delete (ConfigDlg *) configdlg; |
91 | configdlg = 0; | 91 | configdlg = 0; |
92 | } | 92 | } |
93 | 93 | ||
94 | } | 94 | } |
95 | 95 | ||
96 | /* Keyboard::resizeEvent {{{1 */ | 96 | /* Keyboard::resizeEvent {{{1 */ |
97 | void Keyboard::resizeEvent(QResizeEvent*) | 97 | void Keyboard::resizeEvent(QResizeEvent*) |
98 | { | 98 | { |
99 | int ph = picks->sizeHint().height(); | 99 | int ph = picks->sizeHint().height(); |
100 | picks->setGeometry( 0, 0, width(), ph ); | 100 | picks->setGeometry( 0, 0, width(), ph ); |
101 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); | 101 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); |
102 | 102 | ||
103 | int nk; // number of keys? | 103 | int nk; // number of keys? |
104 | if ( useLargeKeys ) { | 104 | if ( useLargeKeys ) { |
105 | nk = 15; | 105 | nk = 15; |
106 | } else { | 106 | } else { |
107 | nk = 19; | 107 | nk = 19; |
108 | } | 108 | } |
109 | defaultKeyWidth = (width()/nk)/2; | 109 | defaultKeyWidth = (width()/nk)/2; |
110 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 110 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
111 | 111 | ||
112 | } | 112 | } |
113 | 113 | ||
114 | /* KeyboardPicks::initialize {{{1 */ | 114 | /* KeyboardPicks::initialize {{{1 */ |
115 | void KeyboardPicks::initialise() | 115 | void KeyboardPicks::initialise() |
116 | { | 116 | { |
117 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 117 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
118 | mode = 0; | 118 | mode = 0; |
119 | dc = new KeyboardConfig(this); | 119 | dc = new KeyboardConfig(this); |
120 | configs.append(dc); | 120 | configs.append(dc); |
121 | } | 121 | } |
122 | 122 | ||
123 | /* KeyboardPicks::sizeHint {{{1 */ | 123 | /* KeyboardPicks::sizeHint {{{1 */ |
124 | QSize KeyboardPicks::sizeHint() const | 124 | QSize KeyboardPicks::sizeHint() const |
125 | { | 125 | { |
126 | return QSize(240,fontMetrics().lineSpacing()); | 126 | return QSize(240,fontMetrics().lineSpacing()); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | /* KeyboardConfig::generateText {{{1 */ | 130 | /* KeyboardConfig::generateText {{{1 */ |
131 | void KeyboardConfig::generateText(const QString &s) | 131 | void KeyboardConfig::generateText(const QString &s) |
132 | { | 132 | { |
133 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 133 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
134 | for (int i=0; i<(int)backspaces; i++) { | 134 | for (int i=0; i<(int)backspaces; i++) { |
135 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 135 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
136 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 136 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
137 | } | 137 | } |
138 | for (int i=0; i<(int)s.length(); i++) { | 138 | for (int i=0; i<(int)s.length(); i++) { |
139 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 139 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
140 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 140 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
141 | } | 141 | } |
142 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 142 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
143 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 143 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
144 | backspaces = 0; | 144 | backspaces = 0; |
145 | #endif | 145 | #endif |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | 149 | ||
150 | 150 | ||
151 | /* Keyboard::paintEvent {{{1 */ | 151 | /* Keyboard::paintEvent {{{1 */ |
152 | void Keyboard::paintEvent(QPaintEvent* e) | 152 | void Keyboard::paintEvent(QPaintEvent* e) |
153 | { | 153 | { |
154 | QPainter painter(this); | 154 | QPainter painter(this); |
155 | painter.setClipRect(e->rect()); | 155 | painter.setClipRect(e->rect()); |
156 | drawKeyboard( painter ); | 156 | drawKeyboard( painter ); |
157 | picks->dc->draw( &painter ); | 157 | picks->dc->draw( &painter ); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | /* Keyboard::drawKeyboard {{{1 */ | 161 | /* Keyboard::drawKeyboard {{{1 */ |
162 | 162 | ||
163 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 163 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
164 | { | 164 | { |
165 | 165 | ||
166 | 166 | ||
167 | if (row != -1 && col != -1) { //just redraw one key | 167 | if (row != -1 && col != -1) { //just redraw one key |
168 | 168 | ||
169 | int x = 0; | 169 | int x = 0; |
170 | for (int i = 0; i < col; i++) { | 170 | for (int i = 0; i < col; i++) { |
171 | 171 | ||
172 | x += keys->width(row, i) * defaultKeyWidth; | 172 | x += keys->width(row, i) * defaultKeyWidth; |
173 | } | 173 | } |
174 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 174 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
175 | 175 | ||
176 | int keyWidth = keys->width(row, col); | 176 | int keyWidth = keys->width(row, col); |
177 | 177 | ||
178 | p.fillRect(x + 1, y + 1, | 178 | p.fillRect(x + 1, y + 1, |
179 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 179 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
180 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 180 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
181 | 181 | ||
182 | QImage *pix = keys->pix(row,col); | 182 | QImage *pix = keys->pix(row,col); |
183 | 183 | ||
184 | ushort c = keys->uni(row, col); | 184 | ushort c = keys->uni(row, col); |
185 | 185 | ||
186 | p.setPen(textcolor); | 186 | p.setPen(textcolor); |
187 | if (!pix) { | 187 | if (!pix) { |
188 | if ((shift || lock) && keys->shift(c)) | 188 | if ((shift || lock) && keys->shift(c)) |
189 | 189 | ||
190 | if (circumflex && keys->circumflex(keys->shift(c))) | 190 | if (circumflex && keys->circumflex(keys->shift(c))) |
191 | c = keys->circumflex(keys->shift(c)); | 191 | c = keys->circumflex(keys->shift(c)); |
192 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 192 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
193 | c = keys->diaeresis(keys->shift(c)); | 193 | c = keys->diaeresis(keys->shift(c)); |
194 | else if (baccent && keys->baccent(keys->shift(c))) | 194 | else if (baccent && keys->baccent(keys->shift(c))) |
195 | c = keys->baccent(keys->shift(c)); | 195 | c = keys->baccent(keys->shift(c)); |
196 | else if (accent && keys->accent(keys->shift(c))) | 196 | else if (accent && keys->accent(keys->shift(c))) |
197 | c = keys->accent(keys->shift(c)); | 197 | c = keys->accent(keys->shift(c)); |
198 | else if (meta && keys->meta(keys->shift(c))) | 198 | else if (meta && keys->meta(keys->shift(c))) |
199 | c = keys->meta(keys->shift(c)); | 199 | c = keys->meta(keys->shift(c)); |
200 | else | 200 | else |
201 | c = keys->shift(c); | 201 | c = keys->shift(c); |
202 | 202 | ||
203 | else if (meta && keys->meta(c)) | 203 | else if (meta && keys->meta(c)) |
204 | c = keys->meta(c); | 204 | c = keys->meta(c); |
205 | else if (circumflex && keys->circumflex(c)) | 205 | else if (circumflex && keys->circumflex(c)) |
206 | c = keys->circumflex(c); | 206 | c = keys->circumflex(c); |
207 | else if (baccent && keys->baccent(c)) | 207 | else if (baccent && keys->baccent(c)) |
208 | c = keys->baccent(c); | 208 | c = keys->baccent(c); |
209 | else if (accent && keys->accent(c)) | 209 | else if (accent && keys->accent(c)) |
210 | c = keys->accent(c); | 210 | c = keys->accent(c); |
211 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 211 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
212 | 212 | ||
213 | // the diaeresis key itself has to be in the diaeresisMap, | 213 | // the diaeresis key itself has to be in the diaeresisMap, |
214 | // or just do this to make it display the diaeresis char. | 214 | // or just do this to make it display the diaeresis char. |
215 | 215 | ||
216 | if (c == 0x2c6) | 216 | if (c == 0x2c6) |
217 | c = 0xa8; | 217 | c = 0xa8; |
218 | else | 218 | else |
219 | c = keys->diaeresis(c); | 219 | c = keys->diaeresis(c); |
220 | } | 220 | } |
221 | 221 | ||
222 | p.drawText(x, y, | 222 | p.drawText(x, y, |
223 | defaultKeyWidth * keyWidth + 3, keyHeight, | 223 | defaultKeyWidth * keyWidth + 3, keyHeight, |
224 | AlignCenter, (QChar)c); | 224 | AlignCenter, (QChar)c); |
225 | } | 225 | } |
226 | else | 226 | else |
227 | // center the image in the middle of the key | 227 | // center the image in the middle of the key |
228 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, | 228 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, |
229 | y + (keyHeight - pix->height())/2 + 1, | 229 | y + (keyHeight - pix->height())/2 + 1, |
230 | *pix ); | 230 | *pix ); |
231 | 231 | ||
232 | // this fixes the problem that the very right end of the board's vertical line | 232 | // this fixes the problem that the very right end of the board's vertical line |
233 | // gets painted over, because it's one pixel shorter than all other keys | 233 | // gets painted over, because it's one pixel shorter than all other keys |
234 | p.setPen(keycolor_lines); | 234 | p.setPen(keycolor_lines); |
235 | p.drawLine(width() - 1, 0, width() - 1, height()); | 235 | p.drawLine(width() - 1, 0, width() - 1, height()); |
236 | 236 | ||
237 | } else { | 237 | } else { |
238 | 238 | ||
239 | 239 | ||
240 | p.fillRect(0, 0, width(), height(), keycolor); | 240 | p.fillRect(0, 0, width(), height(), keycolor); |
241 | 241 | ||
242 | for (row = 1; row <= keys->rows(); row++) { | 242 | for (row = 1; row <= keys->rows(); row++) { |
243 | 243 | ||
244 | int x = 0; | 244 | int x = 0; |
245 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 245 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
246 | 246 | ||
247 | p.setPen(keycolor_lines); | 247 | p.setPen(keycolor_lines); |
248 | p.drawLine(x, y, x + width(), y); | 248 | p.drawLine(x, y, x + width(), y); |
249 | 249 | ||
250 | for (int col = 0; col < keys->numKeys(row); col++) { | 250 | for (int col = 0; col < keys->numKeys(row); col++) { |
251 | 251 | ||
252 | QImage *pix = keys->pix(row, col); | 252 | QImage *pix = keys->pix(row, col); |
253 | int keyWidth = keys->width(row, col); | 253 | int keyWidth = keys->width(row, col); |
254 | 254 | ||
255 | 255 | ||
256 | int keyWidthPix = defaultKeyWidth * keyWidth; | 256 | int keyWidthPix = defaultKeyWidth * keyWidth; |
257 | 257 | ||
258 | if (keys->pressed(row, col)) | 258 | if (keys->pressed(row, col)) |
259 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 259 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
260 | keyHeight - 1, keycolor_pressed); | 260 | keyHeight - 1, keycolor_pressed); |
261 | 261 | ||
262 | ushort c = keys->uni(row, col); | 262 | ushort c = keys->uni(row, col); |
263 | 263 | ||
264 | p.setPen(textcolor); | 264 | p.setPen(textcolor); |
265 | if (!pix) { | 265 | if (!pix) { |
266 | if ((shift || lock) && keys->shift(c)) | 266 | if ((shift || lock) && keys->shift(c)) |
267 | 267 | ||
268 | if (circumflex && keys->circumflex(keys->shift(c))) | 268 | if (circumflex && keys->circumflex(keys->shift(c))) |
269 | c = keys->circumflex(keys->shift(c)); | 269 | c = keys->circumflex(keys->shift(c)); |
270 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 270 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
271 | c = keys->diaeresis(keys->shift(c)); | 271 | c = keys->diaeresis(keys->shift(c)); |
272 | else if (baccent && keys->baccent(keys->shift(c))) | 272 | else if (baccent && keys->baccent(keys->shift(c))) |
273 | c = keys->baccent(keys->shift(c)); | 273 | c = keys->baccent(keys->shift(c)); |
274 | else if (accent && keys->accent(keys->shift(c))) | 274 | else if (accent && keys->accent(keys->shift(c))) |
275 | c = keys->accent(keys->shift(c)); | 275 | c = keys->accent(keys->shift(c)); |
276 | else if (meta && keys->meta(keys->shift(c))) | 276 | else if (meta && keys->meta(keys->shift(c))) |
277 | c = keys->meta(keys->shift(c)); | 277 | c = keys->meta(keys->shift(c)); |
278 | else | 278 | else |
279 | c = keys->shift(c); | 279 | c = keys->shift(c); |
280 | 280 | ||
281 | else if (meta && keys->meta(c)) | 281 | else if (meta && keys->meta(c)) |
282 | c = keys->meta(c); | 282 | c = keys->meta(c); |
283 | else if (circumflex && keys->circumflex(c)) | 283 | else if (circumflex && keys->circumflex(c)) |
284 | c = keys->circumflex(c); | 284 | c = keys->circumflex(c); |
285 | else if (baccent && keys->baccent(c)) | 285 | else if (baccent && keys->baccent(c)) |
286 | c = keys->baccent(c); | 286 | c = keys->baccent(c); |
287 | else if (accent && keys->accent(c)) | 287 | else if (accent && keys->accent(c)) |
288 | c = keys->accent(c); | 288 | c = keys->accent(c); |
289 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 289 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
290 | 290 | ||
291 | if (c == 0x2c6) | 291 | if (c == 0x2c6) |
292 | c = 0xa8; | 292 | c = 0xa8; |
293 | else | 293 | else |
294 | c = keys->diaeresis(c); | 294 | c = keys->diaeresis(c); |
295 | } | 295 | } |
296 | 296 | ||
297 | p.drawText(x, y, | 297 | p.drawText(x, y, |
298 | keyWidthPix + 3, keyHeight, | 298 | keyWidthPix + 3, keyHeight, |
299 | AlignCenter, (QChar)c); | 299 | AlignCenter, (QChar)c); |
300 | } | 300 | } |
301 | else { | 301 | else { |
302 | // center the image in the middle of the key | 302 | // center the image in the middle of the key |
303 | pix->setColor(1, textcolor.rgb()); | 303 | pix->setColor(1, textcolor.rgb()); |
304 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, | 304 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, |
305 | y + (keyHeight - pix->height())/2 + 1, | 305 | y + (keyHeight - pix->height())/2 + 1, |
306 | QImage(*pix) ); | 306 | QImage(*pix) ); |
307 | } | 307 | } |
308 | 308 | ||
309 | p.setPen(keycolor_lines); | 309 | p.setPen(keycolor_lines); |
310 | p.drawLine(x, y, x, y + keyHeight); | 310 | p.drawLine(x, y, x, y + keyHeight); |
311 | 311 | ||
312 | x += keyWidthPix; | 312 | x += keyWidthPix; |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | } | 316 | } |
317 | p.setPen(keycolor_lines); | 317 | p.setPen(keycolor_lines); |
318 | p.drawLine(0, height() - 1, width(), height() - 1); | 318 | p.drawLine(0, height() - 1, width(), height() - 1); |
319 | p.drawLine(width() - 1, 0, width() - 1, height()); | 319 | p.drawLine(width() - 1, 0, width() - 1, height()); |
320 | } | 320 | } |
321 | 321 | ||
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | /* Keyboard::mousePressEvent {{{1 */ | 325 | /* Keyboard::mousePressEvent {{{1 */ |
326 | void Keyboard::mousePressEvent(QMouseEvent *e) | 326 | void Keyboard::mousePressEvent(QMouseEvent *e) |
327 | { | 327 | { |
328 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 328 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
329 | if (row > 5) row = 5; | 329 | if (row > 5) row = 5; |
330 | 330 | ||
331 | // figure out the column | 331 | // figure out the column |
332 | int col = 0; | 332 | int col = 0; |
333 | for (int w = 0; e->x() >= w; col++) | 333 | for (int w = 0; e->x() >= w; col++) |
334 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 334 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
335 | w += keys->width(row,col) * defaultKeyWidth; | 335 | w += keys->width(row,col) * defaultKeyWidth; |
336 | else break; | 336 | else break; |
337 | 337 | ||
338 | if (col <= 0) return; | 338 | if (col <= 0) return; |
339 | 339 | ||
340 | col --; // rewind one... | 340 | col --; // rewind one... |
341 | 341 | ||
342 | qkeycode = keys->qcode(row, col); | 342 | qkeycode = keys->qcode(row, col); |
343 | unicode = keys->uni(row, col); | 343 | unicode = keys->uni(row, col); |
344 | 344 | ||
345 | // might need to repaint if two or more of the same keys. | 345 | // might need to repaint if two or more of the same keys. |
346 | // should be faster if just paint one key even though multiple keys exist. | 346 | // should be faster if just paint one key even though multiple keys exist. |
347 | bool need_repaint = FALSE; | 347 | bool need_repaint = FALSE; |
348 | 348 | ||
349 | // circumflex and diaeresis support | 349 | // circumflex and diaeresis support |
350 | // messy to have this here, but too hard to implement any other method | 350 | // messy to have this here, but too hard to implement any other method |
351 | if (unicode == 0x2c6) { | 351 | if (unicode == 0x2c6) { |
352 | 352 | ||
353 | unicode = 0; | 353 | unicode = 0; |
354 | if (shift || lock) { | 354 | if (shift || lock) { |
355 | 355 | ||
356 | // diaeresis | 356 | // diaeresis |
357 | qkeycode = 0x2001; | 357 | qkeycode = 0x2001; |
358 | } | 358 | } |
359 | else { | 359 | else { |
360 | 360 | ||
361 | // circumflex | 361 | // circumflex |
362 | qkeycode = 0x2000; | 362 | qkeycode = 0x2000; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | // Back accent character support | 366 | // Back accent character support |
367 | 367 | ||
368 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one | 368 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one |
369 | if (unicode == 0x2cb) { | 369 | if (unicode == 0x2cb) { |
370 | 370 | ||
371 | unicode = 0; | 371 | unicode = 0; |
372 | if (shift || lock) { | 372 | if (shift || lock) { |
373 | 373 | ||
374 | // circumblex | 374 | // circumblex |
375 | qkeycode = 0x2000; | 375 | qkeycode = 0x2000; |
376 | } | 376 | } |
377 | else { | 377 | else { |
378 | 378 | ||
379 | // back accent | 379 | // back accent |
380 | qkeycode = 0x2002; | 380 | qkeycode = 0x2002; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | // Accent character support | 384 | // Accent character support |
385 | 385 | ||
386 | if (unicode == 0x2ca) { | 386 | if (unicode == 0x2ca) { |
387 | 387 | ||
388 | unicode = 0; | 388 | unicode = 0; |
389 | if (shift || lock) { | 389 | if (shift || lock) { |
390 | 390 | ||
391 | // diaeresis | 391 | // diaeresis |
392 | qkeycode = 0x2001; | 392 | qkeycode = 0x2001; |
393 | } | 393 | } |
394 | else { | 394 | else { |
395 | 395 | ||
396 | // accent | 396 | // accent |
397 | qkeycode = 0x2003; | 397 | qkeycode = 0x2003; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | if (unicode == 0) { // either Qt char, or nothing | 402 | if (unicode == 0) { // either Qt char, or nothing |
403 | 403 | ||
404 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 404 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
405 | 405 | ||
406 | if ( configdlg ) { | 406 | if ( configdlg ) { |
407 | 407 | ||
408 | delete (ConfigDlg *) configdlg; | 408 | delete (ConfigDlg *) configdlg; |
409 | configdlg = 0; | 409 | configdlg = 0; |
410 | } | 410 | } |
411 | else { | 411 | else { |
412 | configdlg = new ConfigDlg (); | 412 | configdlg = new ConfigDlg (); |
413 | connect(configdlg, SIGNAL(setMapToDefault()), | 413 | connect(configdlg, SIGNAL(setMapToDefault()), |
414 | this, SLOT(setMapToDefault())); | 414 | this, SLOT(setMapToDefault())); |
415 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 415 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
416 | this, SLOT(setMapToFile(QString))); | 416 | this, SLOT(setMapToFile(QString))); |
417 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 417 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
418 | this, SLOT(togglePickboard(bool))); | 418 | this, SLOT(togglePickboard(bool))); |
419 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 419 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
420 | this, SLOT(toggleRepeat(bool))); | 420 | this, SLOT(toggleRepeat(bool))); |
421 | connect(configdlg, SIGNAL(reloadKeyboard()), | 421 | connect(configdlg, SIGNAL(reloadKeyboard()), |
422 | this, SLOT(reloadKeyboard())); | 422 | this, SLOT(reloadKeyboard())); |
423 | connect(configdlg, SIGNAL(configDlgClosed()), | 423 | connect(configdlg, SIGNAL(configDlgClosed()), |
424 | this, SLOT(cleanupConfigDlg())); | 424 | this, SLOT(cleanupConfigDlg())); |
425 | configdlg->showMaximized(); | 425 | configdlg->showMaximized(); |
426 | configdlg->show(); | 426 | configdlg->show(); |
427 | configdlg->raise(); | 427 | configdlg->raise(); |
428 | } | 428 | } |
429 | 429 | ||
430 | } else if (qkeycode == Qt::Key_Control) { | 430 | } else if (qkeycode == Qt::Key_Control) { |
431 | need_repaint = TRUE; | 431 | need_repaint = TRUE; |
432 | 432 | ||
433 | if (ctrl) { | 433 | if (ctrl) { |
434 | 434 | ||
435 | *ctrl = 0; | 435 | *ctrl = 0; |
436 | ctrl = 0; | 436 | ctrl = 0; |
437 | 437 | ||
438 | } else { | 438 | } else { |
439 | 439 | ||
440 | ctrl = keys->pressedPtr(row, col); | 440 | ctrl = keys->pressedPtr(row, col); |
441 | need_repaint = TRUE; | 441 | need_repaint = TRUE; |
442 | *ctrl = !keys->pressed(row, col); | 442 | *ctrl = !keys->pressed(row, col); |
443 | 443 | ||
444 | } | 444 | } |
445 | 445 | ||
446 | } else if (qkeycode == Qt::Key_Alt) { | 446 | } else if (qkeycode == Qt::Key_Alt) { |
447 | need_repaint = TRUE; | 447 | need_repaint = TRUE; |
448 | 448 | ||
449 | if (alt) { | 449 | if (alt) { |
450 | *alt = 0; | 450 | *alt = 0; |
451 | alt = 0; | 451 | alt = 0; |
452 | 452 | ||
453 | } else { | 453 | } else { |
454 | 454 | ||
455 | alt = keys->pressedPtr(row, col); | 455 | alt = keys->pressedPtr(row, col); |
456 | need_repaint = TRUE; | 456 | need_repaint = TRUE; |
457 | *alt = !keys->pressed(row, col); | 457 | *alt = !keys->pressed(row, col); |
458 | } | 458 | } |
459 | 459 | ||
460 | } else if (qkeycode == Qt::Key_Shift) { | 460 | } else if (qkeycode == Qt::Key_Shift) { |
461 | need_repaint = TRUE; | 461 | need_repaint = TRUE; |
462 | 462 | ||
463 | if (shift) { | 463 | if (shift) { |
464 | *shift = 0; | 464 | *shift = 0; |
465 | shift = 0; | 465 | shift = 0; |
466 | } | 466 | } |
467 | else { | 467 | else { |
468 | shift = keys->pressedPtr(row, col); | 468 | shift = keys->pressedPtr(row, col); |
469 | *shift = 1; | 469 | *shift = 1; |
470 | if (lock) { | 470 | if (lock) { |
471 | *lock = 0; | 471 | *lock = 0; |
472 | lock = 0; | 472 | lock = 0; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | 476 | ||
477 | /* | 477 | /* |
478 | * want to be able to hit circumflex/diaeresis -> shift | 478 | * want to be able to hit circumflex/diaeresis -> shift |
479 | * to type in shifted circumflex/diaeresis chars. | 479 | * to type in shifted circumflex/diaeresis chars. |
480 | * same thing with meta | 480 | * same thing with meta |
481 | 481 | ||
482 | if (meta) { *meta = 0; meta = 0; } | 482 | if (meta) { *meta = 0; meta = 0; } |
483 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 483 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
484 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 484 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
485 | 485 | ||
486 | */ | 486 | */ |
487 | 487 | ||
488 | } else if (qkeycode == Qt::Key_CapsLock) { | 488 | } else if (qkeycode == Qt::Key_CapsLock) { |
489 | need_repaint = TRUE; | 489 | need_repaint = TRUE; |
490 | 490 | ||
491 | if (lock) { | 491 | if (lock) { |
492 | *lock = 0; | 492 | *lock = 0; |
493 | lock = 0; | 493 | lock = 0; |
494 | } | 494 | } |
495 | else { | 495 | else { |
496 | lock = keys->pressedPtr(row, col);; | 496 | lock = keys->pressedPtr(row, col);; |
497 | *lock = true;; | 497 | *lock = true;; |
498 | if (shift) { | 498 | if (shift) { |
499 | *shift = 0; | 499 | *shift = 0; |
500 | shift = 0; | 500 | shift = 0; |
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | /* | 504 | /* |
505 | if (meta) { *meta = 0; meta = 0; } | 505 | if (meta) { *meta = 0; meta = 0; } |
506 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 506 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
507 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 507 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
508 | */ | 508 | */ |
509 | 509 | ||
510 | } else if (qkeycode == Qt::Key_Meta) { | 510 | } else if (qkeycode == Qt::Key_Meta) { |
511 | need_repaint = TRUE; | 511 | need_repaint = TRUE; |
512 | 512 | ||
513 | if (meta) { | 513 | if (meta) { |
514 | *meta = 0; | 514 | *meta = 0; |
515 | meta = 0; | 515 | meta = 0; |
516 | 516 | ||
517 | } else { | 517 | } else { |
518 | 518 | ||
519 | meta = keys->pressedPtr(row, col); | 519 | meta = keys->pressedPtr(row, col); |
520 | *meta = true; | 520 | *meta = true; |
521 | } | 521 | } |
522 | 522 | ||
523 | // reset all the other keys | 523 | // reset all the other keys |
524 | if (shift) { *shift = 0; shift = 0; } | 524 | if (shift) { *shift = 0; shift = 0; } |
525 | if (lock) { *lock = 0; lock = 0; } | 525 | if (lock) { *lock = 0; lock = 0; } |
526 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 526 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
527 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 527 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
528 | if (baccent) { *baccent = 0; baccent = 0; } | 528 | if (baccent) { *baccent = 0; baccent = 0; } |
529 | if (accent) { *accent = 0; accent = 0; } | 529 | if (accent) { *accent = 0; accent = 0; } |
530 | 530 | ||
531 | // dont need to emit this key... acts same as alt | 531 | // dont need to emit this key... acts same as alt |
532 | qkeycode = 0; | 532 | qkeycode = 0; |
533 | 533 | ||
534 | // circumflex | 534 | // circumflex |
535 | } else if (qkeycode == 0x2000) { | 535 | } else if (qkeycode == 0x2000) { |
536 | need_repaint = TRUE; | 536 | need_repaint = TRUE; |
537 | 537 | ||
538 | if (circumflex) { | 538 | if (circumflex) { |
539 | 539 | ||
540 | *circumflex = 0; | 540 | *circumflex = 0; |
541 | circumflex = 0; | 541 | circumflex = 0; |
542 | 542 | ||
543 | } else { | 543 | } else { |
544 | 544 | ||
545 | circumflex = keys->pressedPtr(row, col); | 545 | circumflex = keys->pressedPtr(row, col); |
546 | *circumflex = true; | 546 | *circumflex = true; |
547 | } | 547 | } |
548 | 548 | ||
549 | /* no need to turn off shift or lock if circumflex | 549 | /* no need to turn off shift or lock if circumflex |
550 | * keys are pressed | 550 | * keys are pressed |
551 | 551 | ||
552 | if (shift) { *shift = 0; shift = 0; } | 552 | if (shift) { *shift = 0; shift = 0; } |
553 | if (lock) { *lock = 0; lock = 0; } | 553 | if (lock) { *lock = 0; lock = 0; } |
554 | 554 | ||
555 | */ | 555 | */ |
556 | 556 | ||
557 | // have to reset all the other keys | 557 | // have to reset all the other keys |
558 | if (meta) { *meta = 0; meta = 0; } | 558 | if (meta) { *meta = 0; meta = 0; } |
559 | if (diaeresis) { | 559 | if (diaeresis) { |
560 | 560 | ||
561 | // *diaeresis and *circumflex point to the same thing | 561 | // *diaeresis and *circumflex point to the same thing |
562 | // when diaeresis is enabled and you hit the circumflex | 562 | // when diaeresis is enabled and you hit the circumflex |
563 | // since they are the same key, it should turn off the | 563 | // since they are the same key, it should turn off the |
564 | // key | 564 | // key |
565 | 565 | ||
566 | *diaeresis = 0; | 566 | *diaeresis = 0; |
567 | diaeresis = 0; | 567 | diaeresis = 0; |
568 | circumflex = 0; | 568 | circumflex = 0; |
569 | } | 569 | } |
570 | 570 | ||
571 | qkeycode = 0; | 571 | qkeycode = 0; |
572 | 572 | ||
573 | // diaeresis | 573 | // diaeresis |
574 | } else if (qkeycode == 0x2001) { | 574 | } else if (qkeycode == 0x2001) { |
575 | need_repaint = TRUE; | 575 | need_repaint = TRUE; |
576 | 576 | ||
577 | if (diaeresis) { | 577 | if (diaeresis) { |
578 | 578 | ||
579 | *diaeresis = 0; | 579 | *diaeresis = 0; |
580 | diaeresis = 0; | 580 | diaeresis = 0; |
581 | 581 | ||
582 | } else { | 582 | } else { |
583 | 583 | ||
584 | diaeresis = keys->pressedPtr(row, col); | 584 | diaeresis = keys->pressedPtr(row, col); |
585 | *diaeresis = true; | 585 | *diaeresis = true; |
586 | } | 586 | } |
587 | 587 | ||
588 | 588 | ||
589 | if (shift) { *shift = 0; shift = 0; } | 589 | if (shift) { *shift = 0; shift = 0; } |
590 | 590 | ||
591 | /* | 591 | /* |
592 | * | 592 | * |
593 | if (lock) { *lock = 0; lock = 0; } | 593 | if (lock) { *lock = 0; lock = 0; } |
594 | * | 594 | * |
595 | */ | 595 | */ |
596 | 596 | ||
597 | if (meta) { *meta = 0; meta = 0; } | 597 | if (meta) { *meta = 0; meta = 0; } |
598 | if (circumflex) { | 598 | if (circumflex) { |
599 | 599 | ||
600 | // *circumflex = 0; | 600 | // *circumflex = 0; |
601 | // | 601 | // |
602 | // same thing the diaeresis pointer points too | 602 | // same thing the diaeresis pointer points too |
603 | 603 | ||
604 | circumflex = 0; | 604 | circumflex = 0; |
605 | } | 605 | } |
606 | 606 | ||
607 | 607 | ||
608 | qkeycode = 0; | 608 | qkeycode = 0; |
609 | 609 | ||
610 | // Back accent | 610 | // Back accent |
611 | } else if (qkeycode == 0x2002) { | 611 | } else if (qkeycode == 0x2002) { |
612 | need_repaint = TRUE; | 612 | need_repaint = TRUE; |
613 | 613 | ||
614 | if (baccent) { | 614 | if (baccent) { |
615 | 615 | ||
616 | *baccent = 0; | 616 | *baccent = 0; |
617 | baccent = 0; | 617 | baccent = 0; |
618 | 618 | ||
619 | } else { | 619 | } else { |
620 | 620 | ||
621 | baccent = keys->pressedPtr(row, col); | 621 | baccent = keys->pressedPtr(row, col); |
622 | *baccent = true; | 622 | *baccent = true; |
623 | } | 623 | } |
624 | 624 | ||
625 | 625 | ||
626 | if (shift) { *shift = 0; shift = 0; } | 626 | if (shift) { *shift = 0; shift = 0; } |
627 | if (meta) { *meta = 0; meta = 0; } | 627 | if (meta) { *meta = 0; meta = 0; } |
628 | if (accent) { *accent = 0; accent = 0; } | 628 | if (accent) { *accent = 0; accent = 0; } |
629 | 629 | ||
630 | qkeycode = 0; | 630 | qkeycode = 0; |
631 | 631 | ||
632 | // Accent | 632 | // Accent |
633 | } else if (qkeycode == 0x2003) { | 633 | } else if (qkeycode == 0x2003) { |
634 | need_repaint = TRUE; | 634 | need_repaint = TRUE; |
635 | 635 | ||
636 | if (accent) { | 636 | if (accent) { |
637 | 637 | ||
638 | *accent = 0; | 638 | *accent = 0; |
639 | accent = 0; | 639 | accent = 0; |
640 | 640 | ||
641 | } else { | 641 | } else { |
642 | 642 | ||
643 | accent = keys->pressedPtr(row, col); | 643 | accent = keys->pressedPtr(row, col); |
644 | *accent = true; | 644 | *accent = true; |
645 | } | 645 | } |
646 | 646 | ||
647 | 647 | ||
648 | if (shift) { *shift = 0; shift = 0; } | 648 | if (shift) { *shift = 0; shift = 0; } |
649 | if (meta) { *meta = 0; meta = 0; } | 649 | if (meta) { *meta = 0; meta = 0; } |
650 | if (baccent) { *baccent = 0; } | 650 | if (baccent) { *baccent = 0; } |
651 | 651 | ||
652 | qkeycode = 0; | 652 | qkeycode = 0; |
653 | } | 653 | } |
654 | 654 | ||
655 | } | 655 | } |
656 | else { // normal char | 656 | else { // normal char |
657 | if ((shift || lock) && keys->shift(unicode)) { | 657 | if ((shift || lock) && keys->shift(unicode)) { |
658 | 658 | ||
659 | // make diaeresis/circumflex -> shift input shifted | 659 | // make diaeresis/circumflex -> shift input shifted |
660 | // diaeresis/circumflex chars | 660 | // diaeresis/circumflex chars |
661 | 661 | ||
662 | if (circumflex && keys->circumflex(keys->shift(unicode))) | 662 | if (circumflex && keys->circumflex(keys->shift(unicode))) |
663 | unicode = keys->circumflex(keys->shift(unicode)); | 663 | unicode = keys->circumflex(keys->shift(unicode)); |
664 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) | 664 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) |
665 | unicode = keys->diaeresis(keys->shift(unicode)); | 665 | unicode = keys->diaeresis(keys->shift(unicode)); |
666 | else if (baccent && keys->baccent(keys->shift(unicode))) | 666 | else if (baccent && keys->baccent(keys->shift(unicode))) |
667 | unicode = keys->baccent(keys->shift(unicode)); | 667 | unicode = keys->baccent(keys->shift(unicode)); |
668 | else if (accent && keys->accent(keys->shift(unicode))) | 668 | else if (accent && keys->accent(keys->shift(unicode))) |
669 | unicode = keys->accent(keys->shift(unicode)); | 669 | unicode = keys->accent(keys->shift(unicode)); |
670 | else if (meta && keys->meta(keys->shift(unicode))) | 670 | else if (meta && keys->meta(keys->shift(unicode))) |
671 | unicode = keys->meta(keys->shift(unicode)); | 671 | unicode = keys->meta(keys->shift(unicode)); |
672 | else | 672 | else |
673 | unicode = keys->shift(unicode); | 673 | unicode = keys->shift(unicode); |
674 | } | 674 | } |
675 | else if (meta && keys->meta(unicode)) { | 675 | else if (meta && keys->meta(unicode)) { |
676 | unicode = keys->meta(unicode); | 676 | unicode = keys->meta(unicode); |
677 | } | 677 | } |
678 | else if (circumflex && keys->circumflex(unicode)) { | 678 | else if (circumflex && keys->circumflex(unicode)) { |
679 | unicode = keys->circumflex(unicode); | 679 | unicode = keys->circumflex(unicode); |
680 | } | 680 | } |
681 | else if (diaeresis && keys->diaeresis(unicode)) { | 681 | else if (diaeresis && keys->diaeresis(unicode)) { |
682 | 682 | ||
683 | unicode = keys->diaeresis(unicode); | 683 | unicode = keys->diaeresis(unicode); |
684 | } | 684 | } |
685 | else if (baccent && keys->baccent(unicode)) { | 685 | else if (baccent && keys->baccent(unicode)) { |
686 | unicode = keys->baccent(unicode); | 686 | unicode = keys->baccent(unicode); |
687 | } | 687 | } |
688 | else if (accent && keys->accent(unicode)) { | 688 | else if (accent && keys->accent(unicode)) { |
689 | unicode = keys->accent(unicode); | 689 | unicode = keys->accent(unicode); |
690 | } | 690 | } |
691 | } | 691 | } |
692 | 692 | ||
693 | // korean parsing | 693 | // korean parsing |
694 | if (keys->lang == "ko") { | 694 | if (keys->lang == "ko") { |
695 | 695 | ||
696 | unicode = parseKoreanInput(unicode); | 696 | unicode = parseKoreanInput(unicode); |
697 | } | 697 | } |
698 | 698 | ||
699 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 699 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
700 | 700 | ||
701 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 701 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
702 | 702 | ||
703 | qkeycode = QChar(unicode).upper(); | 703 | qkeycode = QChar(unicode).upper(); |
704 | unicode = qkeycode - '@'; | 704 | unicode = qkeycode - '@'; |
705 | } | 705 | } |
706 | 706 | ||
707 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 707 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
708 | 708 | ||
709 | // pickboard stuff | 709 | // pickboard stuff |
710 | if (usePicks) { | 710 | if (usePicks) { |
711 | 711 | ||
712 | KeyboardConfig *dc = picks->dc; | 712 | KeyboardConfig *dc = picks->dc; |
713 | 713 | ||
714 | if (dc) { | 714 | if (dc) { |
715 | if (qkeycode == Qt::Key_Backspace) { | 715 | if (qkeycode == Qt::Key_Backspace) { |
716 | dc->input.remove(dc->input.last()); // remove last input | 716 | dc->input.remove(dc->input.last()); // remove last input |
717 | dc->decBackspaces(); | 717 | dc->decBackspaces(); |
718 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 718 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
719 | dc->input.clear(); | 719 | dc->input.clear(); |
720 | dc->resetBackspaces(); | 720 | dc->resetBackspaces(); |
721 | } else { | 721 | } else { |
722 | dc->add(QString(QChar(unicode))); | 722 | dc->add(QString(QChar(unicode))); |
723 | dc->incBackspaces(); | 723 | dc->incBackspaces(); |
724 | } | 724 | } |
725 | } | 725 | } |
726 | picks->repaint(); | 726 | picks->repaint(); |
727 | } | 727 | } |
728 | 728 | ||
729 | 729 | ||
730 | // painting | 730 | // painting |
731 | pressed = TRUE; | 731 | pressed = TRUE; |
732 | 732 | ||
733 | pressedKeyRow = row; | 733 | pressedKeyRow = row; |
734 | pressedKeyCol = col; | 734 | pressedKeyCol = col; |
735 | 735 | ||
736 | if (need_repaint) repaint(FALSE); | 736 | if (need_repaint) repaint(FALSE); |
737 | else { // just paint the one key pressed | 737 | else { // just paint the one key pressed |
738 | 738 | ||
739 | 739 | ||
740 | 740 | ||
741 | QPainter p(this); | 741 | QPainter p(this); |
742 | drawKeyboard(p, row, col); | 742 | drawKeyboard(p, row, col); |
743 | 743 | ||
744 | } | 744 | } |
745 | 745 | ||
746 | if (useRepeat) repeatTimer->start( 800 ); | 746 | if (useRepeat) repeatTimer->start( 800 ); |
747 | //pressTid = startTimer(80); | 747 | //pressTid = startTimer(80); |
748 | 748 | ||
749 | } | 749 | } |
750 | 750 | ||
751 | 751 | ||
752 | /* Keyboard::mouseReleaseEvent {{{1 */ | 752 | /* Keyboard::mouseReleaseEvent {{{1 */ |
753 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 753 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
754 | { | 754 | { |
755 | pressed = FALSE; | 755 | pressed = FALSE; |
756 | //if ( pressTid == 0 ) | 756 | //if ( pressTid == 0 ) |
757 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 757 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
758 | if ( unicode != -1 ) { | 758 | if ( unicode != -1 ) { |
759 | emit key( unicode, qkeycode, modifiers, false, false ); | 759 | emit key( unicode, qkeycode, modifiers, false, false ); |
760 | repeatTimer->stop(); | 760 | repeatTimer->stop(); |
761 | } | 761 | } |
762 | #endif | 762 | #endif |
763 | if (shift && unicode != 0) { | 763 | if (shift && unicode != 0) { |
764 | 764 | ||
765 | 765 | ||
766 | *shift = 0; // unpress shift key | 766 | *shift = 0; // unpress shift key |
767 | shift = 0; // reset the shift pointer | 767 | shift = 0; // reset the shift pointer |
768 | repaint(FALSE); | 768 | repaint(FALSE); |
769 | 769 | ||
770 | } | 770 | } |
771 | if (ctrl && unicode != 0) { | 771 | if (ctrl && unicode != 0) { |
772 | 772 | ||
773 | *ctrl = 0; | 773 | *ctrl = 0; |
774 | ctrl = 0; | 774 | ctrl = 0; |
775 | repaint(FALSE); | 775 | repaint(FALSE); |
776 | 776 | ||
777 | } | 777 | } |
778 | if (alt && alt != 0) { | 778 | if (alt && alt != 0) { |
779 | 779 | ||
780 | *alt = 0; | 780 | *alt = 0; |
781 | alt = 0; | 781 | alt = 0; |
782 | repaint(FALSE); | 782 | repaint(FALSE); |
783 | 783 | ||
784 | } | 784 | } |
785 | 785 | ||
786 | /* | 786 | /* |
787 | * do not make the meta key release after being pressed | 787 | * do not make the meta key release after being pressed |
788 | * | 788 | * |
789 | 789 | ||
790 | else if (meta && unicode != 0) { | 790 | else if (meta && unicode != 0) { |
791 | 791 | ||
792 | *meta = 0; | 792 | *meta = 0; |
793 | meta = 0; | 793 | meta = 0; |
794 | repaint(FALSE); | 794 | repaint(FALSE); |
795 | } | 795 | } |
796 | 796 | ||
797 | */ | 797 | */ |
798 | 798 | ||
799 | else clearHighlight(); | 799 | else clearHighlight(); |
800 | } | 800 | } |
801 | 801 | ||
802 | /* Keyboard::timerEvent {{{1 */ | 802 | /* Keyboard::timerEvent {{{1 */ |
803 | 803 | ||
804 | /* dont know what this does, but i think it is here so that if your screen | 804 | /* dont know what this does, but i think it is here so that if your screen |
805 | * sticks (like on an ipaq) then it will stop repeating if you click another | 805 | * sticks (like on an ipaq) then it will stop repeating if you click another |
806 | * key... but who knows what anything does in this thing anyway? | 806 | * key... but who knows what anything does in this thing anyway? |
807 | 807 | ||
808 | void Keyboard::timerEvent(QTimerEvent* e) | 808 | void Keyboard::timerEvent(QTimerEvent* e) |
809 | { | 809 | { |
810 | if ( e->timerId() == pressTid ) { | 810 | if ( e->timerId() == pressTid ) { |
811 | killTimer(pressTid); | 811 | killTimer(pressTid); |
812 | pressTid = 0; | 812 | pressTid = 0; |
813 | if ( !pressed ) | 813 | if ( !pressed ) |
814 | cout << "calling clearHighlight from timerEvent\n"; | 814 | cout << "calling clearHighlight from timerEvent\n"; |
815 | //clearHighlight(); | 815 | //clearHighlight(); |
816 | } | 816 | } |
817 | } | 817 | } |
818 | */ | 818 | */ |
819 | 819 | ||
820 | void Keyboard::repeat() | 820 | void Keyboard::repeat() |
821 | { | 821 | { |
822 | 822 | ||
823 | repeatTimer->start( 200 ); | 823 | repeatTimer->start( 200 ); |
824 | emit key( unicode, qkeycode, modifiers, true, true ); | 824 | emit key( unicode, qkeycode, modifiers, true, true ); |