equationeditor

class equationeditor : public QMainWindow

Public Functions

explicit equationeditor(QWidget *parent, QString gDirTwoLevelUp, CustomTextBrowser *b, QString mode)

If mode is equal to 0, then new equation is typed and inserted. If the mode contains file path, then the previous equation is edited(Whose path is passed here).

Parameters:
  • parent

  • gDirTwoLevelUp

  • b

  • mode

~equationeditor()

Destructor.

Private Functions

void load(QString filename)

This function opens, renders and shows an equation in editor from selected file. File should contain a valid MathBran code.

Parameters:

filename

void loadPrompt()

This function shows the dialog to select a file.

void save()

If save path is empty, savePrompt() function is called, else saveAs() function is called with path.

void saveAs(QString save_path)

This function saves the file at specified location. File contents are stored in MathBran notation.

Parameters:

save_path

void savePrompt()

Shows the pop up dialog to user to save the file at desired location.

void printSvgPrompt()

This functions generates the svg of typeset_edit contents and saves at selected location.

Note

QSvgGenerator is used to generate svg file.

Private Slots

void on_actionNew_triggered()

It clears the typeset_edit and path.

void on_actionLoad_triggered()

Loads new file in typeset_edit.

void on_actionSave_triggered()

calls save() function when save button is clicked.

void on_actionSave_As_triggered()

When user clicks on “save as” button, savePrompt() function is called.

void on_actionPrint_triggered()

When user clicks on print button, the current content written in typeset_edit is saved as svg.

void on_actionUndo_triggered()

This function is called on udo operation.

void on_actionRedo_triggered()

This function is called on redo operation.

void on_actionLoad_Test_txt_triggered()

If user wants to load a test project in equation editor, this function is called when clicked on “load test”.

void on_actionZoom_In_triggered()

This function zooms in the typeset_edit contents.

void on_actionZoom_Out_triggered()

This function zooms out the typeset_edit contents.

void on_actionReset_Zoom_triggered()

This function resets the zoom level to default zoom level in the typeset_edit window.

void on_actionShow_Line_Numbers_toggled(bool show)

There is an option to show line numbers when we type the equation in an equation editor. User can turn on/off the line numbers by using this option.

Parameters:

show

void on_actionVanilla_triggered()

This function changes the theme of equation ediotr.

Two themes are available - Vanilla and Chalkboard

void on_actionChalkboard_triggered()

Sets the theme to chalkboard.

void on_actionCopy_as_PNG_triggered()

This function copies the typeset_edit contents as png image.

void on_actionCopy_as_TeX_triggered()

This copies the equation as Latex code which can pasted by user at some other place.

void on_actionCopy_as_Unicode_triggered()

This copies the equation as Unicode code which can pasted by user at some other place.

void enclosedMathBranButton(QString l, QString r)

Inserts the provided strings in the tpeset_edit and renders it as a valid mathematical equation.

Parameters:
  • l

  • r

void on_actionInsert_Equation_triggered()

Inserts the equation in html file at current cursor position.

This functions converts the equation editor contents into a png image and inserts this image in browser at cursor position. This inserted png image is also stored locally inside the project directory, within Equations_ folder. Besides the png image, Latex code and MathBran code is also stored in separate files. For one equation, three files are stored locally. In our udaan post editing tool, we show equations as png images but in html files, it is stored as Latex code within $$ $$ tags which can be rendered by MathJax library in any browser. MathBran files are useful to edit already inserted images because our equation editor can render the MathBran notation only.