summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpeninput.cpp
Unidiff
Diffstat (limited to 'inputmethods/handwriting/qimpeninput.cpp') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpeninput.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/inputmethods/handwriting/qimpeninput.cpp b/inputmethods/handwriting/qimpeninput.cpp
index 9acab8b..6a21931 100644
--- a/inputmethods/handwriting/qimpeninput.cpp
+++ b/inputmethods/handwriting/qimpeninput.cpp
@@ -209,114 +209,117 @@ QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags flags )
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
223QIMPenInput::~QIMPenInput() 223QIMPenInput::~QIMPenInput()
224{ 224{
225 delete (HandwritingHelp*) helpDlg; 225 delete (HandwritingHelp*) helpDlg;
226} 226}
227 227
228QSize QIMPenInput::sizeHint() const 228QSize 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
235void QIMPenInput::loadProfiles() 235void 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( "Shortcut" ); 241 shortcutCharSet->setTitle( "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
257 Config config( "handwriting" ); 258 Config config( "handwriting" );
258 config.setGroup( "Settings" ); 259 config.setGroup( "Settings" );
259 QString prof = config.readEntry( "Profile", "Default" ); 260 QString prof = config.readEntry( "Profile", "Default" );
260 selectProfile( prof ); 261 selectProfile( prof );
261} 262}
262 263
263void QIMPenInput::selectProfile( const QString &name ) 264void QIMPenInput::selectProfile( const QString &name )
264{ 265{
265 QListIterator<QIMPenProfile> it( profileList ); 266 QListIterator<QIMPenProfile> it( profileList );
266 for ( ; it.current(); ++it ) { 267 for ( ; it.current(); ++it ) {
267 if ( it.current()->name() == name ) { 268 if ( it.current()->name() == name ) {
268 profile = it.current(); 269 profile = it.current();
269 break; 270 break;
270 } 271 }
271 } 272 }
272 273
273 if ( !it.current() ) 274 if ( !it.current() ) {
275 qWarning("No profile selected!\n");
274 return; 276 return;
277 }
275 278
276 pw->clearCharSets(); 279 pw->clearCharSets();
277 baseSets.clear(); 280 baseSets.clear();
278 281
279 matcher->setMultiStrokeTimeout( profile->multiStrokeTimeout() ); 282 matcher->setMultiStrokeTimeout( profile->multiStrokeTimeout() );
280 matcher->setWordMatchingEnabled( profile->matchWords() ); 283 matcher->setWordMatchingEnabled( profile->matchWords() );
281 284
282 if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() ) 285 if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() )
283 wordPicker->hide(); 286 wordPicker->hide();
284 else 287 else
285 wordPicker->show(); 288 wordPicker->show();
286 289
287 if ( profile->uppercase() && profile->style() == QIMPenProfile::BothCases ) { 290 if ( profile->uppercase() && profile->style() == QIMPenProfile::BothCases ) {
288 baseSets.append( profile->uppercase() ); 291 baseSets.append( profile->uppercase() );
289 pw->insertCharSet( profile->uppercase() ); 292 pw->insertCharSet( profile->uppercase() );
290 } 293 }
291 294
292 if ( profile->lowercase() ) { 295 if ( profile->lowercase() ) {
293 baseSets.append( profile->lowercase() ); 296 baseSets.append( profile->lowercase() );
294 pw->insertCharSet( profile->lowercase(), profile->style() == QIMPenProfile::BothCases ? 1 : 2 ); 297 pw->insertCharSet( profile->lowercase(), profile->style() == QIMPenProfile::BothCases ? 1 : 2 );
295 } 298 }
296 299
297 if ( profile->numeric() ) { 300 if ( profile->numeric() ) {
298 baseSets.append( profile->numeric() ); 301 baseSets.append( profile->numeric() );
299 pw->insertCharSet( profile->numeric() ); 302 pw->insertCharSet( profile->numeric() );
300 } 303 }
301 304
302 if ( helpDlg ) 305 if ( helpDlg )
303 delete (HandwritingHelp*) helpDlg; 306 delete (HandwritingHelp*) helpDlg;
304} 307}
305 308
306void QIMPenInput::wordPicked( const QString &w ) 309void QIMPenInput::wordPicked( const QString &w )
307{ 310{
308 int bs = matcher->word().length(); 311 int bs = matcher->word().length();
309 for ( int i = 0; i < bs; i++ ) 312 for ( int i = 0; i < bs; i++ )
310 keypress( Qt::Key_Backspace << 16 ); 313 keypress( Qt::Key_Backspace << 16 );
311 314
312 for ( unsigned int i = 0; i < w.length(); i++ ) 315 for ( unsigned int i = 0; i < w.length(); i++ )
313 keypress( w[i].unicode() ); 316 keypress( w[i].unicode() );
314 317
315 matcher->resetState(); 318 matcher->resetState();
316 wordPicker->clear(); 319 wordPicker->clear();
317} 320}
318 321
319void QIMPenInput::selectCharSet( int idx ) 322void QIMPenInput::selectCharSet( int idx )
320{ 323{
321 if ( mode == Switch ) { 324 if ( mode == Switch ) {
322 //qDebug( "Switch back to normal" ); 325 //qDebug( "Switch back to normal" );