From 29e4dd18cbbe6d5967561b428a9632629cff3fde Mon Sep 17 00:00:00 2001 From: llornkcor Date: Wed, 24 Apr 2002 01:00:52 +0000 Subject: changed way of saving files, so a file opened through the file dialog, which is not a DocLnk, gets saved without a DocLnk. I got tired of hearing, 'I edited /etc/so-and-so and it saved it to Documents.' Will make this an option later. :) --- diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 84888c1..19449cb 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -350,6 +350,8 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); nStart->setToggleAction(TRUE); nStart->addTo( font ); + font->insertSeparator(); + font->insertItem(tr("About"), this, SLOT( doAbout()) ); mb->insertItem( tr( "File" ), file ); mb->insertItem( tr( "Edit" ), edit ); @@ -412,6 +414,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) } else { fileOpen(); } + viewSelection = cfg.readNumEntry( "FileView", 0 ); } @@ -504,7 +507,7 @@ void TextEdit::fileOpen() Config cfg("TextEdit"); cfg.setGroup("View"); bool b=FALSE; - if(cfg.readEntry("useOldFileDialog") == "TRUE") + if(cfg.readEntry("useOldFileDialog") == "TRUE") b=TRUE; if(!b) { QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this ); @@ -530,11 +533,11 @@ void TextEdit::fileOpen() if( fileName != "Unnamed" || fileName != "Empty Text" ) { currentFileName = fileName; qDebug("please open "+currentFileName); - openFile(str ); + openFile(currentFileName ); } } viewSelection = browseForFiles->SelectionCombo->currentItem(); - } + } delete browseForFiles; editor->setEdited( FALSE); edited1=FALSE; @@ -663,8 +666,10 @@ void TextEdit::openFile( const QString &f ) filer = sf.file(); break; } - } else + } else { filer = f; + fileIs = TRUE; + } DocLnk nf; nf.setType("text/plain"); @@ -742,11 +747,22 @@ bool TextEdit::save() mode_t mode; stat(file.latin1(), &buf); mode = buf.st_mode; - - doc->setName( name); - FileManager fm; - if ( !fm.saveFile( *doc, rt ) ) { - return false; + if(!fileIs) { + doc->setName( name); + FileManager fm; + if ( !fm.saveFile( *doc, rt ) ) { + return false; + } + } else { + qDebug("regular save file"); + QFile f(file); + if( f.open(IO_WriteOnly)) { + f.writeBlock(rt,rt.length()); + } else { + QMessageBox::message("Text Edit","Write Failed"); + return false; + } + } editor->setEdited( FALSE); edited1=FALSE; @@ -969,3 +985,9 @@ void TextEdit::receive(const QCString&msg, const QByteArray&) { } } +void TextEdit::doAbout() { + QMessageBox::about(0,"Text Edit","Text Edit is copyright\n" + "2000 Trolltech AS, and\n" + "2002 by L.J.Potter \nljp@llornkcor.com\n" + "and is licensed under the GPL"); +} diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index edc6fe3..9d27ab0 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h @@ -65,9 +65,11 @@ public slots: void editorChanged(); void receive(const QCString&, const QByteArray&); protected: + bool fileIs; void closeEvent( QCloseEvent *e ); void doSearchBar(); private slots: + void doAbout(); void setDocument(const QString&); void changeFont(); void fileNew(); -- cgit v0.9.0.2