summaryrefslogtreecommitdiff
path: root/core/apps
Unidiff
Diffstat (limited to 'core/apps') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp39
-rw-r--r--core/apps/textedit/textedit.h1
2 files changed, 28 insertions, 12 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index e978fa4..b199c81 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -234,25 +234,26 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
234 234
235#endif 235#endif
236 236
237 237
238static const int nfontsizes = 6; 238static const int nfontsizes = 6;
239static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; 239static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
240 240
241TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) 241TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
242 : QMainWindow( parent, name, f ), bFromDocView( false ) 242 : QMainWindow( parent, name, f ), bFromDocView( false )
243{ 243{
244 doc = 0; 244 doc = 0;
245 edited=false; 245 edited=false;
246 edited1=false; 246 fromSetDocument=false;
247
247 setToolBarsMovable( false ); 248 setToolBarsMovable( false );
248 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 249 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
249 250
250 channel = new QCopChannel( "QPE/Application/textedit", this ); 251 channel = new QCopChannel( "QPE/Application/textedit", this );
251 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 252 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
252 this, SLOT(receive(const QCString&, const QByteArray&)) ); 253 this, SLOT(receive(const QCString&, const QByteArray&)) );
253 254
254 setIcon( Resource::loadPixmap( "TextEditor" ) ); 255 setIcon( Resource::loadPixmap( "TextEditor" ) );
255 256
256 QPEToolBar *bar = new QPEToolBar( this ); 257 QPEToolBar *bar = new QPEToolBar( this );
257 bar->setHorizontalStretchable( true ); 258 bar->setHorizontalStretchable( true );
258 menu = bar; 259 menu = bar;
@@ -260,35 +261,36 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
260 QPEMenuBar *mb = new QPEMenuBar( bar ); 261 QPEMenuBar *mb = new QPEMenuBar( bar );
261 QPopupMenu *file = new QPopupMenu( this ); 262 QPopupMenu *file = new QPopupMenu( this );
262 QPopupMenu *edit = new QPopupMenu( this ); 263 QPopupMenu *edit = new QPopupMenu( this );
263 QPopupMenu *advancedMenu = new QPopupMenu(this); 264 QPopupMenu *advancedMenu = new QPopupMenu(this);
264 265
265 font = new QPopupMenu( this ); 266 font = new QPopupMenu( this );
266 267
267 bar = new QPEToolBar( this ); 268 bar = new QPEToolBar( this );
268 editBar = bar; 269 editBar = bar;
269 270
270 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 271 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
271 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 272 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
272 a->addTo( bar ); 273// a->addTo( bar );
273 a->addTo( file ); 274 a->addTo( file );
274 275
275 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 276 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
276 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 277 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
277 a->addTo( bar ); 278 a->addTo( bar );
278 a->addTo( file ); 279 a->addTo( file );
279 280
280 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 281 a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
281 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 282 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
282 file->insertSeparator(); 283 file->insertSeparator();
284 a->addTo( bar );
283 a->addTo( file ); 285 a->addTo( file );
284 286
285 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); 287 a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
286 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 288 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
287 a->addTo( file ); 289 a->addTo( file );
288 290
289 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); 291 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
290 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 292 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
291 a->addTo( editBar ); 293 a->addTo( editBar );
292 a->addTo( edit ); 294 a->addTo( edit );
293 295
294 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); 296 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
@@ -330,24 +332,25 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
330 font->insertSeparator(); 332 font->insertSeparator();
331 font->insertItem(tr("Advanced Features"), advancedMenu); 333 font->insertItem(tr("Advanced Features"), advancedMenu);
332 334
333 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 );
334 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); 336 connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) );
335 wa->setToggleAction(true); 337 wa->setToggleAction(true);
336 wa->addTo( advancedMenu); 338 wa->addTo( advancedMenu);
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( advancedMenu ); 343 nStart->addTo( advancedMenu );
344 nStart->setEnabled(false);
342 345
343 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); 346 nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 );
344 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); 347 connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) );
345 nAdvanced->setToggleAction(true); 348 nAdvanced->setToggleAction(true);
346 nAdvanced->addTo( advancedMenu ); 349 nAdvanced->addTo( advancedMenu );
347 350
348 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); 351 desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 );
349 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); 352 connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) );
350 desktopAction->setToggleAction(true); 353 desktopAction->setToggleAction(true);
351 desktopAction->addTo( advancedMenu); 354 desktopAction->addTo( advancedMenu);
352 355
353 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); 356 filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 );
@@ -427,43 +430,46 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
427 if(useSearchBar) searchBarAction->setOn(true); 430 if(useSearchBar) searchBarAction->setOn(true);
428 if(promptExit ) nAdvanced->setOn( true ); 431 if(promptExit ) nAdvanced->setOn( true );
429 if(openDesktop) desktopAction->setOn( true ); 432 if(openDesktop) desktopAction->setOn( true );
430 if(filePerms) filePermAction->setOn( true ); 433 if(filePerms) filePermAction->setOn( true );
431 if(startWithNew) nStart->setOn( true ); 434 if(startWithNew) nStart->setOn( true );
432 435
433 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 436 bool wrap = cfg. readBoolEntry ( "Wrap", true );
434 wa-> setOn ( wrap ); 437 wa-> setOn ( wrap );
435 setWordWrap ( wrap ); 438 setWordWrap ( wrap );
436 439
437 if( qApp->argc() > 1) { 440 if( qApp->argc() > 1) {
438 currentFileName=qApp->argv()[1]; 441 currentFileName=qApp->argv()[1];
439// qDebug("<<<<<<<<<<<<<<<<<<<<<<<< "+currentFileName+" %d",qApp->argc()); 442
440 QFileInfo fi(currentFileName); 443 QFileInfo fi(currentFileName);
441 444
442 if(fi.baseName().left(1) == "") { 445 if(fi.baseName().left(1) == "") {
443 openDotFile(currentFileName); 446 openDotFile(currentFileName);
444 } else { 447 } else {
445 openFile(currentFileName); 448 openFile(currentFileName);
446 } 449 }
447 } else { 450 } else {
448// qDebug("Do other thing"); 451 edited1=false;
449 if(startWithNew) { 452
453// if(startWithNew ) {
450 openDotFile(""); 454 openDotFile("");
451// fileNew(); 455// fileNew();
452 } else { 456// }
453 fileOpen(); 457// else {
454 } 458// fileOpen();
459// }
455 } 460 }
456 461
457 viewSelection = cfg.readNumEntry( "FileView", 0 ); 462 viewSelection = cfg.readNumEntry( "FileView", 0 );
463// setCaption(tr("Text Editor"));
458} 464}
459 465
460TextEdit::~TextEdit() { 466TextEdit::~TextEdit() {
461// qDebug("destr"); 467// qDebug("destr");
462} 468}
463 469
464void TextEdit::closeEvent(QCloseEvent *) { 470void TextEdit::closeEvent(QCloseEvent *) {
465// qDebug("closing here"); 471// qDebug("closing here");
466 if( edited1 && promptExit) 472 if( edited1 && promptExit)
467 saveAs(); 473 saveAs();
468 qApp->quit(); 474 qApp->quit();
469} 475}
@@ -817,24 +823,26 @@ bool TextEdit::save() {
817 823
818 824
819 chmod( file.latin1(), mode); 825 chmod( file.latin1(), mode);
820 } 826 }
821 return true; 827 return true;
822 } 828 }
823 return false; 829 return false;
824} 830}
825 831
826/*! 832/*!
827 prompted save */ 833 prompted save */
828bool TextEdit::saveAs() { 834bool TextEdit::saveAs() {
835 if(caption() == tr("Text Editor"))
836 return false;
829 qDebug("saveAsFile " + currentFileName); 837 qDebug("saveAsFile " + currentFileName);
830 // case of nothing to save... 838 // case of nothing to save...
831// if ( !doc && !currentFileName.isEmpty()) { 839// if ( !doc && !currentFileName.isEmpty()) {
832// //|| !bFromDocView) 840// //|| !bFromDocView)
833// qDebug("no doc"); 841// qDebug("no doc");
834// return true; 842// return true;
835// } 843// }
836// if ( !editor->edited() ) { 844// if ( !editor->edited() ) {
837// delete doc; 845// delete doc;
838// doc = 0; 846// doc = 0;
839// return true; 847// return true;
840// } 848// }
@@ -965,84 +973,91 @@ void TextEdit::setDocument(const QString& fileref) {
965 qDebug("setDocument"); 973 qDebug("setDocument");
966 QFileInfo fi(currentFileName); 974 QFileInfo fi(currentFileName);
967 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); 975 qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
968 if(fi.baseName().left(1) == "") { 976 if(fi.baseName().left(1) == "") {
969// openDotFile(currentFileName); 977// openDotFile(currentFileName);
970 } else { 978 } else {
971 qDebug("setDoc open"); 979 qDebug("setDoc open");
972 bFromDocView = true; 980 bFromDocView = true;
973 openFile(fileref); 981 openFile(fileref);
974 editor->setEdited(true); 982 editor->setEdited(true);
975 edited1=false; 983 edited1=false;
976 edited=true; 984 edited=true;
977 985 // fromSetDocument=false;
978// doSearchBar(); 986// doSearchBar();
979 } 987 }
980 } 988 }
981 updateCaption( currentFileName); 989 updateCaption( currentFileName);
982} 990}
983 991
984void TextEdit::changeFont() { 992void TextEdit::changeFont() {
985 QDialog *d = new QDialog ( this, "FontDialog", true ); 993 QDialog *d = new QDialog ( this, "FontDialog", true );
986 d-> setCaption ( tr( "Choose font" )); 994 d-> setCaption ( tr( "Choose font" ));
987 QBoxLayout *lay = new QVBoxLayout ( d ); 995 QBoxLayout *lay = new QVBoxLayout ( d );
988 OFontSelector *ofs = new OFontSelector ( true, d ); 996 OFontSelector *ofs = new OFontSelector ( true, d );
989 lay-> addWidget ( ofs ); 997 lay-> addWidget ( ofs );
990 ofs-> setSelectedFont ( editor-> font ( )); 998 ofs-> setSelectedFont ( editor-> font ( ));
991 999
992 d-> showMaximized ( ); 1000 d-> showMaximized ( );
993 if ( d-> exec ( ) == QDialog::Accepted ) 1001 if ( d-> exec ( ) == QDialog::Accepted )
994 editor-> setFont ( ofs-> selectedFont ( )); 1002 editor-> setFont ( ofs-> selectedFont ( ));
995 delete d; 1003 delete d;
996 1004
997} 1005}
998 1006
999void TextEdit::editDelete() { 1007void TextEdit::editDelete() {
1000 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) ) { 1008 switch ( QMessageBox::warning(this,tr("Text Editor"),
1009 tr("Do you really want<BR>to <B>delete</B> "
1010 "the current file\nfrom the disk?<BR>This is "
1011 "<B>irreversable!!</B>"),
1012 tr("Yes"),tr("No"),0,0,1) ) {
1001 case 0: 1013 case 0:
1002 if(doc) { 1014 if(doc) {
1003 doc->removeFiles(); 1015 doc->removeFiles();
1004 clear(); 1016 clear();
1005 setCaption( tr("Text Editor") ); 1017 setCaption( tr("Text Editor") );
1006 } 1018 }
1007 break; 1019 break;
1008 case 1: 1020 case 1:
1009 // exit 1021 // exit
1010 break; 1022 break;
1011 }; 1023 };
1012} 1024}
1013 1025
1014void TextEdit::changeStartConfig( bool b ) { 1026void TextEdit::changeStartConfig( bool b ) {
1015 startWithNew=b; 1027 startWithNew=b;
1016 Config cfg("TextEdit"); 1028 Config cfg("TextEdit");
1017 cfg.setGroup("View"); 1029 cfg.setGroup("View");
1018 cfg.writeEntry("startNew",b); 1030 cfg.writeEntry("startNew",b);
1019 update(); 1031 update();
1020} 1032}
1021 1033
1022void TextEdit::editorChanged() { 1034void TextEdit::editorChanged() {
1023 if(editor->edited() && edited && !edited1) { 1035// qDebug("editor changed");
1036 if( /*editor->edited() &&*/ /*edited && */!edited1) {
1024 setCaption( "*"+caption()); 1037 setCaption( "*"+caption());
1025 edited1=true; 1038 edited1=true;
1026 } 1039 }
1027 edited=true; 1040 edited=true;
1028} 1041}
1029 1042
1030void TextEdit::receive(const QCString&msg, const QByteArray&) { 1043void TextEdit::receive(const QCString&msg, const QByteArray &data) {
1031 qDebug("QCop "+msg); 1044 qDebug("QCop "+msg);
1032 if ( msg == "setDocument(QString)" ) { 1045 if ( msg == "setDocument(QString)" ) {
1033 qDebug("bugger all"); 1046 qDebug("bugger all");
1047
1034 } 1048 }
1035 1049
1036} 1050}
1051
1037void TextEdit::doAbout() { 1052void TextEdit::doAbout() {
1038 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" 1053 QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
1039 "2000 Trolltech AS, and<BR>" 1054 "2000 Trolltech AS, and<BR>"
1040 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" 1055 "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
1041 "and is licensed under the GPL")); 1056 "and is licensed under the GPL"));
1042} 1057}
1043 1058
1044void TextEdit::doPrompt(bool b) { 1059void TextEdit::doPrompt(bool b) {
1045 promptExit=b; 1060 promptExit=b;
1046 Config cfg("TextEdit"); 1061 Config cfg("TextEdit");
1047 cfg.setGroup ( "View" ); 1062 cfg.setGroup ( "View" );
1048 cfg.writeEntry ( "PromptExit", b); 1063 cfg.writeEntry ( "PromptExit", b);
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index bb7d693..9f16ebf 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -107,24 +107,25 @@ private slots:
107 void setWordWrap(bool y); 107 void setWordWrap(bool y);
108 void setSearchBar(bool); 108 void setSearchBar(bool);
109 109
110private: 110private:
111 void openDotFile(const QString &); 111 void openDotFile(const QString &);
112 void colorChanged( const QColor &c ); 112 void colorChanged( const QColor &c );
113 void clear(); 113 void clear();
114 void updateCaption( const QString &name=QString::null ); 114 void updateCaption( const QString &name=QString::null );
115 void setFontSize(int sz, bool round_down_not_up); 115 void setFontSize(int sz, bool round_down_not_up);
116private: 116private:
117// fileSaver *fileSaveDlg; 117// fileSaver *fileSaveDlg;
118// fileBrowser *browseForFiles; 118// fileBrowser *browseForFiles;
119 bool fromSetDocument;
119 QpeEditor* editor; 120 QpeEditor* editor;
120 QToolBar *menu, *editBar, *searchBar; 121 QToolBar *menu, *editBar, *searchBar;
121 QPopupMenu *advancedMenu; 122 QPopupMenu *advancedMenu;
122 QLineEdit *searchEdit; 123 QLineEdit *searchEdit;
123 DocLnk *doc; 124 DocLnk *doc;
124 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew; 125 bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew;
125 bool bFromDocView; 126 bool bFromDocView;
126 int viewSelection; 127 int viewSelection;
127 QAction *zin, *zout; 128 QAction *zin, *zout;
128 QString currentFileName; 129 QString currentFileName;
129}; 130};
130 131