-rw-r--r-- | core/apps/textedit/textedit.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 197b28b..c869dc9 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -277,193 +277,193 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
277 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); | 277 | a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 ); |
278 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 278 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
279 | a->addTo( file ); | 279 | a->addTo( file ); |
280 | 280 | ||
281 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 281 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
282 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 282 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
283 | a->addTo( editBar ); | 283 | a->addTo( editBar ); |
284 | a->addTo( edit ); | 284 | a->addTo( edit ); |
285 | 285 | ||
286 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | 286 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); |
287 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 287 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
288 | a->addTo( editBar ); | 288 | a->addTo( editBar ); |
289 | a->addTo( edit ); | 289 | a->addTo( edit ); |
290 | 290 | ||
291 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 291 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
292 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 292 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
293 | a->addTo( editBar ); | 293 | a->addTo( editBar ); |
294 | a->addTo( edit ); | 294 | a->addTo( edit ); |
295 | 295 | ||
296 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 296 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
297 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 297 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
298 | edit->insertSeparator(); | 298 | edit->insertSeparator(); |
299 | a->addTo( bar ); | 299 | a->addTo( bar ); |
300 | a->addTo( edit ); | 300 | a->addTo( edit ); |
301 | 301 | ||
302 | 302 | ||
303 | int defsize; | 303 | int defsize; |
304 | bool defb, defi, wrap; | 304 | bool defb, defi, wrap; |
305 | 305 | ||
306 | Config cfg("TextEdit"); | 306 | Config cfg("TextEdit"); |
307 | cfg.setGroup("View"); | 307 | cfg.setGroup("View"); |
308 | defsize = cfg.readNumEntry("FontSize",10); | 308 | defsize = cfg.readNumEntry("FontSize",10); |
309 | defb = cfg.readBoolEntry("Bold",FALSE); | 309 | defb = cfg.readBoolEntry("Bold",FALSE); |
310 | defi = cfg.readBoolEntry("Italic",FALSE); | 310 | defi = cfg.readBoolEntry("Italic",FALSE); |
311 | wrap = cfg.readBoolEntry("Wrap",TRUE); | 311 | wrap = cfg.readBoolEntry("Wrap",TRUE); |
312 | 312 | ||
313 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 313 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
314 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 314 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
315 | zin->addTo( font ); | 315 | zin->addTo( font ); |
316 | 316 | ||
317 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 317 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
318 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 318 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
319 | zout->addTo( font ); | 319 | zout->addTo( font ); |
320 | 320 | ||
321 | font->insertSeparator(); | 321 | font->insertSeparator(); |
322 | 322 | ||
323 | #if 0 | 323 | #if 0 |
324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | 324 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); |
325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | 325 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); |
326 | ba->setToggleAction(TRUE); | 326 | ba->setToggleAction(TRUE); |
327 | ba->addTo( font ); | 327 | ba->addTo( font ); |
328 | 328 | ||
329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | 329 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); |
330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | 330 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); |
331 | ia->setToggleAction(TRUE); | 331 | ia->setToggleAction(TRUE); |
332 | ia->addTo( font ); | 332 | ia->addTo( font ); |
333 | 333 | ||
334 | ba->setOn(defb); | 334 | ba->setOn(defb); |
335 | ia->setOn(defi); | 335 | ia->setOn(defi); |
336 | 336 | ||
337 | font->insertSeparator(); | 337 | font->insertSeparator(); |
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 340 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 341 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
342 | wa->setToggleAction(TRUE); | 342 | wa->setToggleAction(TRUE); |
343 | wa->addTo( font ); | 343 | wa->addTo( font ); |
344 | 344 | ||
345 | font->insertSeparator(); | 345 | font->insertSeparator(); |
346 | font->insertItem("Font", this, SLOT(changeFont()) ); | 346 | font->insertItem("Font", this, SLOT(changeFont()) ); |
347 | 347 | ||
348 | mb->insertItem( tr( "File" ), file ); | 348 | mb->insertItem( tr( "File" ), file ); |
349 | mb->insertItem( tr( "Edit" ), edit ); | 349 | mb->insertItem( tr( "Edit" ), edit ); |
350 | mb->insertItem( tr( "View" ), font ); | 350 | mb->insertItem( tr( "View" ), font ); |
351 | 351 | ||
352 | searchBar = new QPEToolBar(this); | 352 | searchBar = new QPEToolBar(this); |
353 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 353 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
354 | 354 | ||
355 | searchBar->setHorizontalStretchable( TRUE ); | 355 | searchBar->setHorizontalStretchable( TRUE ); |
356 | 356 | ||
357 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 357 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
358 | searchBar->setStretchableWidget( searchEdit ); | 358 | searchBar->setStretchableWidget( searchEdit ); |
359 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 359 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
360 | this, SLOT( search() ) ); | 360 | this, SLOT( search() ) ); |
361 | 361 | ||
362 | 362 | ||
363 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 363 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
364 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 364 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
365 | a->addTo( searchBar ); | 365 | a->addTo( searchBar ); |
366 | a->addTo( edit ); | 366 | a->addTo( edit ); |
367 | 367 | ||
368 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 368 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
369 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 369 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
370 | a->addTo( searchBar ); | 370 | a->addTo( searchBar ); |
371 | 371 | ||
372 | edit->insertSeparator(); | 372 | edit->insertSeparator(); |
373 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "delete" ), QString::null, 0, this, 0 ); | 373 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
374 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 374 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
375 | a->addTo( edit ); | 375 | a->addTo( edit ); |
376 | 376 | ||
377 | searchBar->hide(); | 377 | searchBar->hide(); |
378 | 378 | ||
379 | editorStack = new QWidgetStack( this ); | 379 | editorStack = new QWidgetStack( this ); |
380 | setCentralWidget( editorStack ); | 380 | setCentralWidget( editorStack ); |
381 | 381 | ||
382 | searchVisible = FALSE; | 382 | searchVisible = FALSE; |
383 | 383 | ||
384 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy | 384 | fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy |
385 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 385 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
386 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 386 | connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
387 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); | 387 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); |
388 | // fileOpen(); | 388 | // fileOpen(); |
389 | 389 | ||
390 | editor = new QpeEditor( editorStack ); | 390 | editor = new QpeEditor( editorStack ); |
391 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 391 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
392 | editorStack->addWidget( editor, get_unique_id() ); | 392 | editorStack->addWidget( editor, get_unique_id() ); |
393 | 393 | ||
394 | resize( 200, 300 ); | 394 | resize( 200, 300 ); |
395 | 395 | ||
396 | // setFontSize(defsize,TRUE); | 396 | // setFontSize(defsize,TRUE); |
397 | FontDatabase fdb; | 397 | FontDatabase fdb; |
398 | QFont defaultFont=editor->font(); | 398 | QFont defaultFont=editor->font(); |
399 | QFontInfo fontInfo(defaultFont); | 399 | QFontInfo fontInfo(defaultFont); |
400 | 400 | ||
401 | cfg.setGroup("Font"); | 401 | cfg.setGroup("Font"); |
402 | QString family = cfg.readEntry("Family", fontInfo.family()); | 402 | QString family = cfg.readEntry("Family", fontInfo.family()); |
403 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 403 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
404 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 404 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
405 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 405 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
406 | 406 | ||
407 | defaultFont = fdb.font(family,style,i_size,charSet); | 407 | defaultFont = fdb.font(family,style,i_size,charSet); |
408 | editor->setFont( defaultFont); | 408 | editor->setFont( defaultFont); |
409 | 409 | ||
410 | wa->setOn(wrap); | 410 | wa->setOn(wrap); |
411 | updateCaption(); | 411 | updateCaption(); |
412 | 412 | ||
413 | fileNew(); | 413 | fileNew(); |
414 | } | 414 | } |
415 | 415 | ||
416 | TextEdit::~TextEdit() | 416 | TextEdit::~TextEdit() |
417 | { | 417 | { |
418 | // saveAs(); | 418 | // saveAs(); |
419 | 419 | ||
420 | Config cfg("TextEdit"); | 420 | Config cfg("TextEdit"); |
421 | cfg.setGroup("View"); | 421 | cfg.setGroup("View"); |
422 | QFont f = editor->font(); | 422 | QFont f = editor->font(); |
423 | cfg.writeEntry("FontSize",f.pointSize()); | 423 | cfg.writeEntry("FontSize",f.pointSize()); |
424 | cfg.writeEntry("Bold",f.bold()); | 424 | cfg.writeEntry("Bold",f.bold()); |
425 | cfg.writeEntry("Italic",f.italic()); | 425 | cfg.writeEntry("Italic",f.italic()); |
426 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 426 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
427 | } | 427 | } |
428 | 428 | ||
429 | void TextEdit::zoomIn() | 429 | void TextEdit::zoomIn() |
430 | { | 430 | { |
431 | setFontSize(editor->font().pointSize()+1,FALSE); | 431 | setFontSize(editor->font().pointSize()+1,FALSE); |
432 | } | 432 | } |
433 | 433 | ||
434 | void TextEdit::zoomOut() | 434 | void TextEdit::zoomOut() |
435 | { | 435 | { |
436 | setFontSize(editor->font().pointSize()-1,TRUE); | 436 | setFontSize(editor->font().pointSize()-1,TRUE); |
437 | } | 437 | } |
438 | 438 | ||
439 | 439 | ||
440 | void TextEdit::setFontSize(int sz, bool round_down_not_up) | 440 | void TextEdit::setFontSize(int sz, bool round_down_not_up) |
441 | { | 441 | { |
442 | int s=10; | 442 | int s=10; |
443 | for (int i=0; i<nfontsizes; i++) { | 443 | for (int i=0; i<nfontsizes; i++) { |
444 | if ( fontsize[i] == sz ) { | 444 | if ( fontsize[i] == sz ) { |
445 | s = sz; | 445 | s = sz; |
446 | break; | 446 | break; |
447 | } else if ( round_down_not_up ) { | 447 | } else if ( round_down_not_up ) { |
448 | if ( fontsize[i] < sz ) | 448 | if ( fontsize[i] < sz ) |
449 | s = fontsize[i]; | 449 | s = fontsize[i]; |
450 | } else { | 450 | } else { |
451 | if ( fontsize[i] > sz ) { | 451 | if ( fontsize[i] > sz ) { |
452 | s = fontsize[i]; | 452 | s = fontsize[i]; |
453 | break; | 453 | break; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | QFont f = editor->font(); | 458 | QFont f = editor->font(); |
459 | f.setPointSize(s); | 459 | f.setPointSize(s); |
460 | editor->setFont(f); | 460 | editor->setFont(f); |
461 | 461 | ||
462 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 462 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
463 | zout->setEnabled(s != fontsize[0]); | 463 | zout->setEnabled(s != fontsize[0]); |
464 | } | 464 | } |
465 | 465 | ||
466 | void TextEdit::setBold(bool y) | 466 | void TextEdit::setBold(bool y) |
467 | { | 467 | { |
468 | QFont f = editor->font(); | 468 | QFont f = editor->font(); |
469 | f.setBold(y); | 469 | f.setBold(y); |