summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index ce868d6..2f62789 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -446,268 +446,274 @@ void TextEdit::closeEvent(QCloseEvent *) {
446 qApp->quit(); 446 qApp->quit();
447 } 447 }
448 break; 448 break;
449 449
450 case 2: 450 case 2:
451 { 451 {
452 qApp->quit(); 452 qApp->quit();
453 } 453 }
454 break; 454 break;
455 455
456 case -1: 456 case -1:
457 break; 457 break;
458 }; 458 };
459 } 459 }
460 else 460 else
461 qApp->quit(); 461 qApp->quit();
462 462
463} 463}
464 464
465void TextEdit::cleanUp() { 465void TextEdit::cleanUp() {
466 466
467 Config cfg ( "TextEdit" ); 467 Config cfg ( "TextEdit" );
468 cfg. setGroup ( "Font" ); 468 cfg. setGroup ( "Font" );
469 QFont f = editor->font(); 469 QFont f = editor->font();
470 cfg.writeEntry ( "Family", f. family ( )); 470 cfg.writeEntry ( "Family", f. family ( ));
471 cfg.writeEntry ( "Size", f. pointSize ( )); 471 cfg.writeEntry ( "Size", f. pointSize ( ));
472 cfg.writeEntry ( "Weight", f. weight ( )); 472 cfg.writeEntry ( "Weight", f. weight ( ));
473 cfg.writeEntry ( "Italic", f. italic ( )); 473 cfg.writeEntry ( "Italic", f. italic ( ));
474 474
475 cfg.setGroup ( "View" ); 475 cfg.setGroup ( "View" );
476 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); 476 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
477 cfg.writeEntry ( "FileView", viewSelection ); 477 cfg.writeEntry ( "FileView", viewSelection );
478 478
479 cfg.writeEntry ( "PromptExit", promptExit ); 479 cfg.writeEntry ( "PromptExit", promptExit );
480 cfg.writeEntry ( "OpenDesktop", openDesktop ); 480 cfg.writeEntry ( "OpenDesktop", openDesktop );
481 cfg.writeEntry ( "FilePermissions", filePerms ); 481 cfg.writeEntry ( "FilePermissions", filePerms );
482 cfg.writeEntry ( "SearchBar", useSearchBar ); 482 cfg.writeEntry ( "SearchBar", useSearchBar );
483 cfg.writeEntry ( "startNew", startWithNew ); 483 cfg.writeEntry ( "startNew", startWithNew );
484 484
485} 485}
486 486
487 487
488void TextEdit::accept() { 488void TextEdit::accept() {
489 if( edited1) 489 if( edited1)
490 saveAs(); 490 saveAs();
491 qApp->quit(); 491 qApp->quit();
492} 492}
493 493
494void TextEdit::zoomIn() { 494void TextEdit::zoomIn() {
495 setFontSize(editor->font().pointSize()+1,false); 495 setFontSize(editor->font().pointSize()+1,false);
496} 496}
497 497
498void TextEdit::zoomOut() { 498void TextEdit::zoomOut() {
499 setFontSize(editor->font().pointSize()-1,true); 499 setFontSize(editor->font().pointSize()-1,true);
500} 500}
501 501
502 502
503void TextEdit::setFontSize(int sz, bool round_down_not_up) { 503void TextEdit::setFontSize(int sz, bool round_down_not_up) {
504 int s=10; 504 int s=10;
505 for (int i=0; i<nfontsizes; i++) { 505 for (int i=0; i<nfontsizes; i++) {
506 if ( fontsize[i] == sz ) { 506 if ( fontsize[i] == sz ) {
507 s = sz; 507 s = sz;
508 break; 508 break;
509 } else if ( round_down_not_up ) { 509 } else if ( round_down_not_up ) {
510 if ( fontsize[i] < sz ) 510 if ( fontsize[i] < sz )
511 s = fontsize[i]; 511 s = fontsize[i];
512 } else { 512 } else {
513 if ( fontsize[i] > sz ) { 513 if ( fontsize[i] > sz ) {
514 s = fontsize[i]; 514 s = fontsize[i];
515 break; 515 break;
516 } 516 }
517 } 517 }
518 } 518 }
519 519
520 QFont f = editor->font(); 520 QFont f = editor->font();
521 f.setPointSize(s); 521 f.setPointSize(s);
522 editor->setFont(f); 522 editor->setFont(f);
523 523
524 zin->setEnabled(s != fontsize[nfontsizes-1]); 524 zin->setEnabled(s != fontsize[nfontsizes-1]);
525 zout->setEnabled(s != fontsize[0]); 525 zout->setEnabled(s != fontsize[0]);
526} 526}
527 527
528void TextEdit::setBold(bool y) { 528void TextEdit::setBold(bool y) {
529 QFont f = editor->font(); 529 QFont f = editor->font();
530 f.setBold(y); 530 f.setBold(y);
531 editor->setFont(f); 531 editor->setFont(f);
532} 532}
533 533
534void TextEdit::setItalic(bool y) { 534void TextEdit::setItalic(bool y) {
535 QFont f = editor->font(); 535 QFont f = editor->font();
536 f.setItalic(y); 536 f.setItalic(y);
537 editor->setFont(f); 537 editor->setFont(f);
538} 538}
539 539
540void TextEdit::setWordWrap(bool y) { 540void TextEdit::setWordWrap(bool y) {
541 bool state = editor->edited(); 541 bool state = editor->edited();
542 QString captionStr = caption(); 542 QString captionStr = caption();
543 bool b1 = edited1; 543 bool b1 = edited1;
544 bool b2 = edited; 544 bool b2 = edited;
545 545
546 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 546 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
547 editor->setEdited( state ); 547 editor->setEdited( state );
548 edited1=b1; 548 edited1=b1;
549 edited=b2; 549 edited=b2;
550 setCaption(captionStr); 550 setCaption(captionStr);
551} 551}
552 552
553void TextEdit::setSearchBar(bool b) { 553void TextEdit::setSearchBar(bool b) {
554 useSearchBar=b; 554 useSearchBar=b;
555 Config cfg("TextEdit"); 555 Config cfg("TextEdit");
556 cfg.setGroup("View"); 556 cfg.setGroup("View");
557 cfg.writeEntry ( "SearchBar", b ); 557 cfg.writeEntry ( "SearchBar", b );
558 searchBarAction->setOn(b); 558 searchBarAction->setOn(b);
559 if(b) 559 if(b)
560 searchBar->show(); 560 searchBar->show();
561 else 561 else
562 searchBar->hide(); 562 searchBar->hide();
563 editor->setFocus(); 563 editor->setFocus();
564} 564}
565 565
566void TextEdit::fileNew() { 566void TextEdit::fileNew() {
567// if( !bFromDocView ) { 567// if( !bFromDocView ) {
568// saveAs(); 568// saveAs();
569// } 569// }
570 newFile(DocLnk()); 570 newFile(DocLnk());
571} 571}
572 572
573void TextEdit::fileOpen() { 573void TextEdit::fileOpen() {
574 Config cfg("TextEdit");
575 cfg. setGroup ( "View" );
576 QString dir = cfg.readEntry("LastOpenDirectory", QPEApplication::documentDir());
574 QMap<QString, QStringList> map; 577 QMap<QString, QStringList> map;
575 map.insert(tr("All"), QStringList() ); 578 map.insert(tr("All"), QStringList() );
576 QStringList text; 579 QStringList text;
577 text << "text/*"; 580 text << "text/*";
578 map.insert(tr("Text"), text ); 581 map.insert(tr("Text"), text );
579 text << "*"; 582 text << "*";
580 map.insert(tr("All"), text ); 583 map.insert(tr("All"), text );
581 QString str = OFileDialog::getOpenFileName( 2, 584 QString str = OFileDialog::getOpenFileName( 2,
582 QPEApplication::documentDir(), 585 dir ,
583 QString::null, map); 586 QString::null, map);
584 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 587 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
585 openFile( str ); 588 {
589 cfg.writeEntry("LastOpenDirectory", QFileInfo(str).dirPath(false));
590 openFile( str );
591 }
586 else 592 else
587 updateCaption(); 593 updateCaption();
588} 594}
589 595
590void TextEdit::doSearchBar() { 596void TextEdit::doSearchBar() {
591 if(!useSearchBar) 597 if(!useSearchBar)
592 searchBar->hide(); 598 searchBar->hide();
593 else 599 else
594 searchBar->show(); 600 searchBar->show();
595} 601}
596 602
597#if 0 603#if 0
598void TextEdit::slotFind() { 604void TextEdit::slotFind() {
599 FindDialog frmFind( tr("Text Editor"), this ); 605 FindDialog frmFind( tr("Text Editor"), this );
600 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), 606 connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
601 editor, SLOT(slotDoFind( const QString&,bool,bool))); 607 editor, SLOT(slotDoFind( const QString&,bool,bool)));
602 608
603 //case sensitive, backwards, [category] 609 //case sensitive, backwards, [category]
604 610
605 connect( editor, SIGNAL(notFound()), 611 connect( editor, SIGNAL(notFound()),
606 &frmFind, SLOT(slotNotFound()) ); 612 &frmFind, SLOT(slotNotFound()) );
607 connect( editor, SIGNAL(searchWrapped()), 613 connect( editor, SIGNAL(searchWrapped()),
608 &frmFind, SLOT(slotWrapAround()) ); 614 &frmFind, SLOT(slotWrapAround()) );
609 615
610 frmFind.exec(); 616 frmFind.exec();
611 617
612 618
613} 619}
614#endif 620#endif
615 621
616void TextEdit::fileRevert() { 622void TextEdit::fileRevert() {
617 clear(); 623 clear();
618 fileOpen(); 624 fileOpen();
619} 625}
620 626
621void TextEdit::editCut() { 627void TextEdit::editCut() {
622#ifndef QT_NO_CLIPBOARD 628#ifndef QT_NO_CLIPBOARD
623 editor->cut(); 629 editor->cut();
624#endif 630#endif
625} 631}
626 632
627void TextEdit::editCopy() { 633void TextEdit::editCopy() {
628#ifndef QT_NO_CLIPBOARD 634#ifndef QT_NO_CLIPBOARD
629 editor->copy(); 635 editor->copy();
630#endif 636#endif
631} 637}
632 638
633void TextEdit::editPaste() { 639void TextEdit::editPaste() {
634#ifndef QT_NO_CLIPBOARD 640#ifndef QT_NO_CLIPBOARD
635 editor->paste(); 641 editor->paste();
636#endif 642#endif
637} 643}
638 644
639void TextEdit::editFind() { 645void TextEdit::editFind() {
640 searchBar->show(); 646 searchBar->show();
641 searchEdit->setFocus(); 647 searchEdit->setFocus();
642} 648}
643 649
644void TextEdit::findNext() { 650void TextEdit::findNext() {
645 editor->find( searchEdit->text(), false, false ); 651 editor->find( searchEdit->text(), false, false );
646 652
647} 653}
648 654
649void TextEdit::findClose() { 655void TextEdit::findClose() {
650 searchBar->hide(); 656 searchBar->hide();
651} 657}
652 658
653void TextEdit::search() { 659void TextEdit::search() {
654 editor->find( searchEdit->text(), false, false ); 660 editor->find( searchEdit->text(), false, false );
655} 661}
656 662
657void TextEdit::newFile( const DocLnk &f ) { 663void TextEdit::newFile( const DocLnk &f ) {
658 DocLnk nf = f; 664 DocLnk nf = f;
659 nf.setType("text/plain"); 665 nf.setType("text/plain");
660 clear(); 666 clear();
661 setWState (WState_Reserved1 ); 667 setWState (WState_Reserved1 );
662 editor->setFocus(); 668 editor->setFocus();
663 doc = new DocLnk(nf); 669 doc = new DocLnk(nf);
664 currentFileName = "Unnamed"; 670 currentFileName = "Unnamed";
665 qDebug("newFile "+currentFileName); 671 qDebug("newFile "+currentFileName);
666 updateCaption( currentFileName); 672 updateCaption( currentFileName);
667// editor->setEdited( false); 673// editor->setEdited( false);
668} 674}
669 675
670void TextEdit::openDotFile( const QString &f ) { 676void TextEdit::openDotFile( const QString &f ) {
671 if(!currentFileName.isEmpty()) { 677 if(!currentFileName.isEmpty()) {
672 currentFileName=f; 678 currentFileName=f;
673 679
674 qDebug("openFile dotfile " + currentFileName); 680 qDebug("openFile dotfile " + currentFileName);
675 QString txt; 681 QString txt;
676 QFile file(f); 682 QFile file(f);
677 file.open(IO_ReadWrite); 683 file.open(IO_ReadWrite);
678 QTextStream t(&file); 684 QTextStream t(&file);
679 while ( !t.atEnd()) { 685 while ( !t.atEnd()) {
680 txt+=t.readLine()+"\n"; 686 txt+=t.readLine()+"\n";
681 } 687 }
682 editor->setText(txt); 688 editor->setText(txt);
683 editor->setEdited( false); 689 editor->setEdited( false);
684 edited1=false; 690 edited1=false;
685 edited=false; 691 edited=false;
686 692
687 693
688 } 694 }
689 updateCaption( currentFileName); 695 updateCaption( currentFileName);
690} 696}
691 697
692void TextEdit::openFile( const QString &f ) { 698void TextEdit::openFile( const QString &f ) {
693 qDebug("filename is "+ f); 699 qDebug("filename is "+ f);
694 QString filer; 700 QString filer;
695 QFileInfo fi( f); 701 QFileInfo fi( f);
696// bFromDocView = true; 702// bFromDocView = true;
697 if(f.find(".desktop",0,true) != -1 && !openDesktop ) { 703 if(f.find(".desktop",0,true) != -1 && !openDesktop ) {
698 switch ( QMessageBox::warning(this,tr("Text Editor"), 704 switch ( QMessageBox::warning(this,tr("Text Editor"),
699 tr("Text Editor has detected<BR>you selected a <B>.desktop</B> 705 tr("Text Editor has detected<BR>you selected a <B>.desktop</B>
700file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), 706file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
701 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 707 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
702 case 0: 708 case 0:
703 filer = f; 709 filer = f;
704 break; 710 break;
705 case 1: 711 case 1:
706 DocLnk sf(f); 712 DocLnk sf(f);
707 filer = sf.file(); 713 filer = sf.file();
708 break; 714 break;
709 } 715 }
710 } else if(fi.baseName().left(1) == "") { 716 } else if(fi.baseName().left(1) == "") {
711 currentFileName=f; 717 currentFileName=f;
712 openDotFile(currentFileName); 718 openDotFile(currentFileName);
713 } else { 719 } else {