Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 124 |
1 files changed, 47 insertions, 77 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f6a869a..7b50a6c 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -27,8 +27,9 @@ | |||
27 | #include "textedit.h" | 27 | #include "textedit.h" |
28 | #include "filePermissions.h" | 28 | #include "filePermissions.h" |
29 | #include "fontDialog.h" | 29 | //#include "fontDialog.h" |
30 | 30 | ||
31 | #include <opie/ofileselector.h> | 31 | #include <opie/ofileselector.h> |
32 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
33 | #include <opie/ofontselector.h> | ||
33 | 34 | ||
34 | #include <qpe/fontdatabase.h> | 35 | #include <qpe/fontdatabase.h> |
@@ -58,4 +59,5 @@ | |||
58 | #include <qcheckbox.h> | 59 | #include <qcheckbox.h> |
59 | #include <qcombo.h> | 60 | #include <qcombo.h> |
61 | #include <qlayout.h> | ||
60 | 62 | ||
61 | #include <unistd.h> | 63 | #include <unistd.h> |
@@ -313,13 +315,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
313 | a->addTo( edit ); | 315 | a->addTo( edit ); |
314 | 316 | ||
315 | int defsize; | ||
316 | bool defb, defi, wrap; | ||
317 | |||
318 | Config cfg("TextEdit"); | ||
319 | cfg.setGroup("View"); | ||
320 | defsize = cfg.readNumEntry("FontSize",10); | ||
321 | defb = cfg.readBoolEntry("Bold",FALSE); | ||
322 | defi = cfg.readBoolEntry("Italic",FALSE); | ||
323 | wrap = cfg.readBoolEntry("Wrap",TRUE); | ||
324 | 317 | ||
325 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 318 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
@@ -333,21 +326,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
333 | font->insertSeparator(); | 326 | font->insertSeparator(); |
334 | 327 | ||
335 | #if 0 | ||
336 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | ||
337 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | ||
338 | ba->setToggleAction(TRUE); | ||
339 | ba->addTo( font ); | ||
340 | |||
341 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | ||
342 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | ||
343 | ia->setToggleAction(TRUE); | ||
344 | ia->addTo( font ); | ||
345 | |||
346 | ba->setOn(defb); | ||
347 | ia->setOn(defi); | ||
348 | |||
349 | font->insertSeparator(); | ||
350 | #endif | ||
351 | |||
352 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 328 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
353 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 329 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
@@ -370,10 +346,4 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
370 | nAdvanced->addTo( font ); | 346 | nAdvanced->addTo( font ); |
371 | 347 | ||
372 | if(cfg.readBoolEntry("AdvancedFeatures")) { | ||
373 | qDebug("using advanced features"); | ||
374 | useAdvancedFeatures = true; | ||
375 | nAdvanced->setOn(TRUE); | ||
376 | } else | ||
377 | useAdvancedFeatures = false; | ||
378 | 348 | ||
379 | font->insertSeparator(); | 349 | font->insertSeparator(); |
@@ -416,24 +386,31 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
416 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 386 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
417 | 387 | ||
418 | // resize( 200, 300 ); | 388 | Config cfg("TextEdit"); |
389 | |||
390 | cfg. setGroup ( "Font" ); | ||
419 | 391 | ||
420 | // setFontSize(defsize,TRUE); | 392 | QFont defaultFont = editor-> font ( ); |
421 | FontDatabase fdb; | ||
422 | QFont defaultFont=editor->font(); | ||
423 | QFontInfo fontInfo(defaultFont); | ||
424 | 393 | ||
425 | cfg.setGroup("Font"); | 394 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
426 | QString family = cfg.readEntry("Family", fontInfo.family()); | 395 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
427 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 396 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
428 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 397 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
429 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | ||
430 | 398 | ||
431 | defaultFont = fdb.font(family,style,i_size,charSet); | 399 | defaultFont = QFont ( family, size, weight, italic ); |
432 | editor->setFont( defaultFont); | 400 | editor-> setFont ( defaultFont ); |
433 | 401 | ||
434 | wa->setOn(wrap); | ||
435 | updateCaption(); | 402 | updateCaption(); |
436 | 403 | ||
437 | cfg.setGroup("View"); | 404 | cfg.setGroup ( "View" ); |
405 | |||
406 | useAdvancedFeatures = cfg. readBoolEntry ( "AdvancedFeatures", false ); | ||
407 | |||
408 | if ( useAdvancedFeatures ) | ||
409 | nAdvanced-> setOn ( true ); | ||
410 | |||
411 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | ||
412 | wa-> setOn ( wrap ); | ||
413 | setWordWrap ( wrap ); | ||
414 | |||
438 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 415 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
439 | nStart->setOn(TRUE); | 416 | nStart->setOn(TRUE); |
@@ -452,13 +429,18 @@ TextEdit::~TextEdit() { | |||
452 | 429 | ||
453 | void TextEdit::cleanUp() { | 430 | void TextEdit::cleanUp() { |
454 | qDebug("cleanUp");// save(); | 431 | qDebug("cleanUp");// save(); |
455 | Config cfg("TextEdit"); | 432 | |
456 | cfg.setGroup("View"); | 433 | Config cfg ( "TextEdit" ); |
434 | cfg. setGroup ( "Font" ); | ||
457 | QFont f = editor->font(); | 435 | QFont f = editor->font(); |
458 | cfg.writeEntry("FontSize",f.pointSize()); | 436 | cfg. writeEntry ( "Family", f. family ( )); |
459 | cfg.writeEntry("Bold",f.bold()); | 437 | cfg. writeEntry ( "Size", f. pointSize ( )); |
460 | cfg.writeEntry("Italic",f.italic()); | 438 | cfg. writeEntry ( "Weight", f. weight ( )); |
461 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 439 | cfg. writeEntry ( "Italic", f. italic ( )); |
462 | cfg.writeEntry( "FileView", viewSelection ); | 440 | |
441 | cfg. setGroup ( "View" ); | ||
442 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); | ||
443 | cfg. writeEntry ( "FileView", viewSelection ); | ||
444 | cfg. writeEntry ( "AdvancedFeatures", useAdvancedFeatures ); | ||
463 | } | 445 | } |
464 | 446 | ||
@@ -901,24 +883,15 @@ void TextEdit::closeEvent( QCloseEvent *e ) { | |||
901 | 883 | ||
902 | void TextEdit::changeFont() { | 884 | void TextEdit::changeFont() { |
903 | FontDatabase fdb; | 885 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
904 | QFont defaultFont=editor->font(); | 886 | d-> setCaption ( tr( "Choose font" )); |
905 | QFontInfo fontInfo(defaultFont); | 887 | QBoxLayout *lay = new QVBoxLayout ( d ); |
906 | Config cfg("TextEdit"); | 888 | OFontSelector *ofs = new OFontSelector ( true, d ); |
907 | cfg.setGroup("Font"); | 889 | lay-> addWidget ( ofs ); |
908 | QString family = cfg.readEntry("Family", fontInfo.family()); | 890 | ofs-> setSelectedFont ( editor-> font ( )); |
909 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | ||
910 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | ||
911 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | ||
912 | |||
913 | defaultFont = fdb.font(family,style,i_size,charSet); | ||
914 | |||
915 | FontDialog *fontDlg; | ||
916 | fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); | ||
917 | 891 | ||
918 | fontDlg->exec(); | 892 | d-> showMaximized ( ); |
919 | 893 | if ( d-> exec ( ) == QDialog::Accepted ) | |
920 | QFont myFont=fontDlg->selectedFont; | 894 | editor-> setFont ( ofs-> selectedFont ( )); |
921 | editor->setFont( myFont); | 895 | delete d; |
922 | delete fontDlg; | ||
923 | 896 | ||
924 | } | 897 | } |
@@ -976,7 +949,4 @@ void TextEdit::doAbout() { | |||
976 | void TextEdit::doAdvanced(bool b) { | 949 | void TextEdit::doAdvanced(bool b) { |
977 | useAdvancedFeatures=b; | 950 | useAdvancedFeatures=b; |
978 | Config cfg("TextEdit"); | ||
979 | cfg.setGroup("View"); | ||
980 | cfg.writeEntry("AdvancedFeatures",b); | ||
981 | } | 951 | } |
982 | 952 | ||