-rw-r--r-- | inputmethods/handwriting/qimpeninput.cpp | 7 | ||||
-rw-r--r-- | inputmethods/handwriting/qimpensetup.cpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/inputmethods/handwriting/qimpeninput.cpp b/inputmethods/handwriting/qimpeninput.cpp index 9acab8b..6a21931 100644 --- a/inputmethods/handwriting/qimpeninput.cpp +++ b/inputmethods/handwriting/qimpeninput.cpp @@ -161,210 +161,213 @@ QIMPenInput::QIMPenInput( QWidget *parent, const char *name, WFlags flags ) wordPicker->setBackgroundColor( white ); gl->addMultiCellWidget( wordPicker, 0, 0, 0, 1 ); if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() ) wordPicker->hide(); pw = new QIMPenWidget( this ); gl->addMultiCellWidget( pw, 1, 4, 0, 0 ); int bh = pw->sizeHint().height()/4; QPushButton *b = new QPushButton( this ); b->setFocusPolicy( NoFocus ); b->setPixmap( QPixmap( (const char **)bs_xpm ) ); b->setFixedHeight(pw->sizeHint().height()-3*bh); // left-over space goes here b->setAutoRepeat( TRUE ); gl->addWidget( b, 1, 1 ); connect( b, SIGNAL(clicked()), SLOT(backspace())); b = new QPushButton( this ); b->setFocusPolicy( NoFocus ); b->setPixmap( QPixmap( (const char **)enter_xpm ) ); b->setFixedHeight(bh); b->setAutoRepeat( TRUE ); gl->addWidget( b, 2, 1 ); connect( b, SIGNAL(clicked()), SLOT(enter())); helpBtn = new QPushButton( this ); helpBtn->setFocusPolicy( NoFocus ); helpBtn->setPixmap( QPixmap( (const char **)help_xpm ) ); helpBtn->setFixedHeight(bh); gl->addWidget( helpBtn, 3, 1 ); connect( helpBtn, SIGNAL(clicked()), SLOT(help())); QPixmap pm( (const char **)pen_xpm ); setupBtn = new QPushButton( this ); setupBtn->setFocusPolicy( NoFocus ); setupBtn->setPixmap( pm ); setupBtn->setFixedHeight(bh); gl->addWidget( setupBtn, 4, 1 ); connect( setupBtn, SIGNAL(clicked()), SLOT(setup())); connect( matcher, SIGNAL(removeStroke()), pw, SLOT(removeStroke()) ); connect( pw, SIGNAL(changeCharSet( QIMPenCharSet * )), matcher, SLOT(setCharSet( QIMPenCharSet * )) ); connect( pw, SIGNAL(changeCharSet( int )), this, SLOT(selectCharSet( int )) ); connect( pw, SIGNAL(beginStroke()), matcher, SLOT(beginStroke()) ); connect( pw, SIGNAL(stroke( QIMPenStroke * )), this, SLOT(strokeEntered( QIMPenStroke * )) ); connect( pw, SIGNAL(stroke( QIMPenStroke * )), matcher, SLOT(strokeEntered( QIMPenStroke * )) ); shortcutCharSet = 0; currCharSet = 0; setupDlg = 0; profile = 0; mode = Normal; loadProfiles(); } QIMPenInput::~QIMPenInput() { delete (HandwritingHelp*) helpDlg; } QSize QIMPenInput::sizeHint() const { int fw = frameWidth(); int ps = wordPicker->isHidden() ? 0 : wordPicker->sizeHint().height(); return pw->sizeHint() + QSize( fw*2, fw*2+ps ); } void QIMPenInput::loadProfiles() { profileList.clear(); profile = 0; delete shortcutCharSet; shortcutCharSet = new QIMPenCharSet(); shortcutCharSet->setTitle( "Shortcut" ); 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 ); if ( p->shortcut() ) { QIMPenCharIterator it( p->shortcut()->characters() ); for ( ; it.current(); ++it ) { shortcutCharSet->addChar( new QIMPenChar(*it.current()) ); } } } + Config config( "handwriting" ); config.setGroup( "Settings" ); QString prof = config.readEntry( "Profile", "Default" ); selectProfile( prof ); } void QIMPenInput::selectProfile( const QString &name ) { QListIterator<QIMPenProfile> it( profileList ); for ( ; it.current(); ++it ) { if ( it.current()->name() == name ) { profile = it.current(); break; } } - if ( !it.current() ) - return; + if ( !it.current() ) { + qWarning("No profile selected!\n"); + return; + } pw->clearCharSets(); baseSets.clear(); matcher->setMultiStrokeTimeout( profile->multiStrokeTimeout() ); matcher->setWordMatchingEnabled( profile->matchWords() ); if ( !Global::fixedDawg().root() || !matcher->isWordMatchingEnabled() ) wordPicker->hide(); else wordPicker->show(); if ( profile->uppercase() && profile->style() == QIMPenProfile::BothCases ) { baseSets.append( profile->uppercase() ); pw->insertCharSet( profile->uppercase() ); } if ( profile->lowercase() ) { baseSets.append( profile->lowercase() ); pw->insertCharSet( profile->lowercase(), profile->style() == QIMPenProfile::BothCases ? 1 : 2 ); } if ( profile->numeric() ) { baseSets.append( profile->numeric() ); pw->insertCharSet( profile->numeric() ); } if ( helpDlg ) delete (HandwritingHelp*) helpDlg; } void QIMPenInput::wordPicked( const QString &w ) { int bs = matcher->word().length(); for ( int i = 0; i < bs; i++ ) keypress( Qt::Key_Backspace << 16 ); for ( unsigned int i = 0; i < w.length(); i++ ) keypress( w[i].unicode() ); matcher->resetState(); wordPicker->clear(); } void QIMPenInput::selectCharSet( int idx ) { if ( mode == Switch ) { //qDebug( "Switch back to normal" ); pw->changeCharSet( baseSets.at(currCharSet), currCharSet ); mode = Normal; } currCharSet = idx; } void QIMPenInput::beginStroke() { } void QIMPenInput::strokeEntered( QIMPenStroke * ) { pw->greyStroke(); } void QIMPenInput::erase() { keypress( Qt::Key_Backspace << 16 ); } void QIMPenInput::matchedCharacters( const QIMPenCharMatchList &cl ) { const QIMPenChar *ch = cl.first().penChar; int scan = ch->character() >> 16; if ( scan < QIMPenChar::ModeBase ) return; // We matched a special character... switch ( scan ) { case QIMPenChar::Caps: if ( profile->style() == QIMPenProfile::ToggleCases ) { // qDebug( "Caps" ); if ( mode == SwitchLock ) { // qDebug( "Switch to normal" ); pw->changeCharSet( profile->lowercase(), currCharSet ); mode = Switch; } else { // qDebug( "Switch to upper" ); pw->changeCharSet( profile->uppercase(), currCharSet ); mode = Switch; } } break; case QIMPenChar::CapsLock: if ( profile->style() == QIMPenProfile::ToggleCases ) { // qDebug( "CapsLock" ); diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp index a6ae3a8..2c06fbc 100644 --- a/inputmethods/handwriting/qimpensetup.cpp +++ b/inputmethods/handwriting/qimpensetup.cpp @@ -1,192 +1,192 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** 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. ** **********************************************************************/ #include "qimpenwidget.h" #include "qimpenprefbase.h" #include "qimpensetup.h" #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qcombobox.h> #include <qlistbox.h> #include <qlabel.h> #include <qpushbutton.h> #include <qlayout.h> #include <qpixmap.h> #include <qbuttongroup.h> #include <qslider.h> #include <qtabwidget.h> #include <qdir.h> #include <qmessagebox.h> /* XPM */ static const char * const left_xpm[] = { "16 16 2 1", " c None", ". c #000000", " ", " ", " ", " . ", " .. ", " ... ", " .... ", " ..... ", " ...... ", " ..... ", " .... ", " ... ", " .. ", " . ", " ", " "}; /* 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 +#if 1 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 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") ); } 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; } } } 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" ); |