-rw-r--r-- | inputmethods/handwriting/qimpenhelp.cpp | 12 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpeninput.cpp | 24 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpensetup.cpp | 12 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 4 |
4 files changed, 26 insertions, 26 deletions
diff --git a/inputmethods/handwriting/qimpenhelp.cpp b/inputmethods/handwriting/qimpenhelp.cpp index a294301..0727931 100644 --- a/inputmethods/handwriting/qimpenhelp.cpp +++ b/inputmethods/handwriting/qimpenhelp.cpp | |||
@@ -1,411 +1,411 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qimpenwidget.h" | 21 | #include "qimpenwidget.h" |
22 | #include "qimpencombining.h" | 22 | #include "qimpencombining.h" |
23 | #include "qimpenmatch.h" | 23 | #include "qimpenmatch.h" |
24 | #include "qimpenhelp.h" | 24 | #include "qimpenhelp.h" |
25 | 25 | ||
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/stringutil.h> | 29 | #include <qpe/stringutil.h> |
30 | 30 | ||
31 | #include <qtextview.h> | 31 | #include <qtextview.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qlistbox.h> | 33 | #include <qlistbox.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | 39 | ||
40 | /* XPM */ | 40 | /* XPM */ |
41 | static const char * const left_xpm[] = { | 41 | static const char * const left_xpm[] = { |
42 | "16 16 2 1", | 42 | "16 16 2 1", |
43 | " c None", | 43 | " c None", |
44 | ". c #000000", | 44 | ". c #000000", |
45 | " ", | 45 | " ", |
46 | " ", | 46 | " ", |
47 | " ", | 47 | " ", |
48 | " . ", | 48 | " . ", |
49 | " .. ", | 49 | " .. ", |
50 | " ... ", | 50 | " ... ", |
51 | " .... ", | 51 | " .... ", |
52 | " ..... ", | 52 | " ..... ", |
53 | " ...... ", | 53 | " ...... ", |
54 | " ..... ", | 54 | " ..... ", |
55 | " .... ", | 55 | " .... ", |
56 | " ... ", | 56 | " ... ", |
57 | " .. ", | 57 | " .. ", |
58 | " . ", | 58 | " . ", |
59 | " ", | 59 | " ", |
60 | " "}; | 60 | " "}; |
61 | 61 | ||
62 | 62 | ||
63 | /* XPM */ | 63 | /* XPM */ |
64 | static const char * const right_xpm[] = { | 64 | static const char * const right_xpm[] = { |
65 | "16 16 2 1", | 65 | "16 16 2 1", |
66 | " c None", | 66 | " c None", |
67 | ". c #000000", | 67 | ". c #000000", |
68 | " ", | 68 | " ", |
69 | " ", | 69 | " ", |
70 | " ", | 70 | " ", |
71 | " . ", | 71 | " . ", |
72 | " .. ", | 72 | " .. ", |
73 | " ... ", | 73 | " ... ", |
74 | " .... ", | 74 | " .... ", |
75 | " ..... ", | 75 | " ..... ", |
76 | " ...... ", | 76 | " ...... ", |
77 | " ..... ", | 77 | " ..... ", |
78 | " .... ", | 78 | " .... ", |
79 | " ... ", | 79 | " ... ", |
80 | " .. ", | 80 | " .. ", |
81 | " . ", | 81 | " . ", |
82 | " ", | 82 | " ", |
83 | " "}; | 83 | " "}; |
84 | 84 | ||
85 | class CharListItem : public QListBoxText | 85 | class CharListItem : public QListBoxText |
86 | { | 86 | { |
87 | public: | 87 | public: |
88 | CharListItem( const QString &text, uint c ) | 88 | CharListItem( const QString &text, uint c ) |
89 | : QListBoxText( text ) | 89 | : QListBoxText( text ) |
90 | { | 90 | { |
91 | _code = c; | 91 | _code = c; |
92 | } | 92 | } |
93 | 93 | ||
94 | uint code() const { return _code; } | 94 | uint code() const { return _code; } |
95 | 95 | ||
96 | protected: | 96 | protected: |
97 | uint _code; | 97 | uint _code; |
98 | }; | 98 | }; |
99 | 99 | ||
100 | HandwritingHelp::HandwritingHelp( QIMPenProfile *p, QWidget *parent, const char *name, WFlags f ) | 100 | HandwritingHelp::HandwritingHelp( QIMPenProfile *p, QWidget *parent, const char *name, WFlags f ) |
101 | : QTabWidget( parent, name, f ) | 101 | : QTabWidget( parent, name, f ) |
102 | { | 102 | { |
103 | setCaption( tr("Handwriting Help") ); | 103 | setCaption( tr("Handwriting Help") ); |
104 | QTextView *help = new QTextView( this ); | 104 | QTextView *help = new QTextView( this ); |
105 | help->setFrameStyle( QFrame::NoFrame ); | 105 | help->setFrameStyle( QFrame::NoFrame ); |
106 | help->setText( | 106 | help->setText( |
107 | tr( "<ul><li>When you start to use the handwriting recogniser " | 107 | tr( "<ul><li>When you start to use the handwriting recogniser " |
108 | "write slowly, accurately and firmly." | 108 | "write slowly, accurately and firmly." |
109 | "<li>Use the guide lines when drawing your characters." | 109 | "<li>Use the guide lines when drawing your characters." |
110 | "<li>When drawing a character with multiple strokes, each " | 110 | "<li>When drawing a character with multiple strokes, each " |
111 | "successive stroke must be drawn before the grayed strokes are erased." | 111 | "successive stroke must be drawn before the grayed strokes are erased." |
112 | "<li>Practice your handwriting using the handwriting trainer." | 112 | "<li>Practice your handwriting using the handwriting trainer." |
113 | "<li>When adding your own character templates make sure they " | 113 | "<li>When adding your own character templates make sure they " |
114 | "are sufficiently different from other characters' templates." | 114 | "are sufficiently different from other characters' templates." |
115 | "</ul>") ); | 115 | "</ul>") ); |
116 | 116 | ||
117 | addTab( help, tr("Tips") ); | 117 | addTab( help, tr("Tips") ); |
118 | 118 | ||
119 | HandwritingTrainer *trainer = new HandwritingTrainer( p, this ); | 119 | HandwritingTrainer *trainer = new HandwritingTrainer( p, this ); |
120 | addTab( trainer, tr("Trainer") ); | 120 | addTab( trainer, tr("Trainer") ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void HandwritingHelp::showEvent( QShowEvent * ) | 123 | void HandwritingHelp::showEvent( QShowEvent * ) |
124 | { | 124 | { |
125 | Global::hideInputMethod(); | 125 | Global::hideInputMethod(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void HandwritingHelp::hideEvent( QHideEvent * ) | 128 | void HandwritingHelp::hideEvent( QHideEvent * ) |
129 | { | 129 | { |
130 | Global::showInputMethod(); | 130 | Global::showInputMethod(); |
131 | } | 131 | } |
132 | 132 | ||
133 | //--------------------------------------------------------------------------- | 133 | //--------------------------------------------------------------------------- |
134 | 134 | ||
135 | HandwritingTrainer::HandwritingTrainer( QIMPenProfile *p, QWidget *parent, const char *name ) | 135 | HandwritingTrainer::HandwritingTrainer( QIMPenProfile *p, QWidget *parent, const char *name ) |
136 | : QWidget( parent, name ), profile(p) | 136 | : QWidget( parent, name ), profile(p) |
137 | { | 137 | { |
138 | QGridLayout *gl = new QGridLayout( this, 4, 2, 0, 4 ); | 138 | QGridLayout *gl = new QGridLayout( this, 4, 2, 0, 4 ); |
139 | gl->setColStretch( 1, 1 ); | 139 | gl->setColStretch( 1, 1 ); |
140 | gl->setRowStretch(3, 1); | 140 | gl->setRowStretch(3, 1); |
141 | 141 | ||
142 | charSetCombo = new QComboBox( this ); | 142 | charSetCombo = new QComboBox( this ); |
143 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); | 143 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); |
144 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); | 144 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); |
145 | QIMPenCharSetIterator it( profile->charSets() ); | 145 | QIMPenCharSetIterator it( profile->charSets() ); |
146 | for ( ; it.current(); ++it ) { | 146 | for ( ; it.current(); ++it ) { |
147 | charSetCombo->insertItem( it.current()->description() ); | 147 | charSetCombo->insertItem( it.current()->description() ); |
148 | } | 148 | } |
149 | 149 | ||
150 | charList = new QListBox( this ); | 150 | charList = new QListBox( this ); |
151 | charList->setHScrollBarMode( QListBox::AlwaysOff ); | 151 | charList->setHScrollBarMode( QListBox::AlwaysOff ); |
152 | charList->setFixedWidth(80); | 152 | charList->setFixedWidth(80); |
153 | connect( charList, SIGNAL(highlighted(int)), this, SLOT(selectChar(int)) ); | 153 | connect( charList, SIGNAL(highlighted(int)), this, SLOT(selectChar(int)) ); |
154 | gl->addWidget(charList, 1, 0); | 154 | gl->addWidget(charList, 1, 0); |
155 | 155 | ||
156 | result = new QLabel( this ); | 156 | result = new QLabel( this ); |
157 | result->setAlignment(AlignLeft | AlignVCenter | WordBreak); | 157 | result->setAlignment(AlignLeft | AlignVCenter | WordBreak); |
158 | result->setText( | 158 | result->setText( |
159 | tr( "Select a reference character from the list. Practice writing in " | 159 | tr( "Select a reference character from the list. Practice writing in " |
160 | "the area on the right.")); | 160 | "the area on the right.")); |
161 | gl->addMultiCellWidget(result, 1, 2, 1, 1); | 161 | gl->addMultiCellWidget(result, 1, 2, 1, 1); |
162 | 162 | ||
163 | matcher = new QIMPenMatch( this ); | 163 | matcher = new QIMPenMatch( this ); |
164 | matcher->setCharSet( currentSet ); | 164 | matcher->setCharSet( currentSet ); |
165 | connect( matcher, SIGNAL(noMatch()), this, SLOT(noMatch()) ); | 165 | connect( matcher, SIGNAL(noMatch()), this, SLOT(noMatch()) ); |
166 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList &)), | 166 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList&)), |
167 | this, SLOT(matched(const QIMPenCharMatchList &)) ); | 167 | this, SLOT(matched(const QIMPenCharMatchList&)) ); |
168 | 168 | ||
169 | QHBoxLayout *hb = new QHBoxLayout(); | 169 | QHBoxLayout *hb = new QHBoxLayout(); |
170 | gl->addLayout( hb, 2, 0 ); | 170 | gl->addLayout( hb, 2, 0 ); |
171 | prevBtn = new QPushButton( this ); | 171 | prevBtn = new QPushButton( this ); |
172 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); | 172 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); |
173 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); | 173 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); |
174 | hb->addWidget( prevBtn ); | 174 | hb->addWidget( prevBtn ); |
175 | 175 | ||
176 | nextBtn = new QPushButton( this ); | 176 | nextBtn = new QPushButton( this ); |
177 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); | 177 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); |
178 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); | 178 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); |
179 | hb->addWidget( nextBtn ); | 179 | hb->addWidget( nextBtn ); |
180 | 180 | ||
181 | refPw = new QIMPenWidget( this ); | 181 | refPw = new QIMPenWidget( this ); |
182 | refPw->setReadOnly( TRUE ); | 182 | refPw->setReadOnly( TRUE ); |
183 | gl->addWidget( refPw, 3, 0 ); | 183 | gl->addWidget( refPw, 3, 0 ); |
184 | 184 | ||
185 | pracPw = new QIMPenWidget( this ); | 185 | pracPw = new QIMPenWidget( this ); |
186 | connect( matcher, SIGNAL(removeStroke()), pracPw, SLOT(removeStroke()) ); | 186 | connect( matcher, SIGNAL(removeStroke()), pracPw, SLOT(removeStroke()) ); |
187 | connect( pracPw, SIGNAL(beginStroke()), | 187 | connect( pracPw, SIGNAL(beginStroke()), |
188 | this, SLOT(beginStroke()) ); | 188 | this, SLOT(beginStroke()) ); |
189 | connect( pracPw, SIGNAL(stroke( QIMPenStroke * )), | 189 | connect( pracPw, SIGNAL(stroke(QIMPenStroke*)), |
190 | this, SLOT(strokeEntered( QIMPenStroke * )) ); | 190 | this, SLOT(strokeEntered(QIMPenStroke*)) ); |
191 | connect( pracPw, SIGNAL(beginStroke()), | 191 | connect( pracPw, SIGNAL(beginStroke()), |
192 | matcher, SLOT(beginStroke()) ); | 192 | matcher, SLOT(beginStroke()) ); |
193 | connect( pracPw, SIGNAL(stroke( QIMPenStroke * )), | 193 | connect( pracPw, SIGNAL(stroke(QIMPenStroke*)), |
194 | matcher, SLOT(strokeEntered( QIMPenStroke * )) ); | 194 | matcher, SLOT(strokeEntered(QIMPenStroke*)) ); |
195 | gl->addWidget( pracPw, 3, 1 ); | 195 | gl->addWidget( pracPw, 3, 1 ); |
196 | 196 | ||
197 | redrawTimer = new QTimer( this ); | 197 | redrawTimer = new QTimer( this ); |
198 | connect( redrawTimer, SIGNAL(timeout()), this, SLOT(redrawChar()) ); | 198 | connect( redrawTimer, SIGNAL(timeout()), this, SLOT(redrawChar()) ); |
199 | redrawTimer->start( 5000 ); | 199 | redrawTimer->start( 5000 ); |
200 | 200 | ||
201 | currentSet = 0; | 201 | currentSet = 0; |
202 | charSetCombo->setCurrentItem( 1 ); | 202 | charSetCombo->setCurrentItem( 1 ); |
203 | selectCharSet( 1 ); | 203 | selectCharSet( 1 ); |
204 | } | 204 | } |
205 | 205 | ||
206 | HandwritingTrainer::~HandwritingTrainer() | 206 | HandwritingTrainer::~HandwritingTrainer() |
207 | { | 207 | { |
208 | } | 208 | } |
209 | 209 | ||
210 | void HandwritingTrainer::showEvent( QShowEvent * ) | 210 | void HandwritingTrainer::showEvent( QShowEvent * ) |
211 | { | 211 | { |
212 | redrawChar(); | 212 | redrawChar(); |
213 | redrawTimer->start( 5000 ); | 213 | redrawTimer->start( 5000 ); |
214 | } | 214 | } |
215 | 215 | ||
216 | void HandwritingTrainer::setCurrentChar( QIMPenChar *c ) | 216 | void HandwritingTrainer::setCurrentChar( QIMPenChar *c ) |
217 | { | 217 | { |
218 | currentChar = c; | 218 | currentChar = c; |
219 | refPw->showCharacter( currentChar ); | 219 | refPw->showCharacter( currentChar ); |
220 | pracPw->clear(); | 220 | pracPw->clear(); |
221 | if ( currentChar ) { | 221 | if ( currentChar ) { |
222 | prevBtn->setEnabled( findPrev() != 0 ); | 222 | prevBtn->setEnabled( findPrev() != 0 ); |
223 | nextBtn->setEnabled( findNext() != 0 ); | 223 | nextBtn->setEnabled( findNext() != 0 ); |
224 | } | 224 | } |
225 | redrawTimer->start( 5000 ); | 225 | redrawTimer->start( 5000 ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void HandwritingTrainer::selectChar( int i ) | 228 | void HandwritingTrainer::selectChar( int i ) |
229 | { | 229 | { |
230 | static int last_char = 0; | 230 | static int last_char = 0; |
231 | 231 | ||
232 | if (last_char != i) { | 232 | if (last_char != i) { |
233 | result->setText(""); | 233 | result->setText(""); |
234 | } | 234 | } |
235 | 235 | ||
236 | currentChar = 0; | 236 | currentChar = 0; |
237 | currentCode = ((CharListItem *)charList->item(i))->code(); | 237 | currentCode = ((CharListItem *)charList->item(i))->code(); |
238 | QIMPenCharIterator it(currentSet->characters() ); | 238 | QIMPenCharIterator it(currentSet->characters() ); |
239 | for ( ; it.current(); ++it ) { | 239 | for ( ; it.current(); ++it ) { |
240 | if ( it.current()->character() == currentCode && | 240 | if ( it.current()->character() == currentCode && |
241 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 241 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
242 | setCurrentChar( it.current() ); | 242 | setCurrentChar( it.current() ); |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | if ( !it.current() ) | 246 | if ( !it.current() ) |
247 | setCurrentChar( 0 ); | 247 | setCurrentChar( 0 ); |
248 | } | 248 | } |
249 | 249 | ||
250 | void HandwritingTrainer::selectCharSet( int i ) | 250 | void HandwritingTrainer::selectCharSet( int i ) |
251 | { | 251 | { |
252 | if ( currentSet ) { | 252 | if ( currentSet ) { |
253 | refPw->removeCharSet( 0 ); | 253 | refPw->removeCharSet( 0 ); |
254 | pracPw->removeCharSet( 0 ); | 254 | pracPw->removeCharSet( 0 ); |
255 | result->setText(""); | 255 | result->setText(""); |
256 | } | 256 | } |
257 | currentSet = profile->charSets().at( i ); | 257 | currentSet = profile->charSets().at( i ); |
258 | fillCharList(); | 258 | fillCharList(); |
259 | refPw->insertCharSet( currentSet ); | 259 | refPw->insertCharSet( currentSet ); |
260 | pracPw->insertCharSet( currentSet ); | 260 | pracPw->insertCharSet( currentSet ); |
261 | matcher->setCharSet( currentSet ); | 261 | matcher->setCharSet( currentSet ); |
262 | if ( charList->count() ) { | 262 | if ( charList->count() ) { |
263 | charList->setSelected( 0, TRUE ); | 263 | charList->setSelected( 0, TRUE ); |
264 | selectChar(0); | 264 | selectChar(0); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | void HandwritingTrainer::noMatch() | 268 | void HandwritingTrainer::noMatch() |
269 | { | 269 | { |
270 | result->setText( tr("No match") ); | 270 | result->setText( tr("No match") ); |
271 | } | 271 | } |
272 | 272 | ||
273 | void HandwritingTrainer::matched( const QIMPenCharMatchList &ml ) | 273 | void HandwritingTrainer::matched( const QIMPenCharMatchList &ml ) |
274 | { | 274 | { |
275 | int maxErr = 20000 + (*ml.begin()).penChar->strokeLength(0) * 1000; | 275 | int maxErr = 20000 + (*ml.begin()).penChar->strokeLength(0) * 1000; |
276 | int baseErr = (*ml.begin()).penChar->strokeLength(0) * 250; | 276 | int baseErr = (*ml.begin()).penChar->strokeLength(0) * 250; |
277 | unsigned int numStrokes = (*ml.begin()).penChar->strokeCount(); | 277 | unsigned int numStrokes = (*ml.begin()).penChar->strokeCount(); |
278 | QIMPenCharMatchList::ConstIterator it; | 278 | QIMPenCharMatchList::ConstIterator it; |
279 | /* | 279 | /* |
280 | for ( it = ml.begin(); it != ml.end(); ++it ) { | 280 | for ( it = ml.begin(); it != ml.end(); ++it ) { |
281 | if ( (*it).penChar->strokeCount() == numStrokes ) { | 281 | if ( (*it).penChar->strokeCount() == numStrokes ) { |
282 | if ( (*it).error > maxErr ) | 282 | if ( (*it).error > maxErr ) |
283 | maxErr = (*it).error; | 283 | maxErr = (*it).error; |
284 | } | 284 | } |
285 | } | 285 | } |
286 | */ | 286 | */ |
287 | int i; | 287 | int i; |
288 | QString res; | 288 | QString res; |
289 | QTextStream ts(&res, IO_WriteOnly); | 289 | QTextStream ts(&res, IO_WriteOnly); |
290 | ts << "<qt>" << tr("Matched: "); | 290 | ts << "<qt>" << tr("Matched: "); |
291 | for ( i = 0, it = ml.begin(); it != ml.end() && i < 4; ++it, i++ ) { | 291 | for ( i = 0, it = ml.begin(); it != ml.end() && i < 4; ++it, i++ ) { |
292 | if ( (*it).penChar->strokeCount() == numStrokes ) { | 292 | if ( (*it).penChar->strokeCount() == numStrokes ) { |
293 | int rate = 100 - ( ((*it).error - baseErr) * 100 ) / maxErr; | 293 | int rate = 100 - ( ((*it).error - baseErr) * 100 ) / maxErr; |
294 | if ( it != ml.begin() ) { | 294 | if ( it != ml.begin() ) { |
295 | if ( rate < -10 ) | 295 | if ( rate < -10 ) |
296 | continue; | 296 | continue; |
297 | ts << "<br>"; | 297 | ts << "<br>"; |
298 | ts << tr("Similar to: "); | 298 | ts << tr("Similar to: "); |
299 | } | 299 | } |
300 | ts << "<big>"; | 300 | ts << "<big>"; |
301 | if ( (*it).penChar->character() == currentChar->character() ) | 301 | if ( (*it).penChar->character() == currentChar->character() ) |
302 | ts << "<b>"; | 302 | ts << "<b>"; |
303 | ts << Qtopia::escapeString((*it).penChar->name()); | 303 | ts << Qtopia::escapeString((*it).penChar->name()); |
304 | ts << " (" << rateString(rate) << ")"; | 304 | ts << " (" << rateString(rate) << ")"; |
305 | if ( (*it).penChar->character() == currentChar->character() ) | 305 | if ( (*it).penChar->character() == currentChar->character() ) |
306 | ts << "</b>"; | 306 | ts << "</b>"; |
307 | ts << "</big>"; | 307 | ts << "</big>"; |
308 | } | 308 | } |
309 | } | 309 | } |
310 | ts << "</qt>"; | 310 | ts << "</qt>"; |
311 | result->setText( res ); | 311 | result->setText( res ); |
312 | } | 312 | } |
313 | 313 | ||
314 | QString HandwritingTrainer::rateString( int rate ) const | 314 | QString HandwritingTrainer::rateString( int rate ) const |
315 | { | 315 | { |
316 | if ( rate < 1 ) | 316 | if ( rate < 1 ) |
317 | rate = 1; | 317 | rate = 1; |
318 | if ( rate > 100 ) | 318 | if ( rate > 100 ) |
319 | rate = 100; | 319 | rate = 100; |
320 | return tr("%1%").arg(rate); | 320 | return tr("%1%").arg(rate); |
321 | } | 321 | } |
322 | 322 | ||
323 | void HandwritingTrainer::prevChar() | 323 | void HandwritingTrainer::prevChar() |
324 | { | 324 | { |
325 | QIMPenChar *pc = findPrev(); | 325 | QIMPenChar *pc = findPrev(); |
326 | if ( pc ) | 326 | if ( pc ) |
327 | setCurrentChar( pc ); | 327 | setCurrentChar( pc ); |
328 | } | 328 | } |
329 | 329 | ||
330 | void HandwritingTrainer::nextChar() | 330 | void HandwritingTrainer::nextChar() |
331 | { | 331 | { |
332 | QIMPenChar *pc = findNext(); | 332 | QIMPenChar *pc = findNext(); |
333 | if ( pc ) | 333 | if ( pc ) |
334 | setCurrentChar( pc ); | 334 | setCurrentChar( pc ); |
335 | } | 335 | } |
336 | 336 | ||
337 | void HandwritingTrainer::redrawChar() | 337 | void HandwritingTrainer::redrawChar() |
338 | { | 338 | { |
339 | if ( currentChar ) | 339 | if ( currentChar ) |
340 | refPw->showCharacter( currentChar ); | 340 | refPw->showCharacter( currentChar ); |
341 | } | 341 | } |
342 | 342 | ||
343 | void HandwritingTrainer::beginStroke() | 343 | void HandwritingTrainer::beginStroke() |
344 | { | 344 | { |
345 | redrawTimer->start( 5000 ); | 345 | redrawTimer->start( 5000 ); |
346 | } | 346 | } |
347 | 347 | ||
348 | void HandwritingTrainer::strokeEntered( QIMPenStroke * ) | 348 | void HandwritingTrainer::strokeEntered( QIMPenStroke * ) |
349 | { | 349 | { |
350 | pracPw->greyStroke(); | 350 | pracPw->greyStroke(); |
351 | } | 351 | } |
352 | 352 | ||
353 | QIMPenChar *HandwritingTrainer::findPrev() | 353 | QIMPenChar *HandwritingTrainer::findPrev() |
354 | { | 354 | { |
355 | if ( !currentChar ) | 355 | if ( !currentChar ) |
356 | return 0; | 356 | return 0; |
357 | QIMPenCharIterator it( currentSet->characters() ); | 357 | QIMPenCharIterator it( currentSet->characters() ); |
358 | bool found = FALSE; | 358 | bool found = FALSE; |
359 | for ( it.toLast(); it.current(); --it ) { | 359 | for ( it.toLast(); it.current(); --it ) { |
360 | if ( !found && it.current() == currentChar ) | 360 | if ( !found && it.current() == currentChar ) |
361 | found = TRUE; | 361 | found = TRUE; |
362 | else if ( found && it.current()->character() == currentCode && | 362 | else if ( found && it.current()->character() == currentCode && |
363 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 363 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
364 | return it.current(); | 364 | return it.current(); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | return 0; | 368 | return 0; |
369 | } | 369 | } |
370 | 370 | ||
371 | QIMPenChar *HandwritingTrainer::findNext() | 371 | QIMPenChar *HandwritingTrainer::findNext() |
372 | { | 372 | { |
373 | if ( !currentChar ) | 373 | if ( !currentChar ) |
374 | return 0; | 374 | return 0; |
375 | QIMPenCharIterator it( currentSet->characters() ); | 375 | QIMPenCharIterator it( currentSet->characters() ); |
376 | bool found = FALSE; | 376 | bool found = FALSE; |
377 | for ( ; it.current(); ++it ) { | 377 | for ( ; it.current(); ++it ) { |
378 | if ( !found && it.current() == currentChar ) | 378 | if ( !found && it.current() == currentChar ) |
379 | found = TRUE; | 379 | found = TRUE; |
380 | else if ( found && it.current()->character() == currentCode && | 380 | else if ( found && it.current()->character() == currentCode && |
381 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 381 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
382 | return it.current(); | 382 | return it.current(); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | return 0; | 386 | return 0; |
387 | } | 387 | } |
388 | 388 | ||
389 | void HandwritingTrainer::fillCharList() | 389 | void HandwritingTrainer::fillCharList() |
390 | { | 390 | { |
391 | charList->clear(); | 391 | charList->clear(); |
392 | QIMPenCharIterator it( currentSet->characters() ); | 392 | QIMPenCharIterator it( currentSet->characters() ); |
393 | CharListItem *li = 0; | 393 | CharListItem *li = 0; |
394 | for ( ; it.current(); ++it ) { | 394 | for ( ; it.current(); ++it ) { |
395 | uint ch = it.current()->character(); | 395 | uint ch = it.current()->character(); |
396 | QString n = it.current()->name(); | 396 | QString n = it.current()->name(); |
397 | if ( !n.isEmpty() ) | 397 | if ( !n.isEmpty() ) |
398 | li = new CharListItem( n, ch ); | 398 | li = new CharListItem( n, ch ); |
399 | if ( li ) { | 399 | if ( li ) { |
400 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); | 400 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); |
401 | if ( !i || i->code() != ch ) { | 401 | if ( !i || i->code() != ch ) { |
402 | charList->insertItem( li ); | 402 | charList->insertItem( li ); |
403 | } else { | 403 | } else { |
404 | delete li; | 404 | delete li; |
405 | li = 0; | 405 | li = 0; |
406 | } | 406 | } |
407 | } | 407 | } |
408 | } | 408 | } |
409 | currentChar = 0; | 409 | currentChar = 0; |
410 | } | 410 | } |
411 | 411 | ||
diff --git a/inputmethods/handwriting/qimpeninput.cpp b/inputmethods/handwriting/qimpeninput.cpp index db33c9b..d073cdf 100644 --- a/inputmethods/handwriting/qimpeninput.cpp +++ b/inputmethods/handwriting/qimpeninput.cpp | |||
@@ -1,515 +1,515 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qimpenwidget.h" | 21 | #include "qimpenwidget.h" |
22 | #include "qimpensetup.h" | 22 | #include "qimpensetup.h" |
23 | #include "qimpeninput.h" | 23 | #include "qimpeninput.h" |
24 | #include "qimpencombining.h" | 24 | #include "qimpencombining.h" |
25 | #include "qimpenwordpick.h" | 25 | #include "qimpenwordpick.h" |
26 | #include "qimpenmatch.h" | 26 | #include "qimpenmatch.h" |
27 | #include "qimpenhelp.h" | 27 | #include "qimpenhelp.h" |
28 | 28 | ||
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/qdawg.h> | 30 | #include <qpe/qdawg.h> |
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | 39 | ||
40 | #include <limits.h> | 40 | #include <limits.h> |
41 | 41 | ||
42 | // We'll use little pixmaps for the buttons to save screen space. | 42 | // We'll use little pixmaps for the buttons to save screen space. |
43 | 43 | ||
44 | /* XPM */ | 44 | /* XPM */ |
45 | static const char * const pen_xpm[] = { | 45 | static const char * const pen_xpm[] = { |
46 | "12 12 4 1", | 46 | "12 12 4 1", |
47 | " c None", | 47 | " c None", |
48 | ".c #000000", | 48 | ".c #000000", |
49 | "+c #FFFFFF", | 49 | "+c #FFFFFF", |
50 | "@c #808080", | 50 | "@c #808080", |
51 | " . ", | 51 | " . ", |
52 | " .+. ", | 52 | " .+. ", |
53 | " ..@@.", | 53 | " ..@@.", |
54 | " .+@.. ", | 54 | " .+@.. ", |
55 | " .+@@. ", | 55 | " .+@@. ", |
56 | " .+@@. ", | 56 | " .+@@. ", |
57 | " .+@@. ", | 57 | " .+@@. ", |
58 | " .@.@. ", | 58 | " .@.@. ", |
59 | " .@@. ", | 59 | " .@@. ", |
60 | " .... ", | 60 | " .... ", |
61 | " .. ", | 61 | " .. ", |
62 | " "}; | 62 | " "}; |
63 | 63 | ||
64 | 64 | ||
65 | /* XPM */ | 65 | /* XPM */ |
66 | static char * bs_xpm[] = { | 66 | static char * bs_xpm[] = { |
67 | "12 12 5 1", | 67 | "12 12 5 1", |
68 | " c None", | 68 | " c None", |
69 | ".c #333333", | 69 | ".c #333333", |
70 | "+c #000000", | 70 | "+c #000000", |
71 | "@c #FFFFFF", | 71 | "@c #FFFFFF", |
72 | "#c #666666", | 72 | "#c #666666", |
73 | " ", | 73 | " ", |
74 | " ", | 74 | " ", |
75 | " ", | 75 | " ", |
76 | " . ", | 76 | " . ", |
77 | " ++ ", | 77 | " ++ ", |
78 | " +@#+++++. ", | 78 | " +@#+++++. ", |
79 | " +@@@@@@@@+ ", | 79 | " +@@@@@@@@+ ", |
80 | " +@#+++++. ", | 80 | " +@#+++++. ", |
81 | " ++ ", | 81 | " ++ ", |
82 | " . ", | 82 | " . ", |
83 | " ", | 83 | " ", |
84 | " "}; | 84 | " "}; |
85 | 85 | ||
86 | 86 | ||
87 | /* XPM */ | 87 | /* XPM */ |
88 | static char * enter_xpm[] = { | 88 | static char * enter_xpm[] = { |
89 | "12 12 5 1", | 89 | "12 12 5 1", |
90 | " c None", | 90 | " c None", |
91 | ".c #333333", | 91 | ".c #333333", |
92 | "+c #000000", | 92 | "+c #000000", |
93 | "@c #FFFFFF", | 93 | "@c #FFFFFF", |
94 | "#c #666666", | 94 | "#c #666666", |
95 | " ", | 95 | " ", |
96 | " .+. ", | 96 | " .+. ", |
97 | " +@+ ", | 97 | " +@+ ", |
98 | " . +@+ ", | 98 | " . +@+ ", |
99 | " ++ +@+ ", | 99 | " ++ +@+ ", |
100 | " +@#++++@+ ", | 100 | " +@#++++@+ ", |
101 | " +@@@@@@@@+ ", | 101 | " +@@@@@@@@+ ", |
102 | " +@#+++++. ", | 102 | " +@#+++++. ", |
103 | " ++ ", | 103 | " ++ ", |
104 | " . ", | 104 | " . ", |
105 | " ", | 105 | " ", |
106 | " "}; | 106 | " "}; |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | /* XPM */ | 110 | /* XPM */ |
111 | static char * help_xpm[] = { | 111 | static char * help_xpm[] = { |
112 | "12 12 5 1", | 112 | "12 12 5 1", |
113 | " c None", | 113 | " c None", |
114 | ".c #000000", | 114 | ".c #000000", |
115 | "+c #FFFFFF", | 115 | "+c #FFFFFF", |
116 | "@c #666666", | 116 | "@c #666666", |
117 | "#c #333333", | 117 | "#c #333333", |
118 | " ", | 118 | " ", |
119 | " ... ", | 119 | " ... ", |
120 | " .+++. ", | 120 | " .+++. ", |
121 | " .+..@+. ", | 121 | " .+..@+. ", |
122 | " #.# .+. ", | 122 | " #.# .+. ", |
123 | " .+. ", | 123 | " .+. ", |
124 | " .+. ", | 124 | " .+. ", |
125 | " .+. ", | 125 | " .+. ", |
126 | " .+. ", | 126 | " .+. ", |
127 | " #.# ", | 127 | " #.# ", |
128 | " .+. ", | 128 | " .+. ", |
129 | " #.# "}; | 129 | " #.# "}; |
130 | 130 | ||
131 | 131 | ||
132 | /*! | 132 | /*! |
133 | \class QIMPenInput qimpeninput.h | 133 | \class QIMPenInput qimpeninput.h |
134 | 134 | ||
135 | Pen input widget. | 135 | Pen input widget. |
136 | */ | 136 | */ |
137 | QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags wf ) | 137 | QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags wf ) |
138 | : QFrame( parent, name, wf ), helpDlg(0), profile(0) | 138 | : QFrame( parent, name, wf ), helpDlg(0), profile(0) |
139 | { | 139 | { |
140 | setFrameStyle( Box | Plain ); | 140 | setFrameStyle( Box | Plain ); |
141 | 141 | ||
142 | profileList.setAutoDelete( true ); | 142 | profileList.setAutoDelete( true ); |
143 | 143 | ||
144 | matcher = new QIMPenMatch( this ); | 144 | matcher = new QIMPenMatch( this ); |
145 | connect( matcher, SIGNAL(keypress(uint)), this, SLOT(keypress(uint)) ); | 145 | connect( matcher, SIGNAL(keypress(uint)), this, SLOT(keypress(uint)) ); |
146 | connect( matcher, SIGNAL(erase()), this, SLOT(erase()) ); | 146 | connect( matcher, SIGNAL(erase()), this, SLOT(erase()) ); |
147 | 147 | ||
148 | QGridLayout *gl = new QGridLayout( this, 5, 2, 1, 0 ); | 148 | QGridLayout *gl = new QGridLayout( this, 5, 2, 1, 0 ); |
149 | gl->setColStretch( 0, 1 ); | 149 | gl->setColStretch( 0, 1 ); |
150 | 150 | ||
151 | wordPicker = new QIMPenWordPick( this ); | 151 | wordPicker = new QIMPenWordPick( this ); |
152 | connect( wordPicker, SIGNAL(wordClicked(const QString &)), | 152 | connect( wordPicker, SIGNAL(wordClicked(const QString&)), |
153 | this, SLOT(wordPicked(const QString &)) ); | 153 | this, SLOT(wordPicked(const QString&)) ); |
154 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList &)), | 154 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList&)), |
155 | this, SLOT(matchedCharacters(const QIMPenCharMatchList &)) ); | 155 | this, SLOT(matchedCharacters(const QIMPenCharMatchList&)) ); |
156 | connect( matcher, SIGNAL(matchedWords(const QIMPenMatch::MatchWordList&)), | 156 | connect( matcher, SIGNAL(matchedWords(const QIMPenMatch::MatchWordList&)), |
157 | wordPicker, SLOT(setWords(const QIMPenMatch::MatchWordList&)) ); | 157 | wordPicker, SLOT(setWords(const QIMPenMatch::MatchWordList&)) ); |
158 | QFont f("smallsmooth",9); | 158 | QFont f("smallsmooth",9); |
159 | QFontInfo fi( f ); | 159 | QFontInfo fi( f ); |
160 | wordPicker->setFont( f ); | 160 | wordPicker->setFont( f ); |
161 | wordPicker->setBackgroundColor( white ); | 161 | wordPicker->setBackgroundColor( white ); |
162 | gl->addMultiCellWidget( wordPicker, 0, 0, 0, 1 ); | 162 | gl->addMultiCellWidget( wordPicker, 0, 0, 0, 1 ); |
163 | if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() ) | 163 | if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() ) |
164 | wordPicker->hide(); | 164 | wordPicker->hide(); |
165 | 165 | ||
166 | pw = new QIMPenWidget( this ); | 166 | pw = new QIMPenWidget( this ); |
167 | gl->addMultiCellWidget( pw, 1, 4, 0, 0 ); | 167 | gl->addMultiCellWidget( pw, 1, 4, 0, 0 ); |
168 | 168 | ||
169 | int bh = pw->sizeHint().height()/4; | 169 | int bh = pw->sizeHint().height()/4; |
170 | 170 | ||
171 | QPushButton *b = new QPushButton( this ); | 171 | QPushButton *b = new QPushButton( this ); |
172 | b->setFocusPolicy( NoFocus ); | 172 | b->setFocusPolicy( NoFocus ); |
173 | b->setPixmap( QPixmap( (const char **)bs_xpm ) ); | 173 | b->setPixmap( QPixmap( (const char **)bs_xpm ) ); |
174 | b->setFixedHeight(pw->sizeHint().height()-3*bh); // left-over space goes here | 174 | b->setFixedHeight(pw->sizeHint().height()-3*bh); // left-over space goes here |
175 | b->setAutoRepeat( TRUE ); | 175 | b->setAutoRepeat( TRUE ); |
176 | gl->addWidget( b, 1, 1 ); | 176 | gl->addWidget( b, 1, 1 ); |
177 | connect( b, SIGNAL(clicked()), SLOT(backspace())); | 177 | connect( b, SIGNAL(clicked()), SLOT(backspace())); |
178 | 178 | ||
179 | b = new QPushButton( this ); | 179 | b = new QPushButton( this ); |
180 | b->setFocusPolicy( NoFocus ); | 180 | b->setFocusPolicy( NoFocus ); |
181 | b->setPixmap( QPixmap( (const char **)enter_xpm ) ); | 181 | b->setPixmap( QPixmap( (const char **)enter_xpm ) ); |
182 | b->setFixedHeight(bh); | 182 | b->setFixedHeight(bh); |
183 | b->setAutoRepeat( TRUE ); | 183 | b->setAutoRepeat( TRUE ); |
184 | gl->addWidget( b, 2, 1 ); | 184 | gl->addWidget( b, 2, 1 ); |
185 | connect( b, SIGNAL(clicked()), SLOT(enter())); | 185 | connect( b, SIGNAL(clicked()), SLOT(enter())); |
186 | 186 | ||
187 | helpBtn = new QPushButton( this ); | 187 | helpBtn = new QPushButton( this ); |
188 | helpBtn->setFocusPolicy( NoFocus ); | 188 | helpBtn->setFocusPolicy( NoFocus ); |
189 | helpBtn->setPixmap( QPixmap( (const char **)help_xpm ) ); | 189 | helpBtn->setPixmap( QPixmap( (const char **)help_xpm ) ); |
190 | helpBtn->setFixedHeight(bh); | 190 | helpBtn->setFixedHeight(bh); |
191 | gl->addWidget( helpBtn, 3, 1 ); | 191 | gl->addWidget( helpBtn, 3, 1 ); |
192 | connect( helpBtn, SIGNAL(clicked()), SLOT(help())); | 192 | connect( helpBtn, SIGNAL(clicked()), SLOT(help())); |
193 | 193 | ||
194 | QPixmap pm( (const char **)pen_xpm ); | 194 | QPixmap pm( (const char **)pen_xpm ); |
195 | setupBtn = new QPushButton( this ); | 195 | setupBtn = new QPushButton( this ); |
196 | setupBtn->setFocusPolicy( NoFocus ); | 196 | setupBtn->setFocusPolicy( NoFocus ); |
197 | setupBtn->setPixmap( pm ); | 197 | setupBtn->setPixmap( pm ); |
198 | setupBtn->setFixedHeight(bh); | 198 | setupBtn->setFixedHeight(bh); |
199 | gl->addWidget( setupBtn, 4, 1 ); | 199 | gl->addWidget( setupBtn, 4, 1 ); |
200 | connect( setupBtn, SIGNAL(clicked()), SLOT(setup())); | 200 | connect( setupBtn, SIGNAL(clicked()), SLOT(setup())); |
201 | 201 | ||
202 | connect( matcher, SIGNAL(removeStroke()), pw, SLOT(removeStroke()) ); | 202 | connect( matcher, SIGNAL(removeStroke()), pw, SLOT(removeStroke()) ); |
203 | connect( pw, SIGNAL(changeCharSet( QIMPenCharSet * )), | 203 | connect( pw, SIGNAL(changeCharSet(QIMPenCharSet*)), |
204 | matcher, SLOT(setCharSet( QIMPenCharSet * )) ); | 204 | matcher, SLOT(setCharSet(QIMPenCharSet*)) ); |
205 | connect( pw, SIGNAL(changeCharSet( int )), | 205 | connect( pw, SIGNAL(changeCharSet(int)), |
206 | this, SLOT(selectCharSet( int )) ); | 206 | this, SLOT(selectCharSet(int)) ); |
207 | connect( pw, SIGNAL(beginStroke()), | 207 | connect( pw, SIGNAL(beginStroke()), |
208 | matcher, SLOT(beginStroke()) ); | 208 | matcher, SLOT(beginStroke()) ); |
209 | connect( pw, SIGNAL(stroke( QIMPenStroke * )), | 209 | connect( pw, SIGNAL(stroke(QIMPenStroke*)), |
210 | this, SLOT(strokeEntered( QIMPenStroke * )) ); | 210 | this, SLOT(strokeEntered(QIMPenStroke*)) ); |
211 | connect( pw, SIGNAL(stroke( QIMPenStroke * )), | 211 | connect( pw, SIGNAL(stroke(QIMPenStroke*)), |
212 | matcher, SLOT(strokeEntered( QIMPenStroke * )) ); | 212 | matcher, SLOT(strokeEntered(QIMPenStroke*)) ); |
213 | 213 | ||
214 | shortcutCharSet = 0; | 214 | shortcutCharSet = 0; |
215 | currCharSet = 0; | 215 | currCharSet = 0; |
216 | setupDlg = 0; | 216 | setupDlg = 0; |
217 | profile = 0; | 217 | profile = 0; |
218 | mode = Normal; | 218 | mode = Normal; |
219 | 219 | ||
220 | loadProfiles(); | 220 | loadProfiles(); |
221 | } | 221 | } |
222 | 222 | ||
223 | QIMPenInput::~QIMPenInput() | 223 | QIMPenInput::~QIMPenInput() |
224 | { | 224 | { |
225 | delete (HandwritingHelp*) helpDlg; | 225 | delete (HandwritingHelp*) helpDlg; |
226 | } | 226 | } |
227 | 227 | ||
228 | QSize QIMPenInput::sizeHint() const | 228 | QSize QIMPenInput::sizeHint() const |
229 | { | 229 | { |
230 | int fw = frameWidth(); | 230 | int fw = frameWidth(); |
231 | int ps = wordPicker->isHidden() ? 0 : wordPicker->sizeHint().height(); | 231 | int ps = wordPicker->isHidden() ? 0 : wordPicker->sizeHint().height(); |
232 | return pw->sizeHint() + QSize( fw*2, fw*2+ps ); | 232 | return pw->sizeHint() + QSize( fw*2, fw*2+ps ); |
233 | } | 233 | } |
234 | 234 | ||
235 | void QIMPenInput::loadProfiles() | 235 | void QIMPenInput::loadProfiles() |
236 | { | 236 | { |
237 | profileList.clear(); | 237 | profileList.clear(); |
238 | profile = 0; | 238 | profile = 0; |
239 | delete shortcutCharSet; | 239 | delete shortcutCharSet; |
240 | shortcutCharSet = new QIMPenCharSet(); | 240 | shortcutCharSet = new QIMPenCharSet(); |
241 | shortcutCharSet->setTitle( tr("Shortcut") ); | 241 | shortcutCharSet->setTitle( tr("Shortcut") ); |
242 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; | 242 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; |
243 | QDir dir( path, "*.conf" ); | 243 | QDir dir( path, "*.conf" ); |
244 | QStringList list = dir.entryList(); | 244 | QStringList list = dir.entryList(); |
245 | QStringList::Iterator it; | 245 | QStringList::Iterator it; |
246 | for ( it = list.begin(); it != list.end(); ++it ) { | 246 | for ( it = list.begin(); it != list.end(); ++it ) { |
247 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); | 247 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); |
248 | profileList.append( p ); | 248 | profileList.append( p ); |
249 | if ( p->shortcut() ) { | 249 | if ( p->shortcut() ) { |
250 | QIMPenCharIterator it( p->shortcut()->characters() ); | 250 | QIMPenCharIterator it( p->shortcut()->characters() ); |
251 | for ( ; it.current(); ++it ) { | 251 | for ( ; it.current(); ++it ) { |
252 | shortcutCharSet->addChar( new QIMPenChar(*it.current()) ); | 252 | shortcutCharSet->addChar( new QIMPenChar(*it.current()) ); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | Config config( "handwriting" ); | 257 | Config config( "handwriting" ); |
258 | config.setGroup( "Settings" ); | 258 | config.setGroup( "Settings" ); |
259 | QString prof = config.readEntry( "Profile", "Default" ); | 259 | QString prof = config.readEntry( "Profile", "Default" ); |
260 | selectProfile( prof ); | 260 | selectProfile( prof ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void QIMPenInput::selectProfile( const QString &name ) | 263 | void QIMPenInput::selectProfile( const QString &name ) |
264 | { | 264 | { |
265 | QListIterator<QIMPenProfile> it( profileList ); | 265 | QListIterator<QIMPenProfile> it( profileList ); |
266 | for ( ; it.current(); ++it ) { | 266 | for ( ; it.current(); ++it ) { |
267 | if ( it.current()->name() == name ) { | 267 | if ( it.current()->name() == name ) { |
268 | profile = it.current(); | 268 | profile = it.current(); |
269 | break; | 269 | break; |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | if ( !it.current() ) | 273 | if ( !it.current() ) |
274 | return; | 274 | return; |
275 | 275 | ||
276 | pw->clearCharSets(); | 276 | pw->clearCharSets(); |
277 | baseSets.clear(); | 277 | baseSets.clear(); |
278 | 278 | ||
279 | matcher->setMultiStrokeTimeout( profile->multiStrokeTimeout() ); | 279 | matcher->setMultiStrokeTimeout( profile->multiStrokeTimeout() ); |
280 | matcher->setWordMatchingEnabled( profile->matchWords() ); | 280 | matcher->setWordMatchingEnabled( profile->matchWords() ); |
281 | 281 | ||
282 | if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() ) | 282 | if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() ) |
283 | wordPicker->hide(); | 283 | wordPicker->hide(); |
284 | else | 284 | else |
285 | wordPicker->show(); | 285 | wordPicker->show(); |
286 | 286 | ||
287 | if ( profile->uppercase() && profile->style() == QIMPenProfile::BothCases ) { | 287 | if ( profile->uppercase() && profile->style() == QIMPenProfile::BothCases ) { |
288 | baseSets.append( profile->uppercase() ); | 288 | baseSets.append( profile->uppercase() ); |
289 | pw->insertCharSet( profile->uppercase() ); | 289 | pw->insertCharSet( profile->uppercase() ); |
290 | } | 290 | } |
291 | 291 | ||
292 | if ( profile->lowercase() ) { | 292 | if ( profile->lowercase() ) { |
293 | baseSets.append( profile->lowercase() ); | 293 | baseSets.append( profile->lowercase() ); |
294 | pw->insertCharSet( profile->lowercase(), profile->style() == QIMPenProfile::BothCases ? 1 : 2 ); | 294 | pw->insertCharSet( profile->lowercase(), profile->style() == QIMPenProfile::BothCases ? 1 : 2 ); |
295 | } | 295 | } |
296 | 296 | ||
297 | if ( profile->numeric() ) { | 297 | if ( profile->numeric() ) { |
298 | baseSets.append( profile->numeric() ); | 298 | baseSets.append( profile->numeric() ); |
299 | pw->insertCharSet( profile->numeric() ); | 299 | pw->insertCharSet( profile->numeric() ); |
300 | } | 300 | } |
301 | 301 | ||
302 | if ( helpDlg ) | 302 | if ( helpDlg ) |
303 | delete (HandwritingHelp*) helpDlg; | 303 | delete (HandwritingHelp*) helpDlg; |
304 | } | 304 | } |
305 | 305 | ||
306 | void QIMPenInput::wordPicked( const QString &w ) | 306 | void QIMPenInput::wordPicked( const QString &w ) |
307 | { | 307 | { |
308 | int bs = matcher->word().length(); | 308 | int bs = matcher->word().length(); |
309 | for ( int i = 0; i < bs; i++ ) | 309 | for ( int i = 0; i < bs; i++ ) |
310 | keypress( Qt::Key_Backspace << 16 ); | 310 | keypress( Qt::Key_Backspace << 16 ); |
311 | 311 | ||
312 | for ( unsigned int i = 0; i < w.length(); i++ ) | 312 | for ( unsigned int i = 0; i < w.length(); i++ ) |
313 | keypress( w[i].unicode() ); | 313 | keypress( w[i].unicode() ); |
314 | 314 | ||
315 | matcher->resetState(); | 315 | matcher->resetState(); |
316 | wordPicker->clear(); | 316 | wordPicker->clear(); |
317 | } | 317 | } |
318 | 318 | ||
319 | void QIMPenInput::selectCharSet( int idx ) | 319 | void QIMPenInput::selectCharSet( int idx ) |
320 | { | 320 | { |
321 | if ( mode == Switch ) { | 321 | if ( mode == Switch ) { |
322 | //qDebug( "Switch back to normal" ); | 322 | //qDebug( "Switch back to normal" ); |
323 | pw->changeCharSet( baseSets.at(currCharSet), currCharSet ); | 323 | pw->changeCharSet( baseSets.at(currCharSet), currCharSet ); |
324 | mode = Normal; | 324 | mode = Normal; |
325 | } | 325 | } |
326 | currCharSet = idx; | 326 | currCharSet = idx; |
327 | } | 327 | } |
328 | 328 | ||
329 | void QIMPenInput::beginStroke() | 329 | void QIMPenInput::beginStroke() |
330 | { | 330 | { |
331 | } | 331 | } |
332 | 332 | ||
333 | void QIMPenInput::strokeEntered( QIMPenStroke * ) | 333 | void QIMPenInput::strokeEntered( QIMPenStroke * ) |
334 | { | 334 | { |
335 | pw->greyStroke(); | 335 | pw->greyStroke(); |
336 | } | 336 | } |
337 | 337 | ||
338 | void QIMPenInput::erase() | 338 | void QIMPenInput::erase() |
339 | { | 339 | { |
340 | keypress( Qt::Key_Backspace << 16 ); | 340 | keypress( Qt::Key_Backspace << 16 ); |
341 | } | 341 | } |
342 | 342 | ||
343 | void QIMPenInput::matchedCharacters( const QIMPenCharMatchList &cl ) | 343 | void QIMPenInput::matchedCharacters( const QIMPenCharMatchList &cl ) |
344 | { | 344 | { |
345 | const QIMPenChar *ch = cl.first().penChar; | 345 | const QIMPenChar *ch = cl.first().penChar; |
346 | int scan = ch->character() >> 16; | 346 | int scan = ch->character() >> 16; |
347 | 347 | ||
348 | if ( scan < QIMPenChar::ModeBase ) | 348 | if ( scan < QIMPenChar::ModeBase ) |
349 | return; | 349 | return; |
350 | 350 | ||
351 | // We matched a special character... | 351 | // We matched a special character... |
352 | 352 | ||
353 | switch ( scan ) { | 353 | switch ( scan ) { |
354 | case QIMPenChar::Caps: | 354 | case QIMPenChar::Caps: |
355 | if ( profile->style() == QIMPenProfile::ToggleCases ) { | 355 | if ( profile->style() == QIMPenProfile::ToggleCases ) { |
356 | // qDebug( "Caps" ); | 356 | // qDebug( "Caps" ); |
357 | if ( mode == SwitchLock ) { | 357 | if ( mode == SwitchLock ) { |
358 | // qDebug( "Switch to normal" ); | 358 | // qDebug( "Switch to normal" ); |
359 | pw->changeCharSet( profile->lowercase(), currCharSet ); | 359 | pw->changeCharSet( profile->lowercase(), currCharSet ); |
360 | mode = Switch; | 360 | mode = Switch; |
361 | } else { | 361 | } else { |
362 | // qDebug( "Switch to upper" ); | 362 | // qDebug( "Switch to upper" ); |
363 | pw->changeCharSet( profile->uppercase(), currCharSet ); | 363 | pw->changeCharSet( profile->uppercase(), currCharSet ); |
364 | mode = Switch; | 364 | mode = Switch; |
365 | } | 365 | } |
366 | } | 366 | } |
367 | break; | 367 | break; |
368 | case QIMPenChar::CapsLock: | 368 | case QIMPenChar::CapsLock: |
369 | if ( profile->style() == QIMPenProfile::ToggleCases ) { | 369 | if ( profile->style() == QIMPenProfile::ToggleCases ) { |
370 | // qDebug( "CapsLock" ); | 370 | // qDebug( "CapsLock" ); |
371 | if ( mode == Switch && | 371 | if ( mode == Switch && |
372 | baseSets.at(currCharSet) == profile->uppercase() ) { | 372 | baseSets.at(currCharSet) == profile->uppercase() ) { |
373 | // qDebug( "Switch to normal" ); | 373 | // qDebug( "Switch to normal" ); |
374 | pw->changeCharSet( profile->lowercase(), currCharSet ); | 374 | pw->changeCharSet( profile->lowercase(), currCharSet ); |
375 | // change our base set back to lower. | 375 | // change our base set back to lower. |
376 | baseSets.remove( currCharSet ); | 376 | baseSets.remove( currCharSet ); |
377 | baseSets.insert( currCharSet, profile->lowercase() ); | 377 | baseSets.insert( currCharSet, profile->lowercase() ); |
378 | mode = Normal; | 378 | mode = Normal; |
379 | } else { | 379 | } else { |
380 | // qDebug( "Switch to caps lock" ); | 380 | // qDebug( "Switch to caps lock" ); |
381 | pw->changeCharSet( profile->uppercase(), currCharSet ); | 381 | pw->changeCharSet( profile->uppercase(), currCharSet ); |
382 | // change our base set to upper. | 382 | // change our base set to upper. |
383 | baseSets.remove( currCharSet ); | 383 | baseSets.remove( currCharSet ); |
384 | baseSets.insert( currCharSet, profile->uppercase() ); | 384 | baseSets.insert( currCharSet, profile->uppercase() ); |
385 | mode = SwitchLock; | 385 | mode = SwitchLock; |
386 | } | 386 | } |
387 | } | 387 | } |
388 | break; | 388 | break; |
389 | case QIMPenChar::Punctuation: | 389 | case QIMPenChar::Punctuation: |
390 | if ( profile->punctuation() ) { | 390 | if ( profile->punctuation() ) { |
391 | //qDebug( "Switch to punctuation" ); | 391 | //qDebug( "Switch to punctuation" ); |
392 | pw->changeCharSet( profile->punctuation(), currCharSet ); | 392 | pw->changeCharSet( profile->punctuation(), currCharSet ); |
393 | mode = Switch; | 393 | mode = Switch; |
394 | } | 394 | } |
395 | break; | 395 | break; |
396 | case QIMPenChar::Symbol: | 396 | case QIMPenChar::Symbol: |
397 | if ( profile->symbol() ) { | 397 | if ( profile->symbol() ) { |
398 | //qDebug( "Switch to symbol" ); | 398 | //qDebug( "Switch to symbol" ); |
399 | pw->changeCharSet( profile->symbol(), currCharSet ); | 399 | pw->changeCharSet( profile->symbol(), currCharSet ); |
400 | mode = Switch; | 400 | mode = Switch; |
401 | } | 401 | } |
402 | break; | 402 | break; |
403 | case QIMPenChar::Shortcut: | 403 | case QIMPenChar::Shortcut: |
404 | if ( shortcutCharSet ) { | 404 | if ( shortcutCharSet ) { |
405 | pw->changeCharSet( shortcutCharSet, currCharSet ); | 405 | pw->changeCharSet( shortcutCharSet, currCharSet ); |
406 | mode = Switch; | 406 | mode = Switch; |
407 | } | 407 | } |
408 | break; | 408 | break; |
409 | case QIMPenChar::Extended: | 409 | case QIMPenChar::Extended: |
410 | handleExtended( ch->data() ); | 410 | handleExtended( ch->data() ); |
411 | break; | 411 | break; |
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | void QIMPenInput::keypress( uint scan_uni ) | 415 | void QIMPenInput::keypress( uint scan_uni ) |
416 | { | 416 | { |
417 | int scan = scan_uni >> 16; | 417 | int scan = scan_uni >> 16; |
418 | if ( !scan ) { | 418 | if ( !scan ) { |
419 | if ( scan_uni >= 'a' && scan_uni <= 'z' ) { | 419 | if ( scan_uni >= 'a' && scan_uni <= 'z' ) { |
420 | scan = Qt::Key_A + scan_uni - 'a'; | 420 | scan = Qt::Key_A + scan_uni - 'a'; |
421 | } else if ( scan_uni >= 'A' && scan_uni <= 'Z' ) { | 421 | } else if ( scan_uni >= 'A' && scan_uni <= 'Z' ) { |
422 | scan = Qt::Key_A + scan_uni - 'A'; | 422 | scan = Qt::Key_A + scan_uni - 'A'; |
423 | } else if ( scan_uni == ' ' ) { | 423 | } else if ( scan_uni == ' ' ) { |
424 | scan = Qt::Key_Space; | 424 | scan = Qt::Key_Space; |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | switch ( scan ) { | 428 | switch ( scan ) { |
429 | case Key_Tab: | 429 | case Key_Tab: |
430 | scan_uni = 9; | 430 | scan_uni = 9; |
431 | break; | 431 | break; |
432 | case Key_Return: | 432 | case Key_Return: |
433 | scan_uni = 13; | 433 | scan_uni = 13; |
434 | break; | 434 | break; |
435 | case Key_Backspace: | 435 | case Key_Backspace: |
436 | scan_uni = 8; | 436 | scan_uni = 8; |
437 | break; | 437 | break; |
438 | case Key_Escape: | 438 | case Key_Escape: |
439 | scan_uni = 27; | 439 | scan_uni = 27; |
440 | break; | 440 | break; |
441 | default: | 441 | default: |
442 | break; | 442 | break; |
443 | } | 443 | } |
444 | 444 | ||
445 | if ( mode == Switch ) { | 445 | if ( mode == Switch ) { |
446 | //qDebug( "Switch back to normal" ); | 446 | //qDebug( "Switch back to normal" ); |
447 | pw->changeCharSet( baseSets.at(currCharSet), currCharSet ); | 447 | pw->changeCharSet( baseSets.at(currCharSet), currCharSet ); |
448 | if ( baseSets.at(currCharSet) == profile->uppercase() ) | 448 | if ( baseSets.at(currCharSet) == profile->uppercase() ) |
449 | mode = SwitchLock; | 449 | mode = SwitchLock; |
450 | else | 450 | else |
451 | mode = Normal; | 451 | mode = Normal; |
452 | } | 452 | } |
453 | 453 | ||
454 | emit key( scan_uni&0xffff, scan, 0, true, false ); | 454 | emit key( scan_uni&0xffff, scan, 0, true, false ); |
455 | emit key( scan_uni&0xffff, scan, 0, false, false ); | 455 | emit key( scan_uni&0xffff, scan, 0, false, false ); |
456 | } | 456 | } |
457 | 457 | ||
458 | void QIMPenInput::handleExtended( const QString &ex ) | 458 | void QIMPenInput::handleExtended( const QString &ex ) |
459 | { | 459 | { |
460 | if ( ex.find( "Select" ) == 0 ) { | 460 | if ( ex.find( "Select" ) == 0 ) { |
461 | QString set = ex.mid( 7 ); | 461 | QString set = ex.mid( 7 ); |
462 | qDebug( "Select new profile: %s", set.latin1() ); | 462 | qDebug( "Select new profile: %s", set.latin1() ); |
463 | selectProfile( set ); | 463 | selectProfile( set ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | void QIMPenInput::help() | 467 | void QIMPenInput::help() |
468 | { | 468 | { |
469 | if ( helpDlg ) | 469 | if ( helpDlg ) |
470 | delete (HandwritingHelp*) helpDlg; | 470 | delete (HandwritingHelp*) helpDlg; |
471 | helpDlg = new HandwritingHelp( profile, 0, 0, WDestructiveClose ); | 471 | helpDlg = new HandwritingHelp( profile, 0, 0, WDestructiveClose ); |
472 | helpDlg->showMaximized(); | 472 | helpDlg->showMaximized(); |
473 | helpDlg->show(); | 473 | helpDlg->show(); |
474 | helpDlg->raise(); | 474 | helpDlg->raise(); |
475 | } | 475 | } |
476 | 476 | ||
477 | /*! | 477 | /*! |
478 | Open the setup dialog | 478 | Open the setup dialog |
479 | */ | 479 | */ |
480 | void QIMPenInput::setup() | 480 | void QIMPenInput::setup() |
481 | { | 481 | { |
482 | if ( !setupDlg ) { | 482 | if ( !setupDlg ) { |
483 | // We are working with our copy of the char sets here. | 483 | // We are working with our copy of the char sets here. |
484 | setupDlg = new QIMPenSetup( profile, 0, 0, TRUE ); | 484 | setupDlg = new QIMPenSetup( profile, 0, 0, TRUE ); |
485 | setupDlg->editor()->selectCharSet( profile->charSets().at(1) );// lower case? This is crap. | 485 | setupDlg->editor()->selectCharSet( profile->charSets().at(1) );// lower case? This is crap. |
486 | if ( qApp->desktop()->width() < 640 ) | 486 | if ( qApp->desktop()->width() < 640 ) |
487 | setupDlg->showMaximized(); | 487 | setupDlg->showMaximized(); |
488 | Global::hideInputMethod(); | 488 | Global::hideInputMethod(); |
489 | setupDlg->exec(); | 489 | setupDlg->exec(); |
490 | loadProfiles(); | 490 | loadProfiles(); |
491 | delete setupDlg; | 491 | delete setupDlg; |
492 | setupDlg = 0; | 492 | setupDlg = 0; |
493 | Global::showInputMethod(); | 493 | Global::showInputMethod(); |
494 | } else { | 494 | } else { |
495 | setupDlg->raise(); | 495 | setupDlg->raise(); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | void QIMPenInput::backspace() | 499 | void QIMPenInput::backspace() |
500 | { | 500 | { |
501 | keypress( Qt::Key_Backspace << 16 ); | 501 | keypress( Qt::Key_Backspace << 16 ); |
502 | matcher->backspace(); | 502 | matcher->backspace(); |
503 | } | 503 | } |
504 | 504 | ||
505 | void QIMPenInput::enter() | 505 | void QIMPenInput::enter() |
506 | { | 506 | { |
507 | keypress( Qt::Key_Return << 16 ); | 507 | keypress( Qt::Key_Return << 16 ); |
508 | matcher->resetState(); | 508 | matcher->resetState(); |
509 | } | 509 | } |
510 | 510 | ||
511 | 511 | ||
512 | void QIMPenInput::resetState() | 512 | void QIMPenInput::resetState() |
513 | { | 513 | { |
514 | matcher->resetState(); | 514 | matcher->resetState(); |
515 | } | 515 | } |
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp index d0f9ffd..d1297a9 100644 --- a/inputmethods/handwriting/qimpensetup.cpp +++ b/inputmethods/handwriting/qimpensetup.cpp | |||
@@ -1,665 +1,665 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qimpenwidget.h" | 21 | #include "qimpenwidget.h" |
22 | #include "qimpenprefbase.h" | 22 | #include "qimpenprefbase.h" |
23 | #include "qimpensetup.h" | 23 | #include "qimpensetup.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
27 | 27 | ||
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qlistbox.h> | 29 | #include <qlistbox.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qpixmap.h> | 33 | #include <qpixmap.h> |
34 | #include <qbuttongroup.h> | 34 | #include <qbuttongroup.h> |
35 | #include <qslider.h> | 35 | #include <qslider.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
39 | 39 | ||
40 | 40 | ||
41 | /* XPM */ | 41 | /* XPM */ |
42 | static const char * const left_xpm[] = { | 42 | static const char * const left_xpm[] = { |
43 | "16 16 2 1", | 43 | "16 16 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 | " ...... ", | 54 | " ...... ", |
55 | " ..... ", | 55 | " ..... ", |
56 | " .... ", | 56 | " .... ", |
57 | " ... ", | 57 | " ... ", |
58 | " .. ", | 58 | " .. ", |
59 | " . ", | 59 | " . ", |
60 | " ", | 60 | " ", |
61 | " "}; | 61 | " "}; |
62 | 62 | ||
63 | 63 | ||
64 | /* XPM */ | 64 | /* XPM */ |
65 | static const char * const right_xpm[] = { | 65 | static const char * const right_xpm[] = { |
66 | "16 16 2 1", | 66 | "16 16 2 1", |
67 | " c None", | 67 | " c None", |
68 | ".c #000000", | 68 | ".c #000000", |
69 | " ", | 69 | " ", |
70 | " ", | 70 | " ", |
71 | " ", | 71 | " ", |
72 | " . ", | 72 | " . ", |
73 | " .. ", | 73 | " .. ", |
74 | " ... ", | 74 | " ... ", |
75 | " .... ", | 75 | " .... ", |
76 | " ..... ", | 76 | " ..... ", |
77 | " ...... ", | 77 | " ...... ", |
78 | " ..... ", | 78 | " ..... ", |
79 | " .... ", | 79 | " .... ", |
80 | " ... ", | 80 | " ... ", |
81 | " .. ", | 81 | " .. ", |
82 | " . ", | 82 | " . ", |
83 | " ", | 83 | " ", |
84 | " "}; | 84 | " "}; |
85 | 85 | ||
86 | 86 | ||
87 | 87 | ||
88 | QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, | 88 | QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, |
89 | const char *name, bool modal, int WFlags ) | 89 | const char *name, bool modal, int WFlags ) |
90 | : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) | 90 | : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) |
91 | { | 91 | { |
92 | setCaption( tr("Setup Handwriting Input") ); | 92 | setCaption( tr("Setup Handwriting Input") ); |
93 | 93 | ||
94 | QVBoxLayout *vb = new QVBoxLayout( this ); | 94 | QVBoxLayout *vb = new QVBoxLayout( this ); |
95 | 95 | ||
96 | #define MULTIPROFILE | 96 | #define MULTIPROFILE |
97 | #ifdef MULTIPROFILE | 97 | #ifdef MULTIPROFILE |
98 | profileList.setAutoDelete( true ); | 98 | profileList.setAutoDelete( true ); |
99 | QHBoxLayout *hb = new QHBoxLayout( vb ); | 99 | QHBoxLayout *hb = new QHBoxLayout( vb ); |
100 | hb->setMargin( 6 ); | 100 | hb->setMargin( 6 ); |
101 | QLabel *l = new QLabel( tr("Character Profile:"), this ); | 101 | QLabel *l = new QLabel( tr("Character Profile:"), this ); |
102 | hb->addWidget( l ); | 102 | hb->addWidget( l ); |
103 | profileCombo = new QComboBox( this ); | 103 | profileCombo = new QComboBox( this ); |
104 | connect( profileCombo, SIGNAL(activated(const QString &)), | 104 | connect( profileCombo, SIGNAL(activated(const QString&)), |
105 | this, SLOT(selectProfile(const QString &)) ); | 105 | this, SLOT(selectProfile(const QString&)) ); |
106 | hb->addWidget( profileCombo ); | 106 | hb->addWidget( profileCombo ); |
107 | #else | 107 | #else |
108 | profileList.append( profile ); | 108 | profileList.append( profile ); |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | qWarning("profiles: %d", profileList.count()); | 111 | qWarning("profiles: %d", profileList.count()); |
112 | 112 | ||
113 | QTabWidget *tw = new QTabWidget( this ); | 113 | QTabWidget *tw = new QTabWidget( this ); |
114 | vb->addWidget( tw ); | 114 | vb->addWidget( tw ); |
115 | 115 | ||
116 | pref = new QIMPenPrefBase( this ); | 116 | pref = new QIMPenPrefBase( this ); |
117 | tw->addTab( pref, tr("Preferences") ); | 117 | tw->addTab( pref, tr("Preferences") ); |
118 | 118 | ||
119 | pref->inputStyle->setExclusive( TRUE ); | 119 | pref->inputStyle->setExclusive( TRUE ); |
120 | 120 | ||
121 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; | 121 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; |
122 | pref->inputStyle->setButton( style ); | 122 | pref->inputStyle->setButton( style ); |
123 | connect( pref->inputStyle, SIGNAL(clicked(int)), | 123 | connect( pref->inputStyle, SIGNAL(clicked(int)), |
124 | this, SLOT(styleClicked(int)) ); | 124 | this, SLOT(styleClicked(int)) ); |
125 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); | 125 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); |
126 | 126 | ||
127 | multiTimeout = profile->multiStrokeTimeout(); | 127 | multiTimeout = profile->multiStrokeTimeout(); |
128 | pref->multiStrokeSlider->setValue( multiTimeout ); | 128 | pref->multiStrokeSlider->setValue( multiTimeout ); |
129 | multiTimeoutChanged( multiTimeout ); | 129 | multiTimeoutChanged( multiTimeout ); |
130 | connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), | 130 | connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), |
131 | this, SLOT(multiTimeoutChanged(int)) ); | 131 | this, SLOT(multiTimeoutChanged(int)) ); |
132 | 132 | ||
133 | edit = new QIMPenEdit( p, tw ); | 133 | edit = new QIMPenEdit( p, tw ); |
134 | tw->addTab( edit, tr("Customize") ); | 134 | tw->addTab( edit, tr("Customize") ); |
135 | #ifdef MULTIPROFILE | 135 | #ifdef MULTIPROFILE |
136 | loadProfiles(); | 136 | loadProfiles(); |
137 | #endif | 137 | #endif |
138 | 138 | ||
139 | } | 139 | } |
140 | 140 | ||
141 | void QIMPenSetup::loadProfiles() | 141 | void QIMPenSetup::loadProfiles() |
142 | { | 142 | { |
143 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; | 143 | QString path = QPEApplication::qpeDir() + "etc/qimpen"; |
144 | QDir dir( path, "*.conf" ); | 144 | QDir dir( path, "*.conf" ); |
145 | QStringList list = dir.entryList(); | 145 | QStringList list = dir.entryList(); |
146 | QStringList::Iterator it; | 146 | QStringList::Iterator it; |
147 | for ( it = list.begin(); it != list.end(); ++it ) { | 147 | for ( it = list.begin(); it != list.end(); ++it ) { |
148 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); | 148 | QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); |
149 | profileList.append( p ); | 149 | profileList.append( p ); |
150 | profileCombo->insertItem( p->name() ); | 150 | profileCombo->insertItem( p->name() ); |
151 | if ( p->name() == profile->name() ) { | 151 | if ( p->name() == profile->name() ) { |
152 | profileCombo->setCurrentItem( profileCombo->count()-1 ); | 152 | profileCombo->setCurrentItem( profileCombo->count()-1 ); |
153 | profile = p; | 153 | profile = p; |
154 | edit->setProfile( profile ); | 154 | edit->setProfile( profile ); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | void QIMPenSetup::styleClicked( int id ) | 159 | void QIMPenSetup::styleClicked( int id ) |
160 | { | 160 | { |
161 | style = id; | 161 | style = id; |
162 | } | 162 | } |
163 | 163 | ||
164 | void QIMPenSetup::multiTimeoutChanged( int v ) | 164 | void QIMPenSetup::multiTimeoutChanged( int v ) |
165 | { | 165 | { |
166 | multiTimeout = v; | 166 | multiTimeout = v; |
167 | pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); | 167 | pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); |
168 | } | 168 | } |
169 | 169 | ||
170 | void QIMPenSetup::selectProfile( const QString &p ) | 170 | void QIMPenSetup::selectProfile( const QString &p ) |
171 | { | 171 | { |
172 | if ( p == profile->name() ) | 172 | if ( p == profile->name() ) |
173 | return; | 173 | return; |
174 | 174 | ||
175 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); | 175 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); |
176 | profile->setMultiStrokeTimeout( multiTimeout ); | 176 | profile->setMultiStrokeTimeout( multiTimeout ); |
177 | 177 | ||
178 | for ( int i = 0; i < (int)profileList.count(); i++ ) { | 178 | for ( int i = 0; i < (int)profileList.count(); i++ ) { |
179 | if ( profileList.at(i)->name() == p ) { | 179 | if ( profileList.at(i)->name() == p ) { |
180 | profile = profileList.at(i); | 180 | profile = profileList.at(i); |
181 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; | 181 | style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; |
182 | pref->inputStyle->setButton( style ); | 182 | pref->inputStyle->setButton( style ); |
183 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); | 183 | pref->inputStyle->setEnabled( profile->canSelectStyle() ); |
184 | multiTimeout = profile->multiStrokeTimeout(); | 184 | multiTimeout = profile->multiStrokeTimeout(); |
185 | pref->multiStrokeSlider->setValue( multiTimeout ); | 185 | pref->multiStrokeSlider->setValue( multiTimeout ); |
186 | multiTimeoutChanged( multiTimeout ); | 186 | multiTimeoutChanged( multiTimeout ); |
187 | edit->setProfile( profile ); | 187 | edit->setProfile( profile ); |
188 | break; | 188 | break; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | void QIMPenSetup::accept() | 193 | void QIMPenSetup::accept() |
194 | { | 194 | { |
195 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); | 195 | profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); |
196 | profile->setMultiStrokeTimeout( multiTimeout ); | 196 | profile->setMultiStrokeTimeout( multiTimeout ); |
197 | // Save current profile | 197 | // Save current profile |
198 | if ( profileCombo ) { | 198 | if ( profileCombo ) { |
199 | Config config( "handwriting" ); | 199 | Config config( "handwriting" ); |
200 | config.setGroup( "Settings" ); | 200 | config.setGroup( "Settings" ); |
201 | config.writeEntry( "Profile", profileCombo->currentText() ); | 201 | config.writeEntry( "Profile", profileCombo->currentText() ); |
202 | } | 202 | } |
203 | // Save charsets | 203 | // Save charsets |
204 | bool ok = TRUE; | 204 | bool ok = TRUE; |
205 | for ( int i = 0; i < (int)profileList.count(); i++ ) { | 205 | for ( int i = 0; i < (int)profileList.count(); i++ ) { |
206 | QIMPenProfile *prof = profileList.at(i); | 206 | QIMPenProfile *prof = profileList.at(i); |
207 | QIMPenCharSetIterator it(prof->charSets()); | 207 | QIMPenCharSetIterator it(prof->charSets()); |
208 | for ( ; it.current(); ++it ) { | 208 | for ( ; it.current(); ++it ) { |
209 | if ( !(it.current()->save( QIMPenCharSet::User )) ) { | 209 | if ( !(it.current()->save( QIMPenCharSet::User )) ) { |
210 | ok = FALSE; | 210 | ok = FALSE; |
211 | break; | 211 | break; |
212 | } | 212 | } |
213 | } | 213 | } |
214 | } | 214 | } |
215 | if ( !ok ) { | 215 | if ( !ok ) { |
216 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 216 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
217 | tr("Unable to save information.\n" | 217 | tr("Unable to save information.\n" |
218 | "Free up some space\n" | 218 | "Free up some space\n" |
219 | "and try again.\n" | 219 | "and try again.\n" |
220 | "\nQuit anyway?"), | 220 | "\nQuit anyway?"), |
221 | QMessageBox::Yes|QMessageBox::Escape, | 221 | QMessageBox::Yes|QMessageBox::Escape, |
222 | QMessageBox::No|QMessageBox::Default ) | 222 | QMessageBox::No|QMessageBox::Default ) |
223 | != QMessageBox::No ) { | 223 | != QMessageBox::No ) { |
224 | QDialog::accept(); | 224 | QDialog::accept(); |
225 | } | 225 | } |
226 | } else { | 226 | } else { |
227 | QDialog::accept(); | 227 | QDialog::accept(); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | //--------------------------------------------------------------------------- | 231 | //--------------------------------------------------------------------------- |
232 | 232 | ||
233 | QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, | 233 | QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, |
234 | bool modal, int WFlags) | 234 | bool modal, int WFlags) |
235 | : QDialog( parent, name, modal, WFlags ) | 235 | : QDialog( parent, name, modal, WFlags ) |
236 | { | 236 | { |
237 | setCaption( tr("Enter new character") ); | 237 | setCaption( tr("Enter new character") ); |
238 | uni = 0; | 238 | uni = 0; |
239 | 239 | ||
240 | QVBoxLayout *vb = new QVBoxLayout( this, 10 ); | 240 | QVBoxLayout *vb = new QVBoxLayout( this, 10 ); |
241 | 241 | ||
242 | QHBoxLayout *hb = new QHBoxLayout(); | 242 | QHBoxLayout *hb = new QHBoxLayout(); |
243 | vb->addLayout( hb ); | 243 | vb->addLayout( hb ); |
244 | 244 | ||
245 | QLabel *label = new QLabel( tr("Character:"), this ); | 245 | QLabel *label = new QLabel( tr("Character:"), this ); |
246 | hb->addWidget( label ); | 246 | hb->addWidget( label ); |
247 | 247 | ||
248 | QComboBox *cb = new QComboBox( TRUE, this ); | 248 | QComboBox *cb = new QComboBox( TRUE, this ); |
249 | connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); | 249 | connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); |
250 | connect( cb, SIGNAL(textChanged(const QString &)), | 250 | connect( cb, SIGNAL(textChanged(const QString&)), |
251 | SLOT(setCharacter(const QString &)) ); | 251 | SLOT(setCharacter(const QString&)) ); |
252 | addSpecial( cb ); | 252 | addSpecial( cb ); |
253 | cb->setEditText( "" ); | 253 | cb->setEditText( "" ); |
254 | hb->addWidget( cb ); | 254 | hb->addWidget( cb ); |
255 | 255 | ||
256 | hb = new QHBoxLayout(); | 256 | hb = new QHBoxLayout(); |
257 | vb->addLayout( hb ); | 257 | vb->addLayout( hb ); |
258 | 258 | ||
259 | QPushButton *pb = new QPushButton( "OK", this ); | 259 | QPushButton *pb = new QPushButton( "OK", this ); |
260 | connect( pb, SIGNAL(clicked()), SLOT(accept())); | 260 | connect( pb, SIGNAL(clicked()), SLOT(accept())); |
261 | hb->addWidget( pb ); | 261 | hb->addWidget( pb ); |
262 | pb = new QPushButton( "Cancel", this ); | 262 | pb = new QPushButton( "Cancel", this ); |
263 | connect( pb, SIGNAL(clicked()), SLOT(reject())); | 263 | connect( pb, SIGNAL(clicked()), SLOT(reject())); |
264 | hb->addWidget( pb ); | 264 | hb->addWidget( pb ); |
265 | 265 | ||
266 | cb->setFocus(); | 266 | cb->setFocus(); |
267 | } | 267 | } |
268 | 268 | ||
269 | void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) | 269 | void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) |
270 | { | 270 | { |
271 | int i = 0; | 271 | int i = 0; |
272 | while ( qimpen_specialKeys[i].code != Key_unknown ) { | 272 | while ( qimpen_specialKeys[i].code != Key_unknown ) { |
273 | cb->insertItem( qimpen_specialKeys[i].name ); | 273 | cb->insertItem( qimpen_specialKeys[i].name ); |
274 | i++; | 274 | i++; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void QIMPenInputCharDlg::setSpecial( int sp ) | 278 | void QIMPenInputCharDlg::setSpecial( int sp ) |
279 | { | 279 | { |
280 | uni = qimpen_specialKeys[sp].code << 16; | 280 | uni = qimpen_specialKeys[sp].code << 16; |
281 | } | 281 | } |
282 | 282 | ||
283 | void QIMPenInputCharDlg::setCharacter( const QString &string ) | 283 | void QIMPenInputCharDlg::setCharacter( const QString &string ) |
284 | { | 284 | { |
285 | uni = string[0].unicode(); | 285 | uni = string[0].unicode(); |
286 | } | 286 | } |
287 | 287 | ||
288 | //--------------------------------------------------------------------------- | 288 | //--------------------------------------------------------------------------- |
289 | 289 | ||
290 | class CharListItem : public QListBoxText | 290 | class CharListItem : public QListBoxText |
291 | { | 291 | { |
292 | public: | 292 | public: |
293 | CharListItem( const QString &text, uint c ) | 293 | CharListItem( const QString &text, uint c ) |
294 | : QListBoxText( text ) | 294 | : QListBoxText( text ) |
295 | { | 295 | { |
296 | _code = c; | 296 | _code = c; |
297 | } | 297 | } |
298 | 298 | ||
299 | uint code() const { return _code; } | 299 | uint code() const { return _code; } |
300 | 300 | ||
301 | protected: | 301 | protected: |
302 | uint _code; | 302 | uint _code; |
303 | }; | 303 | }; |
304 | 304 | ||
305 | /*! | 305 | /*! |
306 | \class QIMPenEdit qimpensetup.h | 306 | \class QIMPenEdit qimpensetup.h |
307 | 307 | ||
308 | Class to allow users to input totally useless character definitions | 308 | Class to allow users to input totally useless character definitions |
309 | which could match any number of the default set. | 309 | which could match any number of the default set. |
310 | */ | 310 | */ |
311 | 311 | ||
312 | QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, | 312 | QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, |
313 | const char *name ) | 313 | const char *name ) |
314 | : QWidget( parent, name ), profile(p) | 314 | : QWidget( parent, name ), profile(p) |
315 | { | 315 | { |
316 | currentChar = 0; | 316 | currentChar = 0; |
317 | currentCode = 0; | 317 | currentCode = 0; |
318 | inputChar = new QIMPenChar(); | 318 | inputChar = new QIMPenChar(); |
319 | 319 | ||
320 | QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); | 320 | QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); |
321 | 321 | ||
322 | QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); | 322 | QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); |
323 | gl->setRowStretch( 1, 1 ); | 323 | gl->setRowStretch( 1, 1 ); |
324 | gl->addRowSpacing( 2, 35 ); | 324 | gl->addRowSpacing( 2, 35 ); |
325 | gl->addRowSpacing( 3, 35 ); | 325 | gl->addRowSpacing( 3, 35 ); |
326 | 326 | ||
327 | charSetCombo = new QComboBox( this ); | 327 | charSetCombo = new QComboBox( this ); |
328 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); | 328 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); |
329 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); | 329 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); |
330 | QIMPenCharSetIterator it( profile->charSets() ); | 330 | QIMPenCharSetIterator it( profile->charSets() ); |
331 | for ( ; it.current(); ++it ) { | 331 | for ( ; it.current(); ++it ) { |
332 | charSetCombo->insertItem( it.current()->description() ); | 332 | charSetCombo->insertItem( it.current()->description() ); |
333 | } | 333 | } |
334 | 334 | ||
335 | charList = new QListBox( this ); | 335 | charList = new QListBox( this ); |
336 | charList->setMinimumHeight( charList->sizeHint().height() ); | 336 | charList->setMinimumHeight( charList->sizeHint().height() ); |
337 | connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); | 337 | connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); |
338 | gl->addWidget( charList, 1, 0 ); | 338 | gl->addWidget( charList, 1, 0 ); |
339 | 339 | ||
340 | pw = new QIMPenWidget( this ); | 340 | pw = new QIMPenWidget( this ); |
341 | pw->setFixedHeight( 75 ); | 341 | pw->setFixedHeight( 75 ); |
342 | gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); | 342 | gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); |
343 | connect( pw, SIGNAL(stroke(QIMPenStroke *)), | 343 | connect( pw, SIGNAL(stroke(QIMPenStroke*)), |
344 | SLOT(newStroke(QIMPenStroke *)) ); | 344 | SLOT(newStroke(QIMPenStroke*)) ); |
345 | 345 | ||
346 | QVBoxLayout *vb = new QVBoxLayout(); | 346 | QVBoxLayout *vb = new QVBoxLayout(); |
347 | gl->addLayout( vb, 1, 1 ); | 347 | gl->addLayout( vb, 1, 1 ); |
348 | newBtn = new QPushButton( tr("New..."), this ); | 348 | newBtn = new QPushButton( tr("New..."), this ); |
349 | connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); | 349 | connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); |
350 | vb->addWidget( newBtn ); | 350 | vb->addWidget( newBtn ); |
351 | 351 | ||
352 | addBtn = new QPushButton( tr("Add"), this ); | 352 | addBtn = new QPushButton( tr("Add"), this ); |
353 | connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); | 353 | connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); |
354 | vb->addWidget( addBtn ); | 354 | vb->addWidget( addBtn ); |
355 | 355 | ||
356 | removeBtn = new QPushButton( tr("Remove"), this ); | 356 | removeBtn = new QPushButton( tr("Remove"), this ); |
357 | connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); | 357 | connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); |
358 | vb->addWidget( removeBtn ); | 358 | vb->addWidget( removeBtn ); |
359 | 359 | ||
360 | QPushButton *pb = new QPushButton( tr("Default"), this ); | 360 | QPushButton *pb = new QPushButton( tr("Default"), this ); |
361 | connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); | 361 | connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); |
362 | vb->addWidget( pb ); | 362 | vb->addWidget( pb ); |
363 | 363 | ||
364 | QHBoxLayout *hb = new QHBoxLayout(); | 364 | QHBoxLayout *hb = new QHBoxLayout(); |
365 | gl->addLayout( hb, 2, 1 ); | 365 | gl->addLayout( hb, 2, 1 ); |
366 | prevBtn = new QPushButton( this ); | 366 | prevBtn = new QPushButton( this ); |
367 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); | 367 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); |
368 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); | 368 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); |
369 | hb->addWidget( prevBtn ); | 369 | hb->addWidget( prevBtn ); |
370 | 370 | ||
371 | nextBtn = new QPushButton( this ); | 371 | nextBtn = new QPushButton( this ); |
372 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); | 372 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); |
373 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); | 373 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); |
374 | hb->addWidget( nextBtn ); | 374 | hb->addWidget( nextBtn ); |
375 | 375 | ||
376 | pb = new QPushButton( tr("Clear"), this ); | 376 | pb = new QPushButton( tr("Clear"), this ); |
377 | connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); | 377 | connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); |
378 | gl->addWidget( pb, 3, 1 ); | 378 | gl->addWidget( pb, 3, 1 ); |
379 | 379 | ||
380 | //-- | 380 | //-- |
381 | #if !defined(Q_WS_QWS) | 381 | #if !defined(Q_WS_QWS) |
382 | hb = new QHBoxLayout( tvb ); | 382 | hb = new QHBoxLayout( tvb ); |
383 | pb = new QPushButton( tr("OK"), this ); | 383 | pb = new QPushButton( tr("OK"), this ); |
384 | connect( pb, SIGNAL(clicked()), SLOT(accept()) ); | 384 | connect( pb, SIGNAL(clicked()), SLOT(accept()) ); |
385 | hb->addWidget( pb ); | 385 | hb->addWidget( pb ); |
386 | 386 | ||
387 | pb = new QPushButton( tr("Cancel"), this ); | 387 | pb = new QPushButton( tr("Cancel"), this ); |
388 | connect( pb, SIGNAL(clicked()), SLOT(reject()) ); | 388 | connect( pb, SIGNAL(clicked()), SLOT(reject()) ); |
389 | hb->addWidget( pb ); | 389 | hb->addWidget( pb ); |
390 | #endif | 390 | #endif |
391 | selectCharSet( 0 ); | 391 | selectCharSet( 0 ); |
392 | charList->setFocus(); | 392 | charList->setFocus(); |
393 | 393 | ||
394 | resize( minimumSize() ); | 394 | resize( minimumSize() ); |
395 | enableButtons(); | 395 | enableButtons(); |
396 | } | 396 | } |
397 | 397 | ||
398 | void QIMPenEdit::setProfile( QIMPenProfile *p ) | 398 | void QIMPenEdit::setProfile( QIMPenProfile *p ) |
399 | { | 399 | { |
400 | profile = p; | 400 | profile = p; |
401 | charSetCombo->clear(); | 401 | charSetCombo->clear(); |
402 | QIMPenCharSetIterator it( profile->charSets() ); | 402 | QIMPenCharSetIterator it( profile->charSets() ); |
403 | for ( ; it.current(); ++it ) { | 403 | for ( ; it.current(); ++it ) { |
404 | if ( ! it.current()->hidden() ) | 404 | if ( ! it.current()->hidden() ) |
405 | charSetCombo->insertItem( it.current()->description() ); | 405 | charSetCombo->insertItem( it.current()->description() ); |
406 | } | 406 | } |
407 | selectCharSet( 0 ); | 407 | selectCharSet( 0 ); |
408 | charList->setFocus(); | 408 | charList->setFocus(); |
409 | enableButtons(); | 409 | enableButtons(); |
410 | } | 410 | } |
411 | 411 | ||
412 | void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) | 412 | void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) |
413 | { | 413 | { |
414 | int i = 0; | 414 | int i = 0; |
415 | QIMPenCharSetIterator it( profile->charSets() ); | 415 | QIMPenCharSetIterator it( profile->charSets() ); |
416 | for ( ; it.current(); ++it, i++ ) { | 416 | for ( ; it.current(); ++it, i++ ) { |
417 | if ( it.current() == c ) { | 417 | if ( it.current() == c ) { |
418 | charSetCombo->setCurrentItem( i ); | 418 | charSetCombo->setCurrentItem( i ); |
419 | selectCharSet( i ); | 419 | selectCharSet( i ); |
420 | } | 420 | } |
421 | } | 421 | } |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | /*! | 425 | /*! |
426 | Fill the character list box with the characters. Duplicates are not | 426 | Fill the character list box with the characters. Duplicates are not |
427 | inserted. | 427 | inserted. |
428 | */ | 428 | */ |
429 | void QIMPenEdit::fillCharList() | 429 | void QIMPenEdit::fillCharList() |
430 | { | 430 | { |
431 | charList->clear(); | 431 | charList->clear(); |
432 | QIMPenCharIterator it( currentSet->characters() ); | 432 | QIMPenCharIterator it( currentSet->characters() ); |
433 | CharListItem *li = 0; | 433 | CharListItem *li = 0; |
434 | for ( ; it.current(); ++it ) { | 434 | for ( ; it.current(); ++it ) { |
435 | uint ch = it.current()->character(); | 435 | uint ch = it.current()->character(); |
436 | QString n = it.current()->name(); | 436 | QString n = it.current()->name(); |
437 | if ( !n.isEmpty() ) | 437 | if ( !n.isEmpty() ) |
438 | li = new CharListItem( n, ch ); | 438 | li = new CharListItem( n, ch ); |
439 | if ( li ) { | 439 | if ( li ) { |
440 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); | 440 | CharListItem *i = (CharListItem *)charList->findItem( li->text() ); |
441 | if ( !i || i->code() != ch ) { | 441 | if ( !i || i->code() != ch ) { |
442 | charList->insertItem( li ); | 442 | charList->insertItem( li ); |
443 | } else { | 443 | } else { |
444 | delete li; | 444 | delete li; |
445 | li = 0; | 445 | li = 0; |
446 | } | 446 | } |
447 | } | 447 | } |
448 | } | 448 | } |
449 | currentChar = 0; | 449 | currentChar = 0; |
450 | } | 450 | } |
451 | 451 | ||
452 | void QIMPenEdit::enableButtons() | 452 | void QIMPenEdit::enableButtons() |
453 | { | 453 | { |
454 | bool add = !inputChar->isEmpty(); | 454 | bool add = !inputChar->isEmpty(); |
455 | newBtn->setEnabled( add ); | 455 | newBtn->setEnabled( add ); |
456 | addBtn->setEnabled( add ); | 456 | addBtn->setEnabled( add ); |
457 | removeBtn->setEnabled( currentChar ); | 457 | removeBtn->setEnabled( currentChar ); |
458 | } | 458 | } |
459 | 459 | ||
460 | /*! | 460 | /*! |
461 | Find the previous character with the same code as the current one. | 461 | Find the previous character with the same code as the current one. |
462 | returns 0 if there is no previous character. | 462 | returns 0 if there is no previous character. |
463 | */ | 463 | */ |
464 | QIMPenChar *QIMPenEdit::findPrev() | 464 | QIMPenChar *QIMPenEdit::findPrev() |
465 | { | 465 | { |
466 | if ( !currentChar ) | 466 | if ( !currentChar ) |
467 | return 0; | 467 | return 0; |
468 | QIMPenCharIterator it( currentSet->characters() ); | 468 | QIMPenCharIterator it( currentSet->characters() ); |
469 | bool found = FALSE; | 469 | bool found = FALSE; |
470 | for ( it.toLast(); it.current(); --it ) { | 470 | for ( it.toLast(); it.current(); --it ) { |
471 | if ( !found && it.current() == currentChar ) | 471 | if ( !found && it.current() == currentChar ) |
472 | found = TRUE; | 472 | found = TRUE; |
473 | else if ( found && it.current()->character() == currentCode && | 473 | else if ( found && it.current()->character() == currentCode && |
474 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 474 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
475 | return it.current(); | 475 | return it.current(); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | return 0; | 479 | return 0; |
480 | } | 480 | } |
481 | 481 | ||
482 | /*! | 482 | /*! |
483 | Find the next character with the same code as the current one. | 483 | Find the next character with the same code as the current one. |
484 | returns 0 if there is no next character. | 484 | returns 0 if there is no next character. |
485 | */ | 485 | */ |
486 | QIMPenChar *QIMPenEdit::findNext() | 486 | QIMPenChar *QIMPenEdit::findNext() |
487 | { | 487 | { |
488 | if ( !currentChar ) | 488 | if ( !currentChar ) |
489 | return 0; | 489 | return 0; |
490 | QIMPenCharIterator it( currentSet->characters() ); | 490 | QIMPenCharIterator it( currentSet->characters() ); |
491 | bool found = FALSE; | 491 | bool found = FALSE; |
492 | for ( ; it.current(); ++it ) { | 492 | for ( ; it.current(); ++it ) { |
493 | if ( !found && it.current() == currentChar ) | 493 | if ( !found && it.current() == currentChar ) |
494 | found = TRUE; | 494 | found = TRUE; |
495 | else if ( found && it.current()->character() == currentCode && | 495 | else if ( found && it.current()->character() == currentCode && |
496 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 496 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
497 | return it.current(); | 497 | return it.current(); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | return 0; | 501 | return 0; |
502 | } | 502 | } |
503 | 503 | ||
504 | void QIMPenEdit::setCurrentChar( QIMPenChar *pc ) | 504 | void QIMPenEdit::setCurrentChar( QIMPenChar *pc ) |
505 | { | 505 | { |
506 | currentChar = pc; | 506 | currentChar = pc; |
507 | pw->showCharacter( currentChar ); | 507 | pw->showCharacter( currentChar ); |
508 | if ( currentChar ) { | 508 | if ( currentChar ) { |
509 | prevBtn->setEnabled( findPrev() != 0 ); | 509 | prevBtn->setEnabled( findPrev() != 0 ); |
510 | nextBtn->setEnabled( findNext() != 0 ); | 510 | nextBtn->setEnabled( findNext() != 0 ); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | void QIMPenEdit::prevChar() | 514 | void QIMPenEdit::prevChar() |
515 | { | 515 | { |
516 | QIMPenChar *pc = findPrev(); | 516 | QIMPenChar *pc = findPrev(); |
517 | if ( pc ) | 517 | if ( pc ) |
518 | setCurrentChar( pc ); | 518 | setCurrentChar( pc ); |
519 | } | 519 | } |
520 | 520 | ||
521 | void QIMPenEdit::nextChar() | 521 | void QIMPenEdit::nextChar() |
522 | { | 522 | { |
523 | QIMPenChar *pc = findNext(); | 523 | QIMPenChar *pc = findNext(); |
524 | if ( pc ) | 524 | if ( pc ) |
525 | setCurrentChar( pc ); | 525 | setCurrentChar( pc ); |
526 | } | 526 | } |
527 | 527 | ||
528 | void QIMPenEdit::clearChar() | 528 | void QIMPenEdit::clearChar() |
529 | { | 529 | { |
530 | inputChar->clear(); | 530 | inputChar->clear(); |
531 | pw->clear(); | 531 | pw->clear(); |
532 | enableButtons(); | 532 | enableButtons(); |
533 | } | 533 | } |
534 | 534 | ||
535 | void QIMPenEdit::selectChar( int i ) | 535 | void QIMPenEdit::selectChar( int i ) |
536 | { | 536 | { |
537 | currentChar = 0; | 537 | currentChar = 0; |
538 | currentCode = ((CharListItem *)charList->item(i))->code(); | 538 | currentCode = ((CharListItem *)charList->item(i))->code(); |
539 | QIMPenCharIterator it(currentSet->characters() ); | 539 | QIMPenCharIterator it(currentSet->characters() ); |
540 | for ( ; it.current(); ++it ) { | 540 | for ( ; it.current(); ++it ) { |
541 | if ( it.current()->character() == currentCode && | 541 | if ( it.current()->character() == currentCode && |
542 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { | 542 | !it.current()->testFlag( QIMPenChar::Deleted ) ) { |
543 | setCurrentChar( it.current() ); | 543 | setCurrentChar( it.current() ); |
544 | break; | 544 | break; |
545 | } | 545 | } |
546 | } | 546 | } |
547 | if ( !it.current() ) | 547 | if ( !it.current() ) |
548 | setCurrentChar( 0 ); | 548 | setCurrentChar( 0 ); |
549 | inputChar->clear(); | 549 | inputChar->clear(); |
550 | } | 550 | } |
551 | 551 | ||
552 | void QIMPenEdit::selectCharSet( int i ) | 552 | void QIMPenEdit::selectCharSet( int i ) |
553 | { | 553 | { |
554 | if ( currentSet ) | 554 | if ( currentSet ) |
555 | pw->removeCharSet( 0 ); | 555 | pw->removeCharSet( 0 ); |
556 | currentSet = profile->charSets().at( i ); | 556 | currentSet = profile->charSets().at( i ); |
557 | fillCharList(); | 557 | fillCharList(); |
558 | pw->insertCharSet( currentSet ); | 558 | pw->insertCharSet( currentSet ); |
559 | inputChar->clear(); | 559 | inputChar->clear(); |
560 | if ( charList->count() ) { | 560 | if ( charList->count() ) { |
561 | charList->setSelected( 0, TRUE ); | 561 | charList->setSelected( 0, TRUE ); |
562 | selectChar(0); | 562 | selectChar(0); |
563 | } | 563 | } |
564 | } | 564 | } |
565 | 565 | ||
566 | void QIMPenEdit::addChar() | 566 | void QIMPenEdit::addChar() |
567 | { | 567 | { |
568 | if ( !inputChar->isEmpty() ) { | 568 | if ( !inputChar->isEmpty() ) { |
569 | QIMPenChar *pc = new QIMPenChar( *inputChar ); | 569 | QIMPenChar *pc = new QIMPenChar( *inputChar ); |
570 | pc->setCharacter( currentCode ); | 570 | pc->setCharacter( currentCode ); |
571 | 571 | ||
572 | // User characters override all matching system characters. | 572 | // User characters override all matching system characters. |
573 | // Copy and mark deleted identical system characters. | 573 | // Copy and mark deleted identical system characters. |
574 | 574 | ||
575 | QIMPenCharIterator it(currentSet->characters() ); | 575 | QIMPenCharIterator it(currentSet->characters() ); |
576 | QIMPenChar *sc = 0; | 576 | QIMPenChar *sc = 0; |
577 | while ( (sc = it.current()) != 0 ) { | 577 | while ( (sc = it.current()) != 0 ) { |
578 | ++it; | 578 | ++it; |
579 | if ( sc->character() == currentCode && | 579 | if ( sc->character() == currentCode && |
580 | sc->testFlag( QIMPenChar::System ) && | 580 | sc->testFlag( QIMPenChar::System ) && |
581 | !sc->testFlag( QIMPenChar::Deleted ) ) { | 581 | !sc->testFlag( QIMPenChar::Deleted ) ) { |
582 | QIMPenChar *cc = new QIMPenChar( *sc ); | 582 | QIMPenChar *cc = new QIMPenChar( *sc ); |
583 | cc->clearFlag( QIMPenChar::System ); | 583 | cc->clearFlag( QIMPenChar::System ); |
584 | currentSet->addChar( cc ); | 584 | currentSet->addChar( cc ); |
585 | sc->setFlag( QIMPenChar::Deleted ); | 585 | sc->setFlag( QIMPenChar::Deleted ); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | 588 | ||
589 | currentSet->addChar( pc ); | 589 | currentSet->addChar( pc ); |
590 | setCurrentChar( pc ); | 590 | setCurrentChar( pc ); |
591 | inputChar->clear(); | 591 | inputChar->clear(); |
592 | } | 592 | } |
593 | } | 593 | } |
594 | 594 | ||
595 | void QIMPenEdit::addNewChar() | 595 | void QIMPenEdit::addNewChar() |
596 | { | 596 | { |
597 | if ( !inputChar->isEmpty() ) { | 597 | if ( !inputChar->isEmpty() ) { |
598 | QIMPenInputCharDlg dlg( 0, 0, TRUE ); | 598 | QIMPenInputCharDlg dlg( 0, 0, TRUE ); |
599 | if ( dlg.exec() ) { | 599 | if ( dlg.exec() ) { |
600 | currentCode = dlg.unicode(); | 600 | currentCode = dlg.unicode(); |
601 | addChar(); | 601 | addChar(); |
602 | fillCharList(); | 602 | fillCharList(); |
603 | for ( unsigned int i = 0; i < charList->count(); i++ ) { | 603 | for ( unsigned int i = 0; i < charList->count(); i++ ) { |
604 | CharListItem *li = (CharListItem *)charList->item(i); | 604 | CharListItem *li = (CharListItem *)charList->item(i); |
605 | if ( li->code() == dlg.unicode() ) { | 605 | if ( li->code() == dlg.unicode() ) { |
606 | charList->setSelected( i, TRUE ); | 606 | charList->setSelected( i, TRUE ); |
607 | break; | 607 | break; |
608 | } | 608 | } |
609 | } | 609 | } |
610 | } | 610 | } |
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | void QIMPenEdit::removeChar() | 614 | void QIMPenEdit::removeChar() |
615 | { | 615 | { |
616 | if ( currentChar ) { | 616 | if ( currentChar ) { |
617 | QIMPenChar *pc = findPrev(); | 617 | QIMPenChar *pc = findPrev(); |
618 | if ( !pc ) pc = findNext(); | 618 | if ( !pc ) pc = findNext(); |
619 | if ( currentChar->testFlag( QIMPenChar::System ) ) | 619 | if ( currentChar->testFlag( QIMPenChar::System ) ) |
620 | currentChar->setFlag( QIMPenChar::Deleted ); | 620 | currentChar->setFlag( QIMPenChar::Deleted ); |
621 | else | 621 | else |
622 | currentSet->removeChar( currentChar ); | 622 | currentSet->removeChar( currentChar ); |
623 | setCurrentChar( pc ); | 623 | setCurrentChar( pc ); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | void QIMPenEdit::defaultChars() | 627 | void QIMPenEdit::defaultChars() |
628 | { | 628 | { |
629 | if ( currentCode ) { | 629 | if ( currentCode ) { |
630 | currentChar = 0; | 630 | currentChar = 0; |
631 | bool haveSystem = FALSE; | 631 | bool haveSystem = FALSE; |
632 | QIMPenCharIterator it(currentSet->characters() ); | 632 | QIMPenCharIterator it(currentSet->characters() ); |
633 | for ( ; it.current(); ++it ) { | 633 | for ( ; it.current(); ++it ) { |
634 | if ( it.current()->character() == currentCode && | 634 | if ( it.current()->character() == currentCode && |
635 | it.current()->testFlag( QIMPenChar::System ) ) { | 635 | it.current()->testFlag( QIMPenChar::System ) ) { |
636 | haveSystem = TRUE; | 636 | haveSystem = TRUE; |
637 | break; | 637 | break; |
638 | } | 638 | } |
639 | } | 639 | } |
640 | if ( haveSystem ) { | 640 | if ( haveSystem ) { |
641 | it.toFirst(); | 641 | it.toFirst(); |
642 | while ( it.current() ) { | 642 | while ( it.current() ) { |
643 | QIMPenChar *pc = it.current(); | 643 | QIMPenChar *pc = it.current(); |
644 | ++it; | 644 | ++it; |
645 | if ( pc->character() == currentCode ) { | 645 | if ( pc->character() == currentCode ) { |
646 | if ( pc->testFlag( QIMPenChar::System ) ) { | 646 | if ( pc->testFlag( QIMPenChar::System ) ) { |
647 | pc->clearFlag( QIMPenChar::Deleted ); | 647 | pc->clearFlag( QIMPenChar::Deleted ); |
648 | if ( !currentChar ) | 648 | if ( !currentChar ) |
649 | currentChar = pc; | 649 | currentChar = pc; |
650 | } else { | 650 | } else { |
651 | currentSet->removeChar( pc ); | 651 | currentSet->removeChar( pc ); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | } | 654 | } |
655 | setCurrentChar( currentChar ); | 655 | setCurrentChar( currentChar ); |
656 | } | 656 | } |
657 | } | 657 | } |
658 | } | 658 | } |
659 | 659 | ||
660 | void QIMPenEdit::newStroke( QIMPenStroke *st ) | 660 | void QIMPenEdit::newStroke( QIMPenStroke *st ) |
661 | { | 661 | { |
662 | inputChar->addStroke( st ); | 662 | inputChar->addStroke( st ); |
663 | enableButtons(); | 663 | enableButtons(); |
664 | } | 664 | } |
665 | 665 | ||
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index aec0ad3..4f4f25f 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 | } |