Diffstat (limited to 'inputmethods/handwriting/qimpenhelp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/handwriting/qimpenhelp.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/inputmethods/handwriting/qimpenhelp.cpp b/inputmethods/handwriting/qimpenhelp.cpp index 5ee46a2..a294301 100644 --- a/inputmethods/handwriting/qimpenhelp.cpp +++ b/inputmethods/handwriting/qimpenhelp.cpp | |||
@@ -1,10 +1,10 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of 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 | ** |
@@ -132,75 +132,70 @@ void HandwritingHelp::hideEvent( QHideEvent * ) | |||
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, 5, 2, 0, 4 ); | 138 | QGridLayout *gl = new QGridLayout( this, 4, 2, 0, 4 ); |
139 | gl->setRowStretch( 1, 1 ); | ||
140 | gl->setRowStretch( 2, 1 ); | ||
141 | gl->setColStretch( 1, 1 ); | 139 | gl->setColStretch( 1, 1 ); |
140 | gl->setRowStretch(3, 1); | ||
142 | 141 | ||
143 | charSetCombo = new QComboBox( this ); | 142 | charSetCombo = new QComboBox( this ); |
144 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); | 143 | gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); |
145 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); | 144 | connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); |
146 | QIMPenCharSetIterator it( profile->charSets() ); | 145 | QIMPenCharSetIterator it( profile->charSets() ); |
147 | for ( ; it.current(); ++it ) { | 146 | for ( ; it.current(); ++it ) { |
148 | charSetCombo->insertItem( it.current()->description() ); | 147 | charSetCombo->insertItem( it.current()->description() ); |
149 | } | 148 | } |
150 | 149 | ||
151 | charList = new QListBox( this ); | 150 | charList = new QListBox( this ); |
152 | charList->setHScrollBarMode( QListBox::AlwaysOff ); | 151 | charList->setHScrollBarMode( QListBox::AlwaysOff ); |
153 | charList->setFixedWidth( 80 ); | 152 | charList->setFixedWidth(80); |
154 | connect( charList, SIGNAL(highlighted(int)), this, SLOT(selectChar(int)) ); | 153 | connect( charList, SIGNAL(highlighted(int)), this, SLOT(selectChar(int)) ); |
155 | gl->addMultiCellWidget( charList, 1, 2, 0, 0 ); | 154 | gl->addWidget(charList, 1, 0); |
156 | |||
157 | QLabel *help = new QLabel( this ); | ||
158 | help->setAlignment( AlignLeft | AlignVCenter | WordBreak ); | ||
159 | gl->addWidget( help, 1, 1 ); | ||
160 | help->setText( | ||
161 | tr( "Select a character from the list. The writing area on the left " | ||
162 | "shows the reference character. Practice writing in the area on " | ||
163 | "the right.") ); | ||
164 | 155 | ||
165 | result = new QLabel( this ); | 156 | result = new QLabel( this ); |
166 | gl->addMultiCellWidget( result, 2, 3, 1, 1 ); | 157 | result->setAlignment(AlignLeft | AlignVCenter | WordBreak); |
158 | result->setText( | ||
159 | tr( "Select a reference character from the list. Practice writing in " | ||
160 | "the area on the right.")); | ||
161 | gl->addMultiCellWidget(result, 1, 2, 1, 1); | ||
167 | 162 | ||
168 | matcher = new QIMPenMatch( this ); | 163 | matcher = new QIMPenMatch( this ); |
169 | matcher->setCharSet( currentSet ); | 164 | matcher->setCharSet( currentSet ); |
170 | connect( matcher, SIGNAL(noMatch()), this, SLOT(noMatch()) ); | 165 | connect( matcher, SIGNAL(noMatch()), this, SLOT(noMatch()) ); |
171 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList &)), | 166 | connect( matcher, SIGNAL(matchedCharacters(const QIMPenCharMatchList &)), |
172 | this, SLOT(matched(const QIMPenCharMatchList &)) ); | 167 | this, SLOT(matched(const QIMPenCharMatchList &)) ); |
173 | 168 | ||
174 | QHBoxLayout *hb = new QHBoxLayout(); | 169 | QHBoxLayout *hb = new QHBoxLayout(); |
175 | gl->addLayout( hb, 3, 0 ); | 170 | gl->addLayout( hb, 2, 0 ); |
176 | prevBtn = new QPushButton( this ); | 171 | prevBtn = new QPushButton( this ); |
177 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); | 172 | prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); |
178 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); | 173 | connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); |
179 | hb->addWidget( prevBtn ); | 174 | hb->addWidget( prevBtn ); |
180 | 175 | ||
181 | nextBtn = new QPushButton( this ); | 176 | nextBtn = new QPushButton( this ); |
182 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); | 177 | nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); |
183 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); | 178 | connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); |
184 | hb->addWidget( nextBtn ); | 179 | hb->addWidget( nextBtn ); |
185 | 180 | ||
186 | refPw = new QIMPenWidget( this ); | 181 | refPw = new QIMPenWidget( this ); |
187 | refPw->setReadOnly( TRUE ); | 182 | refPw->setReadOnly( TRUE ); |
188 | gl->addWidget( refPw, 4, 0 ); | 183 | gl->addWidget( refPw, 3, 0 ); |
189 | 184 | ||
190 | pracPw = new QIMPenWidget( this ); | 185 | pracPw = new QIMPenWidget( this ); |
191 | connect( matcher, SIGNAL(removeStroke()), pracPw, SLOT(removeStroke()) ); | 186 | connect( matcher, SIGNAL(removeStroke()), pracPw, SLOT(removeStroke()) ); |
192 | connect( pracPw, SIGNAL(beginStroke()), | 187 | connect( pracPw, SIGNAL(beginStroke()), |
193 | this, SLOT(beginStroke()) ); | 188 | this, SLOT(beginStroke()) ); |
194 | connect( pracPw, SIGNAL(stroke( QIMPenStroke * )), | 189 | connect( pracPw, SIGNAL(stroke( QIMPenStroke * )), |
195 | this, SLOT(strokeEntered( QIMPenStroke * )) ); | 190 | this, SLOT(strokeEntered( QIMPenStroke * )) ); |
196 | connect( pracPw, SIGNAL(beginStroke()), | 191 | connect( pracPw, SIGNAL(beginStroke()), |
197 | matcher, SLOT(beginStroke()) ); | 192 | matcher, SLOT(beginStroke()) ); |
198 | connect( pracPw, SIGNAL(stroke( QIMPenStroke * )), | 193 | connect( pracPw, SIGNAL(stroke( QIMPenStroke * )), |
199 | matcher, SLOT(strokeEntered( QIMPenStroke * )) ); | 194 | matcher, SLOT(strokeEntered( QIMPenStroke * )) ); |
200 | gl->addWidget( pracPw, 4, 1 ); | 195 | gl->addWidget( pracPw, 3, 1 ); |
201 | 196 | ||
202 | redrawTimer = new QTimer( this ); | 197 | redrawTimer = new QTimer( this ); |
203 | connect( redrawTimer, SIGNAL(timeout()), this, SLOT(redrawChar()) ); | 198 | connect( redrawTimer, SIGNAL(timeout()), this, SLOT(redrawChar()) ); |
204 | redrawTimer->start( 5000 ); | 199 | redrawTimer->start( 5000 ); |
205 | 200 | ||
206 | currentSet = 0; | 201 | currentSet = 0; |
@@ -224,18 +219,23 @@ void HandwritingTrainer::setCurrentChar( QIMPenChar *c ) | |||
224 | refPw->showCharacter( currentChar ); | 219 | refPw->showCharacter( currentChar ); |
225 | pracPw->clear(); | 220 | pracPw->clear(); |
226 | if ( currentChar ) { | 221 | if ( currentChar ) { |
227 | prevBtn->setEnabled( findPrev() != 0 ); | 222 | prevBtn->setEnabled( findPrev() != 0 ); |
228 | nextBtn->setEnabled( findNext() != 0 ); | 223 | nextBtn->setEnabled( findNext() != 0 ); |
229 | } | 224 | } |
230 | result->setText( "" ); | ||
231 | redrawTimer->start( 5000 ); | 225 | redrawTimer->start( 5000 ); |
232 | } | 226 | } |
233 | 227 | ||
234 | void HandwritingTrainer::selectChar( int i ) | 228 | void HandwritingTrainer::selectChar( int i ) |
235 | { | 229 | { |
230 | static int last_char = 0; | ||
231 | |||
232 | if (last_char != i) { | ||
233 | result->setText(""); | ||
234 | } | ||
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 ) ) { |
@@ -249,12 +249,13 @@ void HandwritingTrainer::selectChar( int i ) | |||
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 | } | 256 | } |
256 | currentSet = profile->charSets().at( i ); | 257 | currentSet = profile->charSets().at( i ); |
257 | fillCharList(); | 258 | fillCharList(); |
258 | refPw->insertCharSet( currentSet ); | 259 | refPw->insertCharSet( currentSet ); |
259 | pracPw->insertCharSet( currentSet ); | 260 | pracPw->insertCharSet( currentSet ); |
260 | matcher->setCharSet( currentSet ); | 261 | matcher->setCharSet( currentSet ); |
@@ -263,13 +264,13 @@ void HandwritingTrainer::selectCharSet( int i ) | |||
263 | selectChar(0); | 264 | selectChar(0); |
264 | } | 265 | } |
265 | } | 266 | } |
266 | 267 | ||
267 | void HandwritingTrainer::noMatch() | 268 | void HandwritingTrainer::noMatch() |
268 | { | 269 | { |
269 | result->setText( "No match" ); | 270 | result->setText( tr("No match") ); |
270 | } | 271 | } |
271 | 272 | ||
272 | void HandwritingTrainer::matched( const QIMPenCharMatchList &ml ) | 273 | void HandwritingTrainer::matched( const QIMPenCharMatchList &ml ) |
273 | { | 274 | { |
274 | int maxErr = 20000 + (*ml.begin()).penChar->strokeLength(0) * 1000; | 275 | int maxErr = 20000 + (*ml.begin()).penChar->strokeLength(0) * 1000; |
275 | int baseErr = (*ml.begin()).penChar->strokeLength(0) * 250; | 276 | int baseErr = (*ml.begin()).penChar->strokeLength(0) * 250; |