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 );
66 e = new QTextEdit( this, "editor" );
68 e->setTextFormat(RichText); // default
69 e->setTabStopWidth (20); // unit is pixel
71 connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
72 setCentralWidget( e );
73 statusBar()->message( "Ready", statusbarTime);
74 setCaption("VYM - Note Editor");
80 setupSettingsActions();
83 emptyPaper = QBrush(gray);
84 filledPaper = QBrush(white);
85 inactivePaper= QBrush(black);
89 resize (settings.readNumEntry( "/vym/noteeditor/geometry/width", 450),
90 settings.readNumEntry( "/vym/noteeditor/geometry/height",600));
91 move (settings.readNumEntry( "/vym/noteeditor/geometry/posX", 150),
92 settings.readNumEntry( "/vym/noteeditor/geometry/posY", 50));
94 if (settings.readEntry( "/vym/noteeditor/showWithMain","yes") =="yes")
95 setShowWithMain(true);
97 setShowWithMain(false);
99 varFont.fromString( settings.readEntry
100 ("/vym/noteeditor/fonts/varFont",
101 "Nimbus Sans l,14,-1,5,48,0,0,0,0,0")
103 fixedFont.fromString (settings.readEntry (
104 "/vym/noteeditor/fonts/fixedFont",
105 "Courier,14,-1,5,48,0,0,0,1,0")
107 QString s=settings.readEntry ("/vym/noteeditor/fonts/fonthintDefault","variable");
110 actionSettingsFonthintDefault->setOn (true);
111 e->setCurrentFont (fixedFont);
114 actionSettingsFonthintDefault->setOn (false);
115 e->setCurrentFont (varFont);
121 TextEditor::~TextEditor()
123 if (printer) delete printer;
125 settings.writeEntry( "/vym/noteeditor/geometry/width", width() );
126 settings.writeEntry( "/vym/noteeditor/geometry/height", height() );
127 settings.writeEntry( "/vym/noteeditor/geometry/posX", pos().x() );
128 settings.writeEntry( "/vym/noteeditor/geometry/posY", pos().y() );
131 settings.writeEntry( "/vym/noteeditor/showWithMain","yes");
133 settings.writeEntry( "/vym/noteeditor/showWithMain","no");
136 if (actionSettingsFonthintDefault->isOn() )
140 settings.writeEntry( "/vym/noteeditor/fonts/fonthintDefault",s );
141 settings.writeEntry ("/vym/noteeditor/fonts/varFont",
142 varFont.toString() );
143 settings.writeEntry ("/vym/noteeditor/fonts/fixedFont",
144 fixedFont.toString() );
147 bool TextEditor::isEmpty()
149 if (e->text().length())
155 void TextEditor::setShowWithMain(bool v)
160 bool TextEditor::showWithMain()
165 void TextEditor::setFontHint (const QString &fh)
168 actionFormatUseFixedFont->setOn (true);
170 actionFormatUseFixedFont->setOn (false);
174 QString TextEditor::getFontHint()
176 if (actionFormatUseFixedFont->isOn())
182 QString TextEditor::getFontHintDefault()
184 if (actionSettingsFonthintDefault->isOn())
190 void TextEditor::setFilename(const QString &fn)
192 if (state==filledEditor)
196 statusBar()->message( "No filename available for this note.", statusbarTime );
201 statusBar()->message( QString( "Current filename is %1" ).arg( filename ), statusbarTime );
205 QString TextEditor::getFilename()
210 void TextEditor::setFilenameHint(const QString &fnh)
215 QString TextEditor::getFilenameHint()
220 bool TextEditor::findText(const QString &t, const bool &cs)
222 bool wo=false; // word matches
223 if (e->find (t, cs, wo, true, 0, 0 ))
229 void TextEditor::setupFileActions()
231 QToolBar *tb = new QToolBar( this );
232 tb->setLabel( "File Actions" );
233 QPopupMenu *menu = new QPopupMenu( this );
234 menuBar()->insertItem( tr( "&File" ), menu );
237 a = new QAction( tr( "Import" ), QPixmap( fileopen_xpm), tr( "&Import..." ), CTRL + Key_O, this, "fileImport" );
238 connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
239 a->setEnabled(false);
244 menu->insertSeparator();
245 a = new QAction( tr( "Export Note (HTML)" ), QPixmap( filesave_xpm ), tr( "&Export..." ), CTRL + Key_S, this, "fileSave" );
246 connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
251 a = new QAction( tr( "Export Note As (HTML) " ), QPixmap(), tr( "Export &As... (HTML)" ), 0, this, "exportHTML" );
252 connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
256 a = new QAction( tr( "Export Note As (ASCII) " ), QPixmap(), tr( "Export &As...(ASCII)" ), ALT + Key_X, this, "exportASCII" );
257 connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
261 menu->insertSeparator();
262 a = new QAction( tr( "Print Note" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
263 connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
269 void TextEditor::setupEditActions()
271 QToolBar *tb = new QToolBar( this );
272 tb->setLabel( "Edit Actions" );
273 QPopupMenu *menu = new QPopupMenu( this );
274 menuBar()->insertItem( tr( "&Edit" ), menu );
277 a = new QAction( tr( "Undo" ), QPixmap(editundo_xpm), tr( "&Undo" ), CTRL + Key_Z, this, "undoEvent" );
278 connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
283 a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" );
284 connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
289 menu->insertSeparator();
290 a = new QAction( tr( "Select and copy all" ), QPixmap(), tr( "Select and copy &all" ), CTRL + Key_A, this, "editcopyall" );
291 connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
294 menu->insertSeparator();
295 a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
296 connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
301 a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
302 connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
307 a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
308 connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
313 a = new QAction( tr( "Delete all" ), QPixmap( edittrash_xpm ), tr( "&Delete All" ), 0, this, "editDeleteAll" );
314 connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
317 actionEditDeleteAll=a;
319 a = new QAction( tr( "Convert paragraphs to linebreaks" ), QPixmap(), tr( "&Convert Paragraphs" ), ALT + Key_P, this, "editConvertPar" );
320 connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) );
322 actionEditConvertPar=a;
324 a = new QAction( tr( "Join all lines of a paragraph" ), QPixmap(), tr( "&Join lines" ), ALT + Key_J, this, "editJoinLines" );
325 connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) );
327 actionEditJoinLines=a;
330 void TextEditor::setupFormatActions()
332 QToolBar *tb = new QToolBar( this );
333 tb->setLabel( "Format Actions" );
334 QPopupMenu *menu = new QPopupMenu( this );
335 menuBar()->insertItem( tr( "&Format" ), menu );
339 a = new QAction( tr( "Toggle font hint for the whole text" ), QPixmap(formatfixedfont_xpm), tr( "&Font hint" ), ALT + Key_I, this, "fontHint" );
340 a->setToggleAction (true);
341 a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) );
342 connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
345 actionFormatUseFixedFont=a;
347 menu->insertSeparator();
349 comboFont = new QComboBox( true, tb );
351 comboFont->insertStringList( db.families() );
352 connect( comboFont, SIGNAL( activated( const QString & ) ),
353 this, SLOT( textFamily( const QString & ) ) );
354 comboFont->lineEdit()->setText( QApplication::font().family() );
356 comboSize = new QComboBox( true, tb );
357 QValueList<int> sizes = db.standardSizes();
358 QValueList<int>::Iterator it = sizes.begin();
359 for ( ; it != sizes.end(); ++it )
360 comboSize->insertItem( QString::number( *it ) );
361 connect( comboSize, SIGNAL( activated( const QString & ) ),
362 this, SLOT( textSize( const QString & ) ) );
363 comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
365 menu->insertSeparator();
367 QPixmap pix( 16, 16 );
368 pix.fill( e->color());
369 actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
370 connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
371 actionTextColor->addTo( tb );
372 actionTextColor->addTo( menu );
374 actionTextBold = new QAction( QPixmap (formattextbold_xpm), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
375 connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
376 actionTextBold->addTo( tb );
377 actionTextBold->addTo( menu );
378 actionTextBold->setToggleAction( true );
379 actionTextItalic = new QAction( QPixmap(formattextitalic_xpm ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
380 connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
381 actionTextItalic->addTo( tb );
382 actionTextItalic->addTo( menu );
383 actionTextItalic->setToggleAction( true );
384 actionTextUnderline = new QAction( QPixmap (formattextunder_xpm ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
385 connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
386 actionTextUnderline->addTo( tb );
387 actionTextUnderline->addTo( menu );
388 actionTextUnderline->setToggleAction( true );
389 menu->insertSeparator();
391 QActionGroup *grp = new QActionGroup( this );
392 connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
394 actionAlignLeft = new QAction( QPixmap (formattextleft_xpm ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
395 actionAlignLeft->setToggleAction( true );
396 actionAlignCenter = new QAction( QPixmap (formattextcenter_xpm ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
397 actionAlignCenter->setToggleAction( true );
398 actionAlignRight = new QAction( QPixmap (formattextright_xpm ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
399 actionAlignRight->setToggleAction( true );
400 actionAlignJustify = new QAction( QPixmap ( formattextjustify_xpm ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
401 actionAlignJustify->setToggleAction( true );
406 connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
407 this, SLOT( fontChanged( const QFont & ) ) );
408 connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
409 this, SLOT( colorChanged( const QColor & ) ) );
410 connect( e, SIGNAL( currentAlignmentChanged( int ) ),
411 this, SLOT( alignmentChanged( int ) ) );
415 void TextEditor::setupSettingsActions()
417 QPopupMenu *menu = new QPopupMenu( this );
418 menuBar()->insertItem( tr( "&Settings" ), menu );
421 a = new QAction( tr( "Set fixed font" ), QPixmap(), tr( "Set &fixed font" ), 0, this, "setFixedFont" );
422 connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
424 actionSettingsFixedFont=a;
426 a = new QAction( tr( "Set variable font" ), QPixmap(), tr( "Set &variable font" ), 0, this, "setvariableFont" );
427 connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
429 actionSettingsVarFont=a;
431 a = new QAction( tr( "Used fixed font by default" ), QPixmap(), tr( "&fixed font is default" ), 0, this, "fonthintDefault" );
432 a->setToggleAction (true);
433 // set state later in constructor...
435 actionSettingsFonthintDefault=a;
438 void TextEditor::textLoad()
440 if (state!=inactiveEditor)
444 QMessageBox mb( "VYM - Note Editor",
445 "Loading will overwrite the existing note",
446 QMessageBox::Warning,
447 QMessageBox::Yes | QMessageBox::Default,
450 mb.setButtonText( QMessageBox::Yes, "Load note" );
451 switch( mb.exec() ) {
452 case QMessageBox::Cancel:
458 QFileDialog *fd=new QFileDialog( this);
459 fd->addFilter ("ASCII texts (*.txt)");
460 fd->addFilter ("VYM notes (*.html)");
463 if ( fd->exec() == QDialog::Accepted )
464 fn = fd->selectedFile();
469 if ( !f.open( IO_ReadOnly ) )
472 QTextStream ts( &f );
473 setText( ts.read() );
479 void TextEditor::closeEvent( QCloseEvent* ce )
481 if ( !e->isModified() )
483 ce->accept(); // TextEditor can be reopened with show()
484 actionViewToggleNoteEditor->setOn (false);
490 QString TextEditor::getText()
495 void TextEditor::editorChanged()
497 // received, when QTextEdit::text() has changed
498 EditorState oldstate=state;
505 if (state != oldstate)
507 if (state==emptyEditor)
508 e->setPaper (emptyPaper);
510 e->setPaper (filledPaper);
512 // SLOT is LinkableMapObj, which will update systemFlag
513 emit (textHasChanged() );
517 void TextEditor::setText(QString t)
519 if ( !QStyleSheet::mightBeRichText( t ) )
520 t = QStyleSheet::convertFromPlainText( t, QStyleSheetItem::WhiteSpaceNormal );
521 e->setReadOnly(false);
523 editorChanged(); //not called automagically
528 void TextEditor::setInactive()
531 state=inactiveEditor;
532 e->setPaper (inactivePaper);
533 e->setReadOnly (true);
538 void TextEditor::editCopyAll()
544 void TextEditor::textSaveAs()
546 QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
547 this,"export note dialog",tr("Export Note to single file") );
554 QMessageBox mb( "VYM",
555 tr("The file ") + fn +
556 tr(" exists already. "
557 "Do you want to overwrite it?"),
558 QMessageBox::Warning,
559 QMessageBox::Yes | QMessageBox::Default,
560 QMessageBox::Cancel | QMessageBox::Escape,
561 QMessageBox::NoButton );
562 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
563 mb.setButtonText( QMessageBox::No, tr("Cancel"));
564 switch( mb.exec() ) {
565 case QMessageBox::Yes:
570 case QMessageBox::Cancel:
581 statusBar()->message(tr( "Couldn't export note ") + fn, statusbarTime );
585 void TextEditor::textSave()
587 if ( filename.isEmpty() )
593 QString text = e->text();
595 if ( !f.open( IO_WriteOnly ) )
597 statusBar()->message( QString("Could not write to %1").arg(filename),
606 e->setModified( FALSE );
608 statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
611 void TextEditor::textConvertPar()
613 // In X11 a copy&paste generates paragraphs,
614 // which is not always wanted
615 // This function replaces paragraphs by linebreaks.
616 int parFrom, parTo, indFrom, indTo;
617 e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
627 t.replace ("</p>","<br />");
630 e->setCursorPosition (parFrom,indFrom);
632 // Tried to simply insert the changed text with
633 // e->insert (t,(uint)(QTextEdit::RemoveSelected));
634 // but then the html would be quoted. So I use the ugly
635 // way: insert a marker, replace it in whole text of QTextEdit
636 QString marker="R3PlAcEMeL4teR!";
638 e->setText (e->text().replace(marker,t));
643 void TextEditor::textJoinLines()
645 int parFrom, parTo, indFrom, indTo;
646 e->getSelection (&parFrom,&indFrom,&parTo,&indTo);
652 // In addition to textConvertPar it is sometimes
653 // useful to join all lines of a paragraph
654 QRegExp re("</p>\n+<p>(?!</p>)");
658 // Above we may have introduced new " " at beginning of a
659 // paragraph - remove it.
660 re.setPattern("<p> ");
661 t.replace (re,"<p>");
664 e->setCursorPosition (parFrom,indFrom);
666 // Tried to simply insert the changed text with
667 // e->insert (t,(uint)(QTextEdit::RemoveSelected));
668 // but then the html would be quoted. So I use the ugly
669 // way: insert a marker, replace it in whole text of QTextEdit
670 QString marker="R3PlAcEMeL4teR!";
672 e->setText (e->text().replace(marker,t));
677 QString TextEditor::textConvertToASCII(const QString &t)
681 // convert all "<br*>" to "\n"
682 QRegExp re("<br.*>");
686 // convert all "</p>" to "\n"
687 re.setPattern ("/p");
690 // remove all remaining tags
691 re.setPattern ("<.*>");
694 // convert "&", "<" and ">"
695 re.setPattern (">");
697 re.setPattern ("<");
699 re.setPattern ("&");
704 void TextEditor::textExportAsASCII()
706 QString text = textConvertToASCII( e->text());
708 if (!filenameHint.isEmpty())
710 if (!filenameHint.contains (".txt"))
711 s=filenameHint+".txt";
716 fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
724 QMessageBox mb( "VYM",
725 tr("The file ") + fn +
726 tr(" exists already. "
727 "Do you want to overwrite it?"),
728 QMessageBox::Warning,
729 QMessageBox::Yes | QMessageBox::Default,
730 QMessageBox::Cancel | QMessageBox::Escape,
731 QMessageBox::NoButton );
732 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
733 mb.setButtonText( QMessageBox::No, tr("Cancel"));
736 if (ret==QMessageBox::Cancel)
740 if ( !file.open( IO_WriteOnly ) )
741 statusBar()->message( QString("Could not write to %1").arg(filename),
745 QTextStream t( &file );
749 statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
755 void TextEditor::textPrint()
757 printer->setFullPage(TRUE);
758 if ( printer->setup( this ) )
760 QPainter p( printer );
761 // Check that there is a valid device to print to.
762 if ( !p.device() ) return;
763 QPaintDeviceMetrics metrics( p.device() );
764 int dpiy = metrics.logicalDpiY();
765 int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
766 QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
767 QFont font( e->currentFont() );
768 font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
770 QSimpleRichText richText( e->text(), font,
773 e->mimeSourceFactory(),
775 richText.setWidth( &p, body.width() );
780 richText.draw( &p, body.left(), body.top(), view, colorGroup() );
781 view.moveBy( 0, body.height() );
782 p.translate( 0 , -body.height() );
784 p.drawText( view.right() - p.fontMetrics().width( QString::number( page ) ),
785 view.bottom() + p.fontMetrics().ascent() + 5, QString::number( page ) );
786 if ( view.top() >= richText.height() )
794 void TextEditor::textEditUndo()
798 void TextEditor::toggleFonthint()
800 setUpdatesEnabled (false);
802 if (!actionFormatUseFixedFont->isOn() )
803 e->setCurrentFont (varFont);
805 e->setCurrentFont (fixedFont);
806 e->selectAll (false);
807 setUpdatesEnabled (true);
811 void TextEditor::setFixedFont()
814 QFont font =QFontDialog::getFont(
815 &ok, fixedFont, this );
817 // font is set to the font the user selected
821 void TextEditor::setVarFont()
824 QFont font =QFontDialog::getFont(
825 &ok, varFont, this );
827 // font is set to the font the user selected
831 void TextEditor::textBold()
833 e->setBold( actionTextBold->isOn() );
836 void TextEditor::textUnderline()
838 e->setUnderline( actionTextUnderline->isOn() );
841 void TextEditor::textItalic()
843 e->setItalic( actionTextItalic->isOn() );
846 void TextEditor::textFamily( const QString &f )
851 void TextEditor::textSize( const QString &p )
853 e->setPointSize( p.toInt() );
857 void TextEditor::textColor()
859 QColor col = QColorDialog::getColor( e->color(), this );
860 if ( !col.isValid() )
863 QPixmap pix( 16, 16 );
865 actionTextColor->setIconSet( pix );
868 void TextEditor::textAlign( QAction *a )
870 if ( a == actionAlignLeft )
871 e->setAlignment( AlignLeft );
872 else if ( a == actionAlignCenter )
873 e->setAlignment( AlignHCenter );
874 else if ( a == actionAlignRight )
875 e->setAlignment( AlignRight );
876 else if ( a == actionAlignJustify )
877 e->setAlignment( AlignJustify );
880 void TextEditor::fontChanged( const QFont &f )
882 comboFont->lineEdit()->setText( f.family() );
883 comboSize->lineEdit()->setText( QString::number( f.pointSize() ) );
884 actionTextBold->setOn( f.bold() );
885 actionTextItalic->setOn( f.italic() );
886 actionTextUnderline->setOn( f.underline() );
889 void TextEditor::colorChanged( const QColor &c )
891 QPixmap pix( 16, 16 );
893 actionTextColor->setIconSet( pix );
896 void TextEditor::alignmentChanged( int a )
898 if ( ( a == AlignAuto ) || ( a & AlignLeft ))
899 actionAlignLeft->setOn( true );
900 else if ( ( a & AlignHCenter ) )
901 actionAlignCenter->setOn( true );
902 else if ( ( a & AlignRight ) )
903 actionAlignRight->setOn( true );
904 else if ( ( a & AlignJustify ) )
905 actionAlignJustify->setOn( true );
910 void TextEditor::enableActions()
912 actionFileLoad->setEnabled(true);
913 actionFileSave->setEnabled(true);
914 actionFileSaveAs->setEnabled(true);
915 actionFilePrint->setEnabled(true);
916 actionEditUndo->setEnabled(true);
917 actionEditRedo->setEnabled(true);
918 actionEditCopy->setEnabled(true);
919 actionEditCut->setEnabled(true);
920 actionEditPaste->setEnabled(true);
921 actionEditDeleteAll->setEnabled(true);
922 actionEditConvertPar->setEnabled(true);
923 actionEditJoinLines->setEnabled(true);
924 actionFormatUseFixedFont->setEnabled(true);
927 void TextEditor::disableActions()
929 actionFileLoad->setEnabled(false);
930 actionFileSave->setEnabled(false);
931 actionFileSaveAs->setEnabled(false);
932 actionFilePrint->setEnabled(false);
933 actionEditUndo->setEnabled(false);
934 actionEditRedo->setEnabled(false);
935 actionEditCopy->setEnabled(false);
936 actionEditCut->setEnabled(false);
937 actionEditPaste->setEnabled(false);
938 actionEditDeleteAll->setEnabled(false);
939 actionEditConvertPar->setEnabled(false);
940 actionEditJoinLines->setEnabled(false);
941 actionFormatUseFixedFont->setEnabled(false);