summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpeninput.cpp4
-rw-r--r--inputmethods/handwriting/qimpeninput.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/inputmethods/handwriting/qimpeninput.cpp b/inputmethods/handwriting/qimpeninput.cpp
index 3f7a347..db33c9b 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 */
45static const char * const pen_xpm[] = { 45static 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 */
66static char * bs_xpm[] = { 66static 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 */
88static char * enter_xpm[] = { 88static 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 */
111static char * help_xpm[] = { 111static 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*/
137QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags f ) 137QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags wf )
138 : QFrame( parent, name, f ), 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
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( 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
263void QIMPenInput::selectProfile( const QString &name ) 263void 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
306void QIMPenInput::wordPicked( const QString &w ) 306void 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
319void QIMPenInput::selectCharSet( int idx ) 319void 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
329void QIMPenInput::beginStroke() 329void QIMPenInput::beginStroke()
330{ 330{
331} 331}
332 332
333void QIMPenInput::strokeEntered( QIMPenStroke * ) 333void QIMPenInput::strokeEntered( QIMPenStroke * )
334{ 334{
335 pw->greyStroke(); 335 pw->greyStroke();
336} 336}
337 337
338void QIMPenInput::erase() 338void QIMPenInput::erase()
339{ 339{
340 keypress( Qt::Key_Backspace << 16 ); 340 keypress( Qt::Key_Backspace << 16 );
341} 341}
342 342
343void QIMPenInput::matchedCharacters( const QIMPenCharMatchList &cl ) 343void 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
415void QIMPenInput::keypress( uint scan_uni ) 415void 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
458void QIMPenInput::handleExtended( const QString &ex ) 458void 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
467void QIMPenInput::help() 467void 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*/
480void QIMPenInput::setup() 480void 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
499void QIMPenInput::backspace() 499void 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
505void QIMPenInput::enter() 505void 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
512void QIMPenInput::resetState() 512void QIMPenInput::resetState()
513{ 513{
514 matcher->resetState(); 514 matcher->resetState();
515} 515}
diff --git a/inputmethods/handwriting/qimpeninput.h b/inputmethods/handwriting/qimpeninput.h
index b4e4006..75cf260 100644
--- a/inputmethods/handwriting/qimpeninput.h
+++ b/inputmethods/handwriting/qimpeninput.h
@@ -1,94 +1,94 @@
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#ifndef _QIMPENINPUT_H_ 21#ifndef _QIMPENINPUT_H_
22#define _QIMPENINPUT_H_ 22#define _QIMPENINPUT_H_
23 23
24#include "qimpenprofile.h" 24#include "qimpenprofile.h"
25 25
26#include <qpe/qdawg.h> 26#include <qpe/qdawg.h>
27 27
28#include <qframe.h> 28#include <qframe.h>
29#include <qlist.h> 29#include <qlist.h>
30#include <qguardedptr.h> 30#include <qguardedptr.h>
31 31
32class QPushButton; 32class QPushButton;
33class QTimer; 33class QTimer;
34class QIMPenWidget; 34class QIMPenWidget;
35class QIMPenSetup; 35class QIMPenSetup;
36class QIMPenWordPick; 36class QIMPenWordPick;
37class QIMPenMatch; 37class QIMPenMatch;
38class HandwritingHelp; 38class HandwritingHelp;
39 39
40class QIMPenInput : public QFrame 40class QIMPenInput : public QFrame
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 QIMPenInput( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 44 QIMPenInput( QWidget *parent = 0, const char *name = 0, WFlags wf = 0 );
45 virtual ~QIMPenInput(); 45 virtual ~QIMPenInput();
46 46
47 void resetState(); 47 void resetState();
48 48
49 QSize sizeHint() const; 49 QSize sizeHint() const;
50 50
51signals: 51signals:
52 void key( ushort, ushort, ushort, bool, bool ); 52 void key( ushort, ushort, ushort, bool, bool );
53 53
54private slots: 54private slots:
55 void wordPicked( const QString & ); 55 void wordPicked( const QString & );
56 void selectCharSet( int ); 56 void selectCharSet( int );
57 void beginStroke(); 57 void beginStroke();
58 void strokeEntered( QIMPenStroke *st ); 58 void strokeEntered( QIMPenStroke *st );
59 void matchedCharacters( const QIMPenCharMatchList &cl ); 59 void matchedCharacters( const QIMPenCharMatchList &cl );
60 void keypress( uint scan_uni ); 60 void keypress( uint scan_uni );
61 void erase(); 61 void erase();
62 void help(); 62 void help();
63 void setup(); 63 void setup();
64 void backspace(); 64 void backspace();
65 void enter(); 65 void enter();
66 66
67private: 67private:
68 void loadProfiles(); 68 void loadProfiles();
69 void selectProfile( const QString &name ); 69 void selectProfile( const QString &name );
70 void handleExtended( const QString & ); 70 void handleExtended( const QString & );
71 void updateWordMatch( QIMPenCharMatchList &ml ); 71 void updateWordMatch( QIMPenCharMatchList &ml );
72 void matchWords(); 72 void matchWords();
73 void scanDict( const QDawg::Node* n, int ipos, const QString& str, int error ); 73 void scanDict( const QDawg::Node* n, int ipos, const QString& str, int error );
74 74
75 enum Mode { Normal, Switch, SwitchLock }; 75 enum Mode { Normal, Switch, SwitchLock };
76 76
77private: 77private:
78 Mode mode; 78 Mode mode;
79 QRect prefRect; 79 QRect prefRect;
80 QIMPenWidget *pw; 80 QIMPenWidget *pw;
81 QPushButton *helpBtn; 81 QPushButton *helpBtn;
82 QPushButton *setupBtn; 82 QPushButton *setupBtn;
83 QIMPenSetup *setupDlg; 83 QIMPenSetup *setupDlg;
84 QIMPenMatch *matcher; 84 QIMPenMatch *matcher;
85 QGuardedPtr<HandwritingHelp> helpDlg; 85 QGuardedPtr<HandwritingHelp> helpDlg;
86 QIMPenProfile *profile; 86 QIMPenProfile *profile;
87 QList<QIMPenProfile> profileList; 87 QList<QIMPenProfile> profileList;
88 QIMPenCharSet *shortcutCharSet; 88 QIMPenCharSet *shortcutCharSet;
89 QIMPenCharSetList baseSets; 89 QIMPenCharSetList baseSets;
90 int currCharSet; 90 int currCharSet;
91 QIMPenWordPick *wordPicker; 91 QIMPenWordPick *wordPicker;
92}; 92};
93 93
94#endif // _QIMPENINPUT_H_ 94#endif // _QIMPENINPUT_H_