1 #include "texteditor.h"
4 #include <qstatusbar.h>
5 #include <qmessagebox.h>
7 #include <qapplication.h>
11 #include <qfiledialog.h>
13 #include <qpopupmenu.h>
15 #include <qtextedit.h>
17 #include <qtextstream.h>
18 #include <qpaintdevicemetrics.h>
19 #include <qsettings.h>
20 #include <qfontdialog.h>
21 #include <qmessagebox.h>
22 #include <qcolordialog.h>
24 #include <qlineedit.h>
25 #include <qsimplerichtext.h>
31 #include "icons/fileopen.xpm"
32 #include "icons/filesave.xpm"
33 #include "icons/fileprint.xpm"
34 #include "icons/editundo.xpm"
35 #include "icons/editredo.xpm"
36 #include "icons/editcopy.xpm"
37 #include "icons/editcut.xpm"
38 #include "icons/editpaste.xpm"
39 #include "icons/edittrash.xpm"
40 #include "icons/formatfixedfont.xpm"
41 #include "icons/formattextbold.xpm"
42 #include "icons/formattextitalic.xpm"
43 #include "icons/formattextunder.xpm"
44 #include "icons/formattextleft.xpm"
45 #include "icons/formattextcenter.xpm"
46 #include "icons/formattextright.xpm"
47 #include "icons/formattextjustify.xpm"
49 extern QCanvas* actCanvas;
50 extern int statusbarTime;
51 extern QSettings settings;
53 extern QAction *actionViewToggleNoteEditor;
58 ///////////////////////////////////////////////////////////////////////
59 ///////////////////////////////////////////////////////////////////////
61 TextEditor::TextEditor()
63 printer = new QPrinter( QPrinter::HighResolution );
64 printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName()));
67 e = new QTextEdit( this, "editor" );
69 e->setTextFormat(RichText); // default
70 e->setTabStopWidth (20); // unit is pixel
72 connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
73 setCentralWidget( e );
74 statusBar()->message( "Ready", statusbarTime);
75 setCaption("VYM - Note Editor");
81 setupSettingsActions();
84 emptyPaper = QBrush(gray);
85 filledPaper = QBrush(white);
86 inactivePaper= QBrush(black);
90 resize (settings.readNumEntry( "/vym/noteeditor/geometry/width", 450),
91 settings.readNumEntry( "/vym/noteeditor/geometry/height",600));
92 move (settings.readNumEntry( "/vym/noteeditor/geometry/posX", 150),
93 settings.readNumEntry( "/vym/noteeditor/geometry/posY", 50));
95 if (settings.readEntry( "/vym/noteeditor/showWithMain","yes") =="yes")
96 setShowWithMain(true);
98 setShowWithMain(false);
100 varFont.fromString( settings.readEntry
101 ("/vym/noteeditor/fonts/varFont",
102 "Nimbus Sans l,14,-1,5,48,0,0,0,0,0")
104 fixedFont.fromString (settings.readEntry (
105 "/vym/noteeditor/fonts/fixedFont",
106 "Courier,14,-1,5,48,0,0,0,1,0")
108 QString s=settings.readEntry ("/vym/noteeditor/fonts/fonthintDefault","variable");
111 actionSettingsFonthintDefault->setOn (true);
112 e->setCurrentFont (fixedFont);
115 actionSettingsFonthintDefault->setOn (false);
116 e->setCurrentFont (varFont);
118 <<<<<<< texteditor.cpp
121 // Save settings in vymrc
122 settings.writeEntry("/vym/mainwindow/printerName",printer->printerName());
129 TextEditor::~TextEditor()
131 if (printer) delete printer;
133 settings.writeEntry( "/vym/noteeditor/geometry/width", width() );
134 settings.writeEntry( "/vym/noteeditor/geometry/height", height() );
135 settings.writeEntry( "/vym/noteeditor/geometry/posX", pos().x() );
136 settings.writeEntry( "/vym/noteeditor/geometry/posY", pos().y() );
139 settings.writeEntry( "/vym/noteeditor/showWithMain","yes");
141 settings.writeEntry( "/vym/noteeditor/showWithMain","no");
144 if (actionSettingsFonthintDefault->isOn() )
148 settings.writeEntry( "/vym/noteeditor/fonts/fonthintDefault",s );
149 settings.writeEntry ("/vym/noteeditor/fonts/varFont",
150 varFont.toString() );
151 settings.writeEntry ("/vym/noteeditor/fonts/fixedFont",
152 fixedFont.toString() );
155 bool TextEditor::isEmpty()
157 if (e->text().length())
163 void TextEditor::setShowWithMain(bool v)
168 bool TextEditor::showWithMain()
173 void TextEditor::setFontHint (const QString &fh)
176 actionFormatUseFixedFont->setOn (true);
178 actionFormatUseFixedFont->setOn (false);
182 QString TextEditor::getFontHint()
184 if (actionFormatUseFixedFont->isOn())
190 QString TextEditor::getFontHintDefault()
192 if (actionSettingsFonthintDefault->isOn())
198 void TextEditor::setFilename(const QString &fn)
200 if (state==filledEditor)
204 statusBar()->message( "No filename available for this note.", statusbarTime );
209 statusBar()->message( QString( "Current filename is %1" ).arg( filename ), statusbarTime );
213 QString TextEditor::getFilename()
218 void TextEditor::setFilenameHint(const QString &fnh)
223 QString TextEditor::getFilenameHint()
228 bool TextEditor::findText(const QString &t, const bool &cs)
230 bool wo=false; // word matches
231 if (e->find (t, cs, wo, true, 0, 0 ))
237 void TextEditor::setupFileActions()
239 QToolBar *tb = new QToolBar( this );
240 tb->setLabel( "File Actions" );
241 QPopupMenu *menu = new QPopupMenu( this );
242 menuBar()->insertItem( tr( "&File" ), menu );
245 a = new QAction( tr( "Import" ), QPixmap( fileopen_xpm), tr( "&Import..." ), CTRL + Key_O, this, "fileImport" );
246 connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
247 a->setEnabled(false);
252 menu->insertSeparator();
253 a = new QAction( tr( "Export Note (HTML)" ), QPixmap( filesave_xpm ), tr( "&Export..." ), CTRL + Key_S, this, "fileSave" );
254 connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
259 a = new QAction( tr( "Export Note As (HTML) " ), QPixmap(), tr( "Export &As... (HTML)" ), 0, this, "exportHTML" );
260 connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
264 a = new QAction( tr( "Export Note As (ASCII) " ), QPixmap(), tr( "Export &As...(ASCII)" ), ALT + Key_X, this, "exportASCII" );
265 connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
269 menu->insertSeparator();
270 a = new QAction( tr( "Print Note" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
271 connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
277 void TextEditor::setupEditActions()
279 QToolBar *tb = new QToolBar( this );
280 tb->setLabel( "Edit Actions" );
281 QPopupMenu *menu = new QPopupMenu( this );
282 menuBar()->insertItem( tr( "&Edit" ), menu );
285 a = new QAction( tr( "Undo" ), QPixmap(editundo_xpm), tr( "&Undo" ), CTRL + Key_Z, this, "undoEvent" );
286 connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
291 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
292 connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
297 menu->insertSeparator();
298 a = new QAction( tr( "Select and copy all" ), QPixmap(), tr( "Select and copy &all" ), CTRL + Key_A, this, "editcopyall" );
299 connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
302 menu->insertSeparator();
303 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
304 connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
309 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
310 connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
315 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
316 connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
321 a = new QAction( tr( "Delete all" ), QPixmap( edittrash_xpm ), tr( "&Delete All" ), 0, this, "editDeleteAll" );
322 connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
325 actionEditDeleteAll=a;
327 a = new QAction( tr( "Convert paragraphs to linebreaks" ), QPixmap(), tr( "&Convert Paragraphs" ), ALT + Key_P, this, "editConvertPar" );
328 connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) );
330 actionEditConvertPar=a;
332 a = new QAction( tr( "Join all lines of a paragraph" ), QPixmap(), tr( "&Join lines" ), ALT + Key_J, this, "editJoinLines" );
333 connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) );
335 actionEditJoinLines=a;
338 void TextEditor::setupFormatActions()
340 QToolBar *tb = new QToolBar( this );
341 tb->setLabel( "Format Actions" );
342 QPopupMenu *menu = new QPopupMenu( this );
343 menuBar()->insertItem( tr( "&Format" ), menu );
347 a = new QAction( tr( "Toggle font hint for the whole text" ), QPixmap(formatfixedfont_xpm), tr( "&Font hint" ), ALT + Key_I, this, "fontHint" );
348 a->setToggleAction (true);
349 a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) );
350 connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
353 actionFormatUseFixedFont=a;
355 menu->insertSeparator();
357 comboFont = new QComboBox( true, tb );
359 comboFont->insertStringList( db.families() );
360 connect( comboFont, SIGNAL( activated( const QString & ) ),
361 this, SLOT( textFamily( const QString & ) ) );
362 comboFont->lineEdit()->setText( QApplication::font().family() );
364 comboSize = new QComboBox( true, tb );
365 QValueList<int> sizes = db.standardSizes();
366 QValueList<int>::Iterator it = sizes.begin();
367 for ( ; it != sizes.end(); ++it )
368 comboSize->insertItem( QString::number( *it ) );
369 connect( comboSize, SIGNAL( activated( const QString & ) ),
370 this, SLOT( textSize( const QString & ) ) );
371 comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
373 menu->insertSeparator();
375 QPixmap pix( 16, 16 );
376 pix.fill( e->color());
377 actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
378 connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
379 actionTextColor->addTo( tb );
380 actionTextColor->addTo( menu );
382 actionTextBold = new QAction( QPixmap (formattextbold_xpm), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
383 connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
384 actionTextBold->addTo( tb );
385 actionTextBold->addTo( menu );
386 actionTextBold->setToggleAction( true );
387 actionTextItalic = new QAction( QPixmap(formattextitalic_xpm ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
388 connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
389 actionTextItalic->addTo( tb );
390 actionTextItalic->addTo( menu );
391 actionTextItalic->setToggleAction( true );
392 actionTextUnderline = new QAction( QPixmap (formattextunder_xpm ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
393 connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
394 actionTextUnderline->addTo( tb );
395 actionTextUnderline->addTo( menu );
396 actionTextUnderline->setToggleAction( true );
397 menu->insertSeparator();
399 QActionGroup *grp = new QActionGroup( this );
400 connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
402 actionAlignLeft = new QAction( QPixmap (formattextleft_xpm ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
403 actionAlignLeft->setToggleAction( true );
404 actionAlignCenter = new QAction( QPixmap (formattextcenter_xpm ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
405 actionAlignCenter->setToggleAction( true );
406 actionAlignRight = new QAction( QPixmap (formattextright_xpm ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
407 actionAlignRight->setToggleAction( true );
408 actionAlignJustify = new QAction( QPixmap ( formattextjustify_xpm ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
409 actionAlignJustify->setToggleAction( true );
414 connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
415 this, SLOT( fontChanged( const QFont & ) ) );
416 connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
417 this, SLOT( colorChanged( const QColor & ) ) );
418 connect( e, SIGNAL( currentAlignmentChanged( int ) ),
419 this, SLOT( alignmentChanged( int ) ) );
423 void TextEditor::setupSettingsActions()
425 QPopupMenu *menu = new QPopupMenu( this );
426 menuBar()->insertItem( tr( "&Settings" ), menu );
429 a = new QAction( tr( "Set fixed font" ), QPixmap(), tr( "Set &fixed font" ), 0, this, "setFixedFont" );
430 connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
432 actionSettingsFixedFont=a;
434 a = new QAction( tr( "Set variable font" ), QPixmap(), tr( "Set &variable font" ), 0, this, "setvariableFont" );
435 connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
437 actionSettingsVarFont=a;
439 a = new QAction( tr( "Used fixed font by default" ), QPixmap(), tr( "&fixed font is default" ), 0, this, "fonthintDefault" );
440 a->setToggleAction (true);
441 // set state later in constructor...
443 actionSettingsFonthintDefault=a;
446 void TextEditor::textLoad()
448 if (state!=inactiveEditor)
452 QMessageBox mb( "VYM - Note Editor",
453 "Loading will overwrite the existing note",
454 QMessageBox::Warning,
455 QMessageBox::Yes | QMessageBox::Default,
458 mb.setButtonText( QMessageBox::Yes, "Load note" );
459 switch( mb.exec() ) {
460 case QMessageBox::Cancel:
466 QFileDialog *fd=new QFileDialog( this);
467 fd->addFilter ("ASCII texts (*.txt)");
468 fd->addFilter ("VYM notes (*.html)");
471 if ( fd->exec() == QDialog::Accepted )
472 fn = fd->selectedFile();
477 if ( !f.open( IO_ReadOnly ) )
480 QTextStream ts( &f );
481 setText( ts.read() );
487 void TextEditor::closeEvent( QCloseEvent* ce )
489 if ( !e->isModified() )
491 ce->accept(); // TextEditor can be reopened with show()
492 actionViewToggleNoteEditor->setOn (false);
498 QString TextEditor::getText()
503 void TextEditor::editorChanged()
505 // received, when QTextEdit::text() has changed
506 EditorState oldstate=state;
513 if (state != oldstate)
515 if (state==emptyEditor)
516 e->setPaper (emptyPaper);
518 e->setPaper (filledPaper);
520 // SLOT is LinkableMapObj, which will update systemFlag
521 emit (textHasChanged() );
525 void TextEditor::setText(QString t)
527 if ( !QStyleSheet::mightBeRichText( t ) )
528 t = QStyleSheet::convertFromPlainText( t, QStyleSheetItem::WhiteSpaceNormal );
529 e->setReadOnly(false);
531 editorChanged(); //not called automagically
536 void TextEditor::setInactive()
539 state=inactiveEditor;
540 e->setPaper (inactivePaper);
541 e->setReadOnly (true);
546 void TextEditor::editCopyAll()
552 void TextEditor::textSaveAs()
554 QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
555 this,"export note dialog",tr("Export Note to single file") );
562 QMessageBox mb( "VYM",
563 tr("The file ") + fn +
564 tr(" exists already. "
565 "Do you want to overwrite it?"),
566 QMessageBox::Warning,
567 QMessageBox::Yes | QMessageBox::Default,
568 QMessageBox::Cancel | QMessageBox::Escape,
569 QMessageBox::NoButton );
570 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
571 mb.setButtonText( QMessageBox::No, tr("Cancel"));
572 switch( mb.exec() ) {
573 case QMessageBox::Yes:
578 case QMessageBox::Cancel:
589 statusBar()->message(tr( "Couldn't export note ") + fn, statusbarTime );
593 void TextEditor::textSave()
595 if ( filename.isEmpty() )
601 QString text = e->text();
603 if ( !f.open( IO_WriteOnly ) )
605 statusBar()->message( QString("Could not write to %1").arg(filename),
614 e->setModified( FALSE );
616 statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
619 void TextEditor::textConvertPar()
621 // In X11 a copy&paste generates paragraphs,
622 // which is not always wanted
623 // This function replaces paragraphs by linebreaks.
624 int parFrom, parTo, indFrom, indTo;
625 e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
635 t.replace ("</p>","<br />");
638 e->setCursorPosition (parFrom,indFrom);
640 // Tried to simply insert the changed text with
641 // e->insert (t,(uint)(QTextEdit::RemoveSelected));
642 // but then the html would be quoted. So I use the ugly
643 // way: insert a marker, replace it in whole text of QTextEdit
644 QString marker="R3PlAcEMeL4teR!";
646 e->setText (e->text().replace(marker,t));
651 void TextEditor::textJoinLines()
653 int parFrom, parTo, indFrom, indTo;
654 e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
660 // In addition to textConvertPar it is sometimes
661 // useful to join all lines of a paragraph
662 QRegExp re("</p>\n+<p>(?!</p>)");
666 // Above we may have introduced new " " at beginning of a
667 // paragraph - remove it.
668 re.setPattern("<p> ");
669 t.replace (re,"<p>");
672 e->setCursorPosition (parFrom,indFrom);
674 // Tried to simply insert the changed text with
675 // e->insert (t,(uint)(QTextEdit::RemoveSelected));
676 // but then the html would be quoted. So I use the ugly
677 // way: insert a marker, replace it in whole text of QTextEdit
678 QString marker="R3PlAcEMeL4teR!";
680 e->setText (e->text().replace(marker,t));
685 QString TextEditor::textConvertToASCII(const QString &t)
689 // convert all "<br*>" to "\n"
690 QRegExp re("<br.*>");
694 // convert all "</p>" to "\n"
695 re.setPattern ("/p");
698 // remove all remaining tags
699 re.setPattern ("<.*>");
702 // convert "&", "<" and ">"
703 re.setPattern (">");
705 re.setPattern ("<");
707 re.setPattern ("&");
712 void TextEditor::textExportAsASCII()
714 QString text = textConvertToASCII( e->text());
716 if (!filenameHint.isEmpty())
718 if (!filenameHint.contains (".txt"))
719 s=filenameHint+".txt";
724 fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
732 QMessageBox mb( "VYM",
733 tr("The file ") + fn +
734 tr(" exists already. "
735 "Do you want to overwrite it?"),
736 QMessageBox::Warning,
737 QMessageBox::Yes | QMessageBox::Default,
738 QMessageBox::Cancel | QMessageBox::Escape,
739 QMessageBox::NoButton );
740 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
741 mb.setButtonText( QMessageBox::No, tr("Cancel"));
744 if (ret==QMessageBox::Cancel)
748 if ( !file.open( IO_WriteOnly ) )
749 statusBar()->message( QString("Could not write to %1").arg(filename),
753 QTextStream t( &file );
757 statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
763 void TextEditor::textPrint()
765 printer->setFullPage(TRUE);
766 if ( printer->setup( this ) )
768 QPainter p( printer );
769 // Check that there is a valid device to print to.
770 if ( !p.device() ) return;
771 QPaintDeviceMetrics metrics( p.device() );
772 int dpiy = metrics.logicalDpiY();
773 int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
774 QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
775 QFont font( e->currentFont() );
776 font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
778 QSimpleRichText richText( e->text(), font,
781 e->mimeSourceFactory(),
783 richText.setWidth( &p, body.width() );
788 richText.draw( &p, body.left(), body.top(), view, colorGroup() );
789 view.moveBy( 0, body.height() );
790 p.translate( 0 , -body.height() );
792 p.drawText( view.right() - p.fontMetrics().width( QString::number( page ) ),
793 view.bottom() + p.fontMetrics().ascent() + 5, QString::number( page ) );
794 if ( view.top() >= richText.height() )
802 void TextEditor::textEditUndo()
806 void TextEditor::toggleFonthint()
808 setUpdatesEnabled (false);
810 if (!actionFormatUseFixedFont->isOn() )
811 e->setCurrentFont (varFont);
813 e->setCurrentFont (fixedFont);
814 e->selectAll (false);
815 setUpdatesEnabled (true);
819 void TextEditor::setFixedFont()
822 QFont font =QFontDialog::getFont(
823 &ok, fixedFont, this );
825 // font is set to the font the user selected
829 void TextEditor::setVarFont()
832 QFont font =QFontDialog::getFont(
833 &ok, varFont, this );
835 // font is set to the font the user selected
839 void TextEditor::textBold()
841 e->setBold( actionTextBold->isOn() );
844 void TextEditor::textUnderline()
846 e->setUnderline( actionTextUnderline->isOn() );
849 void TextEditor::textItalic()
851 e->setItalic( actionTextItalic->isOn() );
854 void TextEditor::textFamily( const QString &f )
859 void TextEditor::textSize( const QString &p )
861 e->setPointSize( p.toInt() );
865 void TextEditor::textColor()
867 QColor col = QColorDialog::getColor( e->color(), this );
868 if ( !col.isValid() )
871 QPixmap pix( 16, 16 );
873 actionTextColor->setIconSet( pix );
876 void TextEditor::textAlign( QAction *a )
878 if ( a == actionAlignLeft )
879 e->setAlignment( AlignLeft );
880 else if ( a == actionAlignCenter )
881 e->setAlignment( AlignHCenter );
882 else if ( a == actionAlignRight )
883 e->setAlignment( AlignRight );
884 else if ( a == actionAlignJustify )
885 e->setAlignment( AlignJustify );
888 void TextEditor::fontChanged( const QFont &f )
890 comboFont->lineEdit()->setText( f.family() );
891 comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
892 actionTextBold->setOn( f.bold() );
893 actionTextItalic->setOn( f.italic() );
894 actionTextUnderline->setOn( f.underline() );
897 void TextEditor::colorChanged( const QColor &c )
899 QPixmap pix( 16, 16 );
901 actionTextColor->setIconSet( pix );
904 void TextEditor::alignmentChanged( int a )
906 if ( ( a == AlignAuto ) || ( a & AlignLeft ))
907 actionAlignLeft->setOn( true );
908 else if ( ( a & AlignHCenter ) )
909 actionAlignCenter->setOn( true );
910 else if ( ( a & AlignRight ) )
911 actionAlignRight->setOn( true );
912 else if ( ( a & AlignJustify ) )
913 actionAlignJustify->setOn( true );
918 void TextEditor::enableActions()
920 actionFileLoad->setEnabled(true);
921 actionFileSave->setEnabled(true);
922 actionFileSaveAs->setEnabled(true);
923 actionFilePrint->setEnabled(true);
924 actionEditUndo->setEnabled(true);
925 actionEditRedo->setEnabled(true);
926 actionEditCopy->setEnabled(true);
927 actionEditCut->setEnabled(true);
928 actionEditPaste->setEnabled(true);
929 actionEditDeleteAll->setEnabled(true);
930 actionEditConvertPar->setEnabled(true);
931 actionEditJoinLines->setEnabled(true);
932 actionFormatUseFixedFont->setEnabled(true);
935 void TextEditor::disableActions()
937 actionFileLoad->setEnabled(false);
938 actionFileSave->setEnabled(false);
939 actionFileSaveAs->setEnabled(false);
940 actionFilePrint->setEnabled(false);
941 actionEditUndo->setEnabled(false);
942 actionEditRedo->setEnabled(false);
943 actionEditCopy->setEnabled(false);
944 actionEditCut->setEnabled(false);
945 actionEditPaste->setEnabled(false);
946 actionEditDeleteAll->setEnabled(false);
947 actionEditConvertPar->setEnabled(false);
948 actionEditJoinLines->setEnabled(false);
949 actionFormatUseFixedFont->setEnabled(false);