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