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, QTextCursor &cursor)
237 if (e->find (t,flags))
239 cursor=e->textCursor();
244 cursor=QTextCursor();
249 void TextEditor::setupFileActions()
251 QToolBar *tb = addToolBar ( tr("Note Actions") );
252 tb->setObjectName ("noteEditorFileActions");
253 QMenu *fileMenu = menuBar()->addMenu( tr( "&Note","Menubar" ));
256 a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this);
257 a->setStatusTip (tr( "Import","Status tip for Note menu" ) );
258 a->setShortcut( Qt::CTRL + Qt::Key_O );
259 connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
261 fileMenu->addAction (a);
264 fileMenu->addSeparator();
265 a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this);
266 a->setStatusTip (tr( "Export Note (HTML)","Status tip for Note menu" ) );
267 a->setShortcut( Qt::CTRL + Qt::Key_S );
268 connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
270 fileMenu->addAction (a);
273 a = new QAction( QPixmap(), tr( "Export &As... (HTML)" ), this);
274 a->setStatusTip (tr( "Export Note As (HTML) ","Status tip for Note Menu" ));
275 connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
276 fileMenu->addAction (a);
279 a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this);
280 a->setStatusTip ( tr( "Export Note As (ASCII) ","Status tip for note menu" ) );
281 a->setShortcut(Qt::ALT + Qt::Key_X );
282 connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
283 fileMenu->addAction (a);
286 fileMenu->addSeparator();
287 a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this);
288 a->setStatusTip (tr( "Print Note","Status tip for note menu" ) );
289 a->setShortcut( Qt::CTRL + Qt::Key_P );
290 connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
292 fileMenu->addAction (a);
296 void TextEditor::setupEditActions()
298 QToolBar *tb = addToolBar ( tr( "Edit Actions" ));
299 tb->setObjectName ("noteEditorEditActions");
300 QMenu *editMenu = menuBar()->addMenu ( tr( "&Edit" ));
303 a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this );
304 a->setStatusTip ( tr( "Undo","Status tip for note menu" ) );
305 a->setShortcut(Qt::CTRL + Qt::Key_Z );
306 connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
307 editMenu->addAction (a);
311 a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this);
312 a->setStatusTip ( tr( "Redo","Status tip for note menu" ) );
313 a->setShortcut( Qt::CTRL + Qt::Key_Y );
314 connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
315 editMenu->addAction (a);
319 editMenu->addSeparator();
320 a = new QAction(QPixmap(), tr( "Select and copy &all" ),this);
321 a->setStatusTip ( tr( "Select and copy all","Status tip for note menu" ) );
322 a->setShortcut( Qt::CTRL + Qt::Key_A );
323 connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
324 editMenu->addAction (a);
326 editMenu->addSeparator();
327 a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this);
328 a->setStatusTip ( tr( "Copy","Status tip for note menu" ) );
329 a->setShortcut( Qt::CTRL + Qt::Key_C );
330 connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
331 editMenu->addAction (a);
335 a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this);
336 a->setStatusTip ( tr( "Cut","Status tip for note menu" ) );
337 a->setShortcut( Qt::CTRL + Qt::Key_X );
338 connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
339 editMenu->addAction (a);
343 a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this);
344 a->setStatusTip ( tr( "Paste","Status tip for note menu" ) );
345 a->setShortcut( Qt::CTRL + Qt::Key_V );
346 connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
347 editMenu->addAction (a);
351 a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this);
352 a->setStatusTip (tr( "Delete all","Status tip for note menu" ) );
353 connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
354 editMenu->addAction (a);
356 actionEditDeleteAll=a;
360 void TextEditor::setupFormatActions()
362 QToolBar *tb = addToolBar ( tr("Format Actions" ));
363 tb->setObjectName ("noteEditorFormatActions");
364 QMenu *formatMenu = menuBar()->addMenu ( tr( "F&ormat" ));
368 a = new QAction( QPixmap(iconPath+"formatfixedfont.png"), tr( "&Font hint" ), Qt::ALT + Qt::Key_I, this, "fontHint" );
369 a->setStatusTip (tr( "Toggle font hint for the whole text","Status tip for note menu" ) );
370 a->setToggleAction (true);
371 a->setOn (settings.value("/noteeditor/fonts/useFixedByDefault",false).toBool() );
372 connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
373 formatMenu->addAction (a);
375 actionFormatUseFixedFont=a;
377 comboFont = new QComboBox;
378 tb->addWidget (comboFont);
379 QFontDatabase fontDB;
380 comboFont->insertStringList( fontDB.families() );
381 connect( comboFont, SIGNAL( activated( const QString & ) ),
382 this, SLOT( textFamily( const QString & ) ) );
383 comboFont->addItem( QApplication::font().family() );
384 comboSize = new QComboBox;
385 tb->addWidget (comboSize);
386 QList<int> sizes=fontDB.standardSizes();
387 QList<int>::iterator i = sizes.begin();
388 while (i != sizes.end())
390 ++i; // increment i before using it
391 comboSize->insertItem ( QString::number(*i));
393 connect( comboSize, SIGNAL( activated( const QString & ) ),
394 this, SLOT( textSize( const QString & ) ) );
395 comboSize->addItem ( QString::number( QApplication::font().pointSize() ) );
397 formatMenu->addSeparator();
399 QPixmap pix( 16, 16 );
400 pix.fill( e->color());
401 a = new QAction( pix, tr( "&Color..." ), this);
402 formatMenu->addAction (a);
404 connect( a, SIGNAL( activated() ), this, SLOT( textColor() ) );
407 a = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
408 a->setShortcut(Qt::CTRL + Qt::Key_B );
409 connect( a, SIGNAL( activated() ), this, SLOT( textBold() ) );
411 formatMenu->addAction (a);
412 a->setToggleAction( true );
415 a = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ), this);
416 a->setShortcut(Qt::CTRL + Qt::Key_I);
417 connect( a, SIGNAL( activated() ), this, SLOT( textItalic() ) );
419 formatMenu->addAction (a);
420 a->setToggleAction( true );
423 a = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
424 a->setShortcut(Qt::CTRL + Qt::Key_U );
425 connect( a, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
427 formatMenu->addAction (a);
428 a->setToggleAction( true );
429 actionTextUnderline=a;
430 formatMenu->addSeparator();
432 QActionGroup *grp2 = new QActionGroup( this );
433 grp2->setExclusive(true);
434 a = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
435 a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
436 a->setToggleAction( true );
438 formatMenu->addAction (a);
439 connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
440 actionAlignSubScript=a;
442 a = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2 );
443 a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
444 a->setToggleAction( true );
446 formatMenu->addAction (a);
447 connect(a, SIGNAL(activated()), this, SLOT(textVAlign()));
448 actionAlignSuperScript=a;
449 QActionGroup *grp = new QActionGroup( this );
450 connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
452 formatMenu->addSeparator();
454 a = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
455 a->setShortcut( Qt::CTRL+Qt::Key_L );
456 a->setToggleAction( true );
458 formatMenu->addAction (a);
460 a = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
461 a->setShortcut( Qt::CTRL + Qt::Key_E);
462 a->setToggleAction( true );
464 formatMenu->addAction (a);
466 a = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
467 a->setShortcut(Qt::CTRL + Qt::Key_R );
468 a->setToggleAction( true );
470 formatMenu->addAction (a);
472 a = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
473 a->setShortcut(Qt::CTRL + Qt::Key_J );
474 a->setToggleAction( true );
476 formatMenu->addAction (a);
477 actionAlignJustify=a;
480 void TextEditor::setupSettingsActions()
482 QMenu *settingsMenu = menuBar()->addMenu ( tr( "&Settings" ));
485 a = new QAction(tr( "Set &fixed font" ), this);
486 a->setStatusTip ( tr( "Set fixed font","Status tip for note menu" ));
487 connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
488 settingsMenu->addAction (a);
489 actionSettingsFixedFont=a;
491 a = new QAction(tr( "Set &variable font" ), this);
492 a->setStatusTip ( tr( "Set variable font","Status tip for note menu" ) );
493 connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
494 settingsMenu->addAction (a);
495 actionSettingsVarFont=a;
497 a = new QAction(tr( "&fixed font is default" ), this);
498 a->setStatusTip (tr( "Used fixed font by default","Status tip for note menu" ) );
499 a->setToggleAction (true);
500 // set state later in constructor...
501 settingsMenu->addAction (a);
502 actionSettingsFonthintDefault=a;
505 void TextEditor::textLoad()
507 if (state!=inactiveEditor)
511 QMessageBox mb( vymName + " - " +tr("Note Editor"),
512 "Loading will overwrite the existing note",
513 QMessageBox::Warning,
514 QMessageBox::Yes | QMessageBox::Default,
517 mb.setButtonText( QMessageBox::Yes, "Load note" );
518 switch( mb.exec() ) {
519 case QMessageBox::Cancel:
525 QFileDialog *fd=new QFileDialog( this);
527 types<< "Text (*.txt *.html)"<<
528 "VYM notes and HTML (*.html)" <<
529 "ASCII texts (*.txt)" <<
531 fd->setFilters (types);
532 fd->setDirectory (QDir().current());
535 if ( fd->exec() == QDialog::Accepted )
536 fn = fd->selectedFile();
541 if ( !f.open( QIODevice::ReadOnly ) )
544 QTextStream ts( &f );
545 setText( ts.read() );
551 void TextEditor::closeEvent( QCloseEvent* ce )
553 ce->accept(); // TextEditor can be reopened with show()
556 emit (windowClosed() );
560 void TextEditor::editorChanged()
567 if (state==emptyEditor)
568 setState (emptyEditor);
570 setState (filledEditor);
571 // SLOT is LinkableMapObj, which will update systemFlag
572 if (!blockChangedSignal) emit (textHasChanged() );
576 void TextEditor::setText(const QString &t)
578 blockChangedSignal=true;
579 e->setReadOnly(false);
581 if (Qt::mightBeRichText (t))
585 actionFormatUseFixedFont->setChecked (true);
589 blockChangedSignal=false;
592 void TextEditor::setInactive()
594 state=inactiveEditor;
596 setState (inactiveEditor);
597 e->setReadOnly (true);
602 void TextEditor::editCopyAll()
608 void TextEditor::textSaveAs()
610 QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
611 this,"export note dialog",tr("Export Note to single file") );
618 QMessageBox mb( vymName,
619 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
620 QMessageBox::Warning,
621 QMessageBox::Yes | QMessageBox::Default,
622 QMessageBox::Cancel | QMessageBox::Escape,
624 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
625 mb.setButtonText( QMessageBox::No, tr("Cancel"));
626 switch( mb.exec() ) {
627 case QMessageBox::Yes:
632 case QMessageBox::Cancel:
643 statusBar()->message(tr( "Couldn't export note ","dialog 'save note as'") + fn, statusbarTime );
647 void TextEditor::textSave()
649 if ( filename.isEmpty() )
655 QString text = e->text();
657 if ( !f.open( QIODevice::WriteOnly ) )
659 statusBar()->message( QString("Could not write to %1").arg(filename),
668 e->setModified( FALSE );
670 statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
673 void TextEditor::textExportAsASCII()
675 QString text = NoteObj (e->text()).getNoteASCII();
677 if (!filenameHint.isEmpty())
679 if (!filenameHint.contains (".txt"))
680 s=filenameHint+".txt";
685 fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
693 QMessageBox mb( vymName,
694 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
695 QMessageBox::Warning,
696 QMessageBox::Yes | QMessageBox::Default,
697 QMessageBox::Cancel | QMessageBox::Escape,
699 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
700 mb.setButtonText( QMessageBox::No, tr("Cancel"));
703 if (ret==QMessageBox::Cancel)
707 if ( !file.open( QIODevice::WriteOnly ) )
708 statusBar()->message( QString("Could not write to %1").arg(filename),
712 QTextStream t( &file );
716 statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
722 void TextEditor::textPrint()
725 QTextDocument *document = e->document();
728 QPrintDialog *dialog = new QPrintDialog(&printer, this);
729 dialog->setWindowTitle(tr("Print Note"));
730 if (dialog->exec() != QDialog::Accepted)
733 document->print(&printer);
736 void TextEditor::textEditUndo()
740 void TextEditor::toggleFonthint()
742 setUpdatesEnabled (false);
744 if (!actionFormatUseFixedFont->isOn() )
745 e->setCurrentFont (varFont);
747 e->setCurrentFont (fixedFont);
749 setUpdatesEnabled (true);
753 void TextEditor::setFixedFont()
756 QFont font =QFontDialog::getFont(
757 &ok, fixedFont, this );
759 // font is set to the font the user selected
763 void TextEditor::setVarFont()
766 QFont font =QFontDialog::getFont(
767 &ok, varFont, this );
769 // font is set to the font the user selected
773 void TextEditor::textBold()
775 e->setBold( actionTextBold->isOn() );
778 void TextEditor::textUnderline()
780 e->setUnderline( actionTextUnderline->isOn() );
783 void TextEditor::textItalic()
785 e->setItalic( actionTextItalic->isOn() );
788 void TextEditor::textFamily( const QString &f )
793 void TextEditor::textSize( const QString &p )
795 e->setPointSize( p.toInt() );
799 void TextEditor::textColor()
801 QColor col = QColorDialog::getColor( e->color(), this );
802 if ( !col.isValid() ) return;
804 QPixmap pix( 16, 16 );
805 pix.fill( Qt::black );
806 actionTextColor->setIconSet( pix );
809 void TextEditor::textAlign( QAction *a )
811 if ( a == actionAlignLeft )
812 e->setAlignment( Qt::AlignLeft );
813 else if ( a == actionAlignCenter )
814 e->setAlignment( Qt::AlignHCenter );
815 else if ( a == actionAlignRight )
816 e->setAlignment( Qt::AlignRight );
817 else if ( a == actionAlignJustify )
818 e->setAlignment( Qt::AlignJustify );
821 void TextEditor::textVAlign()
823 QTextCharFormat format;
825 if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) {
826 format.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
827 } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) {
828 format.setVerticalAlignment(QTextCharFormat::AlignSubScript);
830 format.setVerticalAlignment(QTextCharFormat::AlignNormal);
832 e->mergeCurrentCharFormat(format);
836 void TextEditor::fontChanged( const QFont &f )
838 int i=comboFont->findText(f.family());
839 if (i>=0) comboFont->setCurrentIndex (i);
840 i=comboSize->findText(QString::number(f.pointSize()));
841 if (i>=0) comboSize->setCurrentIndex(i);
842 actionTextBold->setOn( f.bold() );
843 actionTextItalic->setOn( f.italic() );
844 actionTextUnderline->setOn( f.underline() );
847 void TextEditor::colorChanged( const QColor &c )
849 QPixmap pix( 16, 16 );
851 actionTextColor->setIconSet( pix );
854 void TextEditor::formatChanged( const QTextCharFormat &f )
856 fontChanged(f.font());
857 colorChanged(f.foreground().color());
858 alignmentChanged(e->alignment());
859 verticalAlignmentChanged (f.verticalAlignment());
862 void TextEditor::alignmentChanged( int a )
864 if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft ))
865 actionAlignLeft->setOn( true );
866 else if ( ( a & Qt::AlignHCenter ) )
867 actionAlignCenter->setOn( true );
868 else if ( ( a & Qt::AlignRight ) )
869 actionAlignRight->setOn( true );
870 else if ( ( a & Qt::AlignJustify ) )
871 actionAlignJustify->setOn( true );
874 void TextEditor::verticalAlignmentChanged(QTextCharFormat::VerticalAlignment a)
876 actionAlignSubScript->setOn (false);
877 actionAlignSuperScript->setOn (false);
880 case QTextCharFormat::AlignSuperScript:
881 actionAlignSuperScript->setOn (true);
883 case QTextCharFormat::AlignSubScript:
884 actionAlignSubScript->setOn (true);
892 void TextEditor::enableActions()
894 actionFileLoad->setEnabled(true);
895 actionFileSave->setEnabled(true);
896 actionFileSaveAs->setEnabled(true);
897 actionFilePrint->setEnabled(true);
898 actionEditUndo->setEnabled(true);
899 actionEditRedo->setEnabled(true);
900 actionEditCopy->setEnabled(true);
901 actionEditCut->setEnabled(true);
902 actionEditPaste->setEnabled(true);
903 actionEditDeleteAll->setEnabled(true);
904 actionFormatUseFixedFont->setEnabled(true);
907 void TextEditor::disableActions()
909 actionFileLoad->setEnabled(false);
910 actionFileSave->setEnabled(false);
911 actionFileSaveAs->setEnabled(false);
912 actionFilePrint->setEnabled(false);
913 actionEditUndo->setEnabled(false);
914 actionEditRedo->setEnabled(false);
915 actionEditCopy->setEnabled(false);
916 actionEditCut->setEnabled(false);
917 actionEditPaste->setEnabled(false);
918 actionEditDeleteAll->setEnabled(false);
919 actionFormatUseFixedFont->setEnabled(false);
922 void TextEditor::setState (EditorState s)
925 QPalette p=palette();
929 case emptyEditor: c=QColor (150,150,150); break;
930 case filledEditor: c=QColor (255,255,255); break;
931 case inactiveEditor: c=QColor (0,0,0);
933 p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
934 p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);