-rw-r--r-- | core/apps/textedit/textedit.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index d61da2a..8eaafce 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -420,65 +420,67 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) cfg.setGroup("Font"); QString family = cfg.readEntry("Family", fontInfo.family()); QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 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(); } viewSelection = cfg.readNumEntry( "FileView", 0 ); } TextEdit::~TextEdit() { + if( edited1 & !useAdvancedFeatures ) + saveAs(); } void TextEdit::cleanUp() { -// save(); +qDebug("cleanUp");// save(); Config cfg("TextEdit"); cfg.setGroup("View"); QFont f = editor->font(); cfg.writeEntry("FontSize",f.pointSize()); cfg.writeEntry("Bold",f.bold()); cfg.writeEntry("Italic",f.italic()); cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); cfg.writeEntry( "FileView", viewSelection ); } void TextEdit::accept() { - if(edited1) + if( edited1) saveAs(); exit(0); } void TextEdit::zoomIn() { setFontSize(editor->font().pointSize()+1,FALSE); } void TextEdit::zoomOut() { setFontSize(editor->font().pointSize()-1,TRUE); } void TextEdit::setFontSize(int sz, bool round_down_not_up) { int s=10; for (int i=0; i<nfontsizes; i++) { if ( fontsize[i] == sz ) { s = sz; break; } else if ( round_down_not_up ) { if ( fontsize[i] < sz ) s = fontsize[i]; } else { if ( fontsize[i] > sz ) { @@ -614,61 +616,63 @@ void TextEdit::findClose() { void TextEdit::search() { editor->find( searchEdit->text(), FALSE, FALSE ); } void TextEdit::newFile( const DocLnk &f ) { DocLnk nf = f; nf.setType("text/plain"); clear(); setWState (WState_Reserved1 ); editor->setFocus(); doc = new DocLnk(nf); currentFileName = "Unnamed"; qDebug("newFile "+currentFileName); updateCaption( currentFileName); // editor->setEdited( FALSE); } void TextEdit::openFile( const QString &f ) { qDebug("filename is "+ f); QString filer; // bFromDocView = TRUE; if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { switch ( QMessageBox::warning(this,tr("Text Editor"), - tr("Text Editor has detected\n you selected a .desktop file.\nOpen .desktop file or linked file?"), + tr("Text Editor has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), tr(".desktop File"),tr("Linked Document"),0,1,1) ) { case 0: filer = f; break; case 1: DocLnk sf(f); filer = sf.file(); break; } } else { - filer = f; - fileIs = TRUE; + DocLnk sf(f); + filer = sf.file(); +// filer = f; +// fileIs = TRUE; } DocLnk nf; nf.setType("text/plain"); nf.setFile(filer); currentFileName=filer; QFileInfo fi( currentFileName); nf.setName(fi.baseName()); qDebug("openFile string "+currentFileName); openFile(nf); showEditTools(); // Show filename in caption QString name = filer; int sep = name.findRev( '/' ); if ( sep > 0 ) name = name.mid( sep+1 ); updateCaption( name ); } void TextEdit::openFile( const DocLnk &f ) { // clear(); // bFromDocView = TRUE; FileManager fm; @@ -716,49 +720,49 @@ bool TextEdit::save() { if(name.isEmpty()) { saveAs(); } else { currentFileName= name ; qDebug("saveFile "+currentFileName); struct stat buf; mode_t mode; stat(file.latin1(), &buf); mode = buf.st_mode; 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)) { QCString crt = rt.utf8(); f.writeBlock(crt,crt.length()); } else { - QMessageBox::message("Text Edit","Write Failed"); + QMessageBox::message(tr("Text Edit"),tr("Write Failed")); return false; } } editor->setEdited( FALSE); edited1=FALSE; edited=FALSE; if(caption().left(1)=="*") setCaption(caption().right(caption().length()-1)); chmod( file.latin1(), mode); } return true; } return false; } /*! prompted save */ bool TextEdit::saveAs() { qDebug("saveAsFile "+currentFileName); // case of nothing to save... if ( !doc ) { @@ -893,88 +897,88 @@ void TextEdit::changeFont() { FontDatabase fdb; QFont defaultFont=editor->font(); QFontInfo fontInfo(defaultFont); Config cfg("TextEdit"); cfg.setGroup("Font"); QString family = cfg.readEntry("Family", fontInfo.family()); QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); defaultFont = fdb.font(family,style,i_size,charSet); FontDialog *fontDlg; fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); fontDlg->exec(); QFont myFont=fontDlg->selectedFont; editor->setFont( myFont); delete fontDlg; } void TextEdit::editDelete() { - switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!"),tr("Yes"),tr("No"),0,0,1) ) { + switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) { case 0: if(doc) { doc->removeFiles(); clear(); 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(); } void TextEdit::editorChanged() { if(editor->edited() && edited && !edited1) { setCaption( "*"+caption()); edited1=TRUE; } edited=TRUE; } void TextEdit::receive(const QCString&msg, const QByteArray&) { qDebug("QCop "+msg); if ( msg == "setDocument(QString)" ) { qDebug("bugger all"); } } 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"); + QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" + "2000 Trolltech AS, and<BR>" + "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" + "and is licensed under the GPL")); } void TextEdit::doAdvanced(bool b) { useAdvancedFeatures=b; Config cfg("TextEdit"); cfg.setGroup("View"); cfg.writeEntry("AdvancedFeatures",b); } void TextEdit::editPasteTimeDate() { #ifndef QT_NO_CLIPBOARD QClipboard *cb = QApplication::clipboard(); QDateTime dt = QDateTime::currentDateTime(); cb->setText( dt.toString()); editor->paste(); #endif } |