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);
120 // Save settings in vymrc
121 settings.writeEntry("/vym/mainwindow/printerName",printer->printerName());
125 TextEditor::~TextEditor()
127 if (printer) delete printer;
129 settings.writeEntry( "/vym/noteeditor/geometry/width", width() );
130 settings.writeEntry( "/vym/noteeditor/geometry/height", height() );
131 settings.writeEntry( "/vym/noteeditor/geometry/posX", pos().x() );
132 settings.writeEntry( "/vym/noteeditor/geometry/posY", pos().y() );
135 settings.writeEntry( "/vym/noteeditor/showWithMain","yes");
137 settings.writeEntry( "/vym/noteeditor/showWithMain","no");
140 if (actionSettingsFonthintDefault->isOn() )
144 settings.writeEntry( "/vym/noteeditor/fonts/fonthintDefault",s );
145 settings.writeEntry ("/vym/noteeditor/fonts/varFont",
146 varFont.toString() );
147 settings.writeEntry ("/vym/noteeditor/fonts/fixedFont",
148 fixedFont.toString() );
151 bool TextEditor::isEmpty()
153 if (e->text().length())
159 void TextEditor::setShowWithMain(bool v)
164 bool TextEditor::showWithMain()
169 void TextEditor::setFontHint (const QString &fh)
172 actionFormatUseFixedFont->setOn (true);
174 actionFormatUseFixedFont->setOn (false);
178 QString TextEditor::getFontHint()
180 if (actionFormatUseFixedFont->isOn())
186 QString TextEditor::getFontHintDefault()
188 if (actionSettingsFonthintDefault->isOn())
194 void TextEditor::setFilename(const QString &fn)
196 if (state==filledEditor)
200 statusBar()->message( "No filename available for this note.", statusbarTime );
205 statusBar()->message( QString( "Current filename is %1" ).arg( filename ), statusbarTime );
209 QString TextEditor::getFilename()
214 void TextEditor::setFilenameHint(const QString &fnh)
219 QString TextEditor::getFilenameHint()
224 bool TextEditor::findText(const QString &t, const bool &cs)
226 bool wo=false; // word matches
227 if (e->find (t, cs, wo, true, 0, 0 ))
233 void TextEditor::setupFileActions()
235 QToolBar *tb = new QToolBar( this );
236 tb->setLabel( "File Actions" );
237 QPopupMenu *menu = new QPopupMenu( this );
238 menuBar()->insertItem( tr( "&File" ), menu );
241 a = new QAction( tr( "Import" ), QPixmap( fileopen_xpm), tr( "&Import..." ), CTRL + Key_O, this, "fileImport" );
242 connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
243 a->setEnabled(false);
248 menu->insertSeparator();
249 a = new QAction( tr( "Export Note (HTML)" ), QPixmap( filesave_xpm ), tr( "&Export..." ), CTRL + Key_S, this, "fileSave" );
250 connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
255 a = new QAction( tr( "Export Note As (HTML) " ), QPixmap(), tr( "Export &As... (HTML)" ), 0, this, "exportHTML" );
256 connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
260 a = new QAction( tr( "Export Note As (ASCII) " ), QPixmap(), tr( "Export &As...(ASCII)" ), ALT + Key_X, this, "exportASCII" );
261 connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
265 menu->insertSeparator();
266 a = new QAction( tr( "Print Note" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
267 connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
273 void TextEditor::setupEditActions()
275 QToolBar *tb = new QToolBar( this );
276 tb->setLabel( "Edit Actions" );
277 QPopupMenu *menu = new QPopupMenu( this );
278 menuBar()->insertItem( tr( "&Edit" ), menu );
281 a = new QAction( tr( "Undo" ), QPixmap(editundo_xpm), tr( "&Undo" ), CTRL + Key_Z, this, "undoEvent" );
282 connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
287 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
288 connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
293 menu->insertSeparator();
294 a = new QAction( tr( "Select and copy all" ), QPixmap(), tr( "Select and copy &all" ), CTRL + Key_A, this, "editcopyall" );
295 connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
298 menu->insertSeparator();
299 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
300 connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
305 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
306 connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
311 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
312 connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
317 a = new QAction( tr( "Delete all" ), QPixmap( edittrash_xpm ), tr( "&Delete All" ), 0, this, "editDeleteAll" );
318 connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
321 actionEditDeleteAll=a;
323 a = new QAction( tr( "Convert paragraphs to linebreaks" ), QPixmap(), tr( "&Convert Paragraphs" ), ALT + Key_P, this, "editConvertPar" );
324 connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) );
326 actionEditConvertPar=a;
328 a = new QAction( tr( "Join all lines of a paragraph" ), QPixmap(), tr( "&Join lines" ), ALT + Key_J, this, "editJoinLines" );
329 connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) );
331 actionEditJoinLines=a;
334 void TextEditor::setupFormatActions()
336 QToolBar *tb = new QToolBar( this );
337 tb->setLabel( "Format Actions" );
338 QPopupMenu *menu = new QPopupMenu( this );
339 menuBar()->insertItem( tr( "&Format" ), menu );
343 a = new QAction( tr( "Toggle font hint for the whole text" ), QPixmap(formatfixedfont_xpm), tr( "&Font hint" ), ALT + Key_I, this, "fontHint" );
344 a->setToggleAction (true);
345 a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) );
346 connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
349 actionFormatUseFixedFont=a;
351 menu->insertSeparator();
353 comboFont = new QComboBox( true, tb );
355 comboFont->insertStringList( db.families() );
356 connect( comboFont, SIGNAL( activated( const QString & ) ),
357 this, SLOT( textFamily( const QString & ) ) );
358 comboFont->lineEdit()->setText( QApplication::font().family() );
360 comboSize = new QComboBox( true, tb );
361 QValueList<int> sizes = db.standardSizes();
362 QValueList<int>::Iterator it = sizes.begin();
363 for ( ; it != sizes.end(); ++it )
364 comboSize->insertItem( QString::number( *it ) );
365 connect( comboSize, SIGNAL( activated( const QString & ) ),
366 this, SLOT( textSize( const QString & ) ) );
367 comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
369 menu->insertSeparator();
371 QPixmap pix( 16, 16 );
372 pix.fill( e->color());
373 actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
374 connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
375 actionTextColor->addTo( tb );
376 actionTextColor->addTo( menu );
378 actionTextBold = new QAction( QPixmap (formattextbold_xpm), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
379 connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
380 actionTextBold->addTo( tb );
381 actionTextBold->addTo( menu );
382 actionTextBold->setToggleAction( true );
383 actionTextItalic = new QAction( QPixmap(formattextitalic_xpm ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
384 connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
385 actionTextItalic->addTo( tb );
386 actionTextItalic->addTo( menu );
387 actionTextItalic->setToggleAction( true );
388 actionTextUnderline = new QAction( QPixmap (formattextunder_xpm ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
389 connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
390 actionTextUnderline->addTo( tb );
391 actionTextUnderline->addTo( menu );
392 actionTextUnderline->setToggleAction( true );
393 menu->insertSeparator();
395 QActionGroup *grp = new QActionGroup( this );
396 connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
398 actionAlignLeft = new QAction( QPixmap (formattextleft_xpm ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
399 actionAlignLeft->setToggleAction( true );
400 actionAlignCenter = new QAction( QPixmap (formattextcenter_xpm ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
401 actionAlignCenter->setToggleAction( true );
402 actionAlignRight = new QAction( QPixmap (formattextright_xpm ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
403 actionAlignRight->setToggleAction( true );
404 actionAlignJustify = new QAction( QPixmap ( formattextjustify_xpm ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
405 actionAlignJustify->setToggleAction( true );
410 connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
411 this, SLOT( fontChanged( const QFont & ) ) );
412 connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
413 this, SLOT( colorChanged( const QColor & ) ) );
414 connect( e, SIGNAL( currentAlignmentChanged( int ) ),
415 this, SLOT( alignmentChanged( int ) ) );
419 void TextEditor::setupSettingsActions()
421 QPopupMenu *menu = new QPopupMenu( this );
422 menuBar()->insertItem( tr( "&Settings" ), menu );
425 a = new QAction( tr( "Set fixed font" ), QPixmap(), tr( "Set &fixed font" ), 0, this, "setFixedFont" );
426 connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
428 actionSettingsFixedFont=a;
430 a = new QAction( tr( "Set variable font" ), QPixmap(), tr( "Set &variable font" ), 0, this, "setvariableFont" );
431 connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
433 actionSettingsVarFont=a;
435 a = new QAction( tr( "Used fixed font by default" ), QPixmap(), tr( "&fixed font is default" ), 0, this, "fonthintDefault" );
436 a->setToggleAction (true);
437 // set state later in constructor...
439 actionSettingsFonthintDefault=a;
442 void TextEditor::textLoad()
444 if (state!=inactiveEditor)
448 QMessageBox mb( "VYM - Note Editor",
449 "Loading will overwrite the existing note",
450 QMessageBox::Warning,
451 QMessageBox::Yes | QMessageBox::Default,
454 mb.setButtonText( QMessageBox::Yes, "Load note" );
455 switch( mb.exec() ) {
456 case QMessageBox::Cancel:
462 QFileDialog *fd=new QFileDialog( this);
463 fd->addFilter ("ASCII texts (*.txt)");
464 fd->addFilter ("VYM notes (*.html)");
467 if ( fd->exec() == QDialog::Accepted )
468 fn = fd->selectedFile();
473 if ( !f.open( IO_ReadOnly ) )
476 QTextStream ts( &f );
477 setText( ts.read() );
483 void TextEditor::closeEvent( QCloseEvent* ce )
485 if ( !e->isModified() )
487 ce->accept(); // TextEditor can be reopened with show()
488 actionViewToggleNoteEditor->setOn (false);
494 QString TextEditor::getText()
499 void TextEditor::editorChanged()
501 // received, when QTextEdit::text() has changed
502 EditorState oldstate=state;
509 if (state != oldstate)
511 if (state==emptyEditor)
512 e->setPaper (emptyPaper);
514 e->setPaper (filledPaper);
516 // SLOT is LinkableMapObj, which will update systemFlag
517 emit (textHasChanged() );
521 void TextEditor::setText(QString t)
523 if ( !QStyleSheet::mightBeRichText( t ) )
524 t = QStyleSheet::convertFromPlainText( t, QStyleSheetItem::WhiteSpaceNormal );
525 e->setReadOnly(false);
527 editorChanged(); //not called automagically
532 void TextEditor::setInactive()
534 state=inactiveEditor;
536 e->setPaper (inactivePaper);
537 e->setReadOnly (true);
542 void TextEditor::editCopyAll()
548 void TextEditor::textSaveAs()
550 QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
551 this,"export note dialog",tr("Export Note to single file") );
558 QMessageBox mb( "VYM",
559 tr("The file ") + fn +
560 tr(" exists already. "
561 "Do you want to overwrite it?"),
562 QMessageBox::Warning,
563 QMessageBox::Yes | QMessageBox::Default,
564 QMessageBox::Cancel | QMessageBox::Escape,
565 QMessageBox::NoButton );
566 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
567 mb.setButtonText( QMessageBox::No, tr("Cancel"));
568 switch( mb.exec() ) {
569 case QMessageBox::Yes:
574 case QMessageBox::Cancel:
585 statusBar()->message(tr( "Couldn't export note ") + fn, statusbarTime );
589 void TextEditor::textSave()
591 if ( filename.isEmpty() )
597 QString text = e->text();
599 if ( !f.open( IO_WriteOnly ) )
601 statusBar()->message( QString("Could not write to %1").arg(filename),
610 e->setModified( FALSE );
612 statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
615 void TextEditor::textConvertPar()
617 // In X11 a copy&paste generates paragraphs,
618 // which is not always wanted
619 // This function replaces paragraphs by linebreaks.
620 int parFrom, parTo, indFrom, indTo;
621 e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
631 t.replace ("</p>","<br />");
634 e->setCursorPosition (parFrom,indFrom);
636 // Tried to simply insert the changed text with
637 // e->insert (t,(uint)(QTextEdit::RemoveSelected));
638 // but then the html would be quoted. So I use the ugly
639 // way: insert a marker, replace it in whole text of QTextEdit
640 QString marker="R3PlAcEMeL4teR!";
642 e->setText (e->text().replace(marker,t));
647 void TextEditor::textJoinLines()
649 int parFrom, parTo, indFrom, indTo;
650 e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
656 // In addition to textConvertPar it is sometimes
657 // useful to join all lines of a paragraph
658 QRegExp re("</p>\n+<p>(?!</p>)");
662 // Above we may have introduced new " " at beginning of a
663 // paragraph - remove it.
664 re.setPattern("<p> ");
665 t.replace (re,"<p>");
668 e->setCursorPosition (parFrom,indFrom);
670 // Tried to simply insert the changed text with
671 // e->insert (t,(uint)(QTextEdit::RemoveSelected));
672 // but then the html would be quoted. So I use the ugly
673 // way: insert a marker, replace it in whole text of QTextEdit
674 QString marker="R3PlAcEMeL4teR!";
676 e->setText (e->text().replace(marker,t));
681 QString textConvertToASCII(const QString &t)
685 // convert all "<br*>" to "\n"
686 QRegExp re("<br.*>");
690 // convert all "<p>" to "\n"
691 re.setPattern ("<p>");
694 // remove all remaining tags
695 re.setPattern ("<.*>");
698 // convert "&", "<" and ">"
699 re.setPattern (">");
701 re.setPattern ("<");
703 re.setPattern ("&");
705 re.setPattern (""");
710 void TextEditor::textExportAsASCII()
712 QString text = textConvertToASCII( e->text());
714 if (!filenameHint.isEmpty())
716 if (!filenameHint.contains (".txt"))
717 s=filenameHint+".txt";
722 fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
730 QMessageBox mb( "VYM",
731 tr("The file ") + fn +
732 tr(" exists already. "
733 "Do you want to overwrite it?"),
734 QMessageBox::Warning,
735 QMessageBox::Yes | QMessageBox::Default,
736 QMessageBox::Cancel | QMessageBox::Escape,
737 QMessageBox::NoButton );
738 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
739 mb.setButtonText( QMessageBox::No, tr("Cancel"));
742 if (ret==QMessageBox::Cancel)
746 if ( !file.open( IO_WriteOnly ) )
747 statusBar()->message( QString("Could not write to %1").arg(filename),
751 QTextStream t( &file );
755 statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
761 void TextEditor::textPrint()
763 printer->setFullPage(TRUE);
764 if ( printer->setup( this ) )
766 QPainter p( printer );
767 // Check that there is a valid device to print to.
768 if ( !p.device() ) return;
769 QPaintDeviceMetrics metrics( p.device() );
770 int dpiy = metrics.logicalDpiY();
771 int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
772 QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
773 QFont font( e->currentFont() );
774 font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
776 QSimpleRichText richText( e->text(), font,
779 e->mimeSourceFactory(),
781 richText.setWidth( &p, body.width() );
786 richText.draw( &p, body.left(), body.top(), view, colorGroup() );
787 view.moveBy( 0, body.height() );
788 p.translate( 0 , -body.height() );
790 p.drawText( view.right() - p.fontMetrics().width( QString::number( page ) ),
791 view.bottom() + p.fontMetrics().ascent() + 5, QString::number( page ) );
792 if ( view.top() >= richText.height() )
800 void TextEditor::textEditUndo()
804 void TextEditor::toggleFonthint()
806 setUpdatesEnabled (false);
808 if (!actionFormatUseFixedFont->isOn() )
809 e->setCurrentFont (varFont);
811 e->setCurrentFont (fixedFont);
812 e->selectAll (false);
813 setUpdatesEnabled (true);
817 void TextEditor::setFixedFont()
820 QFont font =QFontDialog::getFont(
821 &ok, fixedFont, this );
823 // font is set to the font the user selected
827 void TextEditor::setVarFont()
830 QFont font =QFontDialog::getFont(
831 &ok, varFont, this );
833 // font is set to the font the user selected
837 void TextEditor::textBold()
839 e->setBold( actionTextBold->isOn() );
842 void TextEditor::textUnderline()
844 e->setUnderline( actionTextUnderline->isOn() );
847 void TextEditor::textItalic()
849 e->setItalic( actionTextItalic->isOn() );
852 void TextEditor::textFamily( const QString &f )
857 void TextEditor::textSize( const QString &p )
859 e->setPointSize( p.toInt() );
863 void TextEditor::textColor()
865 QColor col = QColorDialog::getColor( e->color(), this );
866 if ( !col.isValid() )
869 QPixmap pix( 16, 16 );
871 actionTextColor->setIconSet( pix );
874 void TextEditor::textAlign( QAction *a )
876 if ( a == actionAlignLeft )
877 e->setAlignment( AlignLeft );
878 else if ( a == actionAlignCenter )
879 e->setAlignment( AlignHCenter );
880 else if ( a == actionAlignRight )
881 e->setAlignment( AlignRight );
882 else if ( a == actionAlignJustify )
883 e->setAlignment( AlignJustify );
886 void TextEditor::fontChanged( const QFont &f )
888 comboFont->lineEdit()->setText( f.family() );
889 comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
890 actionTextBold->setOn( f.bold() );
891 actionTextItalic->setOn( f.italic() );
892 actionTextUnderline->setOn( f.underline() );
895 void TextEditor::colorChanged( const QColor &c )
897 QPixmap pix( 16, 16 );
899 actionTextColor->setIconSet( pix );
902 void TextEditor::alignmentChanged( int a )
904 if ( ( a == AlignAuto ) || ( a & AlignLeft ))
905 actionAlignLeft->setOn( true );
906 else if ( ( a & AlignHCenter ) )
907 actionAlignCenter->setOn( true );
908 else if ( ( a & AlignRight ) )
909 actionAlignRight->setOn( true );
910 else if ( ( a & AlignJustify ) )
911 actionAlignJustify->setOn( true );
916 void TextEditor::enableActions()
918 actionFileLoad->setEnabled(true);
919 actionFileSave->setEnabled(true);
920 actionFileSaveAs->setEnabled(true);
921 actionFilePrint->setEnabled(true);
922 actionEditUndo->setEnabled(true);
923 actionEditRedo->setEnabled(true);
924 actionEditCopy->setEnabled(true);
925 actionEditCut->setEnabled(true);
926 actionEditPaste->setEnabled(true);
927 actionEditDeleteAll->setEnabled(true);
928 actionEditConvertPar->setEnabled(true);
929 actionEditJoinLines->setEnabled(true);
930 actionFormatUseFixedFont->setEnabled(true);
933 void TextEditor::disableActions()
935 actionFileLoad->setEnabled(false);
936 actionFileSave->setEnabled(false);
937 actionFileSaveAs->setEnabled(false);
938 actionFilePrint->setEnabled(false);
939 actionEditUndo->setEnabled(false);
940 actionEditRedo->setEnabled(false);
941 actionEditCopy->setEnabled(false);
942 actionEditCut->setEnabled(false);
943 actionEditPaste->setEnabled(false);
944 actionEditDeleteAll->setEnabled(false);
945 actionEditConvertPar->setEnabled(false);
946 actionEditJoinLines->setEnabled(false);
947 actionFormatUseFixedFont->setEnabled(false);