Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index d3f5fb4..f56d5d3 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -215,48 +215,49 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive, | |||
215 | } | 215 | } |
216 | 216 | ||
217 | } | 217 | } |
218 | 218 | ||
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | #else | 222 | #else |
223 | 223 | ||
224 | #error "Must make a QpeEditor that inherits QTextEdit" | 224 | #error "Must make a QpeEditor that inherits QTextEdit" |
225 | 225 | ||
226 | #endif | 226 | #endif |
227 | 227 | ||
228 | 228 | ||
229 | static const int nfontsizes = 6; | 229 | static const int nfontsizes = 6; |
230 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 230 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
231 | 231 | ||
232 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 232 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
233 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 233 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
234 | { | 234 | { |
235 | doc = 0; | 235 | doc = 0; |
236 | edited=FALSE; | 236 | edited=FALSE; |
237 | edited1=FALSE; | 237 | edited1=FALSE; |
238 | setToolBarsMovable( FALSE ); | 238 | setToolBarsMovable( FALSE ); |
239 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | ||
239 | 240 | ||
240 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 241 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
241 | 242 | ||
242 | QPEToolBar *bar = new QPEToolBar( this ); | 243 | QPEToolBar *bar = new QPEToolBar( this ); |
243 | bar->setHorizontalStretchable( TRUE ); | 244 | bar->setHorizontalStretchable( TRUE ); |
244 | menu = bar; | 245 | menu = bar; |
245 | 246 | ||
246 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 247 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
247 | QPopupMenu *file = new QPopupMenu( this ); | 248 | QPopupMenu *file = new QPopupMenu( this ); |
248 | QPopupMenu *edit = new QPopupMenu( this ); | 249 | QPopupMenu *edit = new QPopupMenu( this ); |
249 | font = new QPopupMenu( this ); | 250 | font = new QPopupMenu( this ); |
250 | 251 | ||
251 | bar = new QPEToolBar( this ); | 252 | bar = new QPEToolBar( this ); |
252 | editBar = bar; | 253 | editBar = bar; |
253 | 254 | ||
254 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 255 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
255 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 256 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
256 | a->addTo( bar ); | 257 | a->addTo( bar ); |
257 | a->addTo( file ); | 258 | a->addTo( file ); |
258 | 259 | ||
259 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 260 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
260 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 261 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
261 | a->addTo( bar ); | 262 | a->addTo( bar ); |
262 | a->addTo( file ); | 263 | a->addTo( file ); |
@@ -386,60 +387,64 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
386 | QFontInfo fontInfo(defaultFont); | 387 | QFontInfo fontInfo(defaultFont); |
387 | 388 | ||
388 | cfg.setGroup("Font"); | 389 | cfg.setGroup("Font"); |
389 | QString family = cfg.readEntry("Family", fontInfo.family()); | 390 | QString family = cfg.readEntry("Family", fontInfo.family()); |
390 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 391 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
391 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 392 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
392 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 393 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
393 | 394 | ||
394 | defaultFont = fdb.font(family,style,i_size,charSet); | 395 | defaultFont = fdb.font(family,style,i_size,charSet); |
395 | editor->setFont( defaultFont); | 396 | editor->setFont( defaultFont); |
396 | 397 | ||
397 | wa->setOn(wrap); | 398 | wa->setOn(wrap); |
398 | updateCaption(); | 399 | updateCaption(); |
399 | 400 | ||
400 | cfg.setGroup("View"); | 401 | cfg.setGroup("View"); |
401 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 402 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
402 | nStart->setOn(TRUE); | 403 | nStart->setOn(TRUE); |
403 | fileNew(); | 404 | fileNew(); |
404 | } else { | 405 | } else { |
405 | fileOpen(); | 406 | fileOpen(); |
406 | } | 407 | } |
407 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 408 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
408 | } | 409 | } |
409 | 410 | ||
410 | TextEdit::~TextEdit() | 411 | void TextEdit::cleanUp() |
411 | { | 412 | { |
412 | // save(); | 413 | // save(); |
413 | |||
414 | Config cfg("TextEdit"); | 414 | Config cfg("TextEdit"); |
415 | cfg.setGroup("View"); | 415 | cfg.setGroup("View"); |
416 | QFont f = editor->font(); | 416 | QFont f = editor->font(); |
417 | cfg.writeEntry("FontSize",f.pointSize()); | 417 | cfg.writeEntry("FontSize",f.pointSize()); |
418 | cfg.writeEntry("Bold",f.bold()); | 418 | cfg.writeEntry("Bold",f.bold()); |
419 | cfg.writeEntry("Italic",f.italic()); | 419 | cfg.writeEntry("Italic",f.italic()); |
420 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 420 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
421 | cfg.writeEntry( "FileView", viewSelection ); | 421 | cfg.writeEntry( "FileView", viewSelection ); |
422 | |||
423 | } | ||
424 | |||
425 | TextEdit::~TextEdit() | ||
426 | { | ||
422 | } | 427 | } |
423 | 428 | ||
424 | void TextEdit::zoomIn() | 429 | void TextEdit::zoomIn() |
425 | { | 430 | { |
426 | setFontSize(editor->font().pointSize()+1,FALSE); | 431 | setFontSize(editor->font().pointSize()+1,FALSE); |
427 | } | 432 | } |
428 | 433 | ||
429 | void TextEdit::zoomOut() | 434 | void TextEdit::zoomOut() |
430 | { | 435 | { |
431 | setFontSize(editor->font().pointSize()-1,TRUE); | 436 | setFontSize(editor->font().pointSize()-1,TRUE); |
432 | } | 437 | } |
433 | 438 | ||
434 | 439 | ||
435 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 440 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
436 | { | 441 | { |
437 | int s=10; | 442 | int s=10; |
438 | for (int i=0; i<nfontsizes; i++) { | 443 | for (int i=0; i<nfontsizes; i++) { |
439 | if ( fontsize[i] == sz ) { | 444 | if ( fontsize[i] == sz ) { |
440 | s = sz; | 445 | s = sz; |
441 | break; | 446 | break; |
442 | } else if ( round_down_not_up ) { | 447 | } else if ( round_down_not_up ) { |
443 | if ( fontsize[i] < sz ) | 448 | if ( fontsize[i] < sz ) |
444 | s = fontsize[i]; | 449 | s = fontsize[i]; |
445 | } else { | 450 | } else { |