author | zecke <zecke> | 2004-01-18 13:26:43 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-01-18 13:26:43 (UTC) |
commit | 7d94c9b04f8702d0f94c6c64454d159a186a2576 (patch) (side-by-side diff) | |
tree | a5989f07e02e610abab7cf7514737a67c78b1d68 | |
parent | a2a3aabf21655cc9c7df8e2ed0d420d2b208fd3d (diff) | |
download | opie-7d94c9b04f8702d0f94c6c64454d159a186a2576.zip opie-7d94c9b04f8702d0f94c6c64454d159a186a2576.tar.gz opie-7d94c9b04f8702d0f94c6c64454d159a186a2576.tar.bz2 |
Comit the "Mono" patch by
Brad Campbell <brad@wasp.net.au>
-rw-r--r-- | inputmethods/handwriting/qimpenchar.cpp | 5 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpenchar.h | 3 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpenprofile.cpp | 25 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpenprofile.h | 2 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpensetup.cpp | 1 |
5 files changed, 34 insertions, 2 deletions
diff --git a/inputmethods/handwriting/qimpenchar.cpp b/inputmethods/handwriting/qimpenchar.cpp index 0c37e5c..929f370 100644 --- a/inputmethods/handwriting/qimpenchar.cpp +++ b/inputmethods/handwriting/qimpenchar.cpp @@ -317,76 +317,79 @@ bool QIMPenCharSet::load( const QString &fn, Domain d ) bool ok = FALSE; QFile file( fn ); if ( file.open( IO_ReadOnly ) ) { QDataStream ds( &file ); QString version; ds >> version; ds >> csTitle; ds >> desc; int major = version.mid( 4, 1 ).toInt(); int minor = version.mid( 6 ).toInt(); if ( major >= 1 && minor > 0 ) { ds >> (Q_INT8 &)csType; } else { if ( csTitle == "abc" ) csType = Lower; else if ( csTitle == "ABC" ) csType = Upper; else if ( csTitle == "123" ) csType = Numeric; else if ( fn == "Combining" ) csType = Combining; } while ( !ds.atEnd() ) { QIMPenChar *pc = new QIMPenChar; ds >> *pc; if ( d == User ) markDeleted( pc->character() ); // override system addChar( pc ); } if ( file.status() == IO_Ok ) ok = TRUE; } - + setHidden ( false ); return ok; } /*! Save this character set. */ bool QIMPenCharSet::save( Domain d ) { if ( filename( d ).isEmpty() ) return FALSE; + if ( hidden() ) + return TRUE; + bool ok = FALSE; QString fn = filename( d ); QString tmpFn = fn + ".new"; QFile file( tmpFn ); if ( file.open( IO_WriteOnly|IO_Raw ) ) { QByteArray buf; QDataStream ds( buf, IO_WriteOnly ); ds << QString( "QPT 1.1" ); ds << csTitle; ds << desc; ds << (Q_INT8)csType; QIMPenCharIterator ci( chars ); for ( ; ci.current(); ++ci ) { QIMPenChar *pc = ci.current(); if ( ( ( (d == System) && pc->testFlag( QIMPenChar::System ) ) || ( (d == User) && !pc->testFlag( QIMPenChar::System ) ) ) && ( !pc->testFlag (QIMPenChar::Combined ) ) ) { ds << *pc; } } file.writeBlock( buf ); file.close(); if ( file.status() == IO_Ok ) ok = TRUE; } if ( ok ) { if ( ::rename( tmpFn.latin1(), fn.latin1() ) < 0 ) { qWarning( "problem renaming file %s to %s, errno: %d", tmpFn.latin1(), fn.latin1(), errno ); diff --git a/inputmethods/handwriting/qimpenchar.h b/inputmethods/handwriting/qimpenchar.h index efd6f16..e4e7645 100644 --- a/inputmethods/handwriting/qimpenchar.h +++ b/inputmethods/handwriting/qimpenchar.h @@ -88,70 +88,73 @@ QDataStream & operator>> (QDataStream & s, QIMPenChar &ws); struct QIMPenCharMatch { int error; QIMPenChar *penChar; bool operator>( const QIMPenCharMatch &m ); bool operator<( const QIMPenCharMatch &m ); bool operator<=( const QIMPenCharMatch &m ); }; typedef QValueList<QIMPenCharMatch> QIMPenCharMatchList; class QIMPenCharSet { public: QIMPenCharSet(); QIMPenCharSet( const QString &fn ); bool isEmpty() const { return chars.isEmpty(); } unsigned int count() const { return chars.count(); } void clear() { chars.clear(); } void setDescription( const QString &d ) { desc = d; } QString description() const { return desc; } void setTitle( const QString &t ) { csTitle = t; } QString title() const { return csTitle; } QIMPenCharMatchList match( QIMPenChar *ch ); void addChar( QIMPenChar *ch ); void removeChar( QIMPenChar *ch ); QIMPenChar *at( int i ); + void setHidden ( const bool &b ) { phidden = &b; } + bool hidden() const { return phidden; } unsigned maximumStrokes() const { return maxStrokes; } void up( QIMPenChar *ch ); void down( QIMPenChar *ch ); enum Domain { System, User }; enum Type { Unknown=0x00, Lower=0x01, Upper=0x02, Combining=0x04, Numeric=0x08, Punctuation=0x10, Symbol=0x20, Shortcut=0x40 }; const QIMPenCharList &characters() const { return chars; } void setType( Type t ) { csType = t; } Type type() const { return csType; } const QString &filename( Domain d ) const; void setFilename( const QString &fn, Domain d=System ); bool load( const QString &fn, Domain d=System ); bool save( Domain d=System ); protected: void markDeleted( uint ch ); protected: QString csTitle; QString desc; QString sysFilename; QString userFilename; Type csType; unsigned maxStrokes; QIMPenCharList chars; QIMPenCharMatchList matches; + bool phidden : 1; }; typedef QList<QIMPenCharSet> QIMPenCharSetList; typedef QListIterator<QIMPenCharSet> QIMPenCharSetIterator; #endif diff --git a/inputmethods/handwriting/qimpenprofile.cpp b/inputmethods/handwriting/qimpenprofile.cpp index 3b1b5e9..b1a6592 100644 --- a/inputmethods/handwriting/qimpenprofile.cpp +++ b/inputmethods/handwriting/qimpenprofile.cpp @@ -19,64 +19,67 @@ **********************************************************************/ #include "qimpencombining.h" #include "qimpenprofile.h" #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/global.h> QIMPenProfile::QIMPenProfile( const QString &fn ) : filename( fn ) { sets.setAutoDelete( true ); Config config( filename, Config::File ); config.setGroup( "Handwriting" ); pname = config.readEntry( "Name" ); pdesc = config.readEntry( "Description" ); tstyle = config.readBoolEntry( "CanSelectStyle", false ); wordMatch = config.readBoolEntry( "MatchWords", true ); config.setGroup( "Settings" ); pstyle = BothCases; QString s = config.readEntry( "Style", "BothCases" ); if ( s == "ToggleCases" ) pstyle = ToggleCases; + QString t = config.readEntry( "Mono", "Dual" ); + pmono = (QString::fromLatin1("Mono") == t ); + msTimeout = config.readNumEntry( "MultiTimeout", 500 ); // Read user configuration Config usrConfig( userConfig() ); usrConfig.setGroup( "Settings" ); msTimeout = usrConfig.readNumEntry( "MultiTimeout", msTimeout ); if ( tstyle && usrConfig.hasKey( "Style" ) ) { pstyle = BothCases; QString s = usrConfig.readEntry( "Style", "BothCases" ); if ( s == "ToggleCases" ) pstyle = ToggleCases; } } void QIMPenProfile::setStyle( Style s ) { if ( tstyle && s != pstyle ) { pstyle = s; Config config( userConfig() ); config.setGroup( "Settings" ); QString s = pstyle == ToggleCases ? "ToggleCases" : "BothCases"; config.writeEntry( "Style", s ); } } void QIMPenProfile::setMultiStrokeTimeout( int t ) { if ( t != msTimeout ) { msTimeout = t; Config config( userConfig() ); config.setGroup( "Settings" ); @@ -90,78 +93,98 @@ QString QIMPenProfile::userConfig() int pos = un.findRev( '/' ); if ( pos >= 0 ) un = un.mid( pos + 1 ); pos = un.find( '.' ); if ( pos > 0 ) un.truncate( pos ); un = "handwriting-" + un; // No tr return un; } void QIMPenProfile::loadData() { Config config( filename, Config::File ); config.setGroup( "CharSets" ); QString baseDir = QPEApplication::qpeDir(); baseDir += "/etc/"; // accents QIMPenCombining *combining = 0; QString s = config.readEntry( "Combining" ); if ( !s.isEmpty() ) { combining = new QIMPenCombining( baseDir + "qimpen/" + s ); if ( combining->isEmpty() ) { delete combining; combining = 0; } } // uppercase latin1 QIMPenCharSet *cs = 0; s = config.readEntry( "Uppercase" ); - if ( !s.isEmpty() ) { + if ( !s.isEmpty() && !mono() ) { cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); if ( !cs->isEmpty() ) { if ( combining ) combining->addCombined( cs ); sets.append( cs ); } else { delete cs; } } // lowercase latin1 s = config.readEntry( "Lowercase" ); if ( !s.isEmpty() ) { + if ( mono() ) { + cs = new QIMPenCharSet ( baseDir + "qimpen/" + s ); + cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); + if ( !cs->isEmpty() ) { + cs->setTitle( cs->title().upper() ); + cs->setType( QIMPenCharSet::Upper ); + cs->setHidden ( true ); + QIMPenCharIterator it( cs->characters() ); + for ( ; it.current(); ++it ) { + uint ch = it.current()->character(); + if ( ch >= 'a' && ch <= 'z' ) + it.current()->setCharacter( QChar(ch).upper() ); + } + if ( combining ) + combining->addCombined( cs ); + sets.append( cs ); + } else { + delete cs; + } + } cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); if ( !cs->isEmpty() ) { if ( combining ) combining->addCombined( cs ); sets.append( cs ); } else { delete cs; } } // numeric (may comtain punctuation and symbols) s = config.readEntry( "Numeric" ); if ( !s.isEmpty() ) { cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); if ( !cs->isEmpty() ) { sets.append( cs ); } else { delete cs; } } // punctuation s = config.readEntry( "Punctuation" ); if ( !s.isEmpty() ) { cs = new QIMPenCharSet( baseDir + "qimpen/" + s ); cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User ); if ( !cs->isEmpty() ) { sets.append( cs ); } else { delete cs; } } diff --git a/inputmethods/handwriting/qimpenprofile.h b/inputmethods/handwriting/qimpenprofile.h index 4ce4367..adfa866 100644 --- a/inputmethods/handwriting/qimpenprofile.h +++ b/inputmethods/handwriting/qimpenprofile.h @@ -4,67 +4,69 @@ ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QIMPENPROFILE_H_ #define QIMPENPROFILE_H_ #include "qimpenchar.h" class QIMPenProfile { public: QIMPenProfile( const QString &fn ); const QString &name() const { return pname; } const QString &description() const { return pdesc; } enum Style { ToggleCases, BothCases }; Style style() const { return pstyle; } + bool mono() const { return pmono; } void setStyle( Style s ); bool canSelectStyle() const { return tstyle; } int multiStrokeTimeout() const { return msTimeout; } void setMultiStrokeTimeout( int t ); bool matchWords() const { return wordMatch; } QIMPenCharSet *uppercase(); QIMPenCharSet *lowercase(); QIMPenCharSet *numeric(); QIMPenCharSet *punctuation(); QIMPenCharSet *symbol(); QIMPenCharSet *shortcut(); QIMPenCharSet *find( QIMPenCharSet::Type t ); QIMPenCharSetList &charSets(); private: QString userConfig(); void loadData(); private: QIMPenCharSetList sets; QString filename; QString pname; QString pdesc; Style pstyle; bool tstyle; int msTimeout; bool wordMatch; + bool pmono; }; #endif diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp index 2441102..d0f9ffd 100644 --- a/inputmethods/handwriting/qimpensetup.cpp +++ b/inputmethods/handwriting/qimpensetup.cpp @@ -372,64 +372,65 @@ QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); hb->addWidget( nextBtn ); pb = new QPushButton( tr("Clear"), this ); connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); gl->addWidget( pb, 3, 1 ); //-- #if !defined(Q_WS_QWS) hb = new QHBoxLayout( tvb ); pb = new QPushButton( tr("OK"), this ); connect( pb, SIGNAL(clicked()), SLOT(accept()) ); hb->addWidget( pb ); pb = new QPushButton( tr("Cancel"), this ); connect( pb, SIGNAL(clicked()), SLOT(reject()) ); hb->addWidget( pb ); #endif selectCharSet( 0 ); charList->setFocus(); resize( minimumSize() ); enableButtons(); } void QIMPenEdit::setProfile( QIMPenProfile *p ) { profile = p; charSetCombo->clear(); QIMPenCharSetIterator it( profile->charSets() ); for ( ; it.current(); ++it ) { + if ( ! it.current()->hidden() ) charSetCombo->insertItem( it.current()->description() ); } selectCharSet( 0 ); charList->setFocus(); enableButtons(); } void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) { int i = 0; QIMPenCharSetIterator it( profile->charSets() ); for ( ; it.current(); ++it, i++ ) { if ( it.current() == c ) { charSetCombo->setCurrentItem( i ); selectCharSet( i ); } } } /*! Fill the character list box with the characters. Duplicates are not inserted. */ void QIMPenEdit::fillCharList() { charList->clear(); QIMPenCharIterator it( currentSet->characters() ); CharListItem *li = 0; for ( ; it.current(); ++it ) { uint ch = it.current()->character(); QString n = it.current()->name(); |