summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpeninput.cpp7
-rw-r--r--inputmethods/handwriting/qimpensetup.cpp2
2 files changed, 6 insertions, 3 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
@@ -1,515 +1,518 @@
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 "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 flags ) 137QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags flags )
138 : QFrame( parent, name, flags ), helpDlg(0), profile(0) 138 : QFrame( parent, name, flags ), 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( "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() ) {
274 return; 275 qWarning("No profile selected!\n");
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" );
323 pw->changeCharSet( baseSets.at(currCharSet), currCharSet ); 326 pw->changeCharSet( baseSets.at(currCharSet), currCharSet );
324 mode = Normal; 327 mode = Normal;
325 } 328 }
326 currCharSet = idx; 329 currCharSet = idx;
327} 330}
328 331
329void QIMPenInput::beginStroke() 332void QIMPenInput::beginStroke()
330{ 333{
331} 334}
332 335
333void QIMPenInput::strokeEntered( QIMPenStroke * ) 336void QIMPenInput::strokeEntered( QIMPenStroke * )
334{ 337{
335 pw->greyStroke(); 338 pw->greyStroke();
336} 339}
337 340
338void QIMPenInput::erase() 341void QIMPenInput::erase()
339{ 342{
340 keypress( Qt::Key_Backspace << 16 ); 343 keypress( Qt::Key_Backspace << 16 );
341} 344}
342 345
343void QIMPenInput::matchedCharacters( const QIMPenCharMatchList &cl ) 346void QIMPenInput::matchedCharacters( const QIMPenCharMatchList &cl )
344{ 347{
345 const QIMPenChar *ch = cl.first().penChar; 348 const QIMPenChar *ch = cl.first().penChar;
346 int scan = ch->character() >> 16; 349 int scan = ch->character() >> 16;
347 350
348 if ( scan < QIMPenChar::ModeBase ) 351 if ( scan < QIMPenChar::ModeBase )
349 return; 352 return;
350 353
351 // We matched a special character... 354 // We matched a special character...
352 355
353 switch ( scan ) { 356 switch ( scan ) {
354 case QIMPenChar::Caps: 357 case QIMPenChar::Caps:
355 if ( profile->style() == QIMPenProfile::ToggleCases ) { 358 if ( profile->style() == QIMPenProfile::ToggleCases ) {
356 // qDebug( "Caps" ); 359 // qDebug( "Caps" );
357 if ( mode == SwitchLock ) { 360 if ( mode == SwitchLock ) {
358 // qDebug( "Switch to normal" ); 361 // qDebug( "Switch to normal" );
359 pw->changeCharSet( profile->lowercase(), currCharSet ); 362 pw->changeCharSet( profile->lowercase(), currCharSet );
360 mode = Switch; 363 mode = Switch;
361 } else { 364 } else {
362 // qDebug( "Switch to upper" ); 365 // qDebug( "Switch to upper" );
363 pw->changeCharSet( profile->uppercase(), currCharSet ); 366 pw->changeCharSet( profile->uppercase(), currCharSet );
364 mode = Switch; 367 mode = Switch;
365 } 368 }
366 } 369 }
367 break; 370 break;
368 case QIMPenChar::CapsLock: 371 case QIMPenChar::CapsLock:
369 if ( profile->style() == QIMPenProfile::ToggleCases ) { 372 if ( profile->style() == QIMPenProfile::ToggleCases ) {
370 // qDebug( "CapsLock" ); 373 // qDebug( "CapsLock" );
371 if ( mode == Switch && 374 if ( mode == Switch &&
372 baseSets.at(currCharSet) == profile->uppercase() ) { 375 baseSets.at(currCharSet) == profile->uppercase() ) {
373 // qDebug( "Switch to normal" ); 376 // qDebug( "Switch to normal" );
374 pw->changeCharSet( profile->lowercase(), currCharSet ); 377 pw->changeCharSet( profile->lowercase(), currCharSet );
375 // change our base set back to lower. 378 // change our base set back to lower.
376 baseSets.remove( currCharSet ); 379 baseSets.remove( currCharSet );
377 baseSets.insert( currCharSet, profile->lowercase() ); 380 baseSets.insert( currCharSet, profile->lowercase() );
378 mode = Normal; 381 mode = Normal;
379 } else { 382 } else {
380 // qDebug( "Switch to caps lock" ); 383 // qDebug( "Switch to caps lock" );
381 pw->changeCharSet( profile->uppercase(), currCharSet ); 384 pw->changeCharSet( profile->uppercase(), currCharSet );
382 // change our base set to upper. 385 // change our base set to upper.
383 baseSets.remove( currCharSet ); 386 baseSets.remove( currCharSet );
384 baseSets.insert( currCharSet, profile->uppercase() ); 387 baseSets.insert( currCharSet, profile->uppercase() );
385 mode = SwitchLock; 388 mode = SwitchLock;
386 } 389 }
387 } 390 }
388 break; 391 break;
389 case QIMPenChar::Punctuation: 392 case QIMPenChar::Punctuation:
390 if ( profile->punctuation() ) { 393 if ( profile->punctuation() ) {
391 //qDebug( "Switch to punctuation" ); 394 //qDebug( "Switch to punctuation" );
392 pw->changeCharSet( profile->punctuation(), currCharSet ); 395 pw->changeCharSet( profile->punctuation(), currCharSet );
393 mode = Switch; 396 mode = Switch;
394 } 397 }
395 break; 398 break;
396 case QIMPenChar::Symbol: 399 case QIMPenChar::Symbol:
397 if ( profile->symbol() ) { 400 if ( profile->symbol() ) {
398 //qDebug( "Switch to symbol" ); 401 //qDebug( "Switch to symbol" );
399 pw->changeCharSet( profile->symbol(), currCharSet ); 402 pw->changeCharSet( profile->symbol(), currCharSet );
400 mode = Switch; 403 mode = Switch;
401 } 404 }
402 break; 405 break;
403 case QIMPenChar::Shortcut: 406 case QIMPenChar::Shortcut:
404 if ( shortcutCharSet ) { 407 if ( shortcutCharSet ) {
405 pw->changeCharSet( shortcutCharSet, currCharSet ); 408 pw->changeCharSet( shortcutCharSet, currCharSet );
406 mode = Switch; 409 mode = Switch;
407 } 410 }
408 break; 411 break;
409 case QIMPenChar::Extended: 412 case QIMPenChar::Extended:
410 handleExtended( ch->data() ); 413 handleExtended( ch->data() );
411 break; 414 break;
412 } 415 }
413} 416}
414 417
415void QIMPenInput::keypress( uint scan_uni ) 418void QIMPenInput::keypress( uint scan_uni )
416{ 419{
417 int scan = scan_uni >> 16; 420 int scan = scan_uni >> 16;
418 if ( !scan ) { 421 if ( !scan ) {
419 if ( scan_uni >= 'a' && scan_uni <= 'z' ) { 422 if ( scan_uni >= 'a' && scan_uni <= 'z' ) {
420 scan = Qt::Key_A + scan_uni - 'a'; 423 scan = Qt::Key_A + scan_uni - 'a';
421 } else if ( scan_uni >= 'A' && scan_uni <= 'Z' ) { 424 } else if ( scan_uni >= 'A' && scan_uni <= 'Z' ) {
422 scan = Qt::Key_A + scan_uni - 'A'; 425 scan = Qt::Key_A + scan_uni - 'A';
423 } else if ( scan_uni == ' ' ) { 426 } else if ( scan_uni == ' ' ) {
424 scan = Qt::Key_Space; 427 scan = Qt::Key_Space;
425 } 428 }
426 } 429 }
427 430
428 switch ( scan ) { 431 switch ( scan ) {
429 case Key_Tab: 432 case Key_Tab:
430 scan_uni = 9; 433 scan_uni = 9;
431 break; 434 break;
432 case Key_Return: 435 case Key_Return:
433 scan_uni = 13; 436 scan_uni = 13;
434 break; 437 break;
435 case Key_Backspace: 438 case Key_Backspace:
436 scan_uni = 8; 439 scan_uni = 8;
437 break; 440 break;
438 case Key_Escape: 441 case Key_Escape:
439 scan_uni = 27; 442 scan_uni = 27;
440 break; 443 break;
441 default: 444 default:
442 break; 445 break;
443 } 446 }
444 447
445 if ( mode == Switch ) { 448 if ( mode == Switch ) {
446 //qDebug( "Switch back to normal" ); 449 //qDebug( "Switch back to normal" );
447 pw->changeCharSet( baseSets.at(currCharSet), currCharSet ); 450 pw->changeCharSet( baseSets.at(currCharSet), currCharSet );
448 if ( baseSets.at(currCharSet) == profile->uppercase() ) 451 if ( baseSets.at(currCharSet) == profile->uppercase() )
449 mode = SwitchLock; 452 mode = SwitchLock;
450 else 453 else
451 mode = Normal; 454 mode = Normal;
452 } 455 }
453 456
454 emit key( scan_uni&0xffff, scan, 0, true, false ); 457 emit key( scan_uni&0xffff, scan, 0, true, false );
455 emit key( scan_uni&0xffff, scan, 0, false, false ); 458 emit key( scan_uni&0xffff, scan, 0, false, false );
456} 459}
457 460
458void QIMPenInput::handleExtended( const QString &ex ) 461void QIMPenInput::handleExtended( const QString &ex )
459{ 462{
460 if ( ex.find( "Select" ) == 0 ) { 463 if ( ex.find( "Select" ) == 0 ) {
461 QString set = ex.mid( 7 ); 464 QString set = ex.mid( 7 );
462 qDebug( "Select new profile: %s", set.latin1() ); 465 qDebug( "Select new profile: %s", set.latin1() );
463 selectProfile( set ); 466 selectProfile( set );
464 } 467 }
465} 468}
466 469
467void QIMPenInput::help() 470void QIMPenInput::help()
468{ 471{
469 if ( helpDlg ) 472 if ( helpDlg )
470 delete (HandwritingHelp*) helpDlg; 473 delete (HandwritingHelp*) helpDlg;
471 helpDlg = new HandwritingHelp( profile, 0, 0, WDestructiveClose ); 474 helpDlg = new HandwritingHelp( profile, 0, 0, WDestructiveClose );
472 helpDlg->showMaximized(); 475 helpDlg->showMaximized();
473 helpDlg->show(); 476 helpDlg->show();
474 helpDlg->raise(); 477 helpDlg->raise();
475} 478}
476 479
477/*! 480/*!
478 Open the setup dialog 481 Open the setup dialog
479*/ 482*/
480void QIMPenInput::setup() 483void QIMPenInput::setup()
481{ 484{
482 if ( !setupDlg ) { 485 if ( !setupDlg ) {
483 // We are working with our copy of the char sets here. 486 // We are working with our copy of the char sets here.
484 setupDlg = new QIMPenSetup( profile, 0, 0, TRUE ); 487 setupDlg = new QIMPenSetup( profile, 0, 0, TRUE );
485 setupDlg->editor()->selectCharSet( profile->charSets().at(1) );// lower case? This is crap. 488 setupDlg->editor()->selectCharSet( profile->charSets().at(1) );// lower case? This is crap.
486 if ( qApp->desktop()->width() < 640 ) 489 if ( qApp->desktop()->width() < 640 )
487 setupDlg->showMaximized(); 490 setupDlg->showMaximized();
488 Global::hideInputMethod(); 491 Global::hideInputMethod();
489 setupDlg->exec(); 492 setupDlg->exec();
490 loadProfiles(); 493 loadProfiles();
491 delete setupDlg; 494 delete setupDlg;
492 setupDlg = 0; 495 setupDlg = 0;
493 Global::showInputMethod(); 496 Global::showInputMethod();
494 } else { 497 } else {
495 setupDlg->raise(); 498 setupDlg->raise();
496 } 499 }
497} 500}
498 501
499void QIMPenInput::backspace() 502void QIMPenInput::backspace()
500{ 503{
501 keypress( Qt::Key_Backspace << 16 ); 504 keypress( Qt::Key_Backspace << 16 );
502 matcher->backspace(); 505 matcher->backspace();
503} 506}
504 507
505void QIMPenInput::enter() 508void QIMPenInput::enter()
506{ 509{
507 keypress( Qt::Key_Return << 16 ); 510 keypress( Qt::Key_Return << 16 );
508 matcher->resetState(); 511 matcher->resetState();
509} 512}
510 513
511 514
512void QIMPenInput::resetState() 515void QIMPenInput::resetState()
513{ 516{
514 matcher->resetState(); 517 matcher->resetState();
515} 518}
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp
index a6ae3a8..2c06fbc 100644
--- a/inputmethods/handwriting/qimpensetup.cpp
+++ b/inputmethods/handwriting/qimpensetup.cpp
@@ -1,480 +1,480 @@
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 "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 */
42static const char * const left_xpm[] = { 42static 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 */
65static const char * const right_xpm[] = { 65static 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
88QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, 88QIMPenSetup::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#if 0 96#if 1
97 profileList.setAutoDelete( true ); 97 profileList.setAutoDelete( true );
98 QHBoxLayout *hb = new QHBoxLayout( vb ); 98 QHBoxLayout *hb = new QHBoxLayout( vb );
99 hb->setMargin( 6 ); 99 hb->setMargin( 6 );
100 QLabel *l = new QLabel( tr("Character Profile:"), this ); 100 QLabel *l = new QLabel( tr("Character Profile:"), this );
101 hb->addWidget( l ); 101 hb->addWidget( l );
102 profileCombo = new QComboBox( this ); 102 profileCombo = new QComboBox( this );
103 connect( profileCombo, SIGNAL(activated(const QString &)), 103 connect( profileCombo, SIGNAL(activated(const QString &)),
104 this, SLOT(selectProfile(const QString &)) ); 104 this, SLOT(selectProfile(const QString &)) );
105 hb->addWidget( profileCombo ); 105 hb->addWidget( profileCombo );
106 loadProfiles(); 106 loadProfiles();
107#else 107#else
108 profileList.append( profile ); 108 profileList.append( profile );
109#endif 109#endif
110 110
111 QTabWidget *tw = new QTabWidget( this ); 111 QTabWidget *tw = new QTabWidget( this );
112 vb->addWidget( tw ); 112 vb->addWidget( tw );
113 113
114 pref = new QIMPenPrefBase( this ); 114 pref = new QIMPenPrefBase( this );
115 tw->addTab( pref, tr("Preferences") ); 115 tw->addTab( pref, tr("Preferences") );
116 116
117 pref->inputStyle->setExclusive( TRUE ); 117 pref->inputStyle->setExclusive( TRUE );
118 118
119 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; 119 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
120 pref->inputStyle->setButton( style ); 120 pref->inputStyle->setButton( style );
121 connect( pref->inputStyle, SIGNAL(clicked(int)), 121 connect( pref->inputStyle, SIGNAL(clicked(int)),
122 this, SLOT(styleClicked(int)) ); 122 this, SLOT(styleClicked(int)) );
123 pref->inputStyle->setEnabled( profile->canSelectStyle() ); 123 pref->inputStyle->setEnabled( profile->canSelectStyle() );
124 124
125 multiTimeout = profile->multiStrokeTimeout(); 125 multiTimeout = profile->multiStrokeTimeout();
126 pref->multiStrokeSlider->setValue( multiTimeout ); 126 pref->multiStrokeSlider->setValue( multiTimeout );
127 multiTimeoutChanged( multiTimeout ); 127 multiTimeoutChanged( multiTimeout );
128 connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), 128 connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)),
129 this, SLOT(multiTimeoutChanged(int)) ); 129 this, SLOT(multiTimeoutChanged(int)) );
130 130
131 edit = new QIMPenEdit( p, tw ); 131 edit = new QIMPenEdit( p, tw );
132 tw->addTab( edit, tr("Customize") ); 132 tw->addTab( edit, tr("Customize") );
133} 133}
134 134
135void QIMPenSetup::loadProfiles() 135void QIMPenSetup::loadProfiles()
136{ 136{
137 QString path = QPEApplication::qpeDir() + "etc/qimpen"; 137 QString path = QPEApplication::qpeDir() + "etc/qimpen";
138 QDir dir( path, "*.conf" ); 138 QDir dir( path, "*.conf" );
139 QStringList list = dir.entryList(); 139 QStringList list = dir.entryList();
140 QStringList::Iterator it; 140 QStringList::Iterator it;
141 for ( it = list.begin(); it != list.end(); ++it ) { 141 for ( it = list.begin(); it != list.end(); ++it ) {
142 QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); 142 QIMPenProfile *p = new QIMPenProfile( path + "/" + *it );
143 profileList.append( p ); 143 profileList.append( p );
144 profileCombo->insertItem( p->name() ); 144 profileCombo->insertItem( p->name() );
145 if ( p->name() == profile->name() ) { 145 if ( p->name() == profile->name() ) {
146 profileCombo->setCurrentItem( profileCombo->count()-1 ); 146 profileCombo->setCurrentItem( profileCombo->count()-1 );
147 profile = p; 147 profile = p;
148 } 148 }
149 } 149 }
150} 150}
151 151
152void QIMPenSetup::styleClicked( int id ) 152void QIMPenSetup::styleClicked( int id )
153{ 153{
154 style = id; 154 style = id;
155} 155}
156 156
157void QIMPenSetup::multiTimeoutChanged( int v ) 157void QIMPenSetup::multiTimeoutChanged( int v )
158{ 158{
159 multiTimeout = v; 159 multiTimeout = v;
160 pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); 160 pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) );
161} 161}
162 162
163void QIMPenSetup::selectProfile( const QString &p ) 163void QIMPenSetup::selectProfile( const QString &p )
164{ 164{
165 if ( p == profile->name() ) 165 if ( p == profile->name() )
166 return; 166 return;
167 167
168 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); 168 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases );
169 profile->setMultiStrokeTimeout( multiTimeout ); 169 profile->setMultiStrokeTimeout( multiTimeout );
170 170
171 for ( int i = 0; i < (int)profileList.count(); i++ ) { 171 for ( int i = 0; i < (int)profileList.count(); i++ ) {
172 if ( profileList.at(i)->name() == p ) { 172 if ( profileList.at(i)->name() == p ) {
173 profile = profileList.at(i); 173 profile = profileList.at(i);
174 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; 174 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
175 pref->inputStyle->setButton( style ); 175 pref->inputStyle->setButton( style );
176 pref->inputStyle->setEnabled( profile->canSelectStyle() ); 176 pref->inputStyle->setEnabled( profile->canSelectStyle() );
177 multiTimeout = profile->multiStrokeTimeout(); 177 multiTimeout = profile->multiStrokeTimeout();
178 pref->multiStrokeSlider->setValue( multiTimeout ); 178 pref->multiStrokeSlider->setValue( multiTimeout );
179 multiTimeoutChanged( multiTimeout ); 179 multiTimeoutChanged( multiTimeout );
180 edit->setProfile( profile ); 180 edit->setProfile( profile );
181 break; 181 break;
182 } 182 }
183 } 183 }
184} 184}
185 185
186void QIMPenSetup::accept() 186void QIMPenSetup::accept()
187{ 187{
188 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); 188 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases );
189 profile->setMultiStrokeTimeout( multiTimeout ); 189 profile->setMultiStrokeTimeout( multiTimeout );
190 // Save current profile 190 // Save current profile
191 if ( profileCombo ) { 191 if ( profileCombo ) {
192 Config config( "handwriting" ); 192 Config config( "handwriting" );
193 config.setGroup( "Settings" ); 193 config.setGroup( "Settings" );
194 config.writeEntry( "Profile", profileCombo->currentText() ); 194 config.writeEntry( "Profile", profileCombo->currentText() );
195 } 195 }
196 // Save charsets 196 // Save charsets
197 bool ok = TRUE; 197 bool ok = TRUE;
198 for ( int i = 0; i < (int)profileList.count(); i++ ) { 198 for ( int i = 0; i < (int)profileList.count(); i++ ) {
199 QIMPenProfile *prof = profileList.at(i); 199 QIMPenProfile *prof = profileList.at(i);
200 QIMPenCharSetIterator it(prof->charSets()); 200 QIMPenCharSetIterator it(prof->charSets());
201 for ( ; it.current(); ++it ) { 201 for ( ; it.current(); ++it ) {
202 if ( !(it.current()->save( QIMPenCharSet::User )) ) { 202 if ( !(it.current()->save( QIMPenCharSet::User )) ) {
203 ok = FALSE; 203 ok = FALSE;
204 break; 204 break;
205 } 205 }
206 } 206 }
207 } 207 }
208 if ( !ok ) { 208 if ( !ok ) {
209 if ( QMessageBox::critical( 0, tr( "Out of space" ), 209 if ( QMessageBox::critical( 0, tr( "Out of space" ),
210 tr("Unable to save information.\n" 210 tr("Unable to save information.\n"
211 "Free up some space\n" 211 "Free up some space\n"
212 "and try again.\n" 212 "and try again.\n"
213 "\nQuit anyway?"), 213 "\nQuit anyway?"),
214 QMessageBox::Yes|QMessageBox::Escape, 214 QMessageBox::Yes|QMessageBox::Escape,
215 QMessageBox::No|QMessageBox::Default ) 215 QMessageBox::No|QMessageBox::Default )
216 != QMessageBox::No ) { 216 != QMessageBox::No ) {
217 QDialog::accept(); 217 QDialog::accept();
218 } 218 }
219 } else { 219 } else {
220 QDialog::accept(); 220 QDialog::accept();
221 } 221 }
222} 222}
223 223
224//--------------------------------------------------------------------------- 224//---------------------------------------------------------------------------
225 225
226QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, 226QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name,
227 bool modal, int WFlags) 227 bool modal, int WFlags)
228 : QDialog( parent, name, modal, WFlags ) 228 : QDialog( parent, name, modal, WFlags )
229{ 229{
230 setCaption( tr("Enter new character") ); 230 setCaption( tr("Enter new character") );
231 uni = 0; 231 uni = 0;
232 232
233 QVBoxLayout *vb = new QVBoxLayout( this, 10 ); 233 QVBoxLayout *vb = new QVBoxLayout( this, 10 );
234 234
235 QHBoxLayout *hb = new QHBoxLayout(); 235 QHBoxLayout *hb = new QHBoxLayout();
236 vb->addLayout( hb ); 236 vb->addLayout( hb );
237 237
238 QLabel *label = new QLabel( "Character:", this ); 238 QLabel *label = new QLabel( "Character:", this );
239 hb->addWidget( label ); 239 hb->addWidget( label );
240 240
241 QComboBox *cb = new QComboBox( TRUE, this ); 241 QComboBox *cb = new QComboBox( TRUE, this );
242 connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); 242 connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) );
243 connect( cb, SIGNAL(textChanged(const QString &)), 243 connect( cb, SIGNAL(textChanged(const QString &)),
244 SLOT(setCharacter(const QString &)) ); 244 SLOT(setCharacter(const QString &)) );
245 addSpecial( cb ); 245 addSpecial( cb );
246 cb->setEditText( "" ); 246 cb->setEditText( "" );
247 hb->addWidget( cb ); 247 hb->addWidget( cb );
248 248
249 hb = new QHBoxLayout(); 249 hb = new QHBoxLayout();
250 vb->addLayout( hb ); 250 vb->addLayout( hb );
251 251
252 QPushButton *pb = new QPushButton( "OK", this ); 252 QPushButton *pb = new QPushButton( "OK", this );
253 connect( pb, SIGNAL(clicked()), SLOT(accept())); 253 connect( pb, SIGNAL(clicked()), SLOT(accept()));
254 hb->addWidget( pb ); 254 hb->addWidget( pb );
255 pb = new QPushButton( "Cancel", this ); 255 pb = new QPushButton( "Cancel", this );
256 connect( pb, SIGNAL(clicked()), SLOT(reject())); 256 connect( pb, SIGNAL(clicked()), SLOT(reject()));
257 hb->addWidget( pb ); 257 hb->addWidget( pb );
258 258
259 cb->setFocus(); 259 cb->setFocus();
260} 260}
261 261
262void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) 262void QIMPenInputCharDlg::addSpecial( QComboBox *cb )
263{ 263{
264 int i = 0; 264 int i = 0;
265 while ( qimpen_specialKeys[i].code != Key_unknown ) { 265 while ( qimpen_specialKeys[i].code != Key_unknown ) {
266 cb->insertItem( qimpen_specialKeys[i].name ); 266 cb->insertItem( qimpen_specialKeys[i].name );
267 i++; 267 i++;
268 } 268 }
269} 269}
270 270
271void QIMPenInputCharDlg::setSpecial( int sp ) 271void QIMPenInputCharDlg::setSpecial( int sp )
272{ 272{
273 uni = qimpen_specialKeys[sp].code << 16; 273 uni = qimpen_specialKeys[sp].code << 16;
274} 274}
275 275
276void QIMPenInputCharDlg::setCharacter( const QString &string ) 276void QIMPenInputCharDlg::setCharacter( const QString &string )
277{ 277{
278 uni = string[0].unicode(); 278 uni = string[0].unicode();
279} 279}
280 280
281//--------------------------------------------------------------------------- 281//---------------------------------------------------------------------------
282 282
283class CharListItem : public QListBoxText 283class CharListItem : public QListBoxText
284{ 284{
285public: 285public:
286 CharListItem( const QString &text, uint c ) 286 CharListItem( const QString &text, uint c )
287 : QListBoxText( text ) 287 : QListBoxText( text )
288 { 288 {
289 _code = c; 289 _code = c;
290 } 290 }
291 291
292 uint code() const { return _code; } 292 uint code() const { return _code; }
293 293
294protected: 294protected:
295 uint _code; 295 uint _code;
296}; 296};
297 297
298/*! 298/*!
299 \class QIMPenEdit qimpensetup.h 299 \class QIMPenEdit qimpensetup.h
300 300
301 Class to allow users to input totally useless character definitions 301 Class to allow users to input totally useless character definitions
302 which could match any number of the default set. 302 which could match any number of the default set.
303*/ 303*/
304 304
305QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, 305QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent,
306 const char *name ) 306 const char *name )
307 : QWidget( parent, name ), profile(p) 307 : QWidget( parent, name ), profile(p)
308{ 308{
309 currentChar = 0; 309 currentChar = 0;
310 currentCode = 0; 310 currentCode = 0;
311 inputChar = new QIMPenChar(); 311 inputChar = new QIMPenChar();
312 312
313 QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); 313 QVBoxLayout *tvb = new QVBoxLayout( this, 5 );
314 314
315 QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); 315 QGridLayout *gl = new QGridLayout( tvb, 4, 2 );
316 gl->setRowStretch( 1, 1 ); 316 gl->setRowStretch( 1, 1 );
317 gl->addRowSpacing( 2, 35 ); 317 gl->addRowSpacing( 2, 35 );
318 gl->addRowSpacing( 3, 35 ); 318 gl->addRowSpacing( 3, 35 );
319 319
320 charSetCombo = new QComboBox( this ); 320 charSetCombo = new QComboBox( this );
321 gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); 321 gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 );
322 connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); 322 connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int)));
323 QIMPenCharSetIterator it( profile->charSets() ); 323 QIMPenCharSetIterator it( profile->charSets() );
324 for ( ; it.current(); ++it ) { 324 for ( ; it.current(); ++it ) {
325 charSetCombo->insertItem( it.current()->description() ); 325 charSetCombo->insertItem( it.current()->description() );
326 } 326 }
327 327
328 charList = new QListBox( this ); 328 charList = new QListBox( this );
329 charList->setMinimumHeight( charList->sizeHint().height() ); 329 charList->setMinimumHeight( charList->sizeHint().height() );
330 connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); 330 connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) );
331 gl->addWidget( charList, 1, 0 ); 331 gl->addWidget( charList, 1, 0 );
332 332
333 pw = new QIMPenWidget( this ); 333 pw = new QIMPenWidget( this );
334 pw->setFixedHeight( 75 ); 334 pw->setFixedHeight( 75 );
335 gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); 335 gl->addMultiCellWidget( pw, 2, 3, 0, 0 );
336 connect( pw, SIGNAL(stroke(QIMPenStroke *)), 336 connect( pw, SIGNAL(stroke(QIMPenStroke *)),
337 SLOT(newStroke(QIMPenStroke *)) ); 337 SLOT(newStroke(QIMPenStroke *)) );
338 338
339 QVBoxLayout *vb = new QVBoxLayout(); 339 QVBoxLayout *vb = new QVBoxLayout();
340 gl->addLayout( vb, 1, 1 ); 340 gl->addLayout( vb, 1, 1 );
341 newBtn = new QPushButton( tr("New..."), this ); 341 newBtn = new QPushButton( tr("New..."), this );
342 connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); 342 connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) );
343 vb->addWidget( newBtn ); 343 vb->addWidget( newBtn );
344 344
345 addBtn = new QPushButton( tr("Add"), this ); 345 addBtn = new QPushButton( tr("Add"), this );
346 connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); 346 connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) );
347 vb->addWidget( addBtn ); 347 vb->addWidget( addBtn );
348 348
349 removeBtn = new QPushButton( tr("Remove"), this ); 349 removeBtn = new QPushButton( tr("Remove"), this );
350 connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); 350 connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) );
351 vb->addWidget( removeBtn ); 351 vb->addWidget( removeBtn );
352 352
353 QPushButton *pb = new QPushButton( tr("Default"), this ); 353 QPushButton *pb = new QPushButton( tr("Default"), this );
354 connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); 354 connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) );
355 vb->addWidget( pb ); 355 vb->addWidget( pb );
356 356
357 QHBoxLayout *hb = new QHBoxLayout(); 357 QHBoxLayout *hb = new QHBoxLayout();
358 gl->addLayout( hb, 2, 1 ); 358 gl->addLayout( hb, 2, 1 );
359 prevBtn = new QPushButton( this ); 359 prevBtn = new QPushButton( this );
360 prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); 360 prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) );
361 connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); 361 connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar()));
362 hb->addWidget( prevBtn ); 362 hb->addWidget( prevBtn );
363 363
364 nextBtn = new QPushButton( this ); 364 nextBtn = new QPushButton( this );
365 nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); 365 nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) );
366 connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); 366 connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar()));
367 hb->addWidget( nextBtn ); 367 hb->addWidget( nextBtn );
368 368
369 pb = new QPushButton( tr("Clear"), this ); 369 pb = new QPushButton( tr("Clear"), this );
370 connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); 370 connect( pb, SIGNAL(clicked()), SLOT(clearChar()) );
371 gl->addWidget( pb, 3, 1 ); 371 gl->addWidget( pb, 3, 1 );
372 372
373 //-- 373 //--
374#if !defined(Q_WS_QWS) 374#if !defined(Q_WS_QWS)
375 hb = new QHBoxLayout( tvb ); 375 hb = new QHBoxLayout( tvb );
376 pb = new QPushButton( "OK", this ); 376 pb = new QPushButton( "OK", this );
377 connect( pb, SIGNAL(clicked()), SLOT(accept()) ); 377 connect( pb, SIGNAL(clicked()), SLOT(accept()) );
378 hb->addWidget( pb ); 378 hb->addWidget( pb );
379 379
380 pb = new QPushButton( "Cancel", this ); 380 pb = new QPushButton( "Cancel", this );
381 connect( pb, SIGNAL(clicked()), SLOT(reject()) ); 381 connect( pb, SIGNAL(clicked()), SLOT(reject()) );
382 hb->addWidget( pb ); 382 hb->addWidget( pb );
383#endif 383#endif
384 selectCharSet( 0 ); 384 selectCharSet( 0 );
385 charList->setFocus(); 385 charList->setFocus();
386 386
387 resize( minimumSize() ); 387 resize( minimumSize() );
388 enableButtons(); 388 enableButtons();
389} 389}
390 390
391void QIMPenEdit::setProfile( QIMPenProfile *p ) 391void QIMPenEdit::setProfile( QIMPenProfile *p )
392{ 392{
393 profile = p; 393 profile = p;
394 charSetCombo->clear(); 394 charSetCombo->clear();
395 QIMPenCharSetIterator it( profile->charSets() ); 395 QIMPenCharSetIterator it( profile->charSets() );
396 for ( ; it.current(); ++it ) { 396 for ( ; it.current(); ++it ) {
397 charSetCombo->insertItem( it.current()->description() ); 397 charSetCombo->insertItem( it.current()->description() );
398 } 398 }
399 selectCharSet( 0 ); 399 selectCharSet( 0 );
400 charList->setFocus(); 400 charList->setFocus();
401 enableButtons(); 401 enableButtons();
402} 402}
403 403
404void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) 404void QIMPenEdit::selectCharSet( QIMPenCharSet *c )
405{ 405{
406 int i = 0; 406 int i = 0;
407 QIMPenCharSetIterator it( profile->charSets() ); 407 QIMPenCharSetIterator it( profile->charSets() );
408 for ( ; it.current(); ++it, i++ ) { 408 for ( ; it.current(); ++it, i++ ) {
409 if ( it.current() == c ) { 409 if ( it.current() == c ) {
410 charSetCombo->setCurrentItem( i ); 410 charSetCombo->setCurrentItem( i );
411 selectCharSet( i ); 411 selectCharSet( i );
412 } 412 }
413 } 413 }
414} 414}
415 415
416 416
417/*! 417/*!
418 Fill the character list box with the characters. Duplicates are not 418 Fill the character list box with the characters. Duplicates are not
419 inserted. 419 inserted.
420*/ 420*/
421void QIMPenEdit::fillCharList() 421void QIMPenEdit::fillCharList()
422{ 422{
423 charList->clear(); 423 charList->clear();
424 QIMPenCharIterator it( currentSet->characters() ); 424 QIMPenCharIterator it( currentSet->characters() );
425 CharListItem *li = 0; 425 CharListItem *li = 0;
426 for ( ; it.current(); ++it ) { 426 for ( ; it.current(); ++it ) {
427 uint ch = it.current()->character(); 427 uint ch = it.current()->character();
428 QString n = it.current()->name(); 428 QString n = it.current()->name();
429 if ( !n.isEmpty() ) 429 if ( !n.isEmpty() )
430 li = new CharListItem( n, ch ); 430 li = new CharListItem( n, ch );
431 if ( li ) { 431 if ( li ) {
432 CharListItem *i = (CharListItem *)charList->findItem( li->text() ); 432 CharListItem *i = (CharListItem *)charList->findItem( li->text() );
433 if ( !i || i->code() != ch ) { 433 if ( !i || i->code() != ch ) {
434 charList->insertItem( li ); 434 charList->insertItem( li );
435 } else { 435 } else {
436 delete li; 436 delete li;
437 li = 0; 437 li = 0;
438 } 438 }
439 } 439 }
440 } 440 }
441 currentChar = 0; 441 currentChar = 0;
442} 442}
443 443
444void QIMPenEdit::enableButtons() 444void QIMPenEdit::enableButtons()
445{ 445{
446 bool add = !inputChar->isEmpty(); 446 bool add = !inputChar->isEmpty();
447 newBtn->setEnabled( add ); 447 newBtn->setEnabled( add );
448 addBtn->setEnabled( add ); 448 addBtn->setEnabled( add );
449 removeBtn->setEnabled( currentChar ); 449 removeBtn->setEnabled( currentChar );
450} 450}
451 451
452/*! 452/*!
453 Find the previous character with the same code as the current one. 453 Find the previous character with the same code as the current one.
454 returns 0 if there is no previous character. 454 returns 0 if there is no previous character.
455*/ 455*/
456QIMPenChar *QIMPenEdit::findPrev() 456QIMPenChar *QIMPenEdit::findPrev()
457{ 457{
458 if ( !currentChar ) 458 if ( !currentChar )
459 return 0; 459 return 0;
460 QIMPenCharIterator it( currentSet->characters() ); 460 QIMPenCharIterator it( currentSet->characters() );
461 bool found = FALSE; 461 bool found = FALSE;
462 for ( it.toLast(); it.current(); --it ) { 462 for ( it.toLast(); it.current(); --it ) {
463 if ( !found && it.current() == currentChar ) 463 if ( !found && it.current() == currentChar )
464 found = TRUE; 464 found = TRUE;
465 else if ( found && it.current()->character() == currentCode && 465 else if ( found && it.current()->character() == currentCode &&
466 !it.current()->testFlag( QIMPenChar::Deleted ) ) { 466 !it.current()->testFlag( QIMPenChar::Deleted ) ) {
467 return it.current(); 467 return it.current();
468 } 468 }
469 } 469 }
470 470
471 return 0; 471 return 0;
472} 472}
473 473
474/*! 474/*!
475 Find the next character with the same code as the current one. 475 Find the next character with the same code as the current one.
476 returns 0 if there is no next character. 476 returns 0 if there is no next character.
477*/ 477*/
478QIMPenChar *QIMPenEdit::findNext() 478QIMPenChar *QIMPenEdit::findNext()
479{ 479{
480 if ( !currentChar ) 480 if ( !currentChar )