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 /core/apps | |
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 | |||
@@ -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 | ||
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 | } |
419 | 432 | ||
420 | TextEdit::~TextEdit() | 433 | TextEdit::~TextEdit() |
@@ -697,9 +710,14 @@ 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(); |
717 | if( !rt.isEmpty() ) { | ||
718 | if(name.isEmpty()) { | ||
719 | saveAs(); | ||
720 | } else { | ||
703 | currentFileName= name ; | 721 | currentFileName= name ; |
704 | qDebug("saveFile "+currentFileName); | 722 | qDebug("saveFile "+currentFileName); |
705 | 723 | ||
@@ -716,8 +734,11 @@ bool TextEdit::save() | |||
716 | editor->setEdited( false ); | 734 | editor->setEdited( false ); |
717 | 735 | ||
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 | ||
722 | /*! | 743 | /*! |
723 | prompted save */ | 744 | prompted save */ |
@@ -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 | ||
@@ -856,9 +876,14 @@ void TextEdit::closeEvent( QCloseEvent *e ) | |||
856 | 876 | ||
857 | void TextEdit::accept() | 877 | 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 | } |
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 | ||