summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpensetup.cpp
Unidiff
Diffstat (limited to 'inputmethods/handwriting/qimpensetup.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpensetup.cpp12
1 files changed, 6 insertions, 6 deletions
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
@@ -56,98 +56,98 @@ static const char * const left_xpm[] = {
56" .... ", 56" .... ",
57" ... ", 57" ... ",
58" .. ", 58" .. ",
59" . ", 59" . ",
60" ", 60" ",
61" "}; 61" "};
62 62
63 63
64/* XPM */ 64/* XPM */
65static const char * const right_xpm[] = { 65static const char * const right_xpm[] = {
66"16 16 2 1", 66"16 16 2 1",
67 " c None", 67 " c None",
68 ".c #000000", 68 ".c #000000",
69" ", 69" ",
70" ", 70" ",
71" ", 71" ",
72" . ", 72" . ",
73" .. ", 73" .. ",
74" ... ", 74" ... ",
75" .... ", 75" .... ",
76" ..... ", 76" ..... ",
77" ...... ", 77" ...... ",
78" ..... ", 78" ..... ",
79" .... ", 79" .... ",
80" ... ", 80" ... ",
81" .. ", 81" .. ",
82" . ", 82" . ",
83" ", 83" ",
84" "}; 84" "};
85 85
86 86
87 87
88QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, 88QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent,
89 const char *name, bool modal, int WFlags ) 89 const char *name, bool modal, int WFlags )
90 : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) 90 : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p)
91{ 91{
92 setCaption( tr("Setup Handwriting Input") ); 92 setCaption( tr("Setup Handwriting Input") );
93 93
94 QVBoxLayout *vb = new QVBoxLayout( this ); 94 QVBoxLayout *vb = new QVBoxLayout( this );
95 95
96#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
141void QIMPenSetup::loadProfiles() 141void 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;
@@ -202,191 +202,191 @@ void QIMPenSetup::accept()
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
233QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, 233QIMPenInputCharDlg::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
269void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) 269void 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
278void QIMPenInputCharDlg::setSpecial( int sp ) 278void QIMPenInputCharDlg::setSpecial( int sp )
279{ 279{
280 uni = qimpen_specialKeys[sp].code << 16; 280 uni = qimpen_specialKeys[sp].code << 16;
281} 281}
282 282
283void QIMPenInputCharDlg::setCharacter( const QString &string ) 283void 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
290class CharListItem : public QListBoxText 290class CharListItem : public QListBoxText
291{ 291{
292public: 292public:
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
301protected: 301protected:
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
312QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, 312QIMPenEdit::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();