-rw-r--r-- | core/apps/textedit/textedit.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f3937b1..35f9d3c 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -302,192 +302,193 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
302 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 302 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
303 | a->addTo( editBar ); | 303 | a->addTo( editBar ); |
304 | a->addTo( edit ); | 304 | a->addTo( edit ); |
305 | 305 | ||
306 | 306 | ||
307 | #ifndef QT_NO_CLIPBOARD | 307 | #ifndef QT_NO_CLIPBOARD |
308 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 308 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
309 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 309 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
310 | a->addTo( edit ); | 310 | a->addTo( edit ); |
311 | #endif | 311 | #endif |
312 | 312 | ||
313 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 313 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
314 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 314 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
315 | edit->insertSeparator(); | 315 | edit->insertSeparator(); |
316 | a->addTo( bar ); | 316 | a->addTo( bar ); |
317 | a->addTo( edit ); | 317 | a->addTo( edit ); |
318 | 318 | ||
319 | 319 | ||
320 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 320 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
321 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 321 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
322 | zin->addTo( font ); | 322 | zin->addTo( font ); |
323 | 323 | ||
324 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 324 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
325 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 325 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
326 | zout->addTo( font ); | 326 | zout->addTo( font ); |
327 | 327 | ||
328 | font->insertSeparator(); | 328 | font->insertSeparator(); |
329 | // font->insertSeparator(); | 329 | // font->insertSeparator(); |
330 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 330 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
331 | 331 | ||
332 | font->insertSeparator(); | 332 | font->insertSeparator(); |
333 | font->insertItem(tr("Advanced Features"), advancedMenu); | 333 | font->insertItem(tr("Advanced Features"), advancedMenu); |
334 | 334 | ||
335 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 335 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
336 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 336 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
337 | wa->setToggleAction(TRUE); | 337 | wa->setToggleAction(TRUE); |
338 | wa->addTo( advancedMenu); | 338 | wa->addTo( advancedMenu); |
339 | 339 | ||
340 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 340 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
341 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 341 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
342 | nStart->setToggleAction(TRUE); | 342 | nStart->setToggleAction(TRUE); |
343 | nStart->addTo( advancedMenu ); | 343 | nStart->addTo( advancedMenu ); |
344 | 344 | ||
345 | nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); | 345 | nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); |
346 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); | 346 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); |
347 | nAdvanced->setToggleAction(TRUE); | 347 | nAdvanced->setToggleAction(TRUE); |
348 | nAdvanced->addTo( advancedMenu ); | 348 | nAdvanced->addTo( advancedMenu ); |
349 | 349 | ||
350 | desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); | 350 | desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); |
351 | connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); | 351 | connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); |
352 | desktopAction->setToggleAction(TRUE); | 352 | desktopAction->setToggleAction(TRUE); |
353 | desktopAction->addTo( advancedMenu); | 353 | desktopAction->addTo( advancedMenu); |
354 | 354 | ||
355 | filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); | 355 | filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); |
356 | connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); | 356 | connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); |
357 | filePermAction->setToggleAction(TRUE); | 357 | filePermAction->setToggleAction(TRUE); |
358 | filePermAction->addTo( advancedMenu); | 358 | filePermAction->addTo( advancedMenu); |
359 | 359 | ||
360 | font->insertSeparator(); | 360 | font->insertSeparator(); |
361 | 361 | ||
362 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 362 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
363 | 363 | ||
364 | mb->insertItem( tr( "File" ), file ); | 364 | mb->insertItem( tr( "File" ), file ); |
365 | mb->insertItem( tr( "Edit" ), edit ); | 365 | mb->insertItem( tr( "Edit" ), edit ); |
366 | mb->insertItem( tr( "View" ), font ); | 366 | mb->insertItem( tr( "View" ), font ); |
367 | 367 | ||
368 | searchBar = new QPEToolBar(this); | 368 | searchBar = new QPEToolBar(this); |
369 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 369 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
370 | 370 | ||
371 | searchBar->setHorizontalStretchable( TRUE ); | 371 | searchBar->setHorizontalStretchable( TRUE ); |
372 | 372 | ||
373 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 373 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
374 | searchBar->setStretchableWidget( searchEdit ); | 374 | searchBar->setStretchableWidget( searchEdit ); |
375 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 375 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
376 | this, SLOT( search() ) ); | 376 | this, SLOT( search() ) ); |
377 | 377 | ||
378 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 378 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
379 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 379 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
380 | a->addTo( searchBar ); | 380 | a->addTo( searchBar ); |
381 | a->addTo( edit ); | 381 | a->addTo( edit ); |
382 | 382 | ||
383 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 383 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
384 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 384 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
385 | a->addTo( searchBar ); | 385 | a->addTo( searchBar ); |
386 | 386 | ||
387 | edit->insertSeparator(); | 387 | edit->insertSeparator(); |
388 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 388 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
389 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 389 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
390 | a->addTo( edit ); | 390 | a->addTo( edit ); |
391 | 391 | ||
392 | searchBar->hide(); | 392 | searchBar->hide(); |
393 | 393 | ||
394 | editor = new QpeEditor( this ); | 394 | editor = new QpeEditor( this ); |
395 | setCentralWidget( editor ); | 395 | setCentralWidget( editor ); |
396 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 396 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
397 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 397 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
398 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | ||
398 | 399 | ||
399 | Config cfg("TextEdit"); | 400 | Config cfg("TextEdit"); |
400 | cfg. setGroup ( "Font" ); | 401 | cfg. setGroup ( "Font" ); |
401 | 402 | ||
402 | QFont defaultFont = editor-> font ( ); | 403 | QFont defaultFont = editor-> font ( ); |
403 | 404 | ||
404 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 405 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
405 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 406 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
406 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 407 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
407 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 408 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
408 | 409 | ||
409 | defaultFont = QFont ( family, size, weight, italic ); | 410 | defaultFont = QFont ( family, size, weight, italic ); |
410 | editor-> setFont ( defaultFont ); | 411 | editor-> setFont ( defaultFont ); |
411 | 412 | ||
412 | updateCaption(); | 413 | updateCaption(); |
413 | 414 | ||
414 | cfg.setGroup ( "View" ); | 415 | cfg.setGroup ( "View" ); |
415 | 416 | ||
416 | promptExit = cfg. readBoolEntry ( "PromptExit", false ); | 417 | promptExit = cfg. readBoolEntry ( "PromptExit", false ); |
417 | openDesktop = cfg. readBoolEntry ( "OpenDesktop", true ); | 418 | openDesktop = cfg. readBoolEntry ( "OpenDesktop", true ); |
418 | filePerms = cfg. readBoolEntry ( "FilePermissions", false ); | 419 | filePerms = cfg. readBoolEntry ( "FilePermissions", false ); |
419 | 420 | ||
420 | if(promptExit ) nAdvanced->setOn ( true ); | 421 | if(promptExit ) nAdvanced->setOn ( true ); |
421 | if(openDesktop) desktopAction->setOn ( true ); | 422 | if(openDesktop) desktopAction->setOn ( true ); |
422 | if(filePerms) filePermAction->setOn ( true ); | 423 | if(filePerms) filePermAction->setOn ( true ); |
423 | 424 | ||
424 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 425 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
425 | wa-> setOn ( wrap ); | 426 | wa-> setOn ( wrap ); |
426 | setWordWrap ( wrap ); | 427 | setWordWrap ( wrap ); |
427 | 428 | ||
428 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 429 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
429 | nStart->setOn(TRUE); | 430 | nStart->setOn(TRUE); |
430 | fileNew(); | 431 | fileNew(); |
431 | } else { | 432 | } else { |
432 | fileOpen(); | 433 | fileOpen(); |
433 | } | 434 | } |
434 | 435 | ||
435 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 436 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
436 | } | 437 | } |
437 | 438 | ||
438 | TextEdit::~TextEdit() { | 439 | TextEdit::~TextEdit() { |
439 | if( edited1 & promptExit ) | 440 | if( edited1 & promptExit ) |
440 | saveAs(); | 441 | saveAs(); |
441 | } | 442 | } |
442 | 443 | ||
443 | void TextEdit::cleanUp() { | 444 | void TextEdit::cleanUp() { |
444 | qDebug("cleanUp");// save(); | 445 | qDebug("cleanUp");// save(); |
445 | 446 | ||
446 | Config cfg ( "TextEdit" ); | 447 | Config cfg ( "TextEdit" ); |
447 | cfg. setGroup ( "Font" ); | 448 | cfg. setGroup ( "Font" ); |
448 | QFont f = editor->font(); | 449 | QFont f = editor->font(); |
449 | cfg. writeEntry ( "Family", f. family ( )); | 450 | cfg. writeEntry ( "Family", f. family ( )); |
450 | cfg. writeEntry ( "Size", f. pointSize ( )); | 451 | cfg. writeEntry ( "Size", f. pointSize ( )); |
451 | cfg. writeEntry ( "Weight", f. weight ( )); | 452 | cfg. writeEntry ( "Weight", f. weight ( )); |
452 | cfg. writeEntry ( "Italic", f. italic ( )); | 453 | cfg. writeEntry ( "Italic", f. italic ( )); |
453 | 454 | ||
454 | cfg. setGroup ( "View" ); | 455 | cfg. setGroup ( "View" ); |
455 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); | 456 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); |
456 | cfg. writeEntry ( "FileView", viewSelection ); | 457 | cfg. writeEntry ( "FileView", viewSelection ); |
457 | 458 | ||
458 | cfg. writeEntry ( "PromptExit", promptExit ); | 459 | cfg. writeEntry ( "PromptExit", promptExit ); |
459 | cfg. writeEntry ( "OpenDesktop", openDesktop ); | 460 | cfg. writeEntry ( "OpenDesktop", openDesktop ); |
460 | cfg. writeEntry ( "FilePermissions", filePerms ); | 461 | cfg. writeEntry ( "FilePermissions", filePerms ); |
461 | } | 462 | } |
462 | 463 | ||
463 | 464 | ||
464 | void TextEdit::accept() { | 465 | void TextEdit::accept() { |
465 | if( edited1) | 466 | if( edited1) |
466 | saveAs(); | 467 | saveAs(); |
467 | exit(0); | 468 | exit(0); |
468 | } | 469 | } |
469 | 470 | ||
470 | void TextEdit::zoomIn() { | 471 | void TextEdit::zoomIn() { |
471 | setFontSize(editor->font().pointSize()+1,FALSE); | 472 | setFontSize(editor->font().pointSize()+1,FALSE); |
472 | } | 473 | } |
473 | 474 | ||
474 | void TextEdit::zoomOut() { | 475 | void TextEdit::zoomOut() { |
475 | setFontSize(editor->font().pointSize()-1,TRUE); | 476 | setFontSize(editor->font().pointSize()-1,TRUE); |
476 | } | 477 | } |
477 | 478 | ||
478 | 479 | ||
479 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 480 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
480 | int s=10; | 481 | int s=10; |
481 | for (int i=0; i<nfontsizes; i++) { | 482 | for (int i=0; i<nfontsizes; i++) { |
482 | if ( fontsize[i] == sz ) { | 483 | if ( fontsize[i] == sz ) { |
483 | s = sz; | 484 | s = sz; |
484 | break; | 485 | break; |
485 | } else if ( round_down_not_up ) { | 486 | } else if ( round_down_not_up ) { |
486 | if ( fontsize[i] < sz ) | 487 | if ( fontsize[i] < sz ) |
487 | s = fontsize[i]; | 488 | s = fontsize[i]; |
488 | } else { | 489 | } else { |
489 | if ( fontsize[i] > sz ) { | 490 | if ( fontsize[i] > sz ) { |
490 | s = fontsize[i]; | 491 | s = fontsize[i]; |
491 | break; | 492 | break; |
492 | } | 493 | } |
493 | } | 494 | } |