-rw-r--r-- | inputmethods/handwriting/qimpeninput.cpp | 7 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpensetup.cpp | 2 |
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 | |||
@@ -193,146 +193,149 @@ QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags flags ) | |||
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( "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 | ||
263 | void QIMPenInput::selectProfile( const QString &name ) | 264 | void 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 | ||
306 | void QIMPenInput::wordPicked( const QString &w ) | 309 | void 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 | ||
319 | void QIMPenInput::selectCharSet( int idx ) | 322 | void 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 | ||
329 | void QIMPenInput::beginStroke() | 332 | void QIMPenInput::beginStroke() |
330 | { | 333 | { |
331 | } | 334 | } |
332 | 335 | ||
333 | void QIMPenInput::strokeEntered( QIMPenStroke * ) | 336 | void QIMPenInput::strokeEntered( QIMPenStroke * ) |
334 | { | 337 | { |
335 | pw->greyStroke(); | 338 | pw->greyStroke(); |
336 | } | 339 | } |
337 | 340 | ||
338 | void QIMPenInput::erase() | 341 | void QIMPenInput::erase() |
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 | |||
@@ -32,129 +32,129 @@ | |||
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 | #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 | ||
135 | void QIMPenSetup::loadProfiles() | 135 | void 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 | ||
152 | void QIMPenSetup::styleClicked( int id ) | 152 | void QIMPenSetup::styleClicked( int id ) |
153 | { | 153 | { |
154 | style = id; | 154 | style = id; |
155 | } | 155 | } |
156 | 156 | ||
157 | void QIMPenSetup::multiTimeoutChanged( int v ) | 157 | void 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) ); |