summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-02-06 03:49:06 (UTC)
committer llornkcor <llornkcor>2005-02-06 03:49:06 (UTC)
commitb09f9ce74d40f47bc336b4647c6c091a4f3bd5b6 (patch) (unidiff)
tree212816ea85f372b28c22c85b3dbf1e6d4dcfa887
parentd0af8c31f8c74d8aa90477ad672dd876b661eba1 (diff)
downloadopie-b09f9ce74d40f47bc336b4647c6c091a4f3bd5b6.zip
opie-b09f9ce74d40f47bc336b4647c6c091a4f3bd5b6.tar.gz
opie-b09f9ce74d40f47bc336b4647c6c091a4f3bd5b6.tar.bz2
fix #1472 - no prompt on esc exit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp49
1 files changed, 26 insertions, 23 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index c7273c5..26b907b 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -163,541 +163,544 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
163 fromSetDocument=false; 163 fromSetDocument=false;
164 164
165 setToolBarsMovable( false ); 165 setToolBarsMovable( false );
166 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 166 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
167 167
168 channel = new QCopChannel( "QPE/Application/textedit", this ); 168 channel = new QCopChannel( "QPE/Application/textedit", this );
169 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 169 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
170 this, SLOT(receive(const QCString&,const QByteArray&)) ); 170 this, SLOT(receive(const QCString&,const QByteArray&)) );
171 171
172 setIcon( Resource::loadPixmap( "TextEditor" ) ); 172 setIcon( Resource::loadPixmap( "TextEditor" ) );
173 173
174 QToolBar *bar = new QToolBar( this ); 174 QToolBar *bar = new QToolBar( this );
175 bar->setHorizontalStretchable( true ); 175 bar->setHorizontalStretchable( true );
176 menu = bar; 176 menu = bar;
177 177
178 QMenuBar *mb = new QMenuBar( bar ); 178 QMenuBar *mb = new QMenuBar( bar );
179 QPopupMenu *file = new QPopupMenu( this ); 179 QPopupMenu *file = new QPopupMenu( this );
180 QPopupMenu *edit = new QPopupMenu( this ); 180 QPopupMenu *edit = new QPopupMenu( this );
181 QPopupMenu *advancedMenu = new QPopupMenu(this); 181 QPopupMenu *advancedMenu = new QPopupMenu(this);
182 182
183 font = new QPopupMenu( this ); 183 font = new QPopupMenu( this );
184 184
185 bar = new QToolBar( this ); 185 bar = new QToolBar( this );
186 editBar = bar; 186 editBar = bar;
187 187
188 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), 188 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ),
189 QString::null, 0, this, 0 ); 189 QString::null, 0, this, 0 );
190 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 190 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
191// a->addTo( bar ); 191// a->addTo( bar );
192 a->addTo( file ); 192 a->addTo( file );
193 193
194 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), 194 a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ),
195 QString::null, 0, this, 0 ); 195 QString::null, 0, this, 0 );
196 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 196 connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
197 a->addTo( bar ); 197 a->addTo( bar );
198 a->addTo( file ); 198 a->addTo( file );
199 199
200 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , 200 a = new QAction( tr( "Save" ), Resource::loadPixmap("save") ,
201 QString::null, 0, this, 0 ); 201 QString::null, 0, this, 0 );
202 connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); 202 connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
203 file->insertSeparator(); 203 file->insertSeparator();
204 a->addTo( bar ); 204 a->addTo( bar );
205 a->addTo( file ); 205 a->addTo( file );
206 206
207 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , 207 a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") ,
208 QString::null, 0, this, 0 ); 208 QString::null, 0, this, 0 );
209 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); 209 connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
210 a->addTo( file ); 210 a->addTo( file );
211 211
212 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), 212 a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ),
213 QString::null, 0, this, 0 ); 213 QString::null, 0, this, 0 );
214 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 214 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
215 a->addTo( editBar ); 215 a->addTo( editBar );
216 a->addTo( edit ); 216 a->addTo( edit );
217 217
218 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), 218 a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ),
219 QString::null, 0, this, 0 ); 219 QString::null, 0, this, 0 );
220 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 220 connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
221 a->addTo( editBar ); 221 a->addTo( editBar );
222 a->addTo( edit ); 222 a->addTo( edit );
223 223
224 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), 224 a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ),
225 QString::null, 0, this, 0 ); 225 QString::null, 0, this, 0 );
226 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 226 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
227 a->addTo( editBar ); 227 a->addTo( editBar );
228 a->addTo( edit ); 228 a->addTo( edit );
229 229
230 230
231#ifndef QT_NO_CLIPBOARD 231#ifndef QT_NO_CLIPBOARD
232 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), 232 a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ),
233 QString::null, 0, this, 0 ); 233 QString::null, 0, this, 0 );
234 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); 234 connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) );
235 a->addTo( edit ); 235 a->addTo( edit );
236#endif 236#endif
237 237
238 a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), 238 a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ),
239 QString::null, 0, this, 0 ); 239 QString::null, 0, this, 0 );
240 connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); 240 connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) );
241 edit->insertSeparator(); 241 edit->insertSeparator();
242 a->addTo( edit ); 242 a->addTo( edit );
243 243
244 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), 244 a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ),
245 QString::null, 0, this, 0 ); 245 QString::null, 0, this, 0 );
246 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); 246 connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) );
247 a->addTo( bar ); 247 a->addTo( bar );
248 a->addTo( edit ); 248 a->addTo( edit );
249 249
250 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); 250 zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 );
251 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); 251 connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) );
252 zin->addTo( font ); 252 zin->addTo( font );
253 253
254 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); 254 zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 );
255 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); 255 connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) );
256 zout->addTo( font ); 256 zout->addTo( font );
257 257
258 font->insertSeparator(); 258 font->insertSeparator();
259 259
260 font->insertItem(tr("Font"), this, SLOT(changeFont()) ); 260 font->insertItem(tr("Font"), this, SLOT(changeFont()) );
261 261
262 font->insertSeparator(); 262 font->insertSeparator();
263 font->insertItem(tr("Advanced Features"), advancedMenu); 263 font->insertItem(tr("Advanced Features"), advancedMenu);
264 264
265 QAction *wa = new QAction( tr("Wrap lines"), 265 QAction *wa = new QAction( tr("Wrap lines"),
266 QString::null, 0, this, 0 ); 266 QString::null, 0, this, 0 );
267 connect( wa, SIGNAL( toggled(bool) ), 267 connect( wa, SIGNAL( toggled(bool) ),
268 this, SLOT( setWordWrap(bool) ) ); 268 this, SLOT( setWordWrap(bool) ) );
269 wa->setToggleAction(true); 269 wa->setToggleAction(true);
270 wa->addTo( advancedMenu); 270 wa->addTo( advancedMenu);
271 271
272 nStart = new QAction( tr("Start with new file"), 272 nStart = new QAction( tr("Start with new file"),
273 QString::null, 0, this, 0 ); 273 QString::null, 0, this, 0 );
274 connect( nStart, SIGNAL( toggled(bool) ), 274 connect( nStart, SIGNAL( toggled(bool) ),
275 this, SLOT( changeStartConfig(bool) ) ); 275 this, SLOT( changeStartConfig(bool) ) );
276 nStart->setToggleAction(true); 276 nStart->setToggleAction(true);
277 nStart->addTo( advancedMenu ); 277 nStart->addTo( advancedMenu );
278 nStart->setEnabled(false); 278 nStart->setEnabled(false);
279 279
280 nAdvanced = new QAction( tr("Prompt on Exit"), 280 nAdvanced = new QAction( tr("Prompt on Exit"),
281 QString::null, 0, this, 0 ); 281 QString::null, 0, this, 0 );
282 connect( nAdvanced, SIGNAL( toggled(bool) ), 282 connect( nAdvanced, SIGNAL( toggled(bool) ),
283 this, SLOT( doPrompt(bool) ) ); 283 this, SLOT( doPrompt(bool) ) );
284 nAdvanced->setToggleAction(true); 284 nAdvanced->setToggleAction(true);
285 nAdvanced->addTo( advancedMenu ); 285 nAdvanced->addTo( advancedMenu );
286 286
287 desktopAction = new QAction( tr("Always open linked file"), 287 desktopAction = new QAction( tr("Always open linked file"),
288 QString::null, 0, this, 0 ); 288 QString::null, 0, this, 0 );
289 connect( desktopAction, SIGNAL( toggled(bool) ), 289 connect( desktopAction, SIGNAL( toggled(bool) ),
290 this, SLOT( doDesktop(bool) ) ); 290 this, SLOT( doDesktop(bool) ) );
291 desktopAction->setToggleAction(true); 291 desktopAction->setToggleAction(true);
292 desktopAction->addTo( advancedMenu); 292 desktopAction->addTo( advancedMenu);
293 293
294 filePermAction = new QAction( tr("File Permissions"), 294 filePermAction = new QAction( tr("File Permissions"),
295 QString::null, 0, this, 0 ); 295 QString::null, 0, this, 0 );
296 connect( filePermAction, SIGNAL( toggled(bool) ), 296 connect( filePermAction, SIGNAL( toggled(bool) ),
297 this, SLOT( doFilePerms(bool) ) ); 297 this, SLOT( doFilePerms(bool) ) );
298 filePermAction->setToggleAction(true); 298 filePermAction->setToggleAction(true);
299 filePermAction->addTo( advancedMenu); 299 filePermAction->addTo( advancedMenu);
300 300
301 searchBarAction = new QAction( tr("Search Bar Open"), 301 searchBarAction = new QAction( tr("Search Bar Open"),
302 QString::null, 0, this, 0 ); 302 QString::null, 0, this, 0 );
303 connect( searchBarAction, SIGNAL( toggled(bool) ), 303 connect( searchBarAction, SIGNAL( toggled(bool) ),
304 this, SLOT( setSearchBar(bool) ) ); 304 this, SLOT( setSearchBar(bool) ) );
305 searchBarAction->setToggleAction(true); 305 searchBarAction->setToggleAction(true);
306 searchBarAction->addTo( advancedMenu); 306 searchBarAction->addTo( advancedMenu);
307 307
308 nAutoSave = new QAction( tr("Auto Save 5 min."), 308 nAutoSave = new QAction( tr("Auto Save 5 min."),
309 QString::null, 0, this, 0 ); 309 QString::null, 0, this, 0 );
310 connect( nAutoSave, SIGNAL( toggled(bool) ), 310 connect( nAutoSave, SIGNAL( toggled(bool) ),
311 this, SLOT( doTimer(bool) ) ); 311 this, SLOT( doTimer(bool) ) );
312 nAutoSave->setToggleAction(true); 312 nAutoSave->setToggleAction(true);
313 nAutoSave->addTo( advancedMenu); 313 nAutoSave->addTo( advancedMenu);
314 314
315 315
316 //font->insertSeparator(); 316 //font->insertSeparator();
317 317
318 //font->insertItem(tr("About"), this, SLOT( doAbout()) ); 318 //font->insertItem(tr("About"), this, SLOT( doAbout()) );
319 319
320 mb->insertItem( tr( "File" ), file ); 320 mb->insertItem( tr( "File" ), file );
321 mb->insertItem( tr( "Edit" ), edit ); 321 mb->insertItem( tr( "Edit" ), edit );
322 mb->insertItem( tr( "View" ), font ); 322 mb->insertItem( tr( "View" ), font );
323 323
324 searchBar = new QToolBar(this); 324 searchBar = new QToolBar(this);
325 addToolBar( searchBar, "Search", QMainWindow::Top, true ); 325 addToolBar( searchBar, "Search", QMainWindow::Top, true );
326 326
327 searchBar->setHorizontalStretchable( true ); 327 searchBar->setHorizontalStretchable( true );
328 328
329 searchEdit = new QLineEdit( searchBar, "searchEdit" ); 329 searchEdit = new QLineEdit( searchBar, "searchEdit" );
330 searchBar->setStretchableWidget( searchEdit ); 330 searchBar->setStretchableWidget( searchEdit );
331 connect( searchEdit, SIGNAL( textChanged(const QString&) ), 331 connect( searchEdit, SIGNAL( textChanged(const QString&) ),
332 this, SLOT( search() ) ); 332 this, SLOT( search() ) );
333 333
334 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), 334 a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ),
335 QString::null, 0, this, 0 ); 335 QString::null, 0, this, 0 );
336 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); 336 connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) );
337 a->addTo( searchBar ); 337 a->addTo( searchBar );
338 a->addTo( edit ); 338 a->addTo( edit );
339 339
340 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), 340 a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ),
341 QString::null, 0, this, 0 ); 341 QString::null, 0, this, 0 );
342 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); 342 connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
343 a->addTo( searchBar ); 343 a->addTo( searchBar );
344 344
345 edit->insertSeparator(); 345 edit->insertSeparator();
346 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), 346 a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ),
347 QString::null, 0, this, 0 ); 347 QString::null, 0, this, 0 );
348 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); 348 connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) );
349 a->addTo( edit ); 349 a->addTo( edit );
350 350
351 searchBar->hide(); 351 searchBar->hide();
352 352
353 editor = new QpeEditor( this ); 353 editor = new QpeEditor( this );
354 setCentralWidget( editor ); 354 setCentralWidget( editor );
355 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 355 editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
356 connect( editor, SIGNAL( textChanged() ), 356 connect( editor, SIGNAL( textChanged() ),
357 this, SLOT( editorChanged() ) ); 357 this, SLOT( editorChanged() ) );
358 358
359 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); 359 QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold);
360 360
361 Config cfg("TextEdit"); 361 Config cfg("TextEdit");
362 cfg. setGroup ( "Font" ); 362 cfg. setGroup ( "Font" );
363 363
364 QFont defaultFont = editor-> font ( ); 364 QFont defaultFont = editor-> font ( );
365 365
366 QString family = cfg. readEntry ( "Family", defaultFont. family ( )); 366 QString family = cfg. readEntry ( "Family", defaultFont. family ( ));
367 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); 367 int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( ));
368 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); 368 int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( ));
369 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); 369 bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( ));
370 370
371 defaultFont = QFont ( family, size, weight, italic ); 371 defaultFont = QFont ( family, size, weight, italic );
372 editor-> setFont ( defaultFont ); 372 editor-> setFont ( defaultFont );
373// updateCaption(); 373// updateCaption();
374 374
375 cfg.setGroup ( "View" ); 375 cfg.setGroup ( "View" );
376 376
377 promptExit = cfg.readBoolEntry ( "PromptExit", false ); 377 promptExit = cfg.readBoolEntry ( "PromptExit", false );
378 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); 378 openDesktop = cfg.readBoolEntry ( "OpenDesktop", true );
379 filePerms = cfg.readBoolEntry ( "FilePermissions", false ); 379 filePerms = cfg.readBoolEntry ( "FilePermissions", false );
380 useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); 380 useSearchBar = cfg.readBoolEntry ( "SearchBar", false );
381 startWithNew = cfg.readBoolEntry ( "startNew", true); 381 startWithNew = cfg.readBoolEntry ( "startNew", true);
382 featureAutoSave = cfg.readBoolEntry( "autosave", false); 382 featureAutoSave = cfg.readBoolEntry( "autosave", false);
383 383
384 if(useSearchBar) searchBarAction->setOn(true); 384 if(useSearchBar) searchBarAction->setOn(true);
385 if(promptExit) nAdvanced->setOn( true ); 385 if(promptExit) nAdvanced->setOn( true );
386 if(openDesktop) desktopAction->setOn( true ); 386 if(openDesktop) desktopAction->setOn( true );
387 if(filePerms) filePermAction->setOn( true ); 387 if(filePerms) filePermAction->setOn( true );
388 if(startWithNew) nStart->setOn( true ); 388 if(startWithNew) nStart->setOn( true );
389 if(featureAutoSave) nAutoSave->setOn(true); 389 if(featureAutoSave) nAutoSave->setOn(true);
390 390
391// { 391// {
392// doTimer(true); 392// doTimer(true);
393// } 393// }
394 394
395 bool wrap = cfg. readBoolEntry ( "Wrap", true ); 395 bool wrap = cfg. readBoolEntry ( "Wrap", true );
396 wa-> setOn ( wrap ); 396 wa-> setOn ( wrap );
397 setWordWrap ( wrap ); 397 setWordWrap ( wrap );
398 398
399///////////////// 399/////////////////
400 if( qApp->argc() > 1) { 400 if( qApp->argc() > 1) {
401 currentFileName=qApp->argv()[1]; 401 currentFileName=qApp->argv()[1];
402 402
403 QFileInfo fi(currentFileName); 403 QFileInfo fi(currentFileName);
404 404
405 if(fi.baseName().left(1) == "") { 405 if(fi.baseName().left(1) == "") {
406 openDotFile(currentFileName); 406 openDotFile(currentFileName);
407 } else { 407 } else {
408 openFile(currentFileName); 408 openFile(currentFileName);
409 } 409 }
410 } else { 410 } else {
411 edited1=false; 411 edited1=false;
412 openDotFile(""); 412 openDotFile("");
413 } 413 }
414 414
415 viewSelection = cfg.readNumEntry( "FileView", 0 ); 415 viewSelection = cfg.readNumEntry( "FileView", 0 );
416} 416}
417 417
418TextEdit::~TextEdit() { 418TextEdit::~TextEdit() {
419 owarn << "textedit d'tor" << oendl; 419 if( edited1 && !promptExit) {
420 switch( savePrompt() ) {
421 case 1: {
422 saveAs();
423 }
424 break;
425 };
426 }
427
420 delete editor; 428 delete editor;
421} 429}
422 430
423void TextEdit::closeEvent(QCloseEvent *) { 431void TextEdit::closeEvent(QCloseEvent *) {
424 if( edited1 && promptExit) 432 if( promptExit) {
425 { 433 switch( savePrompt() ) {
426 switch( savePrompt() ) 434 case 1: {
427 { 435 saveAs();
428 case 1: 436 qApp->quit();
429 { 437 }
430 saveAs(); 438 break;
431 qApp->quit(); 439
432 } 440 case 2: {
433 break; 441 qApp->quit();
434 442 }
435 case 2: 443 break;
436 { 444
437 qApp->quit(); 445 case -1:
438 } 446 break;
439 break; 447 };
440 448 }
441 case -1:
442 break;
443 };
444 }
445 else 449 else
446 qApp->quit(); 450 qApp->quit();
447
448} 451}
449 452
450void TextEdit::cleanUp() { 453void TextEdit::cleanUp() {
451 454
452 Config cfg ( "TextEdit" ); 455 Config cfg ( "TextEdit" );
453 cfg. setGroup ( "Font" ); 456 cfg. setGroup ( "Font" );
454 QFont f = editor->font(); 457 QFont f = editor->font();
455 cfg.writeEntry ( "Family", f. family ( )); 458 cfg.writeEntry ( "Family", f. family ( ));
456 cfg.writeEntry ( "Size", f. pointSize ( )); 459 cfg.writeEntry ( "Size", f. pointSize ( ));
457 cfg.writeEntry ( "Weight", f. weight ( )); 460 cfg.writeEntry ( "Weight", f. weight ( ));
458 cfg.writeEntry ( "Italic", f. italic ( )); 461 cfg.writeEntry ( "Italic", f. italic ( ));
459 462
460 cfg.setGroup ( "View" ); 463 cfg.setGroup ( "View" );
461 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); 464 cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth );
462 cfg.writeEntry ( "FileView", viewSelection ); 465 cfg.writeEntry ( "FileView", viewSelection );
463 466
464 cfg.writeEntry ( "PromptExit", promptExit ); 467 cfg.writeEntry ( "PromptExit", promptExit );
465 cfg.writeEntry ( "OpenDesktop", openDesktop ); 468 cfg.writeEntry ( "OpenDesktop", openDesktop );
466 cfg.writeEntry ( "FilePermissions", filePerms ); 469 cfg.writeEntry ( "FilePermissions", filePerms );
467 cfg.writeEntry ( "SearchBar", useSearchBar ); 470 cfg.writeEntry ( "SearchBar", useSearchBar );
468 cfg.writeEntry ( "startNew", startWithNew ); 471 cfg.writeEntry ( "startNew", startWithNew );
469 472
470} 473}
471 474
472 475
473void TextEdit::accept() { 476void TextEdit::accept() {
474 if( edited1) 477 if( edited1)
475 saveAs(); 478 saveAs();
476 qApp->quit(); 479 qApp->quit();
477} 480}
478 481
479void TextEdit::zoomIn() { 482void TextEdit::zoomIn() {
480 setFontSize(editor->font().pointSize()+1,false); 483 setFontSize(editor->font().pointSize()+1,false);
481} 484}
482 485
483void TextEdit::zoomOut() { 486void TextEdit::zoomOut() {
484 setFontSize(editor->font().pointSize()-1,true); 487 setFontSize(editor->font().pointSize()-1,true);
485} 488}
486 489
487 490
488void TextEdit::setFontSize(int sz, bool round_down_not_up) { 491void TextEdit::setFontSize(int sz, bool round_down_not_up) {
489 int s=10; 492 int s=10;
490 for (int i=0; i<nfontsizes; i++) { 493 for (int i=0; i<nfontsizes; i++) {
491 if ( fontsize[i] == sz ) { 494 if ( fontsize[i] == sz ) {
492 s = sz; 495 s = sz;
493 break; 496 break;
494 } else if ( round_down_not_up ) { 497 } else if ( round_down_not_up ) {
495 if ( fontsize[i] < sz ) 498 if ( fontsize[i] < sz )
496 s = fontsize[i]; 499 s = fontsize[i];
497 } else { 500 } else {
498 if ( fontsize[i] > sz ) { 501 if ( fontsize[i] > sz ) {
499 s = fontsize[i]; 502 s = fontsize[i];
500 break; 503 break;
501 } 504 }
502 } 505 }
503 } 506 }
504 507
505 QFont f = editor->font(); 508 QFont f = editor->font();
506 f.setPointSize(s); 509 f.setPointSize(s);
507 editor->setFont(f); 510 editor->setFont(f);
508 511
509 zin->setEnabled(s != fontsize[nfontsizes-1]); 512 zin->setEnabled(s != fontsize[nfontsizes-1]);
510 zout->setEnabled(s != fontsize[0]); 513 zout->setEnabled(s != fontsize[0]);
511} 514}
512 515
513void TextEdit::setBold(bool y) { 516void TextEdit::setBold(bool y) {
514 QFont f = editor->font(); 517 QFont f = editor->font();
515 f.setBold(y); 518 f.setBold(y);
516 editor->setFont(f); 519 editor->setFont(f);
517} 520}
518 521
519void TextEdit::setItalic(bool y) { 522void TextEdit::setItalic(bool y) {
520 QFont f = editor->font(); 523 QFont f = editor->font();
521 f.setItalic(y); 524 f.setItalic(y);
522 editor->setFont(f); 525 editor->setFont(f);
523} 526}
524 527
525void TextEdit::setWordWrap(bool y) { 528void TextEdit::setWordWrap(bool y) {
526 bool state = editor->edited(); 529 bool state = editor->edited();
527 QString captionStr = caption(); 530 QString captionStr = caption();
528 bool b1 = edited1; 531 bool b1 = edited1;
529 bool b2 = edited; 532 bool b2 = edited;
530 533
531 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); 534 editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
532 editor->setEdited( state ); 535 editor->setEdited( state );
533 edited1=b1; 536 edited1=b1;
534 edited=b2; 537 edited=b2;
535 setCaption(captionStr); 538 setCaption(captionStr);
536} 539}
537 540
538void TextEdit::setSearchBar(bool b) { 541void TextEdit::setSearchBar(bool b) {
539 useSearchBar=b; 542 useSearchBar=b;
540 Config cfg("TextEdit"); 543 Config cfg("TextEdit");
541 cfg.setGroup("View"); 544 cfg.setGroup("View");
542 cfg.writeEntry ( "SearchBar", b ); 545 cfg.writeEntry ( "SearchBar", b );
543 searchBarAction->setOn(b); 546 searchBarAction->setOn(b);
544 if(b) 547 if(b)
545 searchBar->show(); 548 searchBar->show();
546 else 549 else
547 searchBar->hide(); 550 searchBar->hide();
548 editor->setFocus(); 551 editor->setFocus();
549} 552}
550 553
551void TextEdit::fileNew() { 554void TextEdit::fileNew() {
552// if( !bFromDocView ) { 555// if( !bFromDocView ) {
553// saveAs(); 556// saveAs();
554// } 557// }
555 newFile(DocLnk()); 558 newFile(DocLnk());
556} 559}
557 560
558void TextEdit::fileOpen() { 561void TextEdit::fileOpen() {
559 Config cfg("TextEdit"); 562 Config cfg("TextEdit");
560 cfg. setGroup ( "View" ); 563 cfg. setGroup ( "View" );
561 QMap<QString, QStringList> map; 564 QMap<QString, QStringList> map;
562 map.insert(tr("All"), QStringList() ); 565 map.insert(tr("All"), QStringList() );
563 QStringList text; 566 QStringList text;
564 text << "text/*"; 567 text << "text/*";
565 map.insert(tr("Text"), text ); 568 map.insert(tr("Text"), text );
566 text << "*"; 569 text << "*";
567 map.insert(tr("All"), text ); 570 map.insert(tr("All"), text );
568 QString str = OFileDialog::getOpenFileName( 2, 571 QString str = OFileDialog::getOpenFileName( 2,
569 QString::null , 572 QString::null ,
570 QString::null, map); 573 QString::null, map);
571 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) 574 if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
572 { 575 {
573 openFile( str ); 576 openFile( str );
574 } 577 }
575 else 578 else
576 updateCaption(); 579 updateCaption();
577} 580}
578 581
579void TextEdit::doSearchBar() { 582void TextEdit::doSearchBar() {
580 if(!useSearchBar) 583 if(!useSearchBar)
581 searchBar->hide(); 584 searchBar->hide();
582 else 585 else
583 searchBar->show(); 586 searchBar->show();
584} 587}
585 588
586#if 0 589#if 0
587void TextEdit::slotFind() { 590void TextEdit::slotFind() {
588 FindDialog frmFind( tr("Text Editor"), this ); 591 FindDialog frmFind( tr("Text Editor"), this );
589 connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)), 592 connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)),
590 editor, SLOT(slotDoFind(const QString&,bool,bool))); 593 editor, SLOT(slotDoFind(const QString&,bool,bool)));
591 594
592 //case sensitive, backwards, [category] 595 //case sensitive, backwards, [category]
593 596
594 connect( editor, SIGNAL(notFound()), 597 connect( editor, SIGNAL(notFound()),
595 &frmFind, SLOT(slotNotFound()) ); 598 &frmFind, SLOT(slotNotFound()) );
596 connect( editor, SIGNAL(searchWrapped()), 599 connect( editor, SIGNAL(searchWrapped()),
597 &frmFind, SLOT(slotWrapAround()) ); 600 &frmFind, SLOT(slotWrapAround()) );
598 601
599 frmFind.exec(); 602 frmFind.exec();
600 603
601 604
602} 605}
603#endif 606#endif
604 607
605void TextEdit::fileRevert() { 608void TextEdit::fileRevert() {
606 clear(); 609 clear();
607 fileOpen(); 610 fileOpen();
608} 611}
609 612
610void TextEdit::editCut() { 613void TextEdit::editCut() {
611#ifndef QT_NO_CLIPBOARD 614#ifndef QT_NO_CLIPBOARD
612 editor->cut(); 615 editor->cut();
613#endif 616#endif
614} 617}
615 618
616void TextEdit::editCopy() { 619void TextEdit::editCopy() {
617#ifndef QT_NO_CLIPBOARD 620#ifndef QT_NO_CLIPBOARD
618 editor->copy(); 621 editor->copy();
619#endif 622#endif
620} 623}
621 624
622void TextEdit::editPaste() { 625void TextEdit::editPaste() {
623#ifndef QT_NO_CLIPBOARD 626#ifndef QT_NO_CLIPBOARD
624 editor->paste(); 627 editor->paste();
625#endif 628#endif
626} 629}
627 630
628void TextEdit::editFind() { 631void TextEdit::editFind() {
629 searchBar->show(); 632 searchBar->show();
630 searchEdit->setFocus(); 633 searchEdit->setFocus();
631} 634}
632 635
633void TextEdit::findNext() { 636void TextEdit::findNext() {
634 editor->find( searchEdit->text(), false, false ); 637 editor->find( searchEdit->text(), false, false );
635 638
636} 639}
637 640
638void TextEdit::findClose() { 641void TextEdit::findClose() {
639 searchBar->hide(); 642 searchBar->hide();
640} 643}
641 644
642void TextEdit::search() { 645void TextEdit::search() {
643 editor->find( searchEdit->text(), false, false ); 646 editor->find( searchEdit->text(), false, false );
644} 647}
645 648
646void TextEdit::newFile( const DocLnk &f ) { 649void TextEdit::newFile( const DocLnk &f ) {
647 DocLnk nf = f; 650 DocLnk nf = f;
648 nf.setType("text/plain"); 651 nf.setType("text/plain");
649 clear(); 652 clear();
650 setWState (WState_Reserved1 ); 653 setWState (WState_Reserved1 );
651 editor->setFocus(); 654 editor->setFocus();
652 doc = new DocLnk(nf); 655 doc = new DocLnk(nf);
653 currentFileName = "Unnamed"; 656 currentFileName = "Unnamed";
654 odebug << "newFile "+currentFileName << oendl; 657 odebug << "newFile "+currentFileName << oendl;
655 updateCaption( currentFileName); 658 updateCaption( currentFileName);
656// editor->setEdited( false); 659// editor->setEdited( false);
657} 660}
658 661
659void TextEdit::openDotFile( const QString &f ) { 662void TextEdit::openDotFile( const QString &f ) {
660 if(!currentFileName.isEmpty()) { 663 if(!currentFileName.isEmpty()) {
661 currentFileName=f; 664 currentFileName=f;
662 665
663 odebug << "openFile dotfile " + currentFileName << oendl; 666 odebug << "openFile dotfile " + currentFileName << oendl;
664 QString txt; 667 QString txt;
665 QFile file(f); 668 QFile file(f);
666 file.open(IO_ReadWrite); 669 file.open(IO_ReadWrite);
667 QTextStream t(&file); 670 QTextStream t(&file);
668 while ( !t.atEnd()) { 671 while ( !t.atEnd()) {
669 txt+=t.readLine()+"\n"; 672 txt+=t.readLine()+"\n";
670 } 673 }
671 editor->setText(txt); 674 editor->setText(txt);
672 editor->setEdited( false); 675 editor->setEdited( false);
673 edited1=false; 676 edited1=false;
674 edited=false; 677 edited=false;
675 678
676 679
677 } 680 }
678 updateCaption( currentFileName); 681 updateCaption( currentFileName);
679} 682}
680 683
681void TextEdit::openFile( const QString &f ) { 684void TextEdit::openFile( const QString &f ) {
682 odebug << "filename is "+ f << oendl; 685 odebug << "filename is "+ f << oendl;
683 QString filer; 686 QString filer;
684 QFileInfo fi( f); 687 QFileInfo fi( f);
685// bFromDocView = true; 688// bFromDocView = true;
686 if(f.find(".desktop",0,true) != -1 && !openDesktop ) 689 if(f.find(".desktop",0,true) != -1 && !openDesktop )
687 { 690 {
688 switch ( QMessageBox::warning(this,tr("Text Editor"),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) ) 691 switch ( QMessageBox::warning(this,tr("Text Editor"),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) )
689 { 692 {
690 case 0: //desktop 693 case 0: //desktop
691 filer = f; 694 filer = f;
692 break; 695 break;
693 case 1: //linked 696 case 1: //linked
694 DocLnk sf(f); 697 DocLnk sf(f);
695 filer = sf.file(); 698 filer = sf.file();
696 break; 699 break;
697 }; 700 };
698 } 701 }
699 else if(fi.baseName().left(1) == "") 702 else if(fi.baseName().left(1) == "")
700 { 703 {
701 odebug << "opening dotfile" << oendl; 704 odebug << "opening dotfile" << oendl;
702 currentFileName=f; 705 currentFileName=f;
703 openDotFile(currentFileName); 706 openDotFile(currentFileName);