summaryrefslogtreecommitdiff
path: root/inputmethods
Side-by-side diff
Diffstat (limited to 'inputmethods') (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
@@ -48,148 +48,155 @@ static const char * const left_xpm[] = {
" ",
" . ",
" .. ",
" ... ",
" .... ",
" ..... ",
" ...... ",
" ..... ",
" .... ",
" ... ",
" .. ",
" . ",
" ",
" "};
/* XPM */
static const char * const right_xpm[] = {
"16 16 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" . ",
" .. ",
" ... ",
" .... ",
" ..... ",
" ...... ",
" ..... ",
" .... ",
" ... ",
" .. ",
" . ",
" ",
" "};
QIMPenSetup::QIMPenSetup( QIMPenProfile *p, QWidget *parent,
const char *name, bool modal, int WFlags )
: QDialog( parent, name, modal, WFlags ), profileCombo(0), profile(p)
{
setCaption( tr("Setup Handwriting Input") );
QVBoxLayout *vb = new QVBoxLayout( this );
-#if 0
+#define MULTIPROFILE
+#ifdef MULTIPROFILE
profileList.setAutoDelete( true );
QHBoxLayout *hb = new QHBoxLayout( vb );
hb->setMargin( 6 );
QLabel *l = new QLabel( tr("Character Profile:"), this );
hb->addWidget( l );
profileCombo = new QComboBox( this );
connect( profileCombo, SIGNAL(activated(const QString &)),
this, SLOT(selectProfile(const QString &)) );
hb->addWidget( profileCombo );
- loadProfiles();
#else
profileList.append( profile );
#endif
+
+ qWarning("profiles: %d", profileList.count());
QTabWidget *tw = new QTabWidget( this );
vb->addWidget( tw );
pref = new QIMPenPrefBase( this );
tw->addTab( pref, tr("Preferences") );
pref->inputStyle->setExclusive( TRUE );
style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
pref->inputStyle->setButton( style );
connect( pref->inputStyle, SIGNAL(clicked(int)),
this, SLOT(styleClicked(int)) );
pref->inputStyle->setEnabled( profile->canSelectStyle() );
multiTimeout = profile->multiStrokeTimeout();
pref->multiStrokeSlider->setValue( multiTimeout );
multiTimeoutChanged( multiTimeout );
connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)),
this, SLOT(multiTimeoutChanged(int)) );
edit = new QIMPenEdit( p, tw );
tw->addTab( edit, tr("Customize") );
+#ifdef MULTIPROFILE
+ loadProfiles();
+#endif
+
}
void QIMPenSetup::loadProfiles()
{
QString path = QPEApplication::qpeDir() + "etc/qimpen";
QDir dir( path, "*.conf" );
QStringList list = dir.entryList();
QStringList::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
QIMPenProfile *p = new QIMPenProfile( path + "/" + *it );
profileList.append( p );
profileCombo->insertItem( p->name() );
if ( p->name() == profile->name() ) {
profileCombo->setCurrentItem( profileCombo->count()-1 );
profile = p;
+ edit->setProfile( profile );
}
}
}
void QIMPenSetup::styleClicked( int id )
{
style = id;
}
void QIMPenSetup::multiTimeoutChanged( int v )
{
multiTimeout = v;
pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) );
}
void QIMPenSetup::selectProfile( const QString &p )
{
if ( p == profile->name() )
return;
profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases );
profile->setMultiStrokeTimeout( multiTimeout );
for ( int i = 0; i < (int)profileList.count(); i++ ) {
if ( profileList.at(i)->name() == p ) {
profile = profileList.at(i);
style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
pref->inputStyle->setButton( style );
pref->inputStyle->setEnabled( profile->canSelectStyle() );
multiTimeout = profile->multiStrokeTimeout();
pref->multiStrokeSlider->setValue( multiTimeout );
multiTimeoutChanged( multiTimeout );
edit->setProfile( profile );
break;
}
}
}
void QIMPenSetup::accept()
{
profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases );
profile->setMultiStrokeTimeout( multiTimeout );
// Save current profile
if ( profileCombo ) {
Config config( "handwriting" );
config.setGroup( "Settings" );
config.writeEntry( "Profile", profileCombo->currentText() );
}
@@ -518,96 +525,97 @@ void QIMPenEdit::nextChar()
}
void QIMPenEdit::clearChar()
{
inputChar->clear();
pw->clear();
enableButtons();
}
void QIMPenEdit::selectChar( int i )
{
currentChar = 0;
currentCode = ((CharListItem *)charList->item(i))->code();
QIMPenCharIterator it(currentSet->characters() );
for ( ; it.current(); ++it ) {
if ( it.current()->character() == currentCode &&
!it.current()->testFlag( QIMPenChar::Deleted ) ) {
setCurrentChar( it.current() );
break;
}
}
if ( !it.current() )
setCurrentChar( 0 );
inputChar->clear();
}
void QIMPenEdit::selectCharSet( int i )
{
if ( currentSet )
pw->removeCharSet( 0 );
currentSet = profile->charSets().at( i );
fillCharList();
pw->insertCharSet( currentSet );
inputChar->clear();
if ( charList->count() ) {
charList->setSelected( 0, TRUE );
selectChar(0);
}
}
void QIMPenEdit::addChar()
{
if ( !inputChar->isEmpty() ) {
QIMPenChar *pc = new QIMPenChar( *inputChar );
pc->setCharacter( currentCode );
// User characters override all matching system characters.
// Copy and mark deleted identical system characters.
+
QIMPenCharIterator it(currentSet->characters() );
QIMPenChar *sc = 0;
while ( (sc = it.current()) != 0 ) {
++it;
if ( sc->character() == currentCode &&
sc->testFlag( QIMPenChar::System ) &&
!sc->testFlag( QIMPenChar::Deleted ) ) {
QIMPenChar *cc = new QIMPenChar( *sc );
cc->clearFlag( QIMPenChar::System );
currentSet->addChar( cc );
sc->setFlag( QIMPenChar::Deleted );
}
}
currentSet->addChar( pc );
setCurrentChar( pc );
inputChar->clear();
}
}
void QIMPenEdit::addNewChar()
{
if ( !inputChar->isEmpty() ) {
QIMPenInputCharDlg dlg( 0, 0, TRUE );
if ( dlg.exec() ) {
currentCode = dlg.unicode();
addChar();
fillCharList();
for ( unsigned int i = 0; i < charList->count(); i++ ) {
CharListItem *li = (CharListItem *)charList->item(i);
if ( li->code() == dlg.unicode() ) {
charList->setSelected( i, TRUE );
break;
}
}
}
}
}
void QIMPenEdit::removeChar()
{
if ( currentChar ) {
QIMPenChar *pc = findPrev();
if ( !pc ) pc = findNext();
if ( currentChar->testFlag( QIMPenChar::System ) )
currentChar->setFlag( QIMPenChar::Deleted );
else
currentSet->removeChar( currentChar );