author | bipolar <bipolar> | 2002-03-08 00:12:12 (UTC) |
---|---|---|
committer | bipolar <bipolar> | 2002-03-08 00:12:12 (UTC) |
commit | 11b56113b6641e0b85c6015eafab802dd7663198 (patch) (unidiff) | |
tree | 1899707c9144a342519acf9693ec69d2d4edffc7 | |
parent | 50f8f55346f369787063f42c571d2dc832eb58aa (diff) | |
download | opie-11b56113b6641e0b85c6015eafab802dd7663198.zip opie-11b56113b6641e0b85c6015eafab802dd7663198.tar.gz opie-11b56113b6641e0b85c6015eafab802dd7663198.tar.bz2 |
ljp: added startup option,a dn fixed save when closing with no file edited
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 2 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 52 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 6 |
3 files changed, 51 insertions, 9 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 | |||
@@ -77,3 +77,3 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
77 | move(0,15); | 77 | move(0,15); |
78 | 78 | fileEdit->setFocus(); | |
79 | } | 79 | } |
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 | |||
@@ -254,3 +254,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
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 | ||
@@ -351,2 +351,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
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 ); |
@@ -416,3 +422,10 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
416 | 422 | ||
423 | cfg.setGroup("View"); | ||
424 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | ||
425 | nStart->setOn(TRUE); | ||
417 | fileNew(); | 426 | fileNew(); |
427 | } else { | ||
428 | fileOpen(); | ||
429 | } | ||
430 | |||
418 | } | 431 | } |
@@ -699,5 +712,10 @@ bool TextEdit::save() | |||
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(); |
717 | if( !rt.isEmpty() ) { | ||
718 | if(name.isEmpty()) { | ||
719 | saveAs(); | ||
720 | } else { | ||
703 | currentFileName= name ; | 721 | currentFileName= name ; |
@@ -718,4 +736,7 @@ bool TextEdit::save() | |||
718 | chmod( file.latin1(), mode); | 736 | chmod( file.latin1(), mode); |
737 | } | ||
719 | return true; | 738 | return true; |
720 | } | 739 | } |
740 | return false; | ||
741 | } | ||
721 | 742 | ||
@@ -765,3 +786,3 @@ bool TextEdit::saveAs() | |||
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); |
@@ -774,3 +795,2 @@ bool TextEdit::saveAs() | |||
774 | if(doc) { | 795 | if(doc) { |
775 | qDebug("doclnk exists"); | ||
776 | // QString file = doc->file(); | 796 | // QString file = doc->file(); |
@@ -783,3 +803,3 @@ bool TextEdit::saveAs() | |||
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); |
@@ -858,5 +878,10 @@ void TextEdit::accept() | |||
858 | { | 878 | { |
879 | QString file = doc->file(); | ||
880 | if (file.find("_.txt",0,TRUE) ==-1) | ||
859 | save(); | 881 | save(); |
860 | close(); | 882 | else { |
861 | // fileOpen(); //godamn thats obnoxious! lemme out!!! | 883 | QFile(file).remove(); |
884 | } | ||
885 | exit(0); | ||
886 | |||
862 | } | 887 | } |
@@ -902 +927,14 @@ void TextEdit::editDelete() | |||
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 | |||
@@ -36,2 +36,3 @@ | |||
36 | 36 | ||
37 | class QAction; | ||
37 | class QWidgetStack; | 38 | class QWidgetStack; |
@@ -44,2 +45,3 @@ class FileSelector; | |||
44 | class QpeEditor; | 45 | class QpeEditor; |
46 | class QPopupMenu; | ||
45 | 47 | ||
@@ -52,3 +54,4 @@ public: | |||
52 | ~TextEdit(); | 54 | ~TextEdit(); |
53 | 55 | QPopupMenu *font; | |
56 | QAction *nStart; | ||
54 | void openFile( const QString & ); | 57 | void openFile( const QString & ); |
@@ -65,2 +68,3 @@ private slots: | |||
65 | void newFileOpen(); | 68 | void newFileOpen(); |
69 | void changeStartConfig(bool); | ||
66 | bool save(); | 70 | bool save(); |