summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-01 13:16:27 (UTC)
committer llornkcor <llornkcor>2002-09-01 13:16:27 (UTC)
commit41d125f02fb485f963818efea9f32f3f29148710 (patch) (unidiff)
tree1a56bad99a18d7003543e5456458f23dcb8cee1d
parent21394ee7a48bbe0768a1b820b2493defa534257e (diff)
downloadopie-41d125f02fb485f963818efea9f32f3f29148710.zip
opie-41d125f02fb485f963818efea9f32f3f29148710.tar.gz
opie-41d125f02fb485f963818efea9f32f3f29148710.tar.bz2
added a few remaining tr, fixed a few bugs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index d61da2a..8eaafce 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -420,65 +420,67 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
420 cfg.setGroup("Font"); 420 cfg.setGroup("Font");
421 QString family = cfg.readEntry("Family", fontInfo.family()); 421 QString family = cfg.readEntry("Family", fontInfo.family());
422 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 422 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
423 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 423 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
424 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 424 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
425 425
426 defaultFont = fdb.font(family,style,i_size,charSet); 426 defaultFont = fdb.font(family,style,i_size,charSet);
427 editor->setFont( defaultFont); 427 editor->setFont( defaultFont);
428 428
429 wa->setOn(wrap); 429 wa->setOn(wrap);
430 updateCaption(); 430 updateCaption();
431 431
432 cfg.setGroup("View"); 432 cfg.setGroup("View");
433 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 433 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
434 nStart->setOn(TRUE); 434 nStart->setOn(TRUE);
435 fileNew(); 435 fileNew();
436 } else { 436 } else {
437 fileOpen(); 437 fileOpen();
438 } 438 }
439 439
440 viewSelection = cfg.readNumEntry( "FileView", 0 ); 440 viewSelection = cfg.readNumEntry( "FileView", 0 );
441} 441}
442 442
443TextEdit::~TextEdit() { 443TextEdit::~TextEdit() {
444 if( edited1 & !useAdvancedFeatures )
445 saveAs();
444} 446}
445 447
446void TextEdit::cleanUp() { 448void TextEdit::cleanUp() {
447// save(); 449qDebug("cleanUp");// save();
448 Config cfg("TextEdit"); 450 Config cfg("TextEdit");
449 cfg.setGroup("View"); 451 cfg.setGroup("View");
450 QFont f = editor->font(); 452 QFont f = editor->font();
451 cfg.writeEntry("FontSize",f.pointSize()); 453 cfg.writeEntry("FontSize",f.pointSize());
452 cfg.writeEntry("Bold",f.bold()); 454 cfg.writeEntry("Bold",f.bold());
453 cfg.writeEntry("Italic",f.italic()); 455 cfg.writeEntry("Italic",f.italic());
454 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); 456 cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
455 cfg.writeEntry( "FileView", viewSelection ); 457 cfg.writeEntry( "FileView", viewSelection );
456} 458}
457 459
458 460
459void TextEdit::accept() { 461void TextEdit::accept() {
460 if(edited1) 462 if( edited1)
461 saveAs(); 463 saveAs();
462 exit(0); 464 exit(0);
463} 465}
464 466
465void TextEdit::zoomIn() { 467void TextEdit::zoomIn() {
466 setFontSize(editor->font().pointSize()+1,FALSE); 468 setFontSize(editor->font().pointSize()+1,FALSE);
467} 469}
468 470
469void TextEdit::zoomOut() { 471void TextEdit::zoomOut() {
470 setFontSize(editor->font().pointSize()-1,TRUE); 472 setFontSize(editor->font().pointSize()-1,TRUE);
471} 473}
472 474
473 475
474void TextEdit::setFontSize(int sz, bool round_down_not_up) { 476void TextEdit::setFontSize(int sz, bool round_down_not_up) {
475 int s=10; 477 int s=10;
476 for (int i=0; i<nfontsizes; i++) { 478 for (int i=0; i<nfontsizes; i++) {
477 if ( fontsize[i] == sz ) { 479 if ( fontsize[i] == sz ) {
478 s = sz; 480 s = sz;
479 break; 481 break;
480 } else if ( round_down_not_up ) { 482 } else if ( round_down_not_up ) {
481 if ( fontsize[i] < sz ) 483 if ( fontsize[i] < sz )
482 s = fontsize[i]; 484 s = fontsize[i];
483 } else { 485 } else {
484 if ( fontsize[i] > sz ) { 486 if ( fontsize[i] > sz ) {
@@ -614,61 +616,63 @@ void TextEdit::findClose() {
614 616
615void TextEdit::search() { 617void TextEdit::search() {
616 editor->find( searchEdit->text(), FALSE, FALSE ); 618 editor->find( searchEdit->text(), FALSE, FALSE );
617} 619}
618 620
619void TextEdit::newFile( const DocLnk &f ) { 621void TextEdit::newFile( const DocLnk &f ) {
620 DocLnk nf = f; 622 DocLnk nf = f;
621 nf.setType("text/plain"); 623 nf.setType("text/plain");
622 clear(); 624 clear();
623 setWState (WState_Reserved1 ); 625 setWState (WState_Reserved1 );
624 editor->setFocus(); 626 editor->setFocus();
625 doc = new DocLnk(nf); 627 doc = new DocLnk(nf);
626 currentFileName = "Unnamed"; 628 currentFileName = "Unnamed";
627 qDebug("newFile "+currentFileName); 629 qDebug("newFile "+currentFileName);
628 updateCaption( currentFileName); 630 updateCaption( currentFileName);
629// editor->setEdited( FALSE); 631// editor->setEdited( FALSE);
630} 632}
631 633
632void TextEdit::openFile( const QString &f ) { 634void TextEdit::openFile( const QString &f ) {
633 qDebug("filename is "+ f); 635 qDebug("filename is "+ f);
634 QString filer; 636 QString filer;
635// bFromDocView = TRUE; 637// bFromDocView = TRUE;
636 if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { 638 if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) {
637 switch ( QMessageBox::warning(this,tr("Text Editor"), 639 switch ( QMessageBox::warning(this,tr("Text Editor"),
638 tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), 640 tr("Text Editor has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
639 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 641 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
640 case 0: 642 case 0:
641 filer = f; 643 filer = f;
642 break; 644 break;
643 case 1: 645 case 1:
644 DocLnk sf(f); 646 DocLnk sf(f);
645 filer = sf.file(); 647 filer = sf.file();
646 break; 648 break;
647 } 649 }
648 } else { 650 } else {
649 filer = f; 651 DocLnk sf(f);
650 fileIs = TRUE; 652 filer = sf.file();
653// filer = f;
654// fileIs = TRUE;
651 } 655 }
652 656
653 DocLnk nf; 657 DocLnk nf;
654 nf.setType("text/plain"); 658 nf.setType("text/plain");
655 nf.setFile(filer); 659 nf.setFile(filer);
656 currentFileName=filer; 660 currentFileName=filer;
657 QFileInfo fi( currentFileName); 661 QFileInfo fi( currentFileName);
658 nf.setName(fi.baseName()); 662 nf.setName(fi.baseName());
659 qDebug("openFile string "+currentFileName); 663 qDebug("openFile string "+currentFileName);
660 664
661 openFile(nf); 665 openFile(nf);
662 showEditTools(); 666 showEditTools();
663 // Show filename in caption 667 // Show filename in caption
664 QString name = filer; 668 QString name = filer;
665 int sep = name.findRev( '/' ); 669 int sep = name.findRev( '/' );
666 if ( sep > 0 ) 670 if ( sep > 0 )
667 name = name.mid( sep+1 ); 671 name = name.mid( sep+1 );
668 updateCaption( name ); 672 updateCaption( name );
669} 673}
670 674
671void TextEdit::openFile( const DocLnk &f ) { 675void TextEdit::openFile( const DocLnk &f ) {
672// clear(); 676// clear();
673// bFromDocView = TRUE; 677// bFromDocView = TRUE;
674 FileManager fm; 678 FileManager fm;
@@ -716,49 +720,49 @@ bool TextEdit::save() {
716 if(name.isEmpty()) { 720 if(name.isEmpty()) {
717 saveAs(); 721 saveAs();
718 } else { 722 } else {
719 currentFileName= name ; 723 currentFileName= name ;
720 qDebug("saveFile "+currentFileName); 724 qDebug("saveFile "+currentFileName);
721 725
722 struct stat buf; 726 struct stat buf;
723 mode_t mode; 727 mode_t mode;
724 stat(file.latin1(), &buf); 728 stat(file.latin1(), &buf);
725 mode = buf.st_mode; 729 mode = buf.st_mode;
726 730
727 if(!fileIs) { 731 if(!fileIs) {
728 doc->setName( name); 732 doc->setName( name);
729 FileManager fm; 733 FileManager fm;
730 if ( !fm.saveFile( *doc, rt ) ) { 734 if ( !fm.saveFile( *doc, rt ) ) {
731 return false; 735 return false;
732 } 736 }
733 } else { 737 } else {
734 qDebug("regular save file"); 738 qDebug("regular save file");
735 QFile f(file); 739 QFile f(file);
736 if( f.open(IO_WriteOnly)) { 740 if( f.open(IO_WriteOnly)) {
737 QCString crt = rt.utf8(); 741 QCString crt = rt.utf8();
738 f.writeBlock(crt,crt.length()); 742 f.writeBlock(crt,crt.length());
739 } else { 743 } else {
740 QMessageBox::message("Text Edit","Write Failed"); 744 QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
741 return false; 745 return false;
742 } 746 }
743 747
744 } 748 }
745 editor->setEdited( FALSE); 749 editor->setEdited( FALSE);
746 edited1=FALSE; 750 edited1=FALSE;
747 edited=FALSE; 751 edited=FALSE;
748 if(caption().left(1)=="*") 752 if(caption().left(1)=="*")
749 setCaption(caption().right(caption().length()-1)); 753 setCaption(caption().right(caption().length()-1));
750 754
751 755
752 chmod( file.latin1(), mode); 756 chmod( file.latin1(), mode);
753 } 757 }
754 return true; 758 return true;
755 } 759 }
756 return false; 760 return false;
757} 761}
758 762
759/*! 763/*!
760 prompted save */ 764 prompted save */
761bool TextEdit::saveAs() { 765bool TextEdit::saveAs() {
762 qDebug("saveAsFile "+currentFileName); 766 qDebug("saveAsFile "+currentFileName);
763 // case of nothing to save... 767 // case of nothing to save...
764 if ( !doc ) { 768 if ( !doc ) {
@@ -893,88 +897,88 @@ void TextEdit::changeFont() {
893 FontDatabase fdb; 897 FontDatabase fdb;
894 QFont defaultFont=editor->font(); 898 QFont defaultFont=editor->font();
895 QFontInfo fontInfo(defaultFont); 899 QFontInfo fontInfo(defaultFont);
896 Config cfg("TextEdit"); 900 Config cfg("TextEdit");
897 cfg.setGroup("Font"); 901 cfg.setGroup("Font");
898 QString family = cfg.readEntry("Family", fontInfo.family()); 902 QString family = cfg.readEntry("Family", fontInfo.family());
899 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 903 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
900 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 904 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
901 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 905 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
902 906
903 defaultFont = fdb.font(family,style,i_size,charSet); 907 defaultFont = fdb.font(family,style,i_size,charSet);
904 908
905 FontDialog *fontDlg; 909 FontDialog *fontDlg;
906 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); 910 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE);
907 911
908 fontDlg->exec(); 912 fontDlg->exec();
909 913
910 QFont myFont=fontDlg->selectedFont; 914 QFont myFont=fontDlg->selectedFont;
911 editor->setFont( myFont); 915 editor->setFont( myFont);
912 delete fontDlg; 916 delete fontDlg;
913 917
914} 918}
915 919
916void TextEdit::editDelete() { 920void TextEdit::editDelete() {
917 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { 921 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) {
918 case 0: 922 case 0:
919 if(doc) { 923 if(doc) {
920 doc->removeFiles(); 924 doc->removeFiles();
921 clear(); 925 clear();
922 setCaption( tr("Text Editor") ); 926 setCaption( tr("Text Editor") );
923 } 927 }
924 break; 928 break;
925 case 1: 929 case 1:
926 // exit 930 // exit
927 break; 931 break;
928 }; 932 };
929} 933}
930 934
931void TextEdit::changeStartConfig( bool b ) { 935void TextEdit::changeStartConfig( bool b ) {
932 936
933 Config cfg("TextEdit"); 937 Config cfg("TextEdit");
934 cfg.setGroup("View"); 938 cfg.setGroup("View");
935 if(b) { 939 if(b) {
936 qDebug("bool"); 940 qDebug("bool");
937 cfg.writeEntry("startNew","TRUE"); 941 cfg.writeEntry("startNew","TRUE");
938 } else { 942 } else {
939 cfg.writeEntry("startNew","FALSE"); 943 cfg.writeEntry("startNew","FALSE");
940 } 944 }
941 update(); 945 update();
942} 946}
943 947
944void TextEdit::editorChanged() { 948void TextEdit::editorChanged() {
945 if(editor->edited() && edited && !edited1) { 949 if(editor->edited() && edited && !edited1) {
946 setCaption( "*"+caption()); 950 setCaption( "*"+caption());
947 edited1=TRUE; 951 edited1=TRUE;
948 } 952 }
949 edited=TRUE; 953 edited=TRUE;
950} 954}
951 955
952void TextEdit::receive(const QCString&msg, const QByteArray&) { 956void TextEdit::receive(const QCString&msg, const QByteArray&) {
953 qDebug("QCop "+msg); 957 qDebug("QCop "+msg);
954 if ( msg == "setDocument(QString)" ) { 958 if ( msg == "setDocument(QString)" ) {
955 qDebug("bugger all"); 959 qDebug("bugger all");
956 } 960 }
957 961
958} 962}
959void TextEdit::doAbout() { 963void TextEdit::doAbout() {
960 QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" 964 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
961 "2000 Trolltech AS, and\n" 965 "2000 Trolltech AS, and<BR>"
962 "2002 by L.J.Potter \nljp@llornkcor.com\n" 966 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
963 "and is licensed under the GPL"); 967 "and is licensed under the GPL"));
964} 968}
965 969
966void TextEdit::doAdvanced(bool b) { 970void TextEdit::doAdvanced(bool b) {
967 useAdvancedFeatures=b; 971 useAdvancedFeatures=b;
968 Config cfg("TextEdit"); 972 Config cfg("TextEdit");
969 cfg.setGroup("View"); 973 cfg.setGroup("View");
970 cfg.writeEntry("AdvancedFeatures",b); 974 cfg.writeEntry("AdvancedFeatures",b);
971} 975}
972 976
973void TextEdit::editPasteTimeDate() { 977void TextEdit::editPasteTimeDate() {
974#ifndef QT_NO_CLIPBOARD 978#ifndef QT_NO_CLIPBOARD
975 QClipboard *cb = QApplication::clipboard(); 979 QClipboard *cb = QApplication::clipboard();
976 QDateTime dt = QDateTime::currentDateTime(); 980 QDateTime dt = QDateTime::currentDateTime();
977 cb->setText( dt.toString()); 981 cb->setText( dt.toString());
978 editor->paste(); 982 editor->paste();
979#endif 983#endif
980} 984}