summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/fileSaver.cpp2
-rw-r--r--core/apps/textedit/textedit.cpp52
-rw-r--r--core/apps/textedit/textedit.h6
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
@@ -70,17 +70,17 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl
connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
// tmpFileName=fi.FilePath();
// qDebug( tmpFileName);
currentDir.setPath( QDir::currentDirPath() );
populateList();
move(0,15);
-
+ fileEdit->setFocus();
}
fileSaver::~fileSaver()
{
}
void fileSaver::populateList()
{
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
@@ -247,17 +247,17 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
menu = bar;
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;
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
a->addTo( bar );
a->addTo( file );
@@ -344,16 +344,22 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
wa->setToggleAction(TRUE);
wa->addTo( font );
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 );
searchBar = new QPEToolBar(this);
addToolBar( searchBar, "Search", QMainWindow::Top, TRUE );
searchBar->setHorizontalStretchable( TRUE );
@@ -409,17 +415,24 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
defaultFont = fdb.font(family,style,i_size,charSet);
editor->setFont( defaultFont);
wa->setOn(wrap);
updateCaption();
+ cfg.setGroup("View");
+ if(cfg.readEntry("startNew","TRUE") == "TRUE") {
+ nStart->setOn(TRUE);
fileNew();
+ } else {
+ fileOpen();
+ }
+
}
TextEdit::~TextEdit()
{
// save();
Config cfg("TextEdit");
cfg.setGroup("View");
@@ -692,37 +705,45 @@ void TextEdit::showEditTools()
setWState (WState_Reserved1 );
}
/*!
unprompted save */
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);
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 );
chmod( file.latin1(), mode);
+ }
return true;
}
+ return false;
+}
/*!
prompted save */
bool TextEdit::saveAs()
{
// qDebug("saveAsFile "+currentFileName);
// case of nothing to save... /// there's always something to save
@@ -758,35 +779,34 @@ bool TextEdit::saveAs()
if ( docname.isEmpty() )
docname = "Unnamed";
doc->setName(docname);
currentFileName=docname;
}
}
- 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 ) {
QString fileNm=fileSaveDlg->selectedFileName;
qDebug("saving filename "+fileNm);
QFileInfo fi(fileNm);
currentFileName=fi.fileName();
if(doc) {
- qDebug("doclnk exists");
// QString file = doc->file();
// doc->removeFiles();
delete doc;
DocLnk nf;
nf.setType("text/plain");
nf.setFile( fileNm);
doc = new DocLnk(nf);
// editor->setText(rt);
- qDebug("openFile doclnk "+currentFileName);
+// qDebug("openFile doclnk "+currentFileName);
doc->setName( currentFileName);
updateCaption( currentFileName);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
return false;
}
if( fileSaveDlg->filePermCheck->isChecked() ) {
@@ -851,19 +871,24 @@ void TextEdit::closeEvent( QCloseEvent *e )
} else {
bFromDocView = FALSE;
e->accept();
}
}
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() {
FontDatabase fdb;
QFont defaultFont=editor->font();
QFontInfo fontInfo(defaultFont);
Config cfg("TextEdit");
cfg.setGroup("Font");
@@ -895,8 +920,21 @@ void TextEdit::editDelete()
setCaption( tr("Text Editor") );
}
break;
case 1:
// exit
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
@@ -29,45 +29,49 @@
#include <qpe/filemanager.h>
#include <qmainwindow.h>
#include <qmultilineedit.h>
#include <qlist.h>
#include <qmap.h>
+class QAction;
class QWidgetStack;
class QToolButton;
class QPopupMenu;
class QToolBar;
class QLineEdit;
class QAction;
class FileSelector;
class QpeEditor;
+class QPopupMenu;
class TextEdit : public QMainWindow
{
Q_OBJECT
public:
TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~TextEdit();
-
+ QPopupMenu *font;
+ QAction *nStart;
void openFile( const QString & );
protected:
void closeEvent( QCloseEvent *e );
private slots:
void setDocument(const QString&);
void changeFont();
void fileNew();
void fileRevert();
void fileOpen();
void newFileOpen();
+ void changeStartConfig(bool);
bool save();
bool saveAs();
void editCut();
void editCopy();
void editPaste();
void editFind();