1 #include "texteditor.h"
10 extern int statusbarTime;
11 extern Settings settings;
13 extern QAction *actionViewToggleNoteEditor;
15 extern QString iconPath;
16 extern QString vymName;
23 ///////////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////////
27 TextEditor::TextEditor()
29 printer = new QPrinter( QPrinter::HighResolution );
30 printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString());
32 e = new QTextEdit( this);
34 e->setTextFormat(Qt::RichText); // default
35 e->setTabStopWidth (20); // unit is pixel
36 e->setColor (Qt::black);
37 e->setAutoFillBackground (true);
38 connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
39 setCentralWidget( e );
40 statusBar()->message( tr("Ready","Statusbar message"), statusbarTime);
41 setCaption(vymName +" - " +tr ("Note Editor","Window caption"));
44 connect(e, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
45 this, SLOT(formatChanged(const QTextCharFormat &)));
53 setupSettingsActions();
56 blockChangedSignal=false;
60 resize (settings.value ( "/satellite/noteeditor/geometry/size", QSize(450,600)).toSize());
61 move (settings.value ( "/satellite/noteeditor/geometry/pos", QPoint (250,50)).toPoint());
63 setShowWithMain (settings.value ( "/satellite/noteeditor/showWithMain",true).toBool());
65 varFont.fromString( settings.value
66 ("/satellite/noteeditor/fonts/varFont",
67 "Nimbus Sans l,10,-1,5,48,0,0,0,0,0").toString()
69 fixedFont.fromString (settings.value(
70 "/satellite/noteeditor/fonts/fixedFont",
71 "Courier,10-1,5,48,0,0,0,1,0").toString()
73 QString s=settings.value ("/satellite/noteeditor/fonts/fonthintDefault","variable").toString();
76 actionSettingsFonthintDefault->setOn (true);
77 e->setCurrentFont (fixedFont);
80 actionSettingsFonthintDefault->setOn (false);
81 e->setCurrentFont (varFont);
85 // Restore position of toolbars
86 restoreState (settings.value("/satellite/noteeditor/state",0).toByteArray());
88 // Save settings in vymrc
89 settings.setValue("/mainwindow/printerName",printer->printerName());
93 TextEditor::~TextEditor()
95 if (printer) delete printer;
97 settings.setValue( "/satellite/noteeditor/geometry/size", size() );
98 settings.setValue( "/satellite/noteeditor/geometry/pos", pos() );
99 settings.setValue ("/satellite/noteeditor/state",saveState(0));
101 settings.setValue( "/satellite/noteeditor/showWithMain",showwithmain);
104 if (actionSettingsFonthintDefault->isOn() )
108 settings.setValue( "/satellite/noteeditor/fonts/fonthintDefault",s );
109 settings.setValue("/satellite/noteeditor/fonts/varFont", varFont.toString() );
110 settings.setValue("/satellite/noteeditor/fonts/fixedFont", fixedFont.toString() );
115 void TextEditor::reset()
118 actionFormatUseFixedFont->setOn (false);
119 actionTextBold->setOn (false);
122 actionTextUnderline->setOn (false);
123 e->setUnderline (false);
125 actionTextItalic->setOn (false);
126 e->setItalic (false);
128 QPixmap pix( 16, 16 );
129 pix.fill( Qt::black );
130 actionTextColor->setIconSet( pix );
131 e->setColor (Qt::black);
133 actionAlignSubScript->setOn (false);
134 actionAlignSuperScript->setOn (false);
135 actionAlignLeft->setOn (true);
136 e->setAlignment( Qt::AlignLeft );
139 bool TextEditor::isEmpty()
141 if (e->toPlainText().length()>0)
147 void TextEditor::setShowWithMain(bool v)
152 bool TextEditor::showWithMain()
158 void TextEditor::setFontHint (const QString &fh)
161 actionFormatUseFixedFont->setOn (true);
163 actionFormatUseFixedFont->setOn (false);
167 QString TextEditor::getFontHint()
169 if (actionFormatUseFixedFont->isOn())
175 QString TextEditor::getFontHintDefault()
177 if (actionSettingsFonthintDefault->isOn())
183 void TextEditor::setFilename(const QString &fn)
185 if (state==filledEditor)
190 statusBar()->message( tr("No filename available for this note.","Statusbar message"), statusbarTime );
195 statusBar()->message( tr(QString( "Current filename is %1" ).arg( filename ),"Statusbar message"), statusbarTime );
200 QString TextEditor::getFilename()
205 void TextEditor::setFilenameHint(const QString &fnh)
210 QString TextEditor::getFilenameHint()
215 QString TextEditor::getText()
217 if (e->toPlainText().isEmpty())
223 NoteObj TextEditor::getNoteObj()
225 NoteObj note (getText() );
226 note.setFontHint (getFontHint() );
227 note.setFilenameHint (getFilenameHint () );
231 void TextEditor::setNote (const NoteObj ¬e)
233 setText (note.getNote() );
234 setFilenameHint (note.getFilenameHint() );
235 setFontHint (note.getFontHint() );
238 bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags)
240 if (e->find (t,flags))
246 void TextEditor::setupFileActions()
248 QToolBar *tb = addToolBar ( tr("Note Actions") );
249 tb->setObjectName ("noteEditorFileActions");
250 QMenu *fileMenu = menuBar()->addMenu( tr( "&Note","Menubar" ));
253 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this);
254 a->setStatusTip (tr( "Import","Status tip for Note menu" ) );
255 a->setShortcut( Qt::CTRL + Qt::Key_O );
256 connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
258 fileMenu->addAction (a);
261 fileMenu->addSeparator();
262 a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this);
263 a->setStatusTip (tr( "Export Note (HTML)","Status tip for Note menu" ) );
264 a->setShortcut( Qt::CTRL + Qt::Key_S );
265 connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
267 fileMenu->addAction (a);
270 a = new QAction( QPixmap(), tr( "Export &As... (HTML)" ), this);
271 a->setStatusTip (tr( "Export Note As (HTML) ","Status tip for Note Menu" ));
272 connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
273 fileMenu->addAction (a);
276 a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this);
277 a->setStatusTip ( tr( "Export Note As (ASCII) ","Status tip for note menu" ) );
278 a->setShortcut(Qt::ALT + Qt::Key_X );
279 connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
280 fileMenu->addAction (a);
283 fileMenu->addSeparator();
284 a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this);
285 a->setStatusTip (tr( "Print Note","Status tip for note menu" ) );
286 a->setShortcut( Qt::CTRL + Qt::Key_P );
287 connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
289 fileMenu->addAction (a);
293 void TextEditor::setupEditActions()
295 QToolBar *tb = addToolBar ( tr( "Edit Actions" ));
296 tb->setObjectName ("noteEditorEditActions");
297 QMenu *editMenu = menuBar()->addMenu ( tr( "&Edit" ));
300 a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this );
301 a->setStatusTip ( tr( "Undo","Status tip for note menu" ) );
302 a->setShortcut(Qt::CTRL + Qt::Key_Z );
303 connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
304 editMenu->addAction (a);
308 a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this);
309 a->setStatusTip ( tr( "Redo","Status tip for note menu" ) );
310 a->setShortcut( Qt::CTRL + Qt::Key_Y );
311 connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
312 editMenu->addAction (a);
316 editMenu->addSeparator();
317 a = new QAction(QPixmap(), tr( "Select and copy &all" ),this);
318 a->setStatusTip ( tr( "Select and copy all","Status tip for note menu" ) );
319 a->setShortcut( Qt::CTRL + Qt::Key_A );
320 connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
321 editMenu->addAction (a);
323 editMenu->addSeparator();
324 a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this);
325 a->setStatusTip ( tr( "Copy","Status tip for note menu" ) );
326 a->setShortcut( Qt::CTRL + Qt::Key_C );
327 connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
328 editMenu->addAction (a);
332 a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this);
333 a->setStatusTip ( tr( "Cut","Status tip for note menu" ) );
334 a->setShortcut( Qt::CTRL + Qt::Key_X );
335 connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
336 editMenu->addAction (a);
340 a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this);
341 a->setStatusTip ( tr( "Paste","Status tip for note menu" ) );
342 a->setShortcut( Qt::CTRL + Qt::Key_V );
343 connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
344 editMenu->addAction (a);
348 a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this);
349 a->setStatusTip (tr( "Delete all","Status tip for note menu" ) );
350 connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
351 editMenu->addAction (a);
353 actionEditDeleteAll=a;
357 void TextEditor::setupFormatActions()
359 QToolBar *tb = addToolBar ( tr("Format Actions" ));
360 tb->setObjectName ("noteEditorFormatActions");
361 QMenu *formatMenu = menuBar()->addMenu ( tr( "F&ormat" ));
365 a = new QAction( QPixmap(iconPath+"formatfixedfont.png"), tr( "&Font hint" ), Qt::ALT + Qt::Key_I, this, "fontHint" );
366 a->setStatusTip (tr( "Toggle font hint for the whole text","Status tip for note menu" ) );
367 a->setToggleAction (true);
368 a->setOn (settings.value("/noteeditor/fonts/useFixedByDefault",false).toBool() );
369 connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
370 formatMenu->addAction (a);
372 actionFormatUseFixedFont=a;
374 comboFont = new QComboBox;
375 tb->addWidget (comboFont);
376 QFontDatabase fontDB;
377 comboFont->insertStringList( fontDB.families() );
378 connect( comboFont, SIGNAL( activated( const QString & ) ),
379 this, SLOT( textFamily( const QString & ) ) );
380 comboFont->addItem( QApplication::font().family() );
381 comboSize = new QComboBox;
382 tb->addWidget (comboSize);
383 QList<int> sizes=fontDB.standardSizes();
384 QList<int>::iterator i = sizes.begin();
385 while (i != sizes.end())
387 ++i; // increment i before using it
388 comboSize->insertItem ( QString::number(*i));
390 connect( comboSize, SIGNAL( activated( const QString & ) ),
391 this, SLOT( textSize( const QString & ) ) );
392 comboSize->addItem ( QString::number( QApplication::font().pointSize() ) );
394 formatMenu->addSeparator();
396 QPixmap pix( 16, 16 );
397 pix.fill( e->color());
398 a = new QAction( pix, tr( "&Color..." ), this);
399 formatMenu->addAction (a);
401 connect( a, SIGNAL( activated() ), this, SLOT( textColor() ) );
404 a = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
405 a->setShortcut(Qt::CTRL + Qt::Key_B );
406 connect( a, SIGNAL( activated() ), this, SLOT( textBold() ) );
408 formatMenu->addAction (a);
409 a->setToggleAction( true );
412 a = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this);
413 a->setShortcut(Qt::CTRL + Qt::Key_I);
414 connect( a, SIGNAL( activated() ), this, SLOT( textItalic() ) );
416 formatMenu->addAction (a);
417 a->setToggleAction( true );
420 a = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
421 a->setShortcut(Qt::CTRL + Qt::Key_U );
422 connect( a, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
424 formatMenu->addAction (a);
425 a->setToggleAction( true );
426 actionTextUnderline=a;
427 formatMenu->addSeparator();
429 QActionGroup *grp2 = new QActionGroup( this );
430 grp2->setExclusive(true);
431 a = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
432 a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
433 a->setToggleAction( true );
435 formatMenu->addAction (a);
436 connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
437 actionAlignSubScript=a;
439 a = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 );
440 a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
441 a->setToggleAction( true );
443 formatMenu->addAction (a);
444 connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
445 actionAlignSuperScript=a;
446 QActionGroup *grp = new QActionGroup( this );
447 connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
449 formatMenu->addSeparator();
451 a = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
452 a->setShortcut( Qt::CTRL+Qt::Key_L );
453 a->setToggleAction( true );
455 formatMenu->addAction (a);
457 a = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
458 a->setShortcut( Qt::CTRL + Qt::Key_E);
459 a->setToggleAction( true );
461 formatMenu->addAction (a);
463 a = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
464 a->setShortcut(Qt::CTRL + Qt::Key_R );
465 a->setToggleAction( true );
467 formatMenu->addAction (a);
469 a = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
470 a->setShortcut(Qt::CTRL + Qt::Key_J );
471 a->setToggleAction( true );
473 formatMenu->addAction (a);
474 actionAlignJustify=a;
477 void TextEditor::setupSettingsActions()
479 QMenu *settingsMenu = menuBar()->addMenu ( tr( "&Settings" ));
482 a = new QAction(tr( "Set &fixed font" ), this);
483 a->setStatusTip ( tr( "Set fixed font","Status tip for note menu" ));
484 connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
485 settingsMenu->addAction (a);
486 actionSettingsFixedFont=a;
488 a = new QAction(tr( "Set &variable font" ), this);
489 a->setStatusTip ( tr( "Set variable font","Status tip for note menu" ) );
490 connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
491 settingsMenu->addAction (a);
492 actionSettingsVarFont=a;
494 a = new QAction(tr( "&fixed font is default" ), this);
495 a->setStatusTip (tr( "Used fixed font by default","Status tip for note menu" ) );
496 a->setToggleAction (true);
497 // set state later in constructor...
498 settingsMenu->addAction (a);
499 actionSettingsFonthintDefault=a;
502 void TextEditor::textLoad()
504 if (state!=inactiveEditor)
508 QMessageBox mb( vymName + " - " +tr("Note Editor"),
509 "Loading will overwrite the existing note",
510 QMessageBox::Warning,
511 QMessageBox::Yes | QMessageBox::Default,
514 mb.setButtonText( QMessageBox::Yes, "Load note" );
515 switch( mb.exec() ) {
516 case QMessageBox::Cancel:
522 QFileDialog *fd=new QFileDialog( this);
524 types<< "Text (*.txt *.html)"<<
525 "VYM notes and HTML (*.html)" <<
526 "ASCII texts (*.txt)" <<
528 fd->setFilters (types);
529 fd->setDirectory (QDir().current());
532 if ( fd->exec() == QDialog::Accepted )
533 fn = fd->selectedFile();
538 if ( !f.open( QIODevice::ReadOnly ) )
541 QTextStream ts( &f );
542 setText( ts.read() );
548 void TextEditor::closeEvent( QCloseEvent* ce )
550 ce->accept(); // TextEditor can be reopened with show()
553 emit (windowClosed() );
557 void TextEditor::editorChanged()
564 if (state==emptyEditor)
565 setState (emptyEditor);
567 setState (filledEditor);
568 // SLOT is LinkableMapObj, which will update systemFlag
569 if (!blockChangedSignal) emit (textHasChanged() );
573 void TextEditor::setText(const QString &t)
575 blockChangedSignal=true;
576 e->setReadOnly(false);
578 if (Qt::mightBeRichText (t))
582 actionFormatUseFixedFont->setChecked (true);
586 blockChangedSignal=false;
589 void TextEditor::setInactive()
591 state=inactiveEditor;
593 setState (inactiveEditor);
594 e->setReadOnly (true);
599 void TextEditor::editCopyAll()
605 void TextEditor::textSaveAs()
607 QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
608 this,"export note dialog",tr("Export Note to single file") );
615 QMessageBox mb( vymName,
616 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
617 QMessageBox::Warning,
618 QMessageBox::Yes | QMessageBox::Default,
619 QMessageBox::Cancel | QMessageBox::Escape,
621 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
622 mb.setButtonText( QMessageBox::No, tr("Cancel"));
623 switch( mb.exec() ) {
624 case QMessageBox::Yes:
629 case QMessageBox::Cancel:
640 statusBar()->message(tr( "Couldn't export note ","dialog 'save note as'") + fn, statusbarTime );
644 void TextEditor::textSave()
646 if ( filename.isEmpty() )
652 QString text = e->text();
654 if ( !f.open( QIODevice::WriteOnly ) )
656 statusBar()->message( QString("Could not write to %1").arg(filename),
665 e->setModified( FALSE );
667 statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
670 void TextEditor::textExportAsASCII()
672 QString text = NoteObj (e->text()).getNoteASCII();
674 if (!filenameHint.isEmpty())
676 if (!filenameHint.contains (".txt"))
677 s=filenameHint+".txt";
682 fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
690 QMessageBox mb( vymName,
691 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
692 QMessageBox::Warning,
693 QMessageBox::Yes | QMessageBox::Default,
694 QMessageBox::Cancel | QMessageBox::Escape,
696 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
697 mb.setButtonText( QMessageBox::No, tr("Cancel"));
700 if (ret==QMessageBox::Cancel)
704 if ( !file.open( QIODevice::WriteOnly ) )
705 statusBar()->message( QString("Could not write to %1").arg(filename),
709 QTextStream t( &file );
713 statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
719 void TextEditor::textPrint()
722 QTextDocument *document = e->document();
725 QPrintDialog *dialog = new QPrintDialog(&printer, this);
726 dialog->setWindowTitle(tr("Print Note"));
727 if (dialog->exec() != QDialog::Accepted)
730 document->print(&printer);
733 void TextEditor::textEditUndo()
737 void TextEditor::toggleFonthint()
739 setUpdatesEnabled (false);
741 if (!actionFormatUseFixedFont->isOn() )
742 e->setCurrentFont (varFont);
744 e->setCurrentFont (fixedFont);
746 setUpdatesEnabled (true);
750 void TextEditor::setFixedFont()
753 QFont font =QFontDialog::getFont(
754 &ok, fixedFont, this );
756 // font is set to the font the user selected
760 void TextEditor::setVarFont()
763 QFont font =QFontDialog::getFont(
764 &ok, varFont, this );
766 // font is set to the font the user selected
770 void TextEditor::textBold()
772 e->setBold( actionTextBold->isOn() );
775 void TextEditor::textUnderline()
777 e->setUnderline( actionTextUnderline->isOn() );
780 void TextEditor::textItalic()
782 e->setItalic( actionTextItalic->isOn() );
785 void TextEditor::textFamily( const QString &f )
790 void TextEditor::textSize( const QString &p )
792 e->setPointSize( p.toInt() );
796 void TextEditor::textColor()
798 QColor col = QColorDialog::getColor( e->color(), this );
799 if ( !col.isValid() ) return;
801 QPixmap pix( 16, 16 );
802 pix.fill( Qt::black );
803 actionTextColor->setIconSet( pix );
806 void TextEditor::textAlign( QAction *a )
808 if ( a == actionAlignLeft )
809 e->setAlignment( Qt::AlignLeft );
810 else if ( a == actionAlignCenter )
811 e->setAlignment( Qt::AlignHCenter );
812 else if ( a == actionAlignRight )
813 e->setAlignment( Qt::AlignRight );
814 else if ( a == actionAlignJustify )
815 e->setAlignment( Qt::AlignJustify );
818 void TextEditor::textVAlign()
820 QTextCharFormat format;
822 if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) {
823 format.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
824 } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) {
825 format.setVerticalAlignment(QTextCharFormat::AlignSubScript);
827 format.setVerticalAlignment(QTextCharFormat::AlignNormal);
829 e->mergeCurrentCharFormat(format);
833 void TextEditor::fontChanged( const QFont &f )
835 int i=comboFont->findText(f.family());
836 if (i>=0) comboFont->setCurrentIndex (i);
837 i=comboSize->findText(QString::number(f.pointSize()));
838 if (i>=0) comboSize->setCurrentIndex(i);
839 actionTextBold->setOn( f.bold() );
840 actionTextItalic->setOn( f.italic() );
841 actionTextUnderline->setOn( f.underline() );
844 void TextEditor::colorChanged( const QColor &c )
846 QPixmap pix( 16, 16 );
848 actionTextColor->setIconSet( pix );
851 void TextEditor::formatChanged( const QTextCharFormat &f )
853 fontChanged(f.font());
854 colorChanged(f.foreground().color());
855 alignmentChanged(e->alignment());
856 verticalAlignmentChanged (f.verticalAlignment());
859 void TextEditor::alignmentChanged( int a )
861 if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft ))
862 actionAlignLeft->setOn( true );
863 else if ( ( a & Qt::AlignHCenter ) )
864 actionAlignCenter->setOn( true );
865 else if ( ( a & Qt::AlignRight ) )
866 actionAlignRight->setOn( true );
867 else if ( ( a & Qt::AlignJustify ) )
868 actionAlignJustify->setOn( true );
871 void TextEditor::verticalAlignmentChanged(QTextCharFormat::VerticalAlignment a)
873 actionAlignSubScript->setOn (false);
874 actionAlignSuperScript->setOn (false);
877 case QTextCharFormat::AlignSuperScript:
878 actionAlignSuperScript->setOn (true);
880 case QTextCharFormat::AlignSubScript:
881 actionAlignSubScript->setOn (true);
889 void TextEditor::enableActions()
891 actionFileLoad->setEnabled(true);
892 actionFileSave->setEnabled(true);
893 actionFileSaveAs->setEnabled(true);
894 actionFilePrint->setEnabled(true);
895 actionEditUndo->setEnabled(true);
896 actionEditRedo->setEnabled(true);
897 actionEditCopy->setEnabled(true);
898 actionEditCut->setEnabled(true);
899 actionEditPaste->setEnabled(true);
900 actionEditDeleteAll->setEnabled(true);
901 actionFormatUseFixedFont->setEnabled(true);
904 void TextEditor::disableActions()
906 actionFileLoad->setEnabled(false);
907 actionFileSave->setEnabled(false);
908 actionFileSaveAs->setEnabled(false);
909 actionFilePrint->setEnabled(false);
910 actionEditUndo->setEnabled(false);
911 actionEditRedo->setEnabled(false);
912 actionEditCopy->setEnabled(false);
913 actionEditCut->setEnabled(false);
914 actionEditPaste->setEnabled(false);
915 actionEditDeleteAll->setEnabled(false);
916 actionFormatUseFixedFont->setEnabled(false);
919 void TextEditor::setState (EditorState s)
922 QPalette p=palette();
926 case emptyEditor: c=QColor (150,150,150); break;
927 case filledEditor: c=QColor (255,255,255); break;
928 case inactiveEditor: c=QColor (0,0,0);
930 p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
931 p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);