summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpensetup.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp
index 10c136d..2441102 100644
--- a/inputmethods/handwriting/qimpensetup.cpp
+++ b/inputmethods/handwriting/qimpensetup.cpp
@@ -64,116 +64,123 @@ static const char * const left_xpm[] = {
64/* XPM */ 64/* XPM */
65static const char * const right_xpm[] = { 65static const char * const right_xpm[] = {
66"16 16 2 1", 66"16 16 2 1",
67 " c None", 67 " c None",
68 ".c #000000", 68 ".c #000000",
69" ", 69" ",
70" ", 70" ",
71" ", 71" ",
72" . ", 72" . ",
73" .. ", 73" .. ",
74" ... ", 74" ... ",
75" .... ", 75" .... ",
76" ..... ", 76" ..... ",
77" ...... ", 77" ...... ",
78" ..... ", 78" ..... ",
79" .... ", 79" .... ",
80" ... ", 80" ... ",
81" .. ", 81" .. ",
82" . ", 82" . ",
83" ", 83" ",
84" "}; 84" "};
85 85
86 86
87 87
88QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent, 88QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent,
89 const char *name, bool modal, int WFlags ) 89 const char *name, bool modal, int WFlags )
90 : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p) 90 : QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p)
91{ 91{
92 setCaption( tr("Setup Handwriting Input") ); 92 setCaption( tr("Setup Handwriting Input") );
93 93
94 QVBoxLayout *vb = new QVBoxLayout( this ); 94 QVBoxLayout *vb = new QVBoxLayout( this );
95 95
96#if 0 96#define MULTIPROFILE
97#ifdef MULTIPROFILE
97 profileList.setAutoDelete( true ); 98 profileList.setAutoDelete( true );
98 QHBoxLayout *hb = new QHBoxLayout( vb ); 99 QHBoxLayout *hb = new QHBoxLayout( vb );
99 hb->setMargin( 6 ); 100 hb->setMargin( 6 );
100 QLabel *l = new QLabel( tr("Character Profile:"), this ); 101 QLabel *l = new QLabel( tr("Character Profile:"), this );
101 hb->addWidget( l ); 102 hb->addWidget( l );
102 profileCombo = new QComboBox( this ); 103 profileCombo = new QComboBox( this );
103 connect( profileCombo, SIGNAL(activated(const QString &)), 104 connect( profileCombo, SIGNAL(activated(const QString &)),
104 this, SLOT(selectProfile(const QString &)) ); 105 this, SLOT(selectProfile(const QString &)) );
105 hb->addWidget( profileCombo ); 106 hb->addWidget( profileCombo );
106 loadProfiles();
107#else 107#else
108 profileList.append( profile ); 108 profileList.append( profile );
109#endif 109#endif
110
111 qWarning("profiles: %d", profileList.count());
110 112
111 QTabWidget *tw = new QTabWidget( this ); 113 QTabWidget *tw = new QTabWidget( this );
112 vb->addWidget( tw ); 114 vb->addWidget( tw );
113 115
114 pref = new QIMPenPrefBase( this ); 116 pref = new QIMPenPrefBase( this );
115 tw->addTab( pref, tr("Preferences") ); 117 tw->addTab( pref, tr("Preferences") );
116 118
117 pref->inputStyle->setExclusive( TRUE ); 119 pref->inputStyle->setExclusive( TRUE );
118 120
119 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; 121 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
120 pref->inputStyle->setButton( style ); 122 pref->inputStyle->setButton( style );
121 connect( pref->inputStyle, SIGNAL(clicked(int)), 123 connect( pref->inputStyle, SIGNAL(clicked(int)),
122 this, SLOT(styleClicked(int)) ); 124 this, SLOT(styleClicked(int)) );
123 pref->inputStyle->setEnabled( profile->canSelectStyle() ); 125 pref->inputStyle->setEnabled( profile->canSelectStyle() );
124 126
125 multiTimeout = profile->multiStrokeTimeout(); 127 multiTimeout = profile->multiStrokeTimeout();
126 pref->multiStrokeSlider->setValue( multiTimeout ); 128 pref->multiStrokeSlider->setValue( multiTimeout );
127 multiTimeoutChanged( multiTimeout ); 129 multiTimeoutChanged( multiTimeout );
128 connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), 130 connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)),
129 this, SLOT(multiTimeoutChanged(int)) ); 131 this, SLOT(multiTimeoutChanged(int)) );
130 132
131 edit = new QIMPenEdit( p, tw ); 133 edit = new QIMPenEdit( p, tw );
132 tw->addTab( edit, tr("Customize") ); 134 tw->addTab( edit, tr("Customize") );
135#ifdef MULTIPROFILE
136 loadProfiles();
137#endif
138
133} 139}
134 140
135void QIMPenSetup::loadProfiles() 141void QIMPenSetup::loadProfiles()
136{ 142{
137 QString path = QPEApplication::qpeDir() + "etc/qimpen"; 143 QString path = QPEApplication::qpeDir() + "etc/qimpen";
138 QDir dir( path, "*.conf" ); 144 QDir dir( path, "*.conf" );
139 QStringList list = dir.entryList(); 145 QStringList list = dir.entryList();
140 QStringList::Iterator it; 146 QStringList::Iterator it;
141 for ( it = list.begin(); it != list.end(); ++it ) { 147 for ( it = list.begin(); it != list.end(); ++it ) {
142 QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); 148 QIMPenProfile *p = new QIMPenProfile( path + "/" + *it );
143 profileList.append( p ); 149 profileList.append( p );
144 profileCombo->insertItem( p->name() ); 150 profileCombo->insertItem( p->name() );
145 if ( p->name() == profile->name() ) { 151 if ( p->name() == profile->name() ) {
146 profileCombo->setCurrentItem( profileCombo->count()-1 ); 152 profileCombo->setCurrentItem( profileCombo->count()-1 );
147 profile = p; 153 profile = p;
154 edit->setProfile( profile );
148 } 155 }
149 } 156 }
150} 157}
151 158
152void QIMPenSetup::styleClicked( int id ) 159void QIMPenSetup::styleClicked( int id )
153{ 160{
154 style = id; 161 style = id;
155} 162}
156 163
157void QIMPenSetup::multiTimeoutChanged( int v ) 164void QIMPenSetup::multiTimeoutChanged( int v )
158{ 165{
159 multiTimeout = v; 166 multiTimeout = v;
160 pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); 167 pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) );
161} 168}
162 169
163void QIMPenSetup::selectProfile( const QString &p ) 170void QIMPenSetup::selectProfile( const QString &p )
164{ 171{
165 if ( p == profile->name() ) 172 if ( p == profile->name() )
166 return; 173 return;
167 174
168 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); 175 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases );
169 profile->setMultiStrokeTimeout( multiTimeout ); 176 profile->setMultiStrokeTimeout( multiTimeout );
170 177
171 for ( int i = 0; i < (int)profileList.count(); i++ ) { 178 for ( int i = 0; i < (int)profileList.count(); i++ ) {
172 if ( profileList.at(i)->name() == p ) { 179 if ( profileList.at(i)->name() == p ) {
173 profile = profileList.at(i); 180 profile = profileList.at(i);
174 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; 181 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
175 pref->inputStyle->setButton( style ); 182 pref->inputStyle->setButton( style );
176 pref->inputStyle->setEnabled( profile->canSelectStyle() ); 183 pref->inputStyle->setEnabled( profile->canSelectStyle() );
177 multiTimeout = profile->multiStrokeTimeout(); 184 multiTimeout = profile->multiStrokeTimeout();
178 pref->multiStrokeSlider->setValue( multiTimeout ); 185 pref->multiStrokeSlider->setValue( multiTimeout );
179 multiTimeoutChanged( multiTimeout ); 186 multiTimeoutChanged( multiTimeout );
@@ -534,64 +541,65 @@ void QIMPenEdit::selectChar( int i )
534 !it.current()->testFlag( QIMPenChar::Deleted ) ) { 541 !it.current()->testFlag( QIMPenChar::Deleted ) ) {
535 setCurrentChar( it.current() ); 542 setCurrentChar( it.current() );
536 break; 543 break;
537 } 544 }
538 } 545 }
539 if ( !it.current() ) 546 if ( !it.current() )
540 setCurrentChar( 0 ); 547 setCurrentChar( 0 );
541 inputChar->clear(); 548 inputChar->clear();
542} 549}
543 550
544void QIMPenEdit::selectCharSet( int i ) 551void QIMPenEdit::selectCharSet( int i )
545{ 552{
546 if ( currentSet ) 553 if ( currentSet )
547 pw->removeCharSet( 0 ); 554 pw->removeCharSet( 0 );
548 currentSet = profile->charSets().at( i ); 555 currentSet = profile->charSets().at( i );
549 fillCharList(); 556 fillCharList();
550 pw->insertCharSet( currentSet ); 557 pw->insertCharSet( currentSet );
551 inputChar->clear(); 558 inputChar->clear();
552 if ( charList->count() ) { 559 if ( charList->count() ) {
553 charList->setSelected( 0, TRUE ); 560 charList->setSelected( 0, TRUE );
554 selectChar(0); 561 selectChar(0);
555 } 562 }
556} 563}
557 564
558void QIMPenEdit::addChar() 565void QIMPenEdit::addChar()
559{ 566{
560 if ( !inputChar->isEmpty() ) { 567 if ( !inputChar->isEmpty() ) {
561 QIMPenChar *pc = new QIMPenChar( *inputChar ); 568 QIMPenChar *pc = new QIMPenChar( *inputChar );
562 pc->setCharacter( currentCode ); 569 pc->setCharacter( currentCode );
563 570
564 // User characters override all matching system characters. 571 // User characters override all matching system characters.
565 // Copy and mark deleted identical system characters. 572 // Copy and mark deleted identical system characters.
573
566 QIMPenCharIterator it(currentSet->characters() ); 574 QIMPenCharIterator it(currentSet->characters() );
567 QIMPenChar *sc = 0; 575 QIMPenChar *sc = 0;
568 while ( (sc = it.current()) != 0 ) { 576 while ( (sc = it.current()) != 0 ) {
569 ++it; 577 ++it;
570 if ( sc->character() == currentCode && 578 if ( sc->character() == currentCode &&
571 sc->testFlag( QIMPenChar::System ) && 579 sc->testFlag( QIMPenChar::System ) &&
572 !sc->testFlag( QIMPenChar::Deleted ) ) { 580 !sc->testFlag( QIMPenChar::Deleted ) ) {
573 QIMPenChar *cc = new QIMPenChar( *sc ); 581 QIMPenChar *cc = new QIMPenChar( *sc );
574 cc->clearFlag( QIMPenChar::System ); 582 cc->clearFlag( QIMPenChar::System );
575 currentSet->addChar( cc ); 583 currentSet->addChar( cc );
576 sc->setFlag( QIMPenChar::Deleted ); 584 sc->setFlag( QIMPenChar::Deleted );
577 } 585 }
578 } 586 }
579 587
580 currentSet->addChar( pc ); 588 currentSet->addChar( pc );
581 setCurrentChar( pc ); 589 setCurrentChar( pc );
582 inputChar->clear(); 590 inputChar->clear();
583 } 591 }
584} 592}
585 593
586void QIMPenEdit::addNewChar() 594void QIMPenEdit::addNewChar()
587{ 595{
588 if ( !inputChar->isEmpty() ) { 596 if ( !inputChar->isEmpty() ) {
589 QIMPenInputCharDlg dlg( 0, 0, TRUE ); 597 QIMPenInputCharDlg dlg( 0, 0, TRUE );
590 if ( dlg.exec() ) { 598 if ( dlg.exec() ) {
591 currentCode = dlg.unicode(); 599 currentCode = dlg.unicode();
592 addChar(); 600 addChar();
593 fillCharList(); 601 fillCharList();
594 for ( unsigned int i = 0; i < charList->count(); i++ ) { 602 for ( unsigned int i = 0; i < charList->count(); i++ ) {
595 CharListItem *li = (CharListItem *)charList->item(i); 603 CharListItem *li = (CharListItem *)charList->item(i);
596 if ( li->code() == dlg.unicode() ) { 604 if ( li->code() == dlg.unicode() ) {
597 charList->setSelected( i, TRUE ); 605 charList->setSelected( i, TRUE );