1 #include "texteditor.h"
9 extern int statusbarTime;
10 extern Settings settings;
12 extern QAction *actionViewToggleNoteEditor;
14 extern QString iconPath;
15 extern QString vymName;
20 ///////////////////////////////////////////////////////////////////////
21 ///////////////////////////////////////////////////////////////////////
24 TextEditor::TextEditor()
26 printer = new QPrinter( QPrinter::HighResolution );
27 printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString());
29 e = new QTextEdit( this);
31 e->setTextFormat(Qt::RichText); // default
32 e->setTabStopWidth (20); // unit is pixel
33 e->setColor (Qt::black);
34 e->setAutoFillBackground (true);
35 connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
36 setCentralWidget( e );
37 statusBar()->message( tr("Ready","Statusbar message"), statusbarTime);
38 setCaption(vymName +" - " +tr ("Note Editor","Window caption"));
41 connect(e, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
42 this, SLOT(formatChanged(const QTextCharFormat &)));
50 setupSettingsActions();
53 blockChangedSignal=false;
57 resize (settings.value ( "/satellite/noteeditor/geometry/size", QSize(450,600)).toSize());
58 move (settings.value ( "/satellite/noteeditor/geometry/pos", QPoint (250,50)).toPoint());
60 setShowWithMain (settings.value ( "/satellite/noteeditor/showWithMain",true).toBool());
62 varFont.fromString( settings.value
63 ("/satellite/noteeditor/fonts/varFont",
64 "Nimbus Sans l,10,-1,5,48,0,0,0,0,0").toString()
66 fixedFont.fromString (settings.value(
67 "/satellite/noteeditor/fonts/fixedFont",
68 "Courier,10-1,5,48,0,0,0,1,0").toString()
70 QString s=settings.value ("/satellite/noteeditor/fonts/fonthintDefault","variable").toString();
73 actionSettingsFonthintDefault->setOn (true);
74 e->setCurrentFont (fixedFont);
77 actionSettingsFonthintDefault->setOn (false);
78 e->setCurrentFont (varFont);
82 // Restore position of toolbars
83 restoreState (settings.value("/satellite/noteeditor/state",0).toByteArray());
85 // Save settings in vymrc
86 settings.setValue("/mainwindow/printerName",printer->printerName());
90 TextEditor::~TextEditor()
92 if (printer) delete printer;
94 settings.setValue( "/satellite/noteeditor/geometry/size", size() );
95 settings.setValue( "/satellite/noteeditor/geometry/pos", pos() );
96 settings.setValue ("/satellite/noteeditor/state",saveState(0));
98 settings.setValue( "/satellite/noteeditor/showWithMain",showwithmain);
101 if (actionSettingsFonthintDefault->isOn() )
105 settings.setValue( "/satellite/noteeditor/fonts/fonthintDefault",s );
106 settings.setValue("/satellite/noteeditor/fonts/varFont", varFont.toString() );
107 settings.setValue("/satellite/noteeditor/fonts/fixedFont", fixedFont.toString() );
112 void TextEditor::reset()
115 actionFormatUseFixedFont->setOn (false);
116 actionTextBold->setOn (false);
119 actionTextUnderline->setOn (false);
120 e->setUnderline (false);
122 actionTextItalic->setOn (false);
123 e->setItalic (false);
125 QPixmap pix( 16, 16 );
126 pix.fill( Qt::black );
127 actionTextColor->setIconSet( pix );
128 e->setColor (Qt::black);
130 actionAlignSubScript->setOn (false);
131 actionAlignSuperScript->setOn (false);
132 actionAlignLeft->setOn (true);
133 e->setAlignment( Qt::AlignLeft );
136 bool TextEditor::isEmpty()
138 if (e->toPlainText().length()>0)
144 void TextEditor::setShowWithMain(bool v)
149 bool TextEditor::showWithMain()
155 void TextEditor::setFontHint (const QString &fh)
158 actionFormatUseFixedFont->setOn (true);
160 actionFormatUseFixedFont->setOn (false);
164 QString TextEditor::getFontHint()
166 if (actionFormatUseFixedFont->isOn())
172 QString TextEditor::getFontHintDefault()
174 if (actionSettingsFonthintDefault->isOn())
180 void TextEditor::setFilename(const QString &fn)
182 if (state==filledEditor)
187 statusBar()->message( tr("No filename available for this note.","Statusbar message"), statusbarTime );
192 statusBar()->message( tr(QString( "Current filename is %1" ).arg( filename ),"Statusbar message"), statusbarTime );
197 QString TextEditor::getFilename()
202 void TextEditor::setFilenameHint(const QString &fnh)
207 QString TextEditor::getFilenameHint()
212 QString TextEditor::getText()
214 if (e->toPlainText().isEmpty())
220 NoteObj TextEditor::getNoteObj()
222 NoteObj note (getText() );
223 note.setFontHint (getFontHint() );
224 note.setFilenameHint (getFilenameHint () );
228 void TextEditor::setNote (const NoteObj ¬e)
230 setText (note.getNote() );
231 setFilenameHint (note.getFilenameHint() );
232 setFontHint (note.getFontHint() );
235 bool TextEditor::findText(const QString &t, const QTextDocument::FindFlags &flags)
237 if (e->find (t,flags))
243 void TextEditor::setupFileActions()
245 QToolBar *tb = addToolBar ( tr("Note Actions") );
246 tb->setObjectName ("noteEditorFileActions");
247 QMenu *fileMenu = menuBar()->addMenu( tr( "&Note","Menubar" ));
250 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this);
251 a->setStatusTip (tr( "Import","Status tip for Note menu" ) );
252 a->setShortcut( Qt::CTRL + Qt::Key_O );
253 connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
255 fileMenu->addAction (a);
258 fileMenu->addSeparator();
259 a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this);
260 a->setStatusTip (tr( "Export Note (HTML)","Status tip for Note menu" ) );
261 a->setShortcut( Qt::CTRL + Qt::Key_S );
262 connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
264 fileMenu->addAction (a);
267 a = new QAction( QPixmap(), tr( "Export &As... (HTML)" ), this);
268 a->setStatusTip (tr( "Export Note As (HTML) ","Status tip for Note Menu" ));
269 connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
270 fileMenu->addAction (a);
273 a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this);
274 a->setStatusTip ( tr( "Export Note As (ASCII) ","Status tip for note menu" ) );
275 a->setShortcut(Qt::ALT + Qt::Key_X );
276 connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
277 fileMenu->addAction (a);
280 fileMenu->addSeparator();
281 a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this);
282 a->setStatusTip (tr( "Print Note","Status tip for note menu" ) );
283 a->setShortcut( Qt::CTRL + Qt::Key_P );
284 connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
286 fileMenu->addAction (a);
290 void TextEditor::setupEditActions()
292 QToolBar *tb = addToolBar ( tr( "Edit Actions" ));
293 tb->setObjectName ("noteEditorEditActions");
294 QMenu *editMenu = menuBar()->addMenu ( tr( "&Edit" ));
297 a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this );
298 a->setStatusTip ( tr( "Undo","Status tip for note menu" ) );
299 a->setShortcut(Qt::CTRL + Qt::Key_Z );
300 connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
301 editMenu->addAction (a);
305 a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this);
306 a->setStatusTip ( tr( "Redo","Status tip for note menu" ) );
307 a->setShortcut( Qt::CTRL + Qt::Key_Y );
308 connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
309 editMenu->addAction (a);
313 editMenu->addSeparator();
314 a = new QAction(QPixmap(), tr( "Select and copy &all" ),this);
315 a->setStatusTip ( tr( "Select and copy all","Status tip for note menu" ) );
316 a->setShortcut( Qt::CTRL + Qt::Key_A );
317 connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
318 editMenu->addAction (a);
320 editMenu->addSeparator();
321 a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this);
322 a->setStatusTip ( tr( "Copy","Status tip for note menu" ) );
323 a->setShortcut( Qt::CTRL + Qt::Key_C );
324 connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
325 editMenu->addAction (a);
329 a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this);
330 a->setStatusTip ( tr( "Cut","Status tip for note menu" ) );
331 a->setShortcut( Qt::CTRL + Qt::Key_X );
332 connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
333 editMenu->addAction (a);
337 a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this);
338 a->setStatusTip ( tr( "Paste","Status tip for note menu" ) );
339 a->setShortcut( Qt::CTRL + Qt::Key_V );
340 connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
341 editMenu->addAction (a);
345 a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this);
346 a->setStatusTip (tr( "Delete all","Status tip for note menu" ) );
347 connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
348 editMenu->addAction (a);
350 actionEditDeleteAll=a;
354 void TextEditor::setupFormatActions()
356 QToolBar *tb = addToolBar ( tr("Format Actions" ));
357 tb->setObjectName ("noteEditorFormatActions");
358 QMenu *formatMenu = menuBar()->addMenu ( tr( "F&ormat" ));
362 a = new QAction( QPixmap(iconPath+"formatfixedfont.png"), tr( "&Font hint" ), Qt::ALT + Qt::Key_I, this, "fontHint" );
363 a->setStatusTip (tr( "Toggle font hint for the whole text","Status tip for note menu" ) );
364 a->setToggleAction (true);
365 a->setOn (settings.value("/noteeditor/fonts/useFixedByDefault",false).toBool() );
366 connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
367 formatMenu->addAction (a);
369 actionFormatUseFixedFont=a;
371 comboFont = new QComboBox;
372 tb->addWidget (comboFont);
373 QFontDatabase fontDB;
374 comboFont->insertStringList( fontDB.families() );
375 connect( comboFont, SIGNAL( activated( const QString & ) ),
376 this, SLOT( textFamily( const QString & ) ) );
377 comboFont->addItem( QApplication::font().family() );
378 comboSize = new QComboBox;
379 tb->addWidget (comboSize);
380 QList<int> sizes=fontDB.standardSizes();
381 QList<int>::iterator i = sizes.begin();
382 while (i != sizes.end())
384 ++i; // increment i before using it
385 comboSize->insertItem ( QString::number(*i));
387 connect( comboSize, SIGNAL( activated( const QString & ) ),
388 this, SLOT( textSize( const QString & ) ) );
389 comboSize->addItem ( QString::number( QApplication::font().pointSize() ) );
391 formatMenu->addSeparator();
393 QPixmap pix( 16, 16 );
394 pix.fill( e->color());
395 a = new QAction( pix, tr( "&Color..." ), this);
396 formatMenu->addAction (a);
398 connect( a, SIGNAL( activated() ), this, SLOT( textColor() ) );
401 a = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
402 a->setShortcut(Qt::CTRL + Qt::Key_B );
403 connect( a, SIGNAL( activated() ), this, SLOT( textBold() ) );
405 formatMenu->addAction (a);
406 a->setToggleAction( true );
409 a = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this);
410 a->setShortcut(Qt::CTRL + Qt::Key_I);
411 connect( a, SIGNAL( activated() ), this, SLOT( textItalic() ) );
413 formatMenu->addAction (a);
414 a->setToggleAction( true );
417 a = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
418 a->setShortcut(Qt::CTRL + Qt::Key_U );
419 connect( a, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
421 formatMenu->addAction (a);
422 a->setToggleAction( true );
423 actionTextUnderline=a;
424 formatMenu->addSeparator();
426 QActionGroup *grp2 = new QActionGroup( this );
427 grp2->setExclusive(true);
428 a = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
429 a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
430 a->setToggleAction( true );
432 formatMenu->addAction (a);
433 connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
434 actionAlignSubScript=a;
436 a = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 );
437 a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
438 a->setToggleAction( true );
440 formatMenu->addAction (a);
441 connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
442 actionAlignSuperScript=a;
443 QActionGroup *grp = new QActionGroup( this );
444 connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
446 formatMenu->addSeparator();
448 a = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
449 a->setShortcut( Qt::CTRL+Qt::Key_L );
450 a->setToggleAction( true );
452 formatMenu->addAction (a);
454 a = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
455 a->setShortcut( Qt::CTRL + Qt::Key_E);
456 a->setToggleAction( true );
458 formatMenu->addAction (a);
460 a = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
461 a->setShortcut(Qt::CTRL + Qt::Key_R );
462 a->setToggleAction( true );
464 formatMenu->addAction (a);
466 a = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
467 a->setShortcut(Qt::CTRL + Qt::Key_J );
468 a->setToggleAction( true );
470 formatMenu->addAction (a);
471 actionAlignJustify=a;
474 void TextEditor::setupSettingsActions()
476 QMenu *settingsMenu = menuBar()->addMenu ( tr( "&Settings" ));
479 a = new QAction(tr( "Set &fixed font" ), this);
480 a->setStatusTip ( tr( "Set fixed font","Status tip for note menu" ));
481 connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
482 settingsMenu->addAction (a);
483 actionSettingsFixedFont=a;
485 a = new QAction(tr( "Set &variable font" ), this);
486 a->setStatusTip ( tr( "Set variable font","Status tip for note menu" ) );
487 connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
488 settingsMenu->addAction (a);
489 actionSettingsVarFont=a;
491 a = new QAction(tr( "&fixed font is default" ), this);
492 a->setStatusTip (tr( "Used fixed font by default","Status tip for note menu" ) );
493 a->setToggleAction (true);
494 // set state later in constructor...
495 settingsMenu->addAction (a);
496 actionSettingsFonthintDefault=a;
499 void TextEditor::textLoad()
501 if (state!=inactiveEditor)
505 QMessageBox mb( vymName + " - " +tr("Note Editor"),
506 "Loading will overwrite the existing note",
507 QMessageBox::Warning,
508 QMessageBox::Yes | QMessageBox::Default,
511 mb.setButtonText( QMessageBox::Yes, "Load note" );
512 switch( mb.exec() ) {
513 case QMessageBox::Cancel:
519 QFileDialog *fd=new QFileDialog( this);
521 types<< "Text (*.txt *.html)"<<
522 "VYM notes and HTML (*.html)" <<
523 "ASCII texts (*.txt)" <<
525 fd->setFilters (types);
526 fd->setDirectory (QDir().current());
529 if ( fd->exec() == QDialog::Accepted )
530 fn = fd->selectedFile();
535 if ( !f.open( QIODevice::ReadOnly ) )
538 QTextStream ts( &f );
539 setText( ts.read() );
545 void TextEditor::closeEvent( QCloseEvent* ce )
547 ce->accept(); // TextEditor can be reopened with show()
550 emit (windowClosed() );
554 void TextEditor::editorChanged()
561 if (state==emptyEditor)
562 setState (emptyEditor);
564 setState (filledEditor);
565 // SLOT is LinkableMapObj, which will update systemFlag
566 if (!blockChangedSignal) emit (textHasChanged() );
570 void TextEditor::setText(const QString &t)
572 blockChangedSignal=true;
573 e->setReadOnly(false);
575 if (Qt::mightBeRichText (t))
579 actionFormatUseFixedFont->setChecked (true);
583 blockChangedSignal=false;
586 void TextEditor::setInactive()
588 state=inactiveEditor;
590 setState (inactiveEditor);
591 e->setReadOnly (true);
596 void TextEditor::editCopyAll()
602 void TextEditor::textSaveAs()
604 QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
605 this,"export note dialog",tr("Export Note to single file") );
612 QMessageBox mb( vymName,
613 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
614 QMessageBox::Warning,
615 QMessageBox::Yes | QMessageBox::Default,
616 QMessageBox::Cancel | QMessageBox::Escape,
618 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
619 mb.setButtonText( QMessageBox::No, tr("Cancel"));
620 switch( mb.exec() ) {
621 case QMessageBox::Yes:
626 case QMessageBox::Cancel:
637 statusBar()->message(tr( "Couldn't export note ","dialog 'save note as'") + fn, statusbarTime );
641 void TextEditor::textSave()
643 if ( filename.isEmpty() )
649 QString text = e->text();
651 if ( !f.open( QIODevice::WriteOnly ) )
653 statusBar()->message( QString("Could not write to %1").arg(filename),
662 e->setModified( FALSE );
664 statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
667 void TextEditor::textExportAsASCII()
669 QString text = NoteObj (e->text()).getNoteASCII();
671 if (!filenameHint.isEmpty())
673 if (!filenameHint.contains (".txt"))
674 s=filenameHint+".txt";
679 fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
687 QMessageBox mb( vymName,
688 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
689 QMessageBox::Warning,
690 QMessageBox::Yes | QMessageBox::Default,
691 QMessageBox::Cancel | QMessageBox::Escape,
693 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
694 mb.setButtonText( QMessageBox::No, tr("Cancel"));
697 if (ret==QMessageBox::Cancel)
701 if ( !file.open( QIODevice::WriteOnly ) )
702 statusBar()->message( QString("Could not write to %1").arg(filename),
706 QTextStream t( &file );
710 statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
716 void TextEditor::textPrint()
719 QTextDocument *document = e->document();
722 QPrintDialog *dialog = new QPrintDialog(&printer, this);
723 dialog->setWindowTitle(tr("Print Note"));
724 if (dialog->exec() != QDialog::Accepted)
727 document->print(&printer);
730 void TextEditor::textEditUndo()
734 void TextEditor::toggleFonthint()
736 setUpdatesEnabled (false);
738 if (!actionFormatUseFixedFont->isOn() )
739 e->setCurrentFont (varFont);
741 e->setCurrentFont (fixedFont);
743 setUpdatesEnabled (true);
747 void TextEditor::setFixedFont()
750 QFont font =QFontDialog::getFont(
751 &ok, fixedFont, this );
753 // font is set to the font the user selected
757 void TextEditor::setVarFont()
760 QFont font =QFontDialog::getFont(
761 &ok, varFont, this );
763 // font is set to the font the user selected
767 void TextEditor::textBold()
769 e->setBold( actionTextBold->isOn() );
772 void TextEditor::textUnderline()
774 e->setUnderline( actionTextUnderline->isOn() );
777 void TextEditor::textItalic()
779 e->setItalic( actionTextItalic->isOn() );
782 void TextEditor::textFamily( const QString &f )
787 void TextEditor::textSize( const QString &p )
789 e->setPointSize( p.toInt() );
793 void TextEditor::textColor()
795 QColor col = QColorDialog::getColor( e->color(), this );
796 if ( !col.isValid() ) return;
798 QPixmap pix( 16, 16 );
799 pix.fill( Qt::black );
800 actionTextColor->setIconSet( pix );
803 void TextEditor::textAlign( QAction *a )
805 if ( a == actionAlignLeft )
806 e->setAlignment( Qt::AlignLeft );
807 else if ( a == actionAlignCenter )
808 e->setAlignment( Qt::AlignHCenter );
809 else if ( a == actionAlignRight )
810 e->setAlignment( Qt::AlignRight );
811 else if ( a == actionAlignJustify )
812 e->setAlignment( Qt::AlignJustify );
815 void TextEditor::textVAlign()
817 QTextCharFormat format;
819 if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) {
820 format.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
821 } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) {
822 format.setVerticalAlignment(QTextCharFormat::AlignSubScript);
824 format.setVerticalAlignment(QTextCharFormat::AlignNormal);
826 e->mergeCurrentCharFormat(format);
830 void TextEditor::fontChanged( const QFont &f )
832 int i=comboFont->findText(f.family());
833 if (i>=0) comboFont->setCurrentIndex (i);
834 i=comboSize->findText(QString::number(f.pointSize()));
835 if (i>=0) comboSize->setCurrentIndex(i);
836 actionTextBold->setOn( f.bold() );
837 actionTextItalic->setOn( f.italic() );
838 actionTextUnderline->setOn( f.underline() );
841 void TextEditor::colorChanged( const QColor &c )
843 QPixmap pix( 16, 16 );
845 actionTextColor->setIconSet( pix );
848 void TextEditor::formatChanged( const QTextCharFormat &f )
850 fontChanged(f.font());
851 colorChanged(f.foreground().color());
852 alignmentChanged(e->alignment());
853 verticalAlignmentChanged (f.verticalAlignment());
856 void TextEditor::alignmentChanged( int a )
858 if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft ))
859 actionAlignLeft->setOn( true );
860 else if ( ( a & Qt::AlignHCenter ) )
861 actionAlignCenter->setOn( true );
862 else if ( ( a & Qt::AlignRight ) )
863 actionAlignRight->setOn( true );
864 else if ( ( a & Qt::AlignJustify ) )
865 actionAlignJustify->setOn( true );
868 void TextEditor::verticalAlignmentChanged(QTextCharFormat::VerticalAlignment a)
870 actionAlignSubScript->setOn (false);
871 actionAlignSuperScript->setOn (false);
874 case QTextCharFormat::AlignSuperScript:
875 actionAlignSuperScript->setOn (true);
877 case QTextCharFormat::AlignSubScript:
878 actionAlignSubScript->setOn (true);
886 void TextEditor::enableActions()
888 actionFileLoad->setEnabled(true);
889 actionFileSave->setEnabled(true);
890 actionFileSaveAs->setEnabled(true);
891 actionFilePrint->setEnabled(true);
892 actionEditUndo->setEnabled(true);
893 actionEditRedo->setEnabled(true);
894 actionEditCopy->setEnabled(true);
895 actionEditCut->setEnabled(true);
896 actionEditPaste->setEnabled(true);
897 actionEditDeleteAll->setEnabled(true);
898 actionFormatUseFixedFont->setEnabled(true);
901 void TextEditor::disableActions()
903 actionFileLoad->setEnabled(false);
904 actionFileSave->setEnabled(false);
905 actionFileSaveAs->setEnabled(false);
906 actionFilePrint->setEnabled(false);
907 actionEditUndo->setEnabled(false);
908 actionEditRedo->setEnabled(false);
909 actionEditCopy->setEnabled(false);
910 actionEditCut->setEnabled(false);
911 actionEditPaste->setEnabled(false);
912 actionEditDeleteAll->setEnabled(false);
913 actionFormatUseFixedFont->setEnabled(false);
916 void TextEditor::setState (EditorState s)
919 QPalette p=palette();
923 case emptyEditor: c=QColor (150,150,150); break;
924 case filledEditor: c=QColor (255,255,255); break;
925 case inactiveEditor: c=QColor (0,0,0);
927 p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
928 p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);