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,14,-1,5,48,0,0,0,0,0").toString()
69 fixedFont.fromString (settings.value(
70 "/satellite/noteeditor/fonts/fixedFont",
71 "Courier,12,-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<< "VYM notes (*.html)" <<
525 "ASCII texts (*.txt)" <<
527 fd->setFilters (types);
528 fd->setDirectory (QDir().current());
531 if ( fd->exec() == QDialog::Accepted )
532 fn = fd->selectedFile();
537 if ( !f.open( QIODevice::ReadOnly ) )
540 QTextStream ts( &f );
541 setText( ts.read() );
547 void TextEditor::closeEvent( QCloseEvent* ce )
549 ce->accept(); // TextEditor can be reopened with show()
552 emit (windowClosed() );
556 void TextEditor::editorChanged()
563 if (state==emptyEditor)
564 setState (emptyEditor);
566 setState (filledEditor);
567 // SLOT is LinkableMapObj, which will update systemFlag
568 if (!blockChangedSignal) emit (textHasChanged() );
572 void TextEditor::setText(const QString &t)
574 blockChangedSignal=true;
575 e->setReadOnly(false);
577 if (Qt::mightBeRichText (t))
581 actionFormatUseFixedFont->setChecked (true);
585 blockChangedSignal=false;
588 void TextEditor::setInactive()
590 state=inactiveEditor;
592 setState (inactiveEditor);
593 e->setReadOnly (true);
598 void TextEditor::editCopyAll()
604 void TextEditor::textSaveAs()
606 QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
607 this,"export note dialog",tr("Export Note to single file") );
614 QMessageBox mb( vymName,
615 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
616 QMessageBox::Warning,
617 QMessageBox::Yes | QMessageBox::Default,
618 QMessageBox::Cancel | QMessageBox::Escape,
620 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
621 mb.setButtonText( QMessageBox::No, tr("Cancel"));
622 switch( mb.exec() ) {
623 case QMessageBox::Yes:
628 case QMessageBox::Cancel:
639 statusBar()->message(tr( "Couldn't export note ","dialog 'save note as'") + fn, statusbarTime );
643 void TextEditor::textSave()
645 if ( filename.isEmpty() )
651 QString text = e->text();
653 if ( !f.open( QIODevice::WriteOnly ) )
655 statusBar()->message( QString("Could not write to %1").arg(filename),
664 e->setModified( FALSE );
666 statusBar()->message( QString( "Note exported as %1" ).arg( filename ), statusbarTime );
669 void TextEditor::textExportAsASCII()
671 QString text = NoteObj (e->text()).getNoteASCII();
673 if (!filenameHint.isEmpty())
675 if (!filenameHint.contains (".txt"))
676 s=filenameHint+".txt";
681 fn = QFileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
689 QMessageBox mb( vymName,
690 tr("The file %1\nexists already.\nDo you want to overwrite it?","dialog 'save note as'").arg(fn),
691 QMessageBox::Warning,
692 QMessageBox::Yes | QMessageBox::Default,
693 QMessageBox::Cancel | QMessageBox::Escape,
695 mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
696 mb.setButtonText( QMessageBox::No, tr("Cancel"));
699 if (ret==QMessageBox::Cancel)
703 if ( !file.open( QIODevice::WriteOnly ) )
704 statusBar()->message( QString("Could not write to %1").arg(filename),
708 QTextStream t( &file );
712 statusBar()->message( QString( "Note exported as %1" ).arg( fn ), statusbarTime );
718 void TextEditor::textPrint()
721 QTextDocument *document = e->document();
724 QPrintDialog *dialog = new QPrintDialog(&printer, this);
725 dialog->setWindowTitle(tr("Print Note"));
726 if (dialog->exec() != QDialog::Accepted)
729 document->print(&printer);
732 void TextEditor::textEditUndo()
736 void TextEditor::toggleFonthint()
738 setUpdatesEnabled (false);
740 if (!actionFormatUseFixedFont->isOn() )
741 e->setCurrentFont (varFont);
743 e->setCurrentFont (fixedFont);
745 setUpdatesEnabled (true);
749 void TextEditor::setFixedFont()
752 QFont font =QFontDialog::getFont(
753 &ok, fixedFont, this );
755 // font is set to the font the user selected
759 void TextEditor::setVarFont()
762 QFont font =QFontDialog::getFont(
763 &ok, varFont, this );
765 // font is set to the font the user selected
769 void TextEditor::textBold()
771 e->setBold( actionTextBold->isOn() );
774 void TextEditor::textUnderline()
776 e->setUnderline( actionTextUnderline->isOn() );
779 void TextEditor::textItalic()
781 e->setItalic( actionTextItalic->isOn() );
784 void TextEditor::textFamily( const QString &f )
789 void TextEditor::textSize( const QString &p )
791 e->setPointSize( p.toInt() );
795 void TextEditor::textColor()
797 QColor col = QColorDialog::getColor( e->color(), this );
798 if ( !col.isValid() ) return;
800 QPixmap pix( 16, 16 );
801 pix.fill( Qt::black );
802 actionTextColor->setIconSet( pix );
805 void TextEditor::textAlign( QAction *a )
807 if ( a == actionAlignLeft )
808 e->setAlignment( Qt::AlignLeft );
809 else if ( a == actionAlignCenter )
810 e->setAlignment( Qt::AlignHCenter );
811 else if ( a == actionAlignRight )
812 e->setAlignment( Qt::AlignRight );
813 else if ( a == actionAlignJustify )
814 e->setAlignment( Qt::AlignJustify );
817 void TextEditor::textVAlign()
819 QTextCharFormat format;
821 if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) {
822 format.setVerticalAlignment(QTextCharFormat::AlignSuperScript);
823 } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) {
824 format.setVerticalAlignment(QTextCharFormat::AlignSubScript);
826 format.setVerticalAlignment(QTextCharFormat::AlignNormal);
828 e->mergeCurrentCharFormat(format);
832 void TextEditor::fontChanged( const QFont &f )
834 int i=comboFont->findText(f.family());
835 if (i>=0) comboFont->setCurrentIndex (i);
836 i=comboSize->findText(QString::number(f.pointSize()));
837 if (i>=0) comboSize->setCurrentIndex(i);
838 actionTextBold->setOn( f.bold() );
839 actionTextItalic->setOn( f.italic() );
840 actionTextUnderline->setOn( f.underline() );
843 void TextEditor::colorChanged( const QColor &c )
845 QPixmap pix( 16, 16 );
847 actionTextColor->setIconSet( pix );
850 void TextEditor::formatChanged( const QTextCharFormat &f )
852 fontChanged(f.font());
853 colorChanged(f.foreground().color());
854 alignmentChanged(e->alignment());
855 verticalAlignmentChanged (f.verticalAlignment());
858 void TextEditor::alignmentChanged( int a )
860 if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft ))
861 actionAlignLeft->setOn( true );
862 else if ( ( a & Qt::AlignHCenter ) )
863 actionAlignCenter->setOn( true );
864 else if ( ( a & Qt::AlignRight ) )
865 actionAlignRight->setOn( true );
866 else if ( ( a & Qt::AlignJustify ) )
867 actionAlignJustify->setOn( true );
870 void TextEditor::verticalAlignmentChanged(QTextCharFormat::VerticalAlignment a)
872 actionAlignSubScript->setOn (false);
873 actionAlignSuperScript->setOn (false);
876 case QTextCharFormat::AlignSuperScript:
877 actionAlignSuperScript->setOn (true);
879 case QTextCharFormat::AlignSubScript:
880 actionAlignSubScript->setOn (true);
888 void TextEditor::enableActions()
890 actionFileLoad->setEnabled(true);
891 actionFileSave->setEnabled(true);
892 actionFileSaveAs->setEnabled(true);
893 actionFilePrint->setEnabled(true);
894 actionEditUndo->setEnabled(true);
895 actionEditRedo->setEnabled(true);
896 actionEditCopy->setEnabled(true);
897 actionEditCut->setEnabled(true);
898 actionEditPaste->setEnabled(true);
899 actionEditDeleteAll->setEnabled(true);
900 actionFormatUseFixedFont->setEnabled(true);
903 void TextEditor::disableActions()
905 actionFileLoad->setEnabled(false);
906 actionFileSave->setEnabled(false);
907 actionFileSaveAs->setEnabled(false);
908 actionFilePrint->setEnabled(false);
909 actionEditUndo->setEnabled(false);
910 actionEditRedo->setEnabled(false);
911 actionEditCopy->setEnabled(false);
912 actionEditCut->setEnabled(false);
913 actionEditPaste->setEnabled(false);
914 actionEditDeleteAll->setEnabled(false);
915 actionFormatUseFixedFont->setEnabled(false);
918 void TextEditor::setState (EditorState s)
921 QPalette p=palette();
925 case emptyEditor: c=QColor (150,150,150); break;
926 case filledEditor: c=QColor (255,255,255); break;
927 case inactiveEditor: c=QColor (0,0,0);
929 p.setColor(QPalette::Active, static_cast<QPalette::ColorRole>(9), c);
930 p.setColor(QPalette::Inactive, static_cast<QPalette::ColorRole>(9), c);