author | llornkcor <llornkcor> | 2002-10-03 13:04:26 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-03 13:04:26 (UTC) |
commit | 8a7f57c5c172958d67d8397eed1860c914df485d (patch) (unidiff) | |
tree | f665602210cf23240c626dabb15b2b4e13ad5e60 | |
parent | ee864e9e055fd23778a8e5dd3c35e3a29cded368 (diff) | |
download | opie-8a7f57c5c172958d67d8397eed1860c914df485d.zip opie-8a7f57c5c172958d67d8397eed1860c914df485d.tar.gz opie-8a7f57c5c172958d67d8397eed1860c914df485d.tar.bz2 |
fix not opening
-rw-r--r-- | core/apps/textedit/textedit.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 7b50a6c..6844023 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -366,103 +366,103 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
366 | 366 | ||
367 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 367 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
369 | a->addTo( searchBar ); | 369 | a->addTo( searchBar ); |
370 | a->addTo( edit ); | 370 | a->addTo( edit ); |
371 | 371 | ||
372 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 372 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
373 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 373 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
374 | a->addTo( searchBar ); | 374 | a->addTo( searchBar ); |
375 | 375 | ||
376 | edit->insertSeparator(); | 376 | edit->insertSeparator(); |
377 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 377 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
378 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 378 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
379 | a->addTo( edit ); | 379 | a->addTo( edit ); |
380 | 380 | ||
381 | searchBar->hide(); | 381 | searchBar->hide(); |
382 | 382 | ||
383 | editor = new QpeEditor( this ); | 383 | editor = new QpeEditor( this ); |
384 | setCentralWidget( editor ); | 384 | setCentralWidget( editor ); |
385 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 385 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
386 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 386 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
387 | 387 | ||
388 | Config cfg("TextEdit"); | 388 | Config cfg("TextEdit"); |
389 | 389 | ||
390 | cfg. setGroup ( "Font" ); | 390 | cfg. setGroup ( "Font" ); |
391 | 391 | ||
392 | QFont defaultFont = editor-> font ( ); | 392 | QFont defaultFont = editor-> font ( ); |
393 | 393 | ||
394 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 394 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
395 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 395 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
396 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 396 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
397 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 397 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
398 | 398 | ||
399 | defaultFont = QFont ( family, size, weight, italic ); | 399 | defaultFont = QFont ( family, size, weight, italic ); |
400 | editor-> setFont ( defaultFont ); | 400 | editor-> setFont ( defaultFont ); |
401 | 401 | ||
402 | updateCaption(); | 402 | updateCaption(); |
403 | 403 | ||
404 | cfg.setGroup ( "View" ); | 404 | cfg.setGroup ( "View" ); |
405 | 405 | ||
406 | useAdvancedFeatures = cfg. readBoolEntry ( "AdvancedFeatures", false ); | 406 | useAdvancedFeatures = cfg. readBoolEntry ( "AdvancedFeatures", false ); |
407 | 407 | ||
408 | if ( useAdvancedFeatures ) | 408 | if ( useAdvancedFeatures ) |
409 | nAdvanced-> setOn ( true ); | 409 | nAdvanced-> setOn ( true ); |
410 | 410 | ||
411 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 411 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
412 | wa-> setOn ( wrap ); | 412 | wa-> setOn ( wrap ); |
413 | setWordWrap ( wrap ); | 413 | setWordWrap ( wrap ); |
414 | 414 | ||
415 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 415 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
416 | nStart->setOn(TRUE); | 416 | nStart->setOn(TRUE); |
417 | fileNew(); | 417 | fileNew(); |
418 | } else { | 418 | } else { |
419 | fileOpen(); | 419 | fileOpen(); |
420 | } | 420 | } |
421 | 421 | ||
422 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 422 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
423 | } | 423 | } |
424 | 424 | ||
425 | TextEdit::~TextEdit() { | 425 | TextEdit::~TextEdit() { |
426 | if( edited1 & !useAdvancedFeatures ) | 426 | if( edited1 & !useAdvancedFeatures ) |
427 | saveAs(); | 427 | saveAs(); |
428 | } | 428 | } |
429 | 429 | ||
430 | void TextEdit::cleanUp() { | 430 | void TextEdit::cleanUp() { |
431 | qDebug("cleanUp");// save(); | 431 | qDebug("cleanUp");// save(); |
432 | 432 | ||
433 | Config cfg ( "TextEdit" ); | 433 | Config cfg ( "TextEdit" ); |
434 | cfg. setGroup ( "Font" ); | 434 | cfg. setGroup ( "Font" ); |
435 | QFont f = editor->font(); | 435 | QFont f = editor->font(); |
436 | cfg. writeEntry ( "Family", f. family ( )); | 436 | cfg. writeEntry ( "Family", f. family ( )); |
437 | cfg. writeEntry ( "Size", f. pointSize ( )); | 437 | cfg. writeEntry ( "Size", f. pointSize ( )); |
438 | cfg. writeEntry ( "Weight", f. weight ( )); | 438 | cfg. writeEntry ( "Weight", f. weight ( )); |
439 | cfg. writeEntry ( "Italic", f. italic ( )); | 439 | cfg. writeEntry ( "Italic", f. italic ( )); |
440 | 440 | ||
441 | cfg. setGroup ( "View" ); | 441 | cfg. setGroup ( "View" ); |
442 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); | 442 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); |
443 | cfg. writeEntry ( "FileView", viewSelection ); | 443 | cfg. writeEntry ( "FileView", viewSelection ); |
444 | cfg. writeEntry ( "AdvancedFeatures", useAdvancedFeatures ); | 444 | cfg. writeEntry ( "AdvancedFeatures", useAdvancedFeatures ); |
445 | } | 445 | } |
446 | 446 | ||
447 | 447 | ||
448 | void TextEdit::accept() { | 448 | void TextEdit::accept() { |
449 | if( edited1) | 449 | if( edited1) |
450 | saveAs(); | 450 | saveAs(); |
451 | exit(0); | 451 | exit(0); |
452 | } | 452 | } |
453 | 453 | ||
454 | void TextEdit::zoomIn() { | 454 | void TextEdit::zoomIn() { |
455 | setFontSize(editor->font().pointSize()+1,FALSE); | 455 | setFontSize(editor->font().pointSize()+1,FALSE); |
456 | } | 456 | } |
457 | 457 | ||
458 | void TextEdit::zoomOut() { | 458 | void TextEdit::zoomOut() { |
459 | setFontSize(editor->font().pointSize()-1,TRUE); | 459 | setFontSize(editor->font().pointSize()-1,TRUE); |
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
463 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 463 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
464 | int s=10; | 464 | int s=10; |
465 | for (int i=0; i<nfontsizes; i++) { | 465 | for (int i=0; i<nfontsizes; i++) { |
466 | if ( fontsize[i] == sz ) { | 466 | if ( fontsize[i] == sz ) { |
467 | s = sz; | 467 | s = sz; |
468 | break; | 468 | break; |
@@ -603,63 +603,64 @@ void TextEdit::findClose() { | |||
603 | 603 | ||
604 | void TextEdit::search() { | 604 | void TextEdit::search() { |
605 | editor->find( searchEdit->text(), FALSE, FALSE ); | 605 | editor->find( searchEdit->text(), FALSE, FALSE ); |
606 | } | 606 | } |
607 | 607 | ||
608 | void TextEdit::newFile( const DocLnk &f ) { | 608 | void TextEdit::newFile( const DocLnk &f ) { |
609 | DocLnk nf = f; | 609 | DocLnk nf = f; |
610 | nf.setType("text/plain"); | 610 | nf.setType("text/plain"); |
611 | clear(); | 611 | clear(); |
612 | setWState (WState_Reserved1 ); | 612 | setWState (WState_Reserved1 ); |
613 | editor->setFocus(); | 613 | editor->setFocus(); |
614 | doc = new DocLnk(nf); | 614 | doc = new DocLnk(nf); |
615 | currentFileName = "Unnamed"; | 615 | currentFileName = "Unnamed"; |
616 | qDebug("newFile "+currentFileName); | 616 | qDebug("newFile "+currentFileName); |
617 | updateCaption( currentFileName); | 617 | updateCaption( currentFileName); |
618 | // editor->setEdited( FALSE); | 618 | // editor->setEdited( FALSE); |
619 | } | 619 | } |
620 | 620 | ||
621 | void TextEdit::openFile( const QString &f ) { | 621 | void TextEdit::openFile( const QString &f ) { |
622 | qDebug("filename is "+ f); | 622 | qDebug("filename is "+ f); |
623 | QString filer; | 623 | QString filer; |
624 | // bFromDocView = TRUE; | 624 | // bFromDocView = TRUE; |
625 | if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { | 625 | if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { |
626 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 626 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
627 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | 627 | tr("Text Editor has detected<BR>you selected a <B>.desktop</B> |
628 | file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), | ||
628 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { | 629 | tr(".desktop File"),tr("Linked Document"),0,1,1) ) { |
629 | case 0: | 630 | case 0: |
630 | filer = f; | 631 | filer = f; |
631 | break; | 632 | break; |
632 | case 1: | 633 | case 1: |
633 | DocLnk sf(f); | 634 | DocLnk sf(f); |
634 | filer = sf.file(); | 635 | filer = sf.file(); |
635 | break; | 636 | break; |
636 | } | 637 | } |
637 | } else { | 638 | } else { |
638 | DocLnk sf(f); | 639 | DocLnk sf(f); |
639 | filer = sf.file(); | 640 | filer = sf.file(); |
640 | // filer = f; | 641 | if(filer.right(1) == "/") |
641 | // fileIs = TRUE; | 642 | filer = f; |
642 | } | 643 | } |
643 | 644 | ||
644 | DocLnk nf; | 645 | DocLnk nf; |
645 | nf.setType("text/plain"); | 646 | nf.setType("text/plain"); |
646 | nf.setFile(filer); | 647 | nf.setFile(filer); |
647 | currentFileName=filer; | 648 | currentFileName=filer; |
648 | QFileInfo fi( currentFileName); | 649 | QFileInfo fi( currentFileName); |
649 | nf.setName(fi.baseName()); | 650 | nf.setName(fi.baseName()); |
650 | qDebug("openFile string "+currentFileName); | 651 | qDebug("openFile string "+currentFileName); |
651 | 652 | ||
652 | openFile(nf); | 653 | openFile(nf); |
653 | showEditTools(); | 654 | showEditTools(); |
654 | // Show filename in caption | 655 | // Show filename in caption |
655 | QString name = filer; | 656 | QString name = filer; |
656 | int sep = name.findRev( '/' ); | 657 | int sep = name.findRev( '/' ); |
657 | if ( sep > 0 ) | 658 | if ( sep > 0 ) |
658 | name = name.mid( sep+1 ); | 659 | name = name.mid( sep+1 ); |
659 | updateCaption( name ); | 660 | updateCaption( name ); |
660 | } | 661 | } |
661 | 662 | ||
662 | void TextEdit::openFile( const DocLnk &f ) { | 663 | void TextEdit::openFile( const DocLnk &f ) { |
663 | // clear(); | 664 | // clear(); |
664 | // bFromDocView = TRUE; | 665 | // bFromDocView = TRUE; |
665 | FileManager fm; | 666 | FileManager fm; |
@@ -861,58 +862,58 @@ void TextEdit::updateCaption( const QString &name ) { | |||
861 | s = tr( "Unnamed" ); | 862 | s = tr( "Unnamed" ); |
862 | currentFileName=s; | 863 | currentFileName=s; |
863 | } | 864 | } |
864 | if(s.left(1) == "/") | 865 | if(s.left(1) == "/") |
865 | s = s.right(s.length()-1); | 866 | s = s.right(s.length()-1); |
866 | setCaption( s + " - " + tr("Text Editor") ); | 867 | setCaption( s + " - " + tr("Text Editor") ); |
867 | } | 868 | } |
868 | } | 869 | } |
869 | 870 | ||
870 | void TextEdit::setDocument(const QString& fileref) { | 871 | void TextEdit::setDocument(const QString& fileref) { |
871 | bFromDocView = TRUE; | 872 | bFromDocView = TRUE; |
872 | openFile(fileref); | 873 | openFile(fileref); |
873 | editor->setEdited(TRUE); | 874 | editor->setEdited(TRUE); |
874 | edited1=FALSE; | 875 | edited1=FALSE; |
875 | edited=TRUE; | 876 | edited=TRUE; |
876 | doSearchBar(); | 877 | doSearchBar(); |
877 | } | 878 | } |
878 | 879 | ||
879 | void TextEdit::closeEvent( QCloseEvent *e ) { | 880 | void TextEdit::closeEvent( QCloseEvent *e ) { |
880 | bFromDocView = FALSE; | 881 | bFromDocView = FALSE; |
881 | e->accept(); | 882 | e->accept(); |
882 | } | 883 | } |
883 | 884 | ||
884 | void TextEdit::changeFont() { | 885 | void TextEdit::changeFont() { |
885 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 886 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
886 | d-> setCaption ( tr( "Choose font" )); | 887 | d-> setCaption ( tr( "Choose font" )); |
887 | QBoxLayout *lay = new QVBoxLayout ( d ); | 888 | QBoxLayout *lay = new QVBoxLayout ( d ); |
888 | OFontSelector *ofs = new OFontSelector ( true, d ); | 889 | OFontSelector *ofs = new OFontSelector ( true, d ); |
889 | lay-> addWidget ( ofs ); | 890 | lay-> addWidget ( ofs ); |
890 | ofs-> setSelectedFont ( editor-> font ( )); | 891 | ofs-> setSelectedFont ( editor-> font ( )); |
891 | 892 | ||
892 | d-> showMaximized ( ); | 893 | d-> showMaximized ( ); |
893 | if ( d-> exec ( ) == QDialog::Accepted ) | 894 | if ( d-> exec ( ) == QDialog::Accepted ) |
894 | editor-> setFont ( ofs-> selectedFont ( )); | 895 | editor-> setFont ( ofs-> selectedFont ( )); |
895 | delete d; | 896 | delete d; |
896 | 897 | ||
897 | } | 898 | } |
898 | 899 | ||
899 | void TextEdit::editDelete() { | 900 | void TextEdit::editDelete() { |
900 | 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) ) { | 901 | 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) ) { |
901 | case 0: | 902 | case 0: |
902 | if(doc) { | 903 | if(doc) { |
903 | doc->removeFiles(); | 904 | doc->removeFiles(); |
904 | clear(); | 905 | clear(); |
905 | setCaption( tr("Text Editor") ); | 906 | setCaption( tr("Text Editor") ); |
906 | } | 907 | } |
907 | break; | 908 | break; |
908 | case 1: | 909 | case 1: |
909 | // exit | 910 | // exit |
910 | break; | 911 | break; |
911 | }; | 912 | }; |
912 | } | 913 | } |
913 | 914 | ||
914 | void TextEdit::changeStartConfig( bool b ) { | 915 | void TextEdit::changeStartConfig( bool b ) { |
915 | 916 | ||
916 | Config cfg("TextEdit"); | 917 | Config cfg("TextEdit"); |
917 | cfg.setGroup("View"); | 918 | cfg.setGroup("View"); |
918 | if(b) { | 919 | if(b) { |