summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting
Side-by-side diff
Diffstat (limited to 'inputmethods/handwriting') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpenchar.h2
-rw-r--r--inputmethods/handwriting/qimpenprofile.cpp3
-rw-r--r--inputmethods/handwriting/qimpensetup.cpp17
-rw-r--r--inputmethods/handwriting/qimpensetup.h1
4 files changed, 19 insertions, 4 deletions
diff --git a/inputmethods/handwriting/qimpenchar.h b/inputmethods/handwriting/qimpenchar.h
index e4e7645..92ee2c1 100644
--- a/inputmethods/handwriting/qimpenchar.h
+++ b/inputmethods/handwriting/qimpenchar.h
@@ -72,89 +72,89 @@ public:
protected:
unsigned int ch;
QString d;
Q_UINT8 flags;
QIMPenStrokeList strokes;
friend QDataStream &operator<< (QDataStream &, const QIMPenChar &);
friend QDataStream &operator>> (QDataStream &, QIMPenChar &);
};
typedef QList<QIMPenChar> QIMPenCharList;
typedef QListIterator<QIMPenChar> QIMPenCharIterator;
QDataStream & operator<< (QDataStream & s, const QIMPenChar &ws);
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; }
+ 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 b1a6592..67343c3 100644
--- a/inputmethods/handwriting/qimpenprofile.cpp
+++ b/inputmethods/handwriting/qimpenprofile.cpp
@@ -97,113 +97,116 @@ QString QIMPenProfile::userConfig()
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() && !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->setDescription( "Hidden uppercase" );
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 ( mono () )
+ cs->setDescription( "Latin Characters" );
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;
}
}
// symbol
s = config.readEntry( "Symbol" );
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;
}
}
// shortcut
s = config.readEntry( "Shortcut" );
if ( !s.isEmpty() ) {
cs = new QIMPenCharSet( baseDir + "qimpen/" + s );
cs->load( Global::applicationFileName("qimpen",s), QIMPenCharSet::User );
if ( !cs->isEmpty() ) {
sets.append( cs );
} else {
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp
index d1297a9..3f4841d 100644
--- a/inputmethods/handwriting/qimpensetup.cpp
+++ b/inputmethods/handwriting/qimpensetup.cpp
@@ -281,175 +281,175 @@ void QIMPenInputCharDlg::setSpecial( int sp )
}
void QIMPenInputCharDlg::setCharacter( const QString &string )
{
uni = string[0].unicode();
}
//---------------------------------------------------------------------------
class CharListItem : public QListBoxText
{
public:
CharListItem( const QString &text, uint c )
: QListBoxText( text )
{
_code = c;
}
uint code() const { return _code; }
protected:
uint _code;
};
/*!
\class QIMPenEdit qimpensetup.h
Class to allow users to input totally useless character definitions
which could match any number of the default set.
*/
QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent,
const char *name )
: QWidget( parent, name ), profile(p)
{
currentChar = 0;
currentCode = 0;
inputChar = new QIMPenChar();
QVBoxLayout *tvb = new QVBoxLayout( this, 5 );
QGridLayout *gl = new QGridLayout( tvb, 4, 2 );
gl->setRowStretch( 1, 1 );
gl->addRowSpacing( 2, 35 );
gl->addRowSpacing( 3, 35 );
charSetCombo = new QComboBox( this );
gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 );
- connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int)));
+ connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSetVisible(int)));
QIMPenCharSetIterator it( profile->charSets() );
for ( ; it.current(); ++it ) {
charSetCombo->insertItem( it.current()->description() );
}
charList = new QListBox( this );
charList->setMinimumHeight( charList->sizeHint().height() );
connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) );
gl->addWidget( charList, 1, 0 );
pw = new QIMPenWidget( this );
pw->setFixedHeight( 75 );
gl->addMultiCellWidget( pw, 2, 3, 0, 0 );
connect( pw, SIGNAL(stroke(QIMPenStroke*)),
SLOT(newStroke(QIMPenStroke*)) );
QVBoxLayout *vb = new QVBoxLayout();
gl->addLayout( vb, 1, 1 );
newBtn = new QPushButton( tr("New..."), this );
connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) );
vb->addWidget( newBtn );
addBtn = new QPushButton( tr("Add"), this );
connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) );
vb->addWidget( addBtn );
removeBtn = new QPushButton( tr("Remove"), this );
connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) );
vb->addWidget( removeBtn );
QPushButton *pb = new QPushButton( tr("Default"), this );
connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) );
vb->addWidget( pb );
QHBoxLayout *hb = new QHBoxLayout();
gl->addLayout( hb, 2, 1 );
prevBtn = new QPushButton( this );
prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) );
connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar()));
hb->addWidget( prevBtn );
nextBtn = new QPushButton( this );
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 );
+ selectCharSetVisible( 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 );
+ selectCharSetVisible( 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();
if ( !n.isEmpty() )
li = new CharListItem( n, ch );
if ( li ) {
CharListItem *i = (CharListItem *)charList->findItem( li->text() );
if ( !i || i->code() != ch ) {
charList->insertItem( li );
} else {
delete li;
li = 0;
}
}
}
currentChar = 0;
}
void QIMPenEdit::enableButtons()
{
bool add = !inputChar->isEmpty();
newBtn->setEnabled( add );
@@ -504,96 +504,107 @@ QIMPenChar *QIMPenEdit::findNext()
void QIMPenEdit::setCurrentChar( QIMPenChar *pc )
{
currentChar = pc;
pw->showCharacter( currentChar );
if ( currentChar ) {
prevBtn->setEnabled( findPrev() != 0 );
nextBtn->setEnabled( findNext() != 0 );
}
}
void QIMPenEdit::prevChar()
{
QIMPenChar *pc = findPrev();
if ( pc )
setCurrentChar( pc );
}
void QIMPenEdit::nextChar()
{
QIMPenChar *pc = findNext();
if ( pc )
setCurrentChar( pc );
}
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::selectCharSetVisible( int c )
+{
+ int i = 0;
+ QIMPenCharSetIterator it( profile->charSets() );
+ for ( ; it.current(); ++it, i++ ) {
+ if ( charSetCombo->text( c ) == it.current()->description() ) {
+ selectCharSet( i );
+ }
+ }
+}
+
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() ) {
diff --git a/inputmethods/handwriting/qimpensetup.h b/inputmethods/handwriting/qimpensetup.h
index 5d3064b..93b981b 100644
--- a/inputmethods/handwriting/qimpensetup.h
+++ b/inputmethods/handwriting/qimpensetup.h
@@ -55,70 +55,71 @@ private:
int multiTimeout;
QIMPenProfile *profile;
QList<QIMPenProfile> profileList;
};
class QIMPenInputCharDlg : public QDialog
{
Q_OBJECT
public:
QIMPenInputCharDlg( QWidget *parent = 0, const char *name = 0,
bool modal = FALSE, int WFlags = 0 );
unsigned int unicode() const { return uni; }
protected:
void addSpecial( QComboBox *cb );
protected slots:
void setSpecial( int sp );
void setCharacter( const QString &string );
protected:
uint uni;
};
class QIMPenEdit : public QWidget
{
Q_OBJECT
public:
QIMPenEdit( QIMPenProfile *p, QWidget *parent=0,
const char *name=0 );
void setProfile( QIMPenProfile *p );
void selectCharSet( QIMPenCharSet *c );
protected:
void fillCharList();
void enableButtons();
QIMPenChar *findPrev();
QIMPenChar *findNext();
void setCurrentChar( QIMPenChar * );
protected slots:
void prevChar();
void nextChar();
void clearChar();
void selectChar( int );
void selectCharSet( int );
+ void selectCharSetVisible( int );
void addChar();
void addNewChar();
void removeChar();
void defaultChars();
void newStroke( QIMPenStroke * );
protected:
QIMPenWidget *pw;
QComboBox *charSetCombo;
QListBox *charList;
QPushButton *newBtn;
QPushButton *addBtn;
QPushButton *removeBtn;
QPushButton *prevBtn;
QPushButton *nextBtn;
uint currentCode;
QIMPenChar *currentChar;
QIMPenChar *inputChar;
QIMPenCharSet *currentSet;
QIMPenProfile *profile;
};