-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 2 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 88 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 6 |
3 files changed, 69 insertions, 27 deletions
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index d78f2e8..4e80735 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -75,7 +75,7 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
75 | currentDir.setPath( QDir::currentDirPath() ); | 75 | currentDir.setPath( QDir::currentDirPath() ); |
76 | populateList(); | 76 | populateList(); |
77 | move(0,15); | 77 | move(0,15); |
78 | 78 | fileEdit->setFocus(); | |
79 | } | 79 | } |
80 | 80 | ||
81 | fileSaver::~fileSaver() | 81 | fileSaver::~fileSaver() |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 0f19da9..03f3a1e 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -252,7 +252,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
252 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 252 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
253 | QPopupMenu *file = new QPopupMenu( this ); | 253 | QPopupMenu *file = new QPopupMenu( this ); |
254 | QPopupMenu *edit = new QPopupMenu( this ); | 254 | QPopupMenu *edit = new QPopupMenu( this ); |
255 | QPopupMenu *font = new QPopupMenu( this ); | 255 | font = new QPopupMenu( this ); |
256 | 256 | ||
257 | bar = new QPEToolBar( this ); | 257 | bar = new QPEToolBar( this ); |
258 | editBar = bar; | 258 | editBar = bar; |
@@ -349,6 +349,12 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
349 | font->insertSeparator(); | 349 | font->insertSeparator(); |
350 | font->insertItem("Font", this, SLOT(changeFont()) ); | 350 | font->insertItem("Font", this, SLOT(changeFont()) ); |
351 | 351 | ||
352 | font->insertSeparator(); | ||
353 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | ||
354 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | ||
355 | nStart->setToggleAction(TRUE); | ||
356 | nStart->addTo( font ); | ||
357 | |||
352 | mb->insertItem( tr( "File" ), file ); | 358 | mb->insertItem( tr( "File" ), file ); |
353 | mb->insertItem( tr( "Edit" ), edit ); | 359 | mb->insertItem( tr( "Edit" ), edit ); |
354 | mb->insertItem( tr( "View" ), font ); | 360 | mb->insertItem( tr( "View" ), font ); |
@@ -414,7 +420,14 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
414 | wa->setOn(wrap); | 420 | wa->setOn(wrap); |
415 | updateCaption(); | 421 | updateCaption(); |
416 | 422 | ||
417 | fileNew(); | 423 | cfg.setGroup("View"); |
424 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | ||
425 | nStart->setOn(TRUE); | ||
426 | fileNew(); | ||
427 | } else { | ||
428 | fileOpen(); | ||
429 | } | ||
430 | |||
418 | } | 431 | } |
419 | 432 | ||
420 | TextEdit::~TextEdit() | 433 | TextEdit::~TextEdit() |
@@ -697,26 +710,34 @@ void TextEdit::showEditTools() | |||
697 | bool TextEdit::save() | 710 | bool TextEdit::save() |
698 | { | 711 | { |
699 | QString file = doc->file(); | 712 | QString file = doc->file(); |
713 | qDebug(file); | ||
700 | QString name= doc->name(); | 714 | QString name= doc->name(); |
701 | 715 | qDebug(name); | |
702 | QString rt = editor->text(); | 716 | QString rt = editor->text(); |
703 | currentFileName= name ; | 717 | if( !rt.isEmpty() ) { |
704 | qDebug("saveFile "+currentFileName); | 718 | if(name.isEmpty()) { |
705 | 719 | saveAs(); | |
706 | struct stat buf; | 720 | } else { |
707 | mode_t mode; | 721 | currentFileName= name ; |
708 | stat(file.latin1(), &buf); | 722 | qDebug("saveFile "+currentFileName); |
709 | mode = buf.st_mode; | 723 | |
724 | struct stat buf; | ||
725 | mode_t mode; | ||
726 | stat(file.latin1(), &buf); | ||
727 | mode = buf.st_mode; | ||
728 | |||
729 | doc->setName( name); | ||
730 | FileManager fm; | ||
731 | if ( !fm.saveFile( *doc, rt ) ) { | ||
732 | return false; | ||
733 | } | ||
734 | editor->setEdited( false ); | ||
710 | 735 | ||
711 | doc->setName( name); | 736 | chmod( file.latin1(), mode); |
712 | FileManager fm; | 737 | } |
713 | if ( !fm.saveFile( *doc, rt ) ) { | 738 | return true; |
714 | return false; | ||
715 | } | 739 | } |
716 | editor->setEdited( false ); | 740 | return false; |
717 | |||
718 | chmod( file.latin1(), mode); | ||
719 | return true; | ||
720 | } | 741 | } |
721 | 742 | ||
722 | /*! | 743 | /*! |
@@ -763,7 +784,7 @@ bool TextEdit::saveAs() | |||
763 | } | 784 | } |
764 | 785 | ||
765 | 786 | ||
766 | fileSaveDlg=new fileSaver(this,"Save File",TRUE, 0, currentFileName); | 787 | fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); |
767 | qDebug("wanna save filename "+currentFileName); | 788 | qDebug("wanna save filename "+currentFileName); |
768 | fileSaveDlg->exec(); | 789 | fileSaveDlg->exec(); |
769 | if( fileSaveDlg->result() == 1 ) { | 790 | if( fileSaveDlg->result() == 1 ) { |
@@ -772,7 +793,6 @@ bool TextEdit::saveAs() | |||
772 | QFileInfo fi(fileNm); | 793 | QFileInfo fi(fileNm); |
773 | currentFileName=fi.fileName(); | 794 | currentFileName=fi.fileName(); |
774 | if(doc) { | 795 | if(doc) { |
775 | qDebug("doclnk exists"); | ||
776 | // QString file = doc->file(); | 796 | // QString file = doc->file(); |
777 | // doc->removeFiles(); | 797 | // doc->removeFiles(); |
778 | delete doc; | 798 | delete doc; |
@@ -781,7 +801,7 @@ bool TextEdit::saveAs() | |||
781 | nf.setFile( fileNm); | 801 | nf.setFile( fileNm); |
782 | doc = new DocLnk(nf); | 802 | doc = new DocLnk(nf); |
783 | // editor->setText(rt); | 803 | // editor->setText(rt); |
784 | qDebug("openFile doclnk "+currentFileName); | 804 | // qDebug("openFile doclnk "+currentFileName); |
785 | doc->setName( currentFileName); | 805 | doc->setName( currentFileName); |
786 | updateCaption( currentFileName); | 806 | updateCaption( currentFileName); |
787 | 807 | ||
@@ -855,10 +875,15 @@ void TextEdit::closeEvent( QCloseEvent *e ) | |||
855 | } | 875 | } |
856 | 876 | ||
857 | void TextEdit::accept() | 877 | void TextEdit::accept() |
858 | { | 878 | { |
859 | save(); | 879 | QString file = doc->file(); |
860 | close(); | 880 | if (file.find("_.txt",0,TRUE) ==-1) |
861 | // fileOpen(); //godamn thats obnoxious! lemme out!!! | 881 | save(); |
882 | else { | ||
883 | QFile(file).remove(); | ||
884 | } | ||
885 | exit(0); | ||
886 | |||
862 | } | 887 | } |
863 | 888 | ||
864 | void TextEdit::changeFont() { | 889 | void TextEdit::changeFont() { |
@@ -900,3 +925,16 @@ void TextEdit::editDelete() | |||
900 | break; | 925 | break; |
901 | }; | 926 | }; |
902 | } | 927 | } |
928 | |||
929 | void TextEdit::changeStartConfig( bool b ) { | ||
930 | |||
931 | Config cfg("TextEdit"); | ||
932 | cfg.setGroup("View"); | ||
933 | if(b) { | ||
934 | qDebug("bool"); | ||
935 | cfg.writeEntry("startNew","TRUE"); | ||
936 | } else { | ||
937 | cfg.writeEntry("startNew","FALSE"); | ||
938 | } | ||
939 | update(); | ||
940 | } | ||
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 781061a..fb58738 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <qlist.h> | 34 | #include <qlist.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | 36 | ||
37 | class QAction; | ||
37 | class QWidgetStack; | 38 | class QWidgetStack; |
38 | class QToolButton; | 39 | class QToolButton; |
39 | class QPopupMenu; | 40 | class QPopupMenu; |
@@ -42,6 +43,7 @@ class QLineEdit; | |||
42 | class QAction; | 43 | class QAction; |
43 | class FileSelector; | 44 | class FileSelector; |
44 | class QpeEditor; | 45 | class QpeEditor; |
46 | class QPopupMenu; | ||
45 | 47 | ||
46 | class TextEdit : public QMainWindow | 48 | class TextEdit : public QMainWindow |
47 | { | 49 | { |
@@ -50,7 +52,8 @@ class TextEdit : public QMainWindow | |||
50 | public: | 52 | public: |
51 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 53 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
52 | ~TextEdit(); | 54 | ~TextEdit(); |
53 | 55 | QPopupMenu *font; | |
56 | QAction *nStart; | ||
54 | void openFile( const QString & ); | 57 | void openFile( const QString & ); |
55 | 58 | ||
56 | protected: | 59 | protected: |
@@ -63,6 +66,7 @@ private slots: | |||
63 | void fileRevert(); | 66 | void fileRevert(); |
64 | void fileOpen(); | 67 | void fileOpen(); |
65 | void newFileOpen(); | 68 | void newFileOpen(); |
69 | void changeStartConfig(bool); | ||
66 | bool save(); | 70 | bool save(); |
67 | bool saveAs(); | 71 | bool saveAs(); |
68 | 72 | ||