@@ -105,12 +105,7 @@ namespace IAEX {
105105 };
106106
107107
108-
109108 /* !
110- * \class MyTextEdit2
111- * \author Anders Ferström
112- * \date 2005-11-01
113- *
114109 * \brief Extends QTextEdit. Mostly so I can catch when a user
115110 * clicks on the editor
116111 */
@@ -183,7 +178,6 @@ namespace IAEX {
183178 */
184179 void MyTextEdit3::keyPressEvent (QKeyEvent *event )
185180 {
186- emit showVariableButton (false );
187181 // EVAL, key: SHIFT + RETURN || SHIFT + ENTER
188182 if ( event->modifiers () == Qt::ShiftModifier &&
189183 (event->key () == Qt::Key_Return || event->key () == Qt::Key_Enter) )
@@ -483,7 +477,7 @@ namespace IAEX {
483477 createLatexCell ();
484478 createOutputCell ();
485479
486- connect (input_, SIGNAL (showVariableButton (bool )), this , SLOT (showVariableButton (bool )));
480+ // connect(input_, SIGNAL(showVariableButton(bool)), this, SLOT(showVariableButton(bool)));
487481
488482 // connect(output_, SIGNAL(anchorClicked(const QUrl&)), input_, SLOT(goToPos(const QUrl&)));
489483
@@ -526,12 +520,13 @@ namespace IAEX {
526520 {
527521
528522 input_ = new MyTextEdit3 ( mainWidget () );
529- variableButton = new QPushButton (" D " ,input_);
530- variableButton ->setToolTip (" New simulation data available " );
531- variableButton ->setMaximumWidth (25 );
523+ hideButton = new QPushButton (" H " ,input_);
524+ hideButton ->setToolTip (" Hide the Latex Source " );
525+ hideButton ->setMaximumWidth (25 );
532526 layout_->addWidget ( input_, 1 , 1 );
533- layout_->addWidget (variableButton, 1 , 2 );
534- variableButton->hide ();
527+ layout_->addWidget (hideButton, 1 , 2 ,Qt::AlignTop);
528+
529+ hideButton->hide ();
535530 // 2006-03-02 AF, Add a chapter counter
536531 createChapterCounter ();
537532
@@ -551,18 +546,20 @@ namespace IAEX {
551546
552547 input_->setPalette (palette);
553548
554- variableButton ->setPalette (palette);
549+ hideButton ->setPalette (palette);
555550 // is this needed, don't know /AF
556551 input_->installEventFilter (this );
557-
558- connect ( input_, SIGNAL ( textChanged () ), this , SLOT ( contentChanged () ));
552+ connect (hideButton, SIGNAL ( clicked ()), this , SLOT ( hidelatexsource ()));
553+ connect ( input_, SIGNAL ( textChanged () ), this , SLOT ( contentChanged ()));
559554 connect ( input_, SIGNAL ( clickOnCell () ), this , SLOT ( clickEvent () ));
560555 connect ( input_, SIGNAL ( wheelMove (QWheelEvent*) ), this , SLOT ( wheelEvent (QWheelEvent*) ));
561556 connect ( input_, SIGNAL ( eval () ), this , SLOT ( eval () ));
562557 connect ( input_, SIGNAL ( command () ), this , SLOT ( command () ));
563558 connect ( input_, SIGNAL ( nextCommand () ), this , SLOT ( nextCommand () ));
564559 connect ( input_, SIGNAL ( nextField () ), this , SLOT ( nextField () ));
565- // connect( input_, SIGNAL( textChanged() ), this, SLOT( addToHighlighter() ));
560+ connect ( input_, SIGNAL ( nextField () ), this , SLOT ( nextField () ));
561+
562+ // connect( input_, SIGNAL( textChanged() ), this, SLOT( addToHighlighter() ));
566563 connect ( input_, SIGNAL ( currentCharFormatChanged (const QTextCharFormat &) ),
567564 this , SLOT ( charFormatChanged (const QTextCharFormat &) ));
568565 connect ( input_, SIGNAL ( forwardAction (int ) ), this , SIGNAL ( forwardAction (int ) ));
@@ -574,13 +571,21 @@ namespace IAEX {
574571 connect (input_, SIGNAL (textChanged ()), input_, SLOT (setModified ()));
575572 }
576573
577- void LatexCell::showVariableButton (bool b)
578- {
579- if (b)
580- variableButton->show ();
581- else
582- variableButton->hide ();
583- }
574+ void LatexCell::hidelatexsource ()
575+ {
576+ input_->hide ();
577+ hideButton->hide ();
578+ latexButton->show ();
579+ output_->show ();
580+ }
581+
582+ void LatexCell::showlatexsource ()
583+ {
584+ output_->hide ();
585+ hideButton->show ();
586+ latexButton->hide ();
587+ input_->show ();
588+ }
584589
585590 /* !
586591 * \brief Creates the QTextEdit for the output part of the
@@ -590,8 +595,12 @@ namespace IAEX {
590595 void LatexCell::createOutputCell ()
591596 {
592597 output_ = new MyTextEdit3 ( mainWidget () );
593- layout_->addWidget ( output_, 2 , 1 );
594-
598+ layout_->addWidget ( output_, 1 , 1 );
599+ latexButton = new QPushButton (" L" ,output_);
600+ latexButton->setToolTip (" Show the Latex Source" );
601+ latexButton->setMaximumWidth (25 );
602+ layout_->addWidget ( latexButton, 1 , 2 , Qt::AlignTop);
603+ latexButton->hide ();
595604 output_->setReadOnly ( true );
596605
597606 output_->setOpenLinks (false );
@@ -601,7 +610,7 @@ namespace IAEX {
601610
602611 output_->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
603612 output_->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
604-
613+ connect (latexButton, SIGNAL ( clicked ()), this , SLOT ( showlatexsource ()));
605614 connect ( output_, SIGNAL ( textChanged () ), this , SLOT (contentChanged ()));
606615 connect ( output_, SIGNAL ( clickOnCell () ), this , SLOT ( clickEventOutput () ));
607616 connect ( output_, SIGNAL ( wheelMove (QWheelEvent*) ), this , SLOT ( wheelEvent (QWheelEvent*) ));
@@ -1149,7 +1158,8 @@ void LatexCell::eval()
11491158 * 4) Display the output as image to the output cell inorder to maintain the
11501159 * equations and formula structures
11511160 */
1152-
1161+ // hideButton->hide();
1162+ // latexButton->show();
11531163 input_->blockSignals (true );
11541164 output_->blockSignals (true );
11551165 output_->textCursor ().insertText (" " );
@@ -1193,14 +1203,13 @@ void LatexCell::eval()
11931203 /* Check for latex is installed */
11941204 if (Latexversion.isEmpty ())
11951205 {
1196- // qDebug()<< "Latex is not installed in your system";
1197- output_->clear ();
1198- output_->textCursor ().insertText (" Error: Latex is not installed in your System" );
1199- setClosed (false );
1206+ QMessageBox::warning ( 0 , " Error" , " Latex is not installed in your System, This cell cannot be evaluated" , " OK" );
12001207 }
12011208 /* Generate the DVI file from tex through latex */
12021209 if (!Latexversion.isEmpty ())
12031210 {
1211+ hideButton->hide ();
1212+ latexButton->show ();
12041213 process->start (" latex" , QStringList () << " -halt-on-error" << Tex);
12051214 process->waitForFinished ();
12061215 QFile logfile (log);
@@ -1244,30 +1253,35 @@ void LatexCell::eval()
12441253 QFileInfo checkpng (Png);
12451254 if (!checkpng.exists ())
12461255 {
1256+ output_->clear ();
12471257 output_->textCursor ().insertText (" Error:Problem in finding dvipng executable" );
12481258 setClosed (false );
1259+
12491260 }
12501261 else
12511262 {
12521263 output_->clear ();
12531264 output_->textCursor ().insertImage (Png);
1254- setClosed (false );
1265+ // setClosed(false);
1266+ input_->hide ();
1267+ output_->show ();
1268+
12551269 }
12561270 }
12571271 else
12581272 {
1259- output_->clear ();
1260- output_->textCursor ().insertText (" Message:Maximum of 1 page document generation is supported per Latexcell, The script generates more than 1 page, Add a new Latex cell and create the document" );
1261- setClosed (false );
12621273
1274+ QMessageBox::warning ( 0 , " Warning" , " Maximum of 1 page document generation is supported per Latexcell, The script generates more than 1 page" , " OK" );
12631275 }
12641276 }
12651277 }
12661278 else
12671279 {
12681280 // qDebug()<< "Empty cells can't be evaluated";
1281+ hideButton->hide ();
1282+ latexButton->show ();
12691283 output_->clear ();
1270- output_->textCursor ().insertText (" Message: Empty Cells cannot be Evaluated" );
1284+ output_->textCursor ().insertText (" Message: Empty Latex Cells cannot be Evaluated" );
12711285 setClosed (false );
12721286 }
12731287 input_->blockSignals (false );
0 commit comments