summaryrefslogtreecommitdiff
path: root/core
authorbipolar <bipolar>2002-03-08 00:12:12 (UTC)
committer bipolar <bipolar>2002-03-08 00:12:12 (UTC)
commit11b56113b6641e0b85c6015eafab802dd7663198 (patch) (side-by-side diff)
tree1899707c9144a342519acf9693ec69d2d4edffc7 /core
parent50f8f55346f369787063f42c571d2dc832eb58aa (diff)
downloadopie-11b56113b6641e0b85c6015eafab802dd7663198.zip
opie-11b56113b6641e0b85c6015eafab802dd7663198.tar.gz
opie-11b56113b6641e0b85c6015eafab802dd7663198.tar.bz2
ljp: added startup option,a dn fixed save when closing with no file edited
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileSaver.cpp2
-rw-r--r--core/apps/textedit/textedit.cpp88
-rw-r--r--core/apps/textedit/textedit.h6
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
currentDir.setPath( QDir::currentDirPath() );
populateList();
move(0,15);
-
+ fileEdit->setFocus();
}
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 )
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();
- fileNew();
+ cfg.setGroup("View");
+ if(cfg.readEntry("startNew","TRUE") == "TRUE") {
+ nStart->setOn(TRUE);
+ fileNew();
+ } else {
+ fileOpen();
+ }
+
}
TextEdit::~TextEdit()
@@ -697,26 +710,34 @@ void TextEdit::showEditTools()
bool TextEdit::save()
{
QString file = doc->file();
+ qDebug(file);
QString name= doc->name();
-
+ qDebug(name);
QString rt = editor->text();
- currentFileName= name ;
- qDebug("saveFile "+currentFileName);
-
- struct stat buf;
- mode_t mode;
- stat(file.latin1(), &buf);
- mode = buf.st_mode;
+ if( !rt.isEmpty() ) {
+ if(name.isEmpty()) {
+ saveAs();
+ } else {
+ currentFileName= name ;
+ qDebug("saveFile "+currentFileName);
+
+ struct stat buf;
+ mode_t mode;
+ stat(file.latin1(), &buf);
+ mode = buf.st_mode;
+
+ doc->setName( name);
+ FileManager fm;
+ if ( !fm.saveFile( *doc, rt ) ) {
+ return false;
+ }
+ editor->setEdited( false );
- doc->setName( name);
- FileManager fm;
- if ( !fm.saveFile( *doc, rt ) ) {
- return false;
+ chmod( file.latin1(), mode);
+ }
+ return true;
}
- editor->setEdited( false );
-
- chmod( file.latin1(), mode);
- return true;
+ return false;
}
/*!
@@ -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);
@@ -855,10 +875,15 @@ void TextEdit::closeEvent( QCloseEvent *e )
}
void TextEdit::accept()
-{
- save();
- close();
-// fileOpen(); //godamn thats obnoxious! lemme out!!!
+ {
+ QString file = doc->file();
+ if (file.find("_.txt",0,TRUE) ==-1)
+ save();
+ 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();
+}
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 @@
#include <qlist.h>
#include <qmap.h>
+class QAction;
class QWidgetStack;
class QToolButton;
class QPopupMenu;
@@ -42,6 +43,7 @@ class QLineEdit;
class QAction;
class FileSelector;
class QpeEditor;
+class QPopupMenu;
class TextEdit : public QMainWindow
{
@@ -50,7 +52,8 @@ class TextEdit : public QMainWindow
public:
TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~TextEdit();
-
+ QPopupMenu *font;
+ QAction *nStart;
void openFile( const QString & );
protected:
@@ -63,6 +66,7 @@ private slots:
void fileRevert();
void fileOpen();
void newFileOpen();
+ void changeStartConfig(bool);
bool save();
bool saveAs();