summaryrefslogtreecommitdiff
path: root/inputmethods/handwriting/qimpensetup.cpp
Unidiff
Diffstat (limited to 'inputmethods/handwriting/qimpensetup.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/handwriting/qimpensetup.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/inputmethods/handwriting/qimpensetup.cpp b/inputmethods/handwriting/qimpensetup.cpp
index d0f9ffd..d1297a9 100644
--- a/inputmethods/handwriting/qimpensetup.cpp
+++ b/inputmethods/handwriting/qimpensetup.cpp
@@ -1,536 +1,536 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "qimpenwidget.h" 21#include "qimpenwidget.h"
22#include "qimpenprefbase.h" 22#include "qimpenprefbase.h"
23#include "qimpensetup.h" 23#include "qimpensetup.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27 27
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qlistbox.h> 29#include <qlistbox.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qpixmap.h> 33#include <qpixmap.h>
34#include <qbuttongroup.h> 34#include <qbuttongroup.h>
35#include <qslider.h> 35#include <qslider.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qdir.h> 37#include <qdir.h>
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39 39
40 40
41/* XPM */ 41/* XPM */
42static const char * const left_xpm[] = { 42static const char * const left_xpm[] = {
43"16 16 2 1", 43"16 16 2 1",
44 " c None", 44 " c None",
45 ".c #000000", 45 ".c #000000",
46" ", 46" ",
47" ", 47" ",
48" ", 48" ",
49" . ", 49" . ",
50" .. ", 50" .. ",
51" ... ", 51" ... ",
52" .... ", 52" .... ",
53" ..... ", 53" ..... ",
54" ...... ", 54" ...... ",
55" ..... ", 55" ..... ",
56" .... ", 56" .... ",
57" ... ", 57" ... ",
58" .. ", 58" .. ",
59" . ", 59" . ",
60" ", 60" ",
61" "}; 61" "};
62 62
63 63
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#define MULTIPROFILE 96#define MULTIPROFILE
97#ifdef MULTIPROFILE 97#ifdef MULTIPROFILE
98 profileList.setAutoDelete( true ); 98 profileList.setAutoDelete( true );
99 QHBoxLayout *hb = new QHBoxLayout( vb ); 99 QHBoxLayout *hb = new QHBoxLayout( vb );
100 hb->setMargin( 6 ); 100 hb->setMargin( 6 );
101 QLabel *l = new QLabel( tr("Character Profile:"), this ); 101 QLabel *l = new QLabel( tr("Character Profile:"), this );
102 hb->addWidget( l ); 102 hb->addWidget( l );
103 profileCombo = new QComboBox( this ); 103 profileCombo = new QComboBox( this );
104 connect( profileCombo, SIGNAL(activated(const QString &)), 104 connect( profileCombo, SIGNAL(activated(const QString&)),
105 this, SLOT(selectProfile(const QString &)) ); 105 this, SLOT(selectProfile(const QString&)) );
106 hb->addWidget( profileCombo ); 106 hb->addWidget( profileCombo );
107#else 107#else
108 profileList.append( profile ); 108 profileList.append( profile );
109#endif 109#endif
110 110
111 qWarning("profiles: %d", profileList.count()); 111 qWarning("profiles: %d", profileList.count());
112 112
113 QTabWidget *tw = new QTabWidget( this ); 113 QTabWidget *tw = new QTabWidget( this );
114 vb->addWidget( tw ); 114 vb->addWidget( tw );
115 115
116 pref = new QIMPenPrefBase( this ); 116 pref = new QIMPenPrefBase( this );
117 tw->addTab( pref, tr("Preferences") ); 117 tw->addTab( pref, tr("Preferences") );
118 118
119 pref->inputStyle->setExclusive( TRUE ); 119 pref->inputStyle->setExclusive( TRUE );
120 120
121 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; 121 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
122 pref->inputStyle->setButton( style ); 122 pref->inputStyle->setButton( style );
123 connect( pref->inputStyle, SIGNAL(clicked(int)), 123 connect( pref->inputStyle, SIGNAL(clicked(int)),
124 this, SLOT(styleClicked(int)) ); 124 this, SLOT(styleClicked(int)) );
125 pref->inputStyle->setEnabled( profile->canSelectStyle() ); 125 pref->inputStyle->setEnabled( profile->canSelectStyle() );
126 126
127 multiTimeout = profile->multiStrokeTimeout(); 127 multiTimeout = profile->multiStrokeTimeout();
128 pref->multiStrokeSlider->setValue( multiTimeout ); 128 pref->multiStrokeSlider->setValue( multiTimeout );
129 multiTimeoutChanged( multiTimeout ); 129 multiTimeoutChanged( multiTimeout );
130 connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)), 130 connect( pref->multiStrokeSlider, SIGNAL(valueChanged(int)),
131 this, SLOT(multiTimeoutChanged(int)) ); 131 this, SLOT(multiTimeoutChanged(int)) );
132 132
133 edit = new QIMPenEdit( p, tw ); 133 edit = new QIMPenEdit( p, tw );
134 tw->addTab( edit, tr("Customize") ); 134 tw->addTab( edit, tr("Customize") );
135#ifdef MULTIPROFILE 135#ifdef MULTIPROFILE
136 loadProfiles(); 136 loadProfiles();
137#endif 137#endif
138 138
139} 139}
140 140
141void QIMPenSetup::loadProfiles() 141void QIMPenSetup::loadProfiles()
142{ 142{
143 QString path = QPEApplication::qpeDir() + "etc/qimpen"; 143 QString path = QPEApplication::qpeDir() + "etc/qimpen";
144 QDir dir( path, "*.conf" ); 144 QDir dir( path, "*.conf" );
145 QStringList list = dir.entryList(); 145 QStringList list = dir.entryList();
146 QStringList::Iterator it; 146 QStringList::Iterator it;
147 for ( it = list.begin(); it != list.end(); ++it ) { 147 for ( it = list.begin(); it != list.end(); ++it ) {
148 QIMPenProfile *p = new QIMPenProfile( path + "/" + *it ); 148 QIMPenProfile *p = new QIMPenProfile( path + "/" + *it );
149 profileList.append( p ); 149 profileList.append( p );
150 profileCombo->insertItem( p->name() ); 150 profileCombo->insertItem( p->name() );
151 if ( p->name() == profile->name() ) { 151 if ( p->name() == profile->name() ) {
152 profileCombo->setCurrentItem( profileCombo->count()-1 ); 152 profileCombo->setCurrentItem( profileCombo->count()-1 );
153 profile = p; 153 profile = p;
154 edit->setProfile( profile ); 154 edit->setProfile( profile );
155 } 155 }
156 } 156 }
157} 157}
158 158
159void QIMPenSetup::styleClicked( int id ) 159void QIMPenSetup::styleClicked( int id )
160{ 160{
161 style = id; 161 style = id;
162} 162}
163 163
164void QIMPenSetup::multiTimeoutChanged( int v ) 164void QIMPenSetup::multiTimeoutChanged( int v )
165{ 165{
166 multiTimeout = v; 166 multiTimeout = v;
167 pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) ); 167 pref->multiStrokeLabel->setText( tr("%1 ms").arg(v) );
168} 168}
169 169
170void QIMPenSetup::selectProfile( const QString &p ) 170void QIMPenSetup::selectProfile( const QString &p )
171{ 171{
172 if ( p == profile->name() ) 172 if ( p == profile->name() )
173 return; 173 return;
174 174
175 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); 175 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases );
176 profile->setMultiStrokeTimeout( multiTimeout ); 176 profile->setMultiStrokeTimeout( multiTimeout );
177 177
178 for ( int i = 0; i < (int)profileList.count(); i++ ) { 178 for ( int i = 0; i < (int)profileList.count(); i++ ) {
179 if ( profileList.at(i)->name() == p ) { 179 if ( profileList.at(i)->name() == p ) {
180 profile = profileList.at(i); 180 profile = profileList.at(i);
181 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0; 181 style = profile->style() == QIMPenProfile::ToggleCases ? 1 : 0;
182 pref->inputStyle->setButton( style ); 182 pref->inputStyle->setButton( style );
183 pref->inputStyle->setEnabled( profile->canSelectStyle() ); 183 pref->inputStyle->setEnabled( profile->canSelectStyle() );
184 multiTimeout = profile->multiStrokeTimeout(); 184 multiTimeout = profile->multiStrokeTimeout();
185 pref->multiStrokeSlider->setValue( multiTimeout ); 185 pref->multiStrokeSlider->setValue( multiTimeout );
186 multiTimeoutChanged( multiTimeout ); 186 multiTimeoutChanged( multiTimeout );
187 edit->setProfile( profile ); 187 edit->setProfile( profile );
188 break; 188 break;
189 } 189 }
190 } 190 }
191} 191}
192 192
193void QIMPenSetup::accept() 193void QIMPenSetup::accept()
194{ 194{
195 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases ); 195 profile->setStyle( style ? QIMPenProfile::ToggleCases : QIMPenProfile::BothCases );
196 profile->setMultiStrokeTimeout( multiTimeout ); 196 profile->setMultiStrokeTimeout( multiTimeout );
197 // Save current profile 197 // Save current profile
198 if ( profileCombo ) { 198 if ( profileCombo ) {
199 Config config( "handwriting" ); 199 Config config( "handwriting" );
200 config.setGroup( "Settings" ); 200 config.setGroup( "Settings" );
201 config.writeEntry( "Profile", profileCombo->currentText() ); 201 config.writeEntry( "Profile", profileCombo->currentText() );
202 } 202 }
203 // Save charsets 203 // Save charsets
204 bool ok = TRUE; 204 bool ok = TRUE;
205 for ( int i = 0; i < (int)profileList.count(); i++ ) { 205 for ( int i = 0; i < (int)profileList.count(); i++ ) {
206 QIMPenProfile *prof = profileList.at(i); 206 QIMPenProfile *prof = profileList.at(i);
207 QIMPenCharSetIterator it(prof->charSets()); 207 QIMPenCharSetIterator it(prof->charSets());
208 for ( ; it.current(); ++it ) { 208 for ( ; it.current(); ++it ) {
209 if ( !(it.current()->save( QIMPenCharSet::User )) ) { 209 if ( !(it.current()->save( QIMPenCharSet::User )) ) {
210 ok = FALSE; 210 ok = FALSE;
211 break; 211 break;
212 } 212 }
213 } 213 }
214 } 214 }
215 if ( !ok ) { 215 if ( !ok ) {
216 if ( QMessageBox::critical( 0, tr( "Out of space" ), 216 if ( QMessageBox::critical( 0, tr( "Out of space" ),
217 tr("Unable to save information.\n" 217 tr("Unable to save information.\n"
218 "Free up some space\n" 218 "Free up some space\n"
219 "and try again.\n" 219 "and try again.\n"
220 "\nQuit anyway?"), 220 "\nQuit anyway?"),
221 QMessageBox::Yes|QMessageBox::Escape, 221 QMessageBox::Yes|QMessageBox::Escape,
222 QMessageBox::No|QMessageBox::Default ) 222 QMessageBox::No|QMessageBox::Default )
223 != QMessageBox::No ) { 223 != QMessageBox::No ) {
224 QDialog::accept(); 224 QDialog::accept();
225 } 225 }
226 } else { 226 } else {
227 QDialog::accept(); 227 QDialog::accept();
228 } 228 }
229} 229}
230 230
231//--------------------------------------------------------------------------- 231//---------------------------------------------------------------------------
232 232
233QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name, 233QIMPenInputCharDlg::QIMPenInputCharDlg( QWidget *parent, const char *name,
234 bool modal, int WFlags) 234 bool modal, int WFlags)
235 : QDialog( parent, name, modal, WFlags ) 235 : QDialog( parent, name, modal, WFlags )
236{ 236{
237 setCaption( tr("Enter new character") ); 237 setCaption( tr("Enter new character") );
238 uni = 0; 238 uni = 0;
239 239
240 QVBoxLayout *vb = new QVBoxLayout( this, 10 ); 240 QVBoxLayout *vb = new QVBoxLayout( this, 10 );
241 241
242 QHBoxLayout *hb = new QHBoxLayout(); 242 QHBoxLayout *hb = new QHBoxLayout();
243 vb->addLayout( hb ); 243 vb->addLayout( hb );
244 244
245 QLabel *label = new QLabel( tr("Character:"), this ); 245 QLabel *label = new QLabel( tr("Character:"), this );
246 hb->addWidget( label ); 246 hb->addWidget( label );
247 247
248 QComboBox *cb = new QComboBox( TRUE, this ); 248 QComboBox *cb = new QComboBox( TRUE, this );
249 connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) ); 249 connect( cb, SIGNAL(activated(int)), SLOT(setSpecial(int)) );
250 connect( cb, SIGNAL(textChanged(const QString &)), 250 connect( cb, SIGNAL(textChanged(const QString&)),
251 SLOT(setCharacter(const QString &)) ); 251 SLOT(setCharacter(const QString&)) );
252 addSpecial( cb ); 252 addSpecial( cb );
253 cb->setEditText( "" ); 253 cb->setEditText( "" );
254 hb->addWidget( cb ); 254 hb->addWidget( cb );
255 255
256 hb = new QHBoxLayout(); 256 hb = new QHBoxLayout();
257 vb->addLayout( hb ); 257 vb->addLayout( hb );
258 258
259 QPushButton *pb = new QPushButton( "OK", this ); 259 QPushButton *pb = new QPushButton( "OK", this );
260 connect( pb, SIGNAL(clicked()), SLOT(accept())); 260 connect( pb, SIGNAL(clicked()), SLOT(accept()));
261 hb->addWidget( pb ); 261 hb->addWidget( pb );
262 pb = new QPushButton( "Cancel", this ); 262 pb = new QPushButton( "Cancel", this );
263 connect( pb, SIGNAL(clicked()), SLOT(reject())); 263 connect( pb, SIGNAL(clicked()), SLOT(reject()));
264 hb->addWidget( pb ); 264 hb->addWidget( pb );
265 265
266 cb->setFocus(); 266 cb->setFocus();
267} 267}
268 268
269void QIMPenInputCharDlg::addSpecial( QComboBox *cb ) 269void QIMPenInputCharDlg::addSpecial( QComboBox *cb )
270{ 270{
271 int i = 0; 271 int i = 0;
272 while ( qimpen_specialKeys[i].code != Key_unknown ) { 272 while ( qimpen_specialKeys[i].code != Key_unknown ) {
273 cb->insertItem( qimpen_specialKeys[i].name ); 273 cb->insertItem( qimpen_specialKeys[i].name );
274 i++; 274 i++;
275 } 275 }
276} 276}
277 277
278void QIMPenInputCharDlg::setSpecial( int sp ) 278void QIMPenInputCharDlg::setSpecial( int sp )
279{ 279{
280 uni = qimpen_specialKeys[sp].code << 16; 280 uni = qimpen_specialKeys[sp].code << 16;
281} 281}
282 282
283void QIMPenInputCharDlg::setCharacter( const QString &string ) 283void QIMPenInputCharDlg::setCharacter( const QString &string )
284{ 284{
285 uni = string[0].unicode(); 285 uni = string[0].unicode();
286} 286}
287 287
288//--------------------------------------------------------------------------- 288//---------------------------------------------------------------------------
289 289
290class CharListItem : public QListBoxText 290class CharListItem : public QListBoxText
291{ 291{
292public: 292public:
293 CharListItem( const QString &text, uint c ) 293 CharListItem( const QString &text, uint c )
294 : QListBoxText( text ) 294 : QListBoxText( text )
295 { 295 {
296 _code = c; 296 _code = c;
297 } 297 }
298 298
299 uint code() const { return _code; } 299 uint code() const { return _code; }
300 300
301protected: 301protected:
302 uint _code; 302 uint _code;
303}; 303};
304 304
305/*! 305/*!
306 \class QIMPenEdit qimpensetup.h 306 \class QIMPenEdit qimpensetup.h
307 307
308 Class to allow users to input totally useless character definitions 308 Class to allow users to input totally useless character definitions
309 which could match any number of the default set. 309 which could match any number of the default set.
310*/ 310*/
311 311
312QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent, 312QIMPenEdit::QIMPenEdit( QIMPenProfile *p, QWidget *parent,
313 const char *name ) 313 const char *name )
314 : QWidget( parent, name ), profile(p) 314 : QWidget( parent, name ), profile(p)
315{ 315{
316 currentChar = 0; 316 currentChar = 0;
317 currentCode = 0; 317 currentCode = 0;
318 inputChar = new QIMPenChar(); 318 inputChar = new QIMPenChar();
319 319
320 QVBoxLayout *tvb = new QVBoxLayout( this, 5 ); 320 QVBoxLayout *tvb = new QVBoxLayout( this, 5 );
321 321
322 QGridLayout *gl = new QGridLayout( tvb, 4, 2 ); 322 QGridLayout *gl = new QGridLayout( tvb, 4, 2 );
323 gl->setRowStretch( 1, 1 ); 323 gl->setRowStretch( 1, 1 );
324 gl->addRowSpacing( 2, 35 ); 324 gl->addRowSpacing( 2, 35 );
325 gl->addRowSpacing( 3, 35 ); 325 gl->addRowSpacing( 3, 35 );
326 326
327 charSetCombo = new QComboBox( this ); 327 charSetCombo = new QComboBox( this );
328 gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 ); 328 gl->addMultiCellWidget( charSetCombo, 0, 0, 0, 1 );
329 connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int))); 329 connect( charSetCombo, SIGNAL(activated(int)), SLOT(selectCharSet(int)));
330 QIMPenCharSetIterator it( profile->charSets() ); 330 QIMPenCharSetIterator it( profile->charSets() );
331 for ( ; it.current(); ++it ) { 331 for ( ; it.current(); ++it ) {
332 charSetCombo->insertItem( it.current()->description() ); 332 charSetCombo->insertItem( it.current()->description() );
333 } 333 }
334 334
335 charList = new QListBox( this ); 335 charList = new QListBox( this );
336 charList->setMinimumHeight( charList->sizeHint().height() ); 336 charList->setMinimumHeight( charList->sizeHint().height() );
337 connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) ); 337 connect( charList, SIGNAL(highlighted(int)), SLOT(selectChar(int)) );
338 gl->addWidget( charList, 1, 0 ); 338 gl->addWidget( charList, 1, 0 );
339 339
340 pw = new QIMPenWidget( this ); 340 pw = new QIMPenWidget( this );
341 pw->setFixedHeight( 75 ); 341 pw->setFixedHeight( 75 );
342 gl->addMultiCellWidget( pw, 2, 3, 0, 0 ); 342 gl->addMultiCellWidget( pw, 2, 3, 0, 0 );
343 connect( pw, SIGNAL(stroke(QIMPenStroke *)), 343 connect( pw, SIGNAL(stroke(QIMPenStroke*)),
344 SLOT(newStroke(QIMPenStroke *)) ); 344 SLOT(newStroke(QIMPenStroke*)) );
345 345
346 QVBoxLayout *vb = new QVBoxLayout(); 346 QVBoxLayout *vb = new QVBoxLayout();
347 gl->addLayout( vb, 1, 1 ); 347 gl->addLayout( vb, 1, 1 );
348 newBtn = new QPushButton( tr("New..."), this ); 348 newBtn = new QPushButton( tr("New..."), this );
349 connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) ); 349 connect( newBtn, SIGNAL(clicked()), SLOT(addNewChar()) );
350 vb->addWidget( newBtn ); 350 vb->addWidget( newBtn );
351 351
352 addBtn = new QPushButton( tr("Add"), this ); 352 addBtn = new QPushButton( tr("Add"), this );
353 connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) ); 353 connect( addBtn, SIGNAL(clicked()), SLOT(addChar()) );
354 vb->addWidget( addBtn ); 354 vb->addWidget( addBtn );
355 355
356 removeBtn = new QPushButton( tr("Remove"), this ); 356 removeBtn = new QPushButton( tr("Remove"), this );
357 connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) ); 357 connect( removeBtn, SIGNAL(clicked()), SLOT(removeChar()) );
358 vb->addWidget( removeBtn ); 358 vb->addWidget( removeBtn );
359 359
360 QPushButton *pb = new QPushButton( tr("Default"), this ); 360 QPushButton *pb = new QPushButton( tr("Default"), this );
361 connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) ); 361 connect( pb, SIGNAL(clicked()), SLOT(defaultChars()) );
362 vb->addWidget( pb ); 362 vb->addWidget( pb );
363 363
364 QHBoxLayout *hb = new QHBoxLayout(); 364 QHBoxLayout *hb = new QHBoxLayout();
365 gl->addLayout( hb, 2, 1 ); 365 gl->addLayout( hb, 2, 1 );
366 prevBtn = new QPushButton( this ); 366 prevBtn = new QPushButton( this );
367 prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) ); 367 prevBtn->setPixmap( QPixmap( (const char **)left_xpm ) );
368 connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar())); 368 connect( prevBtn, SIGNAL(clicked()), SLOT(prevChar()));
369 hb->addWidget( prevBtn ); 369 hb->addWidget( prevBtn );
370 370
371 nextBtn = new QPushButton( this ); 371 nextBtn = new QPushButton( this );
372 nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) ); 372 nextBtn->setPixmap( QPixmap( (const char **)right_xpm ) );
373 connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar())); 373 connect( nextBtn, SIGNAL(clicked()), SLOT(nextChar()));
374 hb->addWidget( nextBtn ); 374 hb->addWidget( nextBtn );
375 375
376 pb = new QPushButton( tr("Clear"), this ); 376 pb = new QPushButton( tr("Clear"), this );
377 connect( pb, SIGNAL(clicked()), SLOT(clearChar()) ); 377 connect( pb, SIGNAL(clicked()), SLOT(clearChar()) );
378 gl->addWidget( pb, 3, 1 ); 378 gl->addWidget( pb, 3, 1 );
379 379
380 //-- 380 //--
381#if !defined(Q_WS_QWS) 381#if !defined(Q_WS_QWS)
382 hb = new QHBoxLayout( tvb ); 382 hb = new QHBoxLayout( tvb );
383 pb = new QPushButton( tr("OK"), this ); 383 pb = new QPushButton( tr("OK"), this );
384 connect( pb, SIGNAL(clicked()), SLOT(accept()) ); 384 connect( pb, SIGNAL(clicked()), SLOT(accept()) );
385 hb->addWidget( pb ); 385 hb->addWidget( pb );
386 386
387 pb = new QPushButton( tr("Cancel"), this ); 387 pb = new QPushButton( tr("Cancel"), this );
388 connect( pb, SIGNAL(clicked()), SLOT(reject()) ); 388 connect( pb, SIGNAL(clicked()), SLOT(reject()) );
389 hb->addWidget( pb ); 389 hb->addWidget( pb );
390#endif 390#endif
391 selectCharSet( 0 ); 391 selectCharSet( 0 );
392 charList->setFocus(); 392 charList->setFocus();
393 393
394 resize( minimumSize() ); 394 resize( minimumSize() );
395 enableButtons(); 395 enableButtons();
396} 396}
397 397
398void QIMPenEdit::setProfile( QIMPenProfile *p ) 398void QIMPenEdit::setProfile( QIMPenProfile *p )
399{ 399{
400 profile = p; 400 profile = p;
401 charSetCombo->clear(); 401 charSetCombo->clear();
402 QIMPenCharSetIterator it( profile->charSets() ); 402 QIMPenCharSetIterator it( profile->charSets() );
403 for ( ; it.current(); ++it ) { 403 for ( ; it.current(); ++it ) {
404 if ( ! it.current()->hidden() ) 404 if ( ! it.current()->hidden() )
405 charSetCombo->insertItem( it.current()->description() ); 405 charSetCombo->insertItem( it.current()->description() );
406 } 406 }
407 selectCharSet( 0 ); 407 selectCharSet( 0 );
408 charList->setFocus(); 408 charList->setFocus();
409 enableButtons(); 409 enableButtons();
410} 410}
411 411
412void QIMPenEdit::selectCharSet( QIMPenCharSet *c ) 412void QIMPenEdit::selectCharSet( QIMPenCharSet *c )
413{ 413{
414 int i = 0; 414 int i = 0;
415 QIMPenCharSetIterator it( profile->charSets() ); 415 QIMPenCharSetIterator it( profile->charSets() );
416 for ( ; it.current(); ++it, i++ ) { 416 for ( ; it.current(); ++it, i++ ) {
417 if ( it.current() == c ) { 417 if ( it.current() == c ) {
418 charSetCombo->setCurrentItem( i ); 418 charSetCombo->setCurrentItem( i );
419 selectCharSet( i ); 419 selectCharSet( i );
420 } 420 }
421 } 421 }
422} 422}
423 423
424 424
425/*! 425/*!
426 Fill the character list box with the characters. Duplicates are not 426 Fill the character list box with the characters. Duplicates are not
427 inserted. 427 inserted.
428*/ 428*/
429void QIMPenEdit::fillCharList() 429void QIMPenEdit::fillCharList()
430{ 430{
431 charList->clear(); 431 charList->clear();
432 QIMPenCharIterator it( currentSet->characters() ); 432 QIMPenCharIterator it( currentSet->characters() );
433 CharListItem *li = 0; 433 CharListItem *li = 0;
434 for ( ; it.current(); ++it ) { 434 for ( ; it.current(); ++it ) {
435 uint ch = it.current()->character(); 435 uint ch = it.current()->character();
436 QString n = it.current()->name(); 436 QString n = it.current()->name();
437 if ( !n.isEmpty() ) 437 if ( !n.isEmpty() )
438 li = new CharListItem( n, ch ); 438 li = new CharListItem( n, ch );
439 if ( li ) { 439 if ( li ) {
440 CharListItem *i = (CharListItem *)charList->findItem( li->text() ); 440 CharListItem *i = (CharListItem *)charList->findItem( li->text() );
441 if ( !i || i->code() != ch ) { 441 if ( !i || i->code() != ch ) {
442 charList->insertItem( li ); 442 charList->insertItem( li );
443 } else { 443 } else {
444 delete li; 444 delete li;
445 li = 0; 445 li = 0;
446 } 446 }
447 } 447 }
448 } 448 }
449 currentChar = 0; 449 currentChar = 0;
450} 450}
451 451
452void QIMPenEdit::enableButtons() 452void QIMPenEdit::enableButtons()
453{ 453{
454 bool add = !inputChar->isEmpty(); 454 bool add = !inputChar->isEmpty();
455 newBtn->setEnabled( add ); 455 newBtn->setEnabled( add );
456 addBtn->setEnabled( add ); 456 addBtn->setEnabled( add );
457 removeBtn->setEnabled( currentChar ); 457 removeBtn->setEnabled( currentChar );
458} 458}
459 459
460/*! 460/*!
461 Find the previous character with the same code as the current one. 461 Find the previous character with the same code as the current one.
462 returns 0 if there is no previous character. 462 returns 0 if there is no previous character.
463*/ 463*/
464QIMPenChar *QIMPenEdit::findPrev() 464QIMPenChar *QIMPenEdit::findPrev()
465{ 465{
466 if ( !currentChar ) 466 if ( !currentChar )
467 return 0; 467 return 0;
468 QIMPenCharIterator it( currentSet->characters() ); 468 QIMPenCharIterator it( currentSet->characters() );
469 bool found = FALSE; 469 bool found = FALSE;
470 for ( it.toLast(); it.current(); --it ) { 470 for ( it.toLast(); it.current(); --it ) {
471 if ( !found && it.current() == currentChar ) 471 if ( !found && it.current() == currentChar )
472 found = TRUE; 472 found = TRUE;
473 else if ( found && it.current()->character() == currentCode && 473 else if ( found && it.current()->character() == currentCode &&
474 !it.current()->testFlag( QIMPenChar::Deleted ) ) { 474 !it.current()->testFlag( QIMPenChar::Deleted ) ) {
475 return it.current(); 475 return it.current();
476 } 476 }
477 } 477 }
478 478
479 return 0; 479 return 0;
480} 480}
481 481
482/*! 482/*!
483 Find the next character with the same code as the current one. 483 Find the next character with the same code as the current one.
484 returns 0 if there is no next character. 484 returns 0 if there is no next character.
485*/ 485*/
486QIMPenChar *QIMPenEdit::findNext() 486QIMPenChar *QIMPenEdit::findNext()
487{ 487{
488 if ( !currentChar ) 488 if ( !currentChar )
489 return 0; 489 return 0;
490 QIMPenCharIterator it( currentSet->characters() ); 490 QIMPenCharIterator it( currentSet->characters() );
491 bool found = FALSE; 491 bool found = FALSE;
492 for ( ; it.current(); ++it ) { 492 for ( ; it.current(); ++it ) {
493 if ( !found && it.current() == currentChar ) 493 if ( !found && it.current() == currentChar )
494 found = TRUE; 494 found = TRUE;
495 else if ( found && it.current()->character() == currentCode && 495 else if ( found && it.current()->character() == currentCode &&
496 !it.current()->testFlag( QIMPenChar::Deleted ) ) { 496 !it.current()->testFlag( QIMPenChar::Deleted ) ) {
497 return it.current(); 497 return it.current();
498 } 498 }
499 } 499 }
500 500
501 return 0; 501 return 0;
502} 502}
503 503
504void QIMPenEdit::setCurrentChar( QIMPenChar *pc ) 504void QIMPenEdit::setCurrentChar( QIMPenChar *pc )
505{ 505{
506 currentChar = pc; 506 currentChar = pc;
507 pw->showCharacter( currentChar ); 507 pw->showCharacter( currentChar );
508 if ( currentChar ) { 508 if ( currentChar ) {
509 prevBtn->setEnabled( findPrev() != 0 ); 509 prevBtn->setEnabled( findPrev() != 0 );
510 nextBtn->setEnabled( findNext() != 0 ); 510 nextBtn->setEnabled( findNext() != 0 );
511 } 511 }
512} 512}
513 513
514void QIMPenEdit::prevChar() 514void QIMPenEdit::prevChar()
515{ 515{
516 QIMPenChar *pc = findPrev(); 516 QIMPenChar *pc = findPrev();
517 if ( pc ) 517 if ( pc )
518 setCurrentChar( pc ); 518 setCurrentChar( pc );
519} 519}
520 520
521void QIMPenEdit::nextChar() 521void QIMPenEdit::nextChar()
522{ 522{
523 QIMPenChar *pc = findNext(); 523 QIMPenChar *pc = findNext();
524 if ( pc ) 524 if ( pc )
525 setCurrentChar( pc ); 525 setCurrentChar( pc );
526} 526}
527 527
528void QIMPenEdit::clearChar() 528void QIMPenEdit::clearChar()
529{ 529{
530 inputChar->clear(); 530 inputChar->clear();
531 pw->clear(); 531 pw->clear();
532 enableButtons(); 532 enableButtons();
533} 533}
534 534
535void QIMPenEdit::selectChar( int i ) 535void QIMPenEdit::selectChar( int i )
536{ 536{