Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 52 |
1 files changed, 45 insertions, 7 deletions
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 ) QPEMenuBar *mb = new QPEMenuBar( bar ); QPopupMenu *file = new QPopupMenu( this ); QPopupMenu *edit = new QPopupMenu( this ); - QPopupMenu *font = new QPopupMenu( this ); + font = new QPopupMenu( this ); bar = new QPEToolBar( this ); editBar = bar; @@ -349,6 +349,12 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) font->insertSeparator(); font->insertItem("Font", this, SLOT(changeFont()) ); + font->insertSeparator(); + nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); + connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); + nStart->setToggleAction(TRUE); + nStart->addTo( font ); + mb->insertItem( tr( "File" ), file ); mb->insertItem( tr( "Edit" ), edit ); mb->insertItem( tr( "View" ), font ); @@ -414,7 +420,14 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) wa->setOn(wrap); updateCaption(); + cfg.setGroup("View"); + if(cfg.readEntry("startNew","TRUE") == "TRUE") { + nStart->setOn(TRUE); fileNew(); + } else { + fileOpen(); + } + } TextEdit::~TextEdit() @@ -697,9 +710,14 @@ void TextEdit::showEditTools() bool TextEdit::save() { QString file = doc->file(); + qDebug(file); QString name= doc->name(); - + qDebug(name); QString rt = editor->text(); + if( !rt.isEmpty() ) { + if(name.isEmpty()) { + saveAs(); + } else { currentFileName= name ; qDebug("saveFile "+currentFileName); @@ -716,8 +734,11 @@ bool TextEdit::save() editor->setEdited( false ); chmod( file.latin1(), mode); + } return true; } + return false; +} /*! prompted save */ @@ -763,7 +784,7 @@ bool TextEdit::saveAs() } - fileSaveDlg=new fileSaver(this,"Save File",TRUE, 0, currentFileName); + fileSaveDlg=new fileSaver(this,"Save File As?",TRUE, 0, currentFileName); qDebug("wanna save filename "+currentFileName); fileSaveDlg->exec(); if( fileSaveDlg->result() == 1 ) { @@ -772,7 +793,6 @@ bool TextEdit::saveAs() QFileInfo fi(fileNm); currentFileName=fi.fileName(); if(doc) { - qDebug("doclnk exists"); // QString file = doc->file(); // doc->removeFiles(); delete doc; @@ -781,7 +801,7 @@ bool TextEdit::saveAs() nf.setFile( fileNm); doc = new DocLnk(nf); // editor->setText(rt); - qDebug("openFile doclnk "+currentFileName); +// qDebug("openFile doclnk "+currentFileName); doc->setName( currentFileName); updateCaption( currentFileName); @@ -856,9 +876,14 @@ void TextEdit::closeEvent( QCloseEvent *e ) void TextEdit::accept() { + QString file = doc->file(); + if (file.find("_.txt",0,TRUE) ==-1) save(); - close(); -// fileOpen(); //godamn thats obnoxious! lemme out!!! + else { + QFile(file).remove(); + } + exit(0); + } void TextEdit::changeFont() { @@ -900,3 +925,16 @@ void TextEdit::editDelete() break; }; } + +void TextEdit::changeStartConfig( bool b ) { + + Config cfg("TextEdit"); + cfg.setGroup("View"); + if(b) { + qDebug("bool"); + cfg.writeEntry("startNew","TRUE"); + } else { + cfg.writeEntry("startNew","FALSE"); + } + update(); +} |