summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp70
-rw-r--r--core/apps/textedit/textedit.h9
2 files changed, 53 insertions, 26 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 6844023..f3937b1 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -257,16 +257,18 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
257 257
258 QPEToolBar *bar = new QPEToolBar( this ); 258 QPEToolBar *bar = new QPEToolBar( this );
259 bar->setHorizontalStretchable( TRUE ); 259 bar->setHorizontalStretchable( TRUE );
260 menu = bar; 260 menu = bar;
261 261
262 QPEMenuBar *mb = new QPEMenuBar( bar ); 262 QPEMenuBar *mb = new QPEMenuBar( bar );
263 QPopupMenu *file = new QPopupMenu( this ); 263 QPopupMenu *file = new QPopupMenu( this );
264 QPopupMenu *edit = new QPopupMenu( this ); 264 QPopupMenu *edit = new QPopupMenu( this );
265 QPopupMenu *advancedMenu = new QPopupMenu(this);
266
265 font = new QPopupMenu( this ); 267 font = new QPopupMenu( this );
266 268
267 bar = new QPEToolBar( this ); 269 bar = new QPEToolBar( this );
268 editBar = bar; 270 editBar = bar;
269 271
270 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 272 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
271 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 273 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
272 a->addTo( bar ); 274 a->addTo( bar );
@@ -319,37 +321,46 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
319 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 321 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
320 zin->addTo( font ); 322 zin->addTo( font );
321 323
322 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 324 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
323 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 325 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
324 zout->addTo( font ); 326 zout->addTo( font );
325 327
326 font->insertSeparator(); 328 font->insertSeparator();
329// font->insertSeparator();
330 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
327 331
332 font->insertSeparator();
333 font->insertItem(tr("Advanced Features"), advancedMenu);
334
328 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); 335 QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 );
329 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 336 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
330 wa->setToggleAction(TRUE); 337 wa->setToggleAction(TRUE);
331 wa->addTo( font ); 338 wa->addTo( advancedMenu);
332
333 font->insertSeparator();
334 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
335
336 font->insertSeparator();
337 339
338 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); 340 nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 );
339 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); 341 connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) );
340 nStart->setToggleAction(TRUE); 342 nStart->setToggleAction(TRUE);
341 nStart->addTo( font ); 343 nStart->addTo( advancedMenu );
342 344
343 nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); 345 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 );
344 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); 346 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) );
345 nAdvanced->setToggleAction(TRUE); 347 nAdvanced->setToggleAction(TRUE);
346 nAdvanced->addTo( font ); 348 nAdvanced->addTo( advancedMenu );
349
350 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 );
351 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) );
352 desktopAction->setToggleAction(TRUE);
353 desktopAction->addTo( advancedMenu);
347 354
355 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 );
356 connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) );
357 filePermAction->setToggleAction(TRUE);
358 filePermAction->addTo( advancedMenu);
348 359
349 font->insertSeparator(); 360 font->insertSeparator();
350 361
351 font->insertItem(tr("About"), this, SLOT( doAbout()) ); 362 font->insertItem(tr("About"), this, SLOT( doAbout()) );
352 363
353 mb->insertItem( tr( "File" ), file ); 364 mb->insertItem( tr( "File" ), file );
354 mb->insertItem( tr( "Edit" ), edit ); 365 mb->insertItem( tr( "Edit" ), edit );
355 mb->insertItem( tr( "View" ), font ); 366 mb->insertItem( tr( "View" ), font );
@@ -381,54 +392,56 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
381 searchBar->hide(); 392 searchBar->hide();
382 393
383 editor = new QpeEditor( this ); 394 editor = new QpeEditor( this );
384 setCentralWidget( editor ); 395 setCentralWidget( editor );
385 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 396 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
386 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); 397 connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
387 398
388 Config cfg("TextEdit"); 399 Config cfg("TextEdit");
389 400 cfg. setGroup ( "Font" );
390 cfg. setGroup ( "Font" );
391 401
392 QFont defaultFont = editor-> font ( ); 402 QFont defaultFont = editor-> font ( );
393 403
394 QString family = cfg. readEntry ( "Family", defaultFont. family ( )); 404 QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
395 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); 405 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
396 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); 406 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
397 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); 407 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
398 408
399 defaultFont = QFont ( family, size, weight, italic ); 409 defaultFont = QFont ( family, size, weight, italic );
400 editor-> setFont ( defaultFont ); 410 editor-> setFont ( defaultFont );
401 411
402 updateCaption(); 412 updateCaption();
403 413
404 cfg.setGroup ( "View" ); 414 cfg.setGroup ( "View" );
405 415
406 useAdvancedFeatures = cfg. readBoolEntry ( "AdvancedFeatures", false ); 416 promptExit = cfg. readBoolEntry ( "PromptExit", false );
407 417 openDesktop = cfg. readBoolEntry ( "OpenDesktop", true );
408 if ( useAdvancedFeatures ) 418 filePerms = cfg. readBoolEntry ( "FilePermissions", false );
409 nAdvanced-> setOn ( true ); 419
410 420 if(promptExit ) nAdvanced->setOn ( true );
421 if(openDesktop) desktopAction->setOn ( true );
422 if(filePerms) filePermAction->setOn ( true );
423
411 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 424 bool wrap = cfg. readBoolEntry ( "Wrap", true );
412 wa-> setOn ( wrap ); 425 wa-> setOn ( wrap );
413 setWordWrap ( wrap ); 426 setWordWrap ( wrap );
414 427
415 if(cfg.readEntry("startNew","TRUE") == "TRUE") { 428 if(cfg.readEntry("startNew","TRUE") == "TRUE") {
416 nStart->setOn(TRUE); 429 nStart->setOn(TRUE);
417 fileNew(); 430 fileNew();
418 } else { 431 } else {
419 fileOpen(); 432 fileOpen();
420 } 433 }
421 434
422 viewSelection = cfg.readNumEntry( "FileView", 0 ); 435 viewSelection = cfg.readNumEntry( "FileView", 0 );
423} 436}
424 437
425TextEdit::~TextEdit() { 438TextEdit::~TextEdit() {
426 if( edited1 & !useAdvancedFeatures ) 439 if( edited1 & promptExit )
427 saveAs(); 440 saveAs();
428} 441}
429 442
430void TextEdit::cleanUp() { 443void TextEdit::cleanUp() {
431 qDebug("cleanUp");// save(); 444 qDebug("cleanUp");// save();
432 445
433 Config cfg ( "TextEdit" ); 446 Config cfg ( "TextEdit" );
434 cfg. setGroup ( "Font" ); 447 cfg. setGroup ( "Font" );
@@ -436,17 +449,20 @@ void TextEdit::cleanUp() {
436 cfg. writeEntry ( "Family", f. family ( )); 449 cfg. writeEntry ( "Family", f. family ( ));
437 cfg. writeEntry ( "Size", f. pointSize ( )); 450 cfg. writeEntry ( "Size", f. pointSize ( ));
438 cfg. writeEntry ( "Weight", f. weight ( )); 451 cfg. writeEntry ( "Weight", f. weight ( ));
439 cfg. writeEntry ( "Italic", f. italic ( )); 452 cfg. writeEntry ( "Italic", f. italic ( ));
440 453
441 cfg. setGroup ( "View" ); 454 cfg. setGroup ( "View" );
442 cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); 455 cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth );
443 cfg. writeEntry ( "FileView", viewSelection ); 456 cfg. writeEntry ( "FileView", viewSelection );
444 cfg. writeEntry ( "AdvancedFeatures", useAdvancedFeatures ); 457
458 cfg. writeEntry ( "PromptExit", promptExit );
459 cfg. writeEntry ( "OpenDesktop", openDesktop );
460 cfg. writeEntry ( "FilePermissions", filePerms );
445} 461}
446 462
447 463
448void TextEdit::accept() { 464void TextEdit::accept() {
449 if( edited1) 465 if( edited1)
450 saveAs(); 466 saveAs();
451 exit(0); 467 exit(0);
452} 468}
@@ -617,17 +633,17 @@ void TextEdit::newFile( const DocLnk &f ) {
617 updateCaption( currentFileName); 633 updateCaption( currentFileName);
618// editor->setEdited( FALSE); 634// editor->setEdited( FALSE);
619} 635}
620 636
621void TextEdit::openFile( const QString &f ) { 637void TextEdit::openFile( const QString &f ) {
622 qDebug("filename is "+ f); 638 qDebug("filename is "+ f);
623 QString filer; 639 QString filer;
624// bFromDocView = TRUE; 640// bFromDocView = TRUE;
625 if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { 641 if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) {
626 switch ( QMessageBox::warning(this,tr("Text Editor"), 642 switch ( QMessageBox::warning(this,tr("Text Editor"),
627 tr("Text Editor has detected<BR>you selected a <B>.desktop</B> 643 tr("Text Editor has detected<BR>you selected a <B>.desktop</B>
628file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), 644file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"),
629 tr(".desktop File"),tr("Linked Document"),0,1,1) ) { 645 tr(".desktop File"),tr("Linked Document"),0,1,1) ) {
630 case 0: 646 case 0:
631 filer = f; 647 filer = f;
632 break; 648 break;
633 case 1: 649 case 1:
@@ -818,17 +834,17 @@ bool TextEdit::saveAs() {
818 doc->setName( currentFileName); 834 doc->setName( currentFileName);
819 updateCaption( currentFileName); 835 updateCaption( currentFileName);
820 836
821 FileManager fm; 837 FileManager fm;
822 if ( !fm.saveFile( *doc, rt ) ) { 838 if ( !fm.saveFile( *doc, rt ) ) {
823 return false; 839 return false;
824 } 840 }
825 841
826 if( useAdvancedFeatures ) { 842 if( filePerms ) {
827 filePermissions *filePerm; 843 filePermissions *filePerm;
828 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); 844 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm);
829 filePerm->showMaximized(); 845 filePerm->showMaximized();
830 filePerm->exec(); 846 filePerm->exec();
831 847
832 if( filePerm) 848 if( filePerm)
833 delete filePerm; 849 delete filePerm;
834 } 850 }
@@ -942,18 +958,26 @@ void TextEdit::receive(const QCString&msg, const QByteArray&) {
942} 958}
943void TextEdit::doAbout() { 959void TextEdit::doAbout() {
944 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 960 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
945 "2000 Trolltech AS, and<BR>" 961 "2000 Trolltech AS, and<BR>"
946 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 962 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
947 "and is licensed under the GPL")); 963 "and is licensed under the GPL"));
948} 964}
949 965
950void TextEdit::doAdvanced(bool b) { 966void TextEdit::doPrompt(bool b) {
951 useAdvancedFeatures=b; 967 promptExit=b;
968}
969
970void TextEdit::doDesktop(bool b) {
971 openDesktop=b;
972}
973
974void TextEdit::doFilePerms(bool b) {
975 filePerms=b;
952} 976}
953 977
954void TextEdit::editPasteTimeDate() { 978void TextEdit::editPasteTimeDate() {
955#ifndef QT_NO_CLIPBOARD 979#ifndef QT_NO_CLIPBOARD
956 QClipboard *cb = QApplication::clipboard(); 980 QClipboard *cb = QApplication::clipboard();
957 QDateTime dt = QDateTime::currentDateTime(); 981 QDateTime dt = QDateTime::currentDateTime();
958 cb->setText( dt.toString()); 982 cb->setText( dt.toString());
959 editor->paste(); 983 editor->paste();
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index a2badaa..4848051 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -52,30 +52,32 @@ class TextEdit : public QMainWindow
52{ 52{
53 Q_OBJECT 53 Q_OBJECT
54 54
55public: 55public:
56 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 56 TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
57 ~TextEdit(); 57 ~TextEdit();
58 58
59 QPopupMenu *font; 59 QPopupMenu *font;
60 QAction *nStart, *nFileDlgOpt, *nAdvanced; 60 QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction;
61 bool edited, edited1; 61 bool edited, edited1;
62 void openFile( const QString & ); 62 void openFile( const QString & );
63 QCopChannel * channel; 63 QCopChannel * channel;
64public slots: 64public slots:
65 void editorChanged(); 65 void editorChanged();
66void receive(const QCString&, const QByteArray&); 66void receive(const QCString&, const QByteArray&);
67protected: 67protected:
68 bool fileIs, useAdvancedFeatures; 68 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms;
69 void closeEvent( QCloseEvent *e ); 69 void closeEvent( QCloseEvent *e );
70 void doSearchBar(); 70 void doSearchBar();
71private slots: 71private slots:
72 void editPasteTimeDate(); 72 void editPasteTimeDate();
73 void doAdvanced(bool); 73 void doPrompt(bool);
74 void doDesktop(bool);
75 void doFilePerms(bool);
74 void doAbout(); 76 void doAbout();
75 void setDocument(const QString&); 77 void setDocument(const QString&);
76 void changeFont(); 78 void changeFont();
77 void fileNew(); 79 void fileNew();
78 void fileRevert(); 80 void fileRevert();
79 void fileOpen(); 81 void fileOpen();
80 void changeStartConfig(bool); 82 void changeStartConfig(bool);
81 bool save(); 83 bool save();
@@ -111,16 +113,17 @@ private:
111 void updateCaption( const QString &name=QString::null ); 113 void updateCaption( const QString &name=QString::null );
112 void setFontSize(int sz, bool round_down_not_up); 114 void setFontSize(int sz, bool round_down_not_up);
113 115
114private: 116private:
115// fileSaver *fileSaveDlg; 117// fileSaver *fileSaveDlg;
116// fileBrowser *browseForFiles; 118// fileBrowser *browseForFiles;
117 QpeEditor* editor; 119 QpeEditor* editor;
118 QToolBar *menu, *editBar, *searchBar; 120 QToolBar *menu, *editBar, *searchBar;
121 QPopupMenu *advancedMenu;
119 QLineEdit *searchEdit; 122 QLineEdit *searchEdit;
120 DocLnk *doc; 123 DocLnk *doc;
121 bool searchVisible; 124 bool searchVisible;
122 bool bFromDocView; 125 bool bFromDocView;
123 int viewSelection; 126 int viewSelection;
124 QAction *zin, *zout; 127 QAction *zin, *zout;
125 QString currentFileName; 128 QString currentFileName;
126}; 129};