MainWindow

class MainWindow : public QMainWindow

Public Functions

explicit MainWindow(QWidget *parent = 0)

This is the constructor which creates the GUI and does all the prerequisites which are needed to be done.

Parameters:

parent

~MainWindow()

Destructor of mainwindow.

bool setRole(QString role)

This function is used to show a box to user to select his role as verifier, project manager or corrector.

After user chooses a role then this function sets other variables accordingly for limiting the access.

Parameters:

role

Returns:

true/false

void reLoadTabWindow()

This function reloads the tab window that is it loads the document again into the current tab.

See also

LoadDocument()

Public Slots

void on_actionLoad_Next_Page_triggered()

Sets the browser window to display the next page.

It traverses over the tree view and clicks on the item succeded by the current item programatically

See also

on_actionSave_triggered() ,get_version(), SaveTimeLog(), GetPageNumber(), LoadDocument()

void on_actionLoad_Prev_Page_triggered()

Sets the browser window to display the previous page.

It traverses over the tree view and clicks on the item preceded by the current item programatically

See also

on_actionSave_triggered() ,get_version(), SaveTimeLog(), GetPageNumber(), LoadDocument()

void LoadDocument(QFile *file, QString ext, QString name)

This function is called whenever user wants to load a document of the project.

This function checks for the current directory of the document and finds the filepath then opens that document into the curr browser. Also before opening the document it checks the type of file and saves its path into the log and removes its extension and saves it for later use then updates the word count UI to display the count of the word.

Parameters:
  • f

  • ext

  • name

void pdfPrintIsReady()

Pdf Creation is in the Process.

  1. Loading Spinner is Stopped

  2. Users are given choice wheather to close the dialog box or wait.

  3. Window Title is set to Wait.

  4. Close option is Added in Push Button.

  5. if close buttton is clicked then Print PDF process is called of.

void readOutputFromPdfPrint()

OutPut from Pdf is read.

If Check String is Ready the pdfPrintIsReady function is called.

void blockCountChanged(int)

Tracks the change in number of blocks.

Copies the bbox of previous block to current block if number of blocks are increased and deletes the bbox of a block if a number of blocks decrease

Parameters:

numOfBlocks

void authenticate()

It starts the authentication process of the user.

void login()

Login using email and password.

Asks user for email and password, then these credentials are verified witrh database and user is logged in if the details submitted by user are correct.

User enail is stored in cache for later usage.

curl is used to send post request to server.

Private Functions

void createMenu()

Adds the “Exit” menu in the File menu of menu bar.

void googleAuth()

Opens a browser where user has to sign in through his/her google account to authenticate.

bool check()

Keep it available globally so that we need not to parse dictionary file at the time of saving logs.

MainWindow::check.

This function checks whether the computer is connected to internet or not

Returns:

Returns true if computer is connected to internet else returns false.

bool check_access()

MainWindow::check_access.

This function checks whether the user has access to the opened set on cloud.

Returns:

Returns true if the logged in user has access to the opened set else returns the false.

void cloud_save()

MainWindow::cloud_save.

This function calls the commit and push functions to push the details to cloud.

Saves the cloud save success message using QSettings.

bool verifier_save()

MainWindow::verifier_save.

This function is called in verifier mode when tool is closed.

Calls commit and push functions

Parameters:

commit_msg

Returns:

Returns true if pushed successfully or false if failed.

void autoSave()

MainWindow::autoSave.

This function is called when tool is closed.

It checks if there are some local changes and calls the cloud_save() or verifier_save() function to save the changes to cloud.

void messageTimer()

MainWindow::messageTimer.

This function shows the message box to user for the specified time(5 seconds in our case).

void speechToTextCall()

MainWindow::speechToTextCall.

This function is called when recording is stopped.

This function sends request to Google Speech-to-text api and receives back response text.

Response text is pasted at cursor position.

Private Slots

void createActions()

sets Icon Size of mainToolbar

void WordCount()

This function is called whenever there is any key pressed after opening the project.

This function counts the number of word in the page and shows it in the statusbar at bottom of the window.

void DisplayJsonDict(CustomTextBrowser *b, QString input)

Load and display *.dict files.

These *.dict files are used for showing translations used in the current page

Parameters:
  • b

  • input

bool eventFilter(QObject*, QEvent*)

Handles ToolTip and ImageMarkingRegion.

  1. Responsible for drawing rectangular region

  2. Placing a PlaceHolder for figure/table/equation entries

  3. Set a MessageBox for figure/table/equation/cancel

  4. Set counter for pagewise for each entry

  5. Mark multiple image regions in a loaded image.

  6. Set various flag: a) drawRectangleFlag: is to prevent triggering of this function twice b) loadimage: check image is loaded on not c) pressedFlag: resposible for dynamic rectangular drawing.

    See also

    MainWindow::displayHolder, MainWindow::updateEntries, MainWindow::createImageInfoXMLFile, findStringSimilarity,

Parameters:
  • object

  • event

Returns:

bool

void saveImageRegion(QPixmap, QString, QString, int, int, int)

Saving Image cropped regions to their respective folder(Figure/Table/Equation)

Saves the files in the set folder under the folder “Cropped_Images”

Parameters:
  • cropped

  • a

  • s1

  • z

  • w

  • h

void AddRecentProjects()

This function will allow user to open the last opened project.

We use QSettings which allows for persistent storage and we store the project and we load the project if user selects the name of the project in recent project section.

void on_actionSave_triggered()

This function will save any changes made in the current file.

In this function we first do the preprocessing needed for the save to happen.

Then we run the function SaveFile_Backend() which will perform the actual saving and commiting of files in a separate worker thread. We synchronise this with the loading window as well.

We call doSaveBackend() of worker class which calls the SaveFile_Backend() function and emits the signal when done. This signal is needed to indicate that the saving is complete and the saving window can be closed.

We quit the thread once the thread is finished and we also deallocate the loading window from memory

We then perform SaveFile_GUI_PostProcessing() and also call the WriteSettings() function (refer functions for more details)

void on_actionSave_As_triggered()

This function saves the file which has never been saved once.

void on_actionSpell_Check_triggered()

Converts the whole html page to the original text page in orange color.

See also

findDictEntries(), find_and_replace_oddInstancesblue(), find_and_replace_oddInstancesorange(),hasM40PerAsci()

Note

works on the basis of a pre-defined flag which helps to always convert the text to Devanagari

void mousePressEvent(QMouseEvent *ev)

Checks if the right click is pressed on the mouse and loads suggestion changes.

Custom mouse event is created which loads a suggestion and translation menu for the string on which the current string highlight is present. These are loaded with the help of dictionary files which are loaded with the help of loaddata function. Works with the help of a flag.

See also

print5NearestEntries(), print2OCRSugg(), loadWConfusionsNindex1(), editDist(), make_pair()

Parameters:

ev

void menuSelection(QAction *action)

This function provides the functionality to select the menu options like slp Dict words or other to insert into the page.

Parameters:

action

void translate_replace(QAction*)

This function replaces the words translated in the current page by accessing the selected text and removing old text and inserts new text on that selected part.

Parameters:

action

void clipboard_paste(QAction*)

Inserts the text copied into the clipboard using the clipboard menu in context menu.

Parameters:

action

void keyPressEvent(QKeyEvent*)

This function handles “Ctrl+C” for storing the copied values and showing when user right clicks.

It also handles “Ctrl+D” which is used for converting english text to devanagari text

Parameters:

e

void on_actionLoadGDocPage_triggered()

Loads PWords and its associated trie data structure.

It first saves the file and then loads the data into the variables

See also

on_actionSave_As_triggered(), loadMap(), loadmaptoTrie(), generateCorrectionPairs(), loadConfusionsFont, loadTopConfusions()

void on_actionToDevanagari_triggered()

Converts transliterated text to devanagri text.

Transliterated here means Hindi/ Sanskrit written in English. This function converts selected translitrate text or last written translitrate word to Devanagri.

void on_actionLoadData_triggered()

Loads the dictionary files only once This function is only called once per project to load the dictionary file of the project, dictionary files can be used to work on suggestions.

void on_actionSugg_triggered()

Displays the context menu that has suggestion item.

Note

It works only when the data is loaded

void on_actionToSlp1_triggered()

Converts devanagri/Sanskrit text to transliterated(english) text This function converts selected Devanagari text to transliterated text.

void on_actionSanskrit_triggered()

Sets the language of the current broweser to Sanskrit by by passing the SanFlag as true.

See also

setText()

void on_actionHindi_triggered()

Sets the language of the current browser to Hindi by by passing the HinFlag as true.

See also

setText()

void on_actionEnglish_triggered()

Sets the language of the current broweser to Hindi by passing the HinFlag and the SanFlag as false.

See also

setText()

void on_actionLeftAlign_triggered()

Sets the browser text alignment to Left Align.

void on_actionRightAlign_triggered()

Sets the browser text alignment to Right Align.

void on_actionCentreAlign_triggered()

Sets the browser text alignment to Center Align.

void on_actionAllFontProperties_triggered()

Opens a pop up font properties selector and applies chosen properties to font.

The font selector lets you choose: Font face, font size, variations of those fonts (regular, bold, italic). The font selector is the Operating System’s native font selector. All fonts installed in the system will appear in the selector (a software restart after font installation/ reopening the selector might be required).

void on_actionUnBold_triggered()

Sets the font weight to regular.

void on_actionJusitfiedAlign_triggered()

Justifies the text.

Here, whenever there is a break in the text, that is being replaced by space and then text is placed in-between paragraph tags. After that, the following selected text is justisfied aligned.

Note

Not used, does not work as intended

void on_actionHighlight_triggered()

Highlights selected text in text browser and then calls LogHighlights()

Only Verifiers can highlight the text, correctors can only remove highlights. Takes the start and end position of cursor and goes to the middle of the word, then formats the word.LogHighlights() is called only when a highlight is made.

See also

LogHighlights()

Note

Text Highlight works by changing the background colour to yellow

void on_actionFontBlack_triggered()

Sets the current font colour to black.

Note

There are no further colour properties provided by the editor.

void updateAverageAccuracies()

The function updates accuracy and error on word and charater level to the files named comments.json and AverageAccuracies.csv.

See also

readJsonFile(), writeJsonFile()

void on_actionViewAverageAccuracies_triggered()

Calculates the average accuracy of the submission based upon the comments and the csv file input which depend upon the page changes.

Also updates in the csv file of the current project.

See also

AverageAccuracies(),readJsonFile()

void on_actionOpen_Project_triggered()

Opens a new OCR project.

  1. Check if file named “project.xml” exists else terminates the function.

  2. Create a new directory if CorrectorOutput, VerifierOutput or Comments folders does not exist.

  3. Loading the requisites.

a) Processing the project.xml file.

b) Load git repository.

Set the model for ProjectHierarchyWindow(TreeView). TreeView is composed of Documents and Images.

Reset the current file name and directory levels.

Get the value for time elapsed from Timelog.json.

See also

process_xml(), open_git_repo(), get_stage(), get_version(), getModel(), AddTemp(), getFilter(), insert(), UpdateFileBrekadown(), readJsonFile()

Note

Every project contains six folders - Images, Inds, CorrectorOutput, VerifierOutput, Dicts and Comments.

void file_click(const QModelIndex &indx)

This function checks for the type of file user clicked in the tree view then loads that file into the text browser if its not image else loads into image tab.

Parameters:

indx

void LoadImageFromFile(QFile *file)

This functions loads the image file in the image tab and provides all the functionality like zoom , cut and resize on that image file.

Parameters:

f

void CustomContextMenuTriggered(const QPoint &p)

This function is called when user wants to change Context menu.

This function maps the tree view of then it regenrates it according to filetype or filter.

Parameters:

p

void AddNewFile()

This function is used to add a new file into the tree to do this this function first checks current index of tree at which user wants new file then it adds the file at that point in tree as well as it updates project.

void OpenDirectory()

This function is used to a folder into the tree at the current index.

Also it adds that folder to the project and imports all of its files and at it into the tree as well as project.

void RemoveFile()

This function provides functionality to remove a file from the project as well as from the tree at that index.

void closetab(int index)

This function is called when tab is closed or when the page is closed.

This function checks if page is in readonly mode and if condition fails then it popups a messagebox asking to save any unsaved works left.

Parameters:

idx

void tabchanged(int index)

When new page is opened without closing the current page or new tab is opened without closing current tab or tabs/pages gets switched then this function is called.

Parameters:

idx

void on_actionTurn_In_triggered()

To turn-in the corrector’s file to git repository when user clicks “submit corrector” button.

See also

checkUnsavedWork(), saveAllWork(), get_version(), commit(), push(), set_stage_verifier() and enable_push()

Note

This function turn-in files only for corrector and not for verifier.

void on_actionPush_triggered()

Pushes the code to the repository.

void on_actionFetch_2_triggered()

Used for syncing cloud data.

void on_actionVerifier_Turn_In_triggered()

To turn-in the verifier’s file to git repository when user clicks “”Submit Verifier” button.

See also

checkUnsavedWork(), saveAllWork(), get_version(), get_stage(), readJsonFile(), writeJsonFile(),set_stage_verifier() and enable_push.

Note

This function turn-in files for verifiers not correctors.

void directoryChanged(const QString &path)

This funcction is called when directory of project is changed.

This function sets all file paths of corrector output and verifier output to the new loaction.

Parameters:

path

void on_actionAccuracyLog_triggered()

Logs various accuracies to AccuracyLog.csv.

Stores the following values in the csv: Page Name Percent Difference in Corrector and Verifier Text Percent Character Level Accuracy (Corrector) Percent Word Level Accuracy (Corrector) Percent Change made by Corrector wrt OCR Text Percent Word Errors Percent Accuracy of OCR

See also

diff_match_patch::diff_main(), Project::LevenshteinWithGraphemes(), Project::GetGraphemesCount()

void on_compareCorrectorOutput_clicked()

Compares the changes made by the Corrector in OCR generated text file.

See also

InternDiffView(), LevenshteinWithGraphemes(), GetGraphemesCount()

void on_viewComments_clicked()

This function is used for viewing the Comments.

It opens up the comment box for showing comments.

void on_actionZoom_In_triggered()

Increases the font size of the text at the cursor.

void on_actionZoom_Out_triggered()

Decreases the font size of the text at the cursor.

void on_actionSymbols_triggered()

It shows the table for various symbols.

See also

Symbols.cpp

void on_actionInsert_Tab_Space_triggered()

inserts tab (4 whitespaces) at cursor

void on_actionInsert_Horizontal_Line_triggered()

Draws a horizontal rule a line below the cursor.

Uses html to insert a horizontal rule using

tag. Selecting text and then using this fuctionality will clear the text, and then insert a horizontal rule below it.

Note

The text browser is a rich text field, so html tags and styling can be used seamlessly.

void on_actionSubscript_triggered()

toggles subscript for selected text/ character at cursor

void on_actionSuperscript_triggered()

toggles superscript for selected text/ character at cursor

void UpdateFileBrekadown()

This function is called whenever there is changes in folder structure or files.

This function updates the location of files and folder into the global variables.

void on_actionAdd_Image_triggered()

This function is called whenever user wishes to add an image in the document in our tool.

void SaveTimeLog()

This function saves the time of changes commit into the log json file.

See also

writeJsonFile()

void DisplayTimeLog()

This function displays the time in statusbar and gets update on every right click.

void on_actionResize_Image_triggered()

This function resizes the images in the document.

User has to input the new height and width and thus the image is appropriately resized.

void LogHighlights(QString word)

Stores highlight metadata to JSON files.

See also

writeJsonFile()

Note

Meta data includes: Word highlighted, timestamp, time elapsed, page name

Parameters:

QString – text

void on_compareVerifierOutput_clicked()

Compares Verifier’s Output, Corrector’s Output and OCR text.

This function also displays the percentage of changes made by the Corrector and Verifier, and the accuracy of the OCR text w.r.t. the verified text.

See also

DiffView()

void on_actionUndo_triggered()

Undo the changes made in QTextBrowser.

void on_actionRedo_triggered()

Redo the changes made in QTextBrowser.

void on_actionInsert_Table_2_triggered()

Inserts table at text cursor Creates a dialog to insert the numbr of rows and columns.

void closeEvent(QCloseEvent *event)

event filter that tracks close event and prompts user to save file if they didn’t

Parameters:

event

QJsonObject getAverageAccuracies(QJsonObject mainObj)

Calculate average char, word accuracy of .html files w.r.t to the .txt files.

Parameters:

mainObj

Returns:

QJsonObject

void on_actionInsert_Columnleft_triggered()

Inserts Column to the left of table.

void on_actionInsert_Columnright_triggered()

Inserts Column to the right of table.

void on_actionInsert_Rowabove_triggered()

Inserts Row above the table.

void on_actionInsert_Rowbelow_triggered()

Inserts Row below the table.

void on_actionRemove_Column_triggered()

Delete selected column.

void on_actionRemove_Row_triggered()

Delete selected row.

void on_actionItalic_triggered()

Sets the font style to italic.

void on_actionNonitalic_triggered()

Resets the font style to non italic.

void on_actionSave_All_triggered()

This is called when user cloases a tab, page or the application.

It saves all the unsaved work of that page.

void on_actionFind_and_Replace_triggered()

Helps to find particular text and replaces them with new user entered text.

See also

openFindAndReplace()

bool checkUnsavedWork()

This function is called when user closes a tab or page then this function checks for the unsaved changes in that tab or page and if any unsaved work found then it returns true else false.

Returns:

bool

void saveAllWork()

This function is called when user closes a tab or page and it has some unsaved work containg in that page or tab and this function saves all those changes in that page or tab.

void readSettings()

We use function read settings to read the positions of the cursor from a binary file and thus get the cursor position of that file.

We read the file by first opening it and we feed it into QMap and get the cursor position of that file. Then we hughlight that area by setting stylesheet of text browser.

void writeSettings()

We use function write settings to write the positions of the cursor to a binary file We retrieve the cursor position and put it in a QMap first and then write it in the file and subsequently flush it in persistent storage.

void setMFilename(QString)

This function is used to set the file name or image file name of the project tree when opened.

Also this functions removes extentions of those file and keep only name of that file.

Parameters:

name

void on_pushButton_clicked()

When button is clicked, then we can add placeholders for figure/table/equation.

void on_pushButton_2_clicked()

Button for resizing an image.

Captures src, width and height attributes, modifies height and width and change the image size it does not change the quality of an image.

void runGlobalReplace(QString, QVector<QString>)

It calls the function which replaces the words and add the words into the CPair file in a multithreaded fashion.

  1. Opens up dialog box for asking the user if he wants to do global-replace or not.

    1. Then it runs another thread for doing global replace.

    2. After completion of global replace, it runs another thread for adding the replaced words to CPair.

Parameters:
  • currentFileDirectory

  • changedWords

bool globalReplaceQueryMessageBox(QString old_word, QString new_word, int &chk)

spawns a MessageBox and returns true if Replace is chosen

Parameters:
  • old_word

  • new_word

  • chk

Returns:

bool

int writeGlobalCPairsToFiles(QString file_path, QMap<QString, QString> globalReplacementMap)

writes CPairs by iterating over all files

Parameters:
  • file_path

  • globalReplacementMap

void addCurrentlyOpenFileToEditedFilesLog()

adds currently opened file in editor in .EditedFiles.txt to mark it as dirty

void deleteEditedFilesLog()

Deletes .EditedFiles.txt which stores the edited files list.

void RecentPageInfo()

Used for storing recent page info in QSettings, so that last page opened for the set gets opened when that set is opened again.

bool isStringInFile(QString file_path, QString searchString)

Checks if a QString is in file at file_path.

Parameters:
  • file_path

  • searchString

Returns:

0 if not present and 1 if it is present

void dumpStringToFile(QString file_path, QString string)

Writes given QString to file at file_path.

Parameters:
  • file_path

  • string

void highlight(CustomTextBrowser *b, QString input)

This function highlights words of Globally Replaced Words.

We have a map where we store all global replace word list and we get this data from CPair File in the project set folder.

We loop through this map and we also loop through all the files in the set.

Now we get the index of the globally replaced word, we check if the word is a whole word and not a substring and after passing all the condition we set the background of the word in yellow.

Parameters:
  • b

  • input

QMap<QString, QString> getGlobalReplacementMapFromChecklistDialog(QVector<QString> replacedWords, QVector<int> *replaceInAllPages)

Spawns a checklist and returns a QMap of selected pairs.

Parameters:
  • changedWords

  • replaceInAllPages

Returns:

ReplacementMap

void on_actionas_PDF_triggered()

This function gets the book project set in PDF format for easy reading.

Depending on whether the user has opened the tool in corrector or verifier mode the appropriate folder is opened and we scan the html contents of only html files in the folder.

We then print the html contents using QPrinter and output it in the project set folder with the name “Bookset.pdf”.

void on_actionGet_Help_triggered()

Redirects user to OCR Tool Help documentation.

void on_actionTutorial_triggered()

Redirects user to Team OCR Youtube channel.

void on_actionLinux_triggered()

Redirects user to OpenOCRCorrect Linux Installation Guide.

void on_actionWindows_triggered()

Redirects user to OpenOCRCorrect Windows Installation Guide.

void on_actionShortcut_Guide_triggered()

Opens shortcut guide for all available features.

void on_textBrowser_textChanged()

Updates the word count based on browser text change.

void on_zoom_Out_Button_clicked()

Zooms out the image set in the graphics view.

void on_zoom_In_Button_clicked()

Zooms in the image set in the graphics view.

void zoom_slider_valueChanged(int value)

Updates the zoom percentage to QLabel.

Parameters:

value

void zoom_slider_moved(int value)

Updates the zoom value when the slider is moved.

Parameters:

value

void zoomedUsingScroll()

Set the zoom level of horizontal slider based on scroll.

void on_actionUndo_Global_Replace_triggered()

This feature allows user to undo global replacements when it has been done previously This function checks if last global replace was for single word or multiple word and accordingly the appropriate function is called.

This function retrives a map for undo global replace in a variable “UndoGRMap” and writes all the new words back to the old words thereby undoing the last global replace

bool undoGlobalReplace_Single_Word(QString oldWord, QString newWord)

This function shows a dialog box asking the user whether the global replacement for the word has to be undone This function is only called when the last global replace was done for a single word ONLY.

Parameters:
  • oldWord

  • newWord

Returns:

bool

void reverseGlobalReplacedWordsMap()

This function adds the words requested by the user for global replace undo change to a map “reversedMap”.

QMap<QString, QString> getUndoGlobalReplaceMap_Multiple_Words(QMap<QString, QString>)

This function shows a dialog box asking the user whether the global replacement for the word has to be undone This function is only called when the last global replace was done for more than ONE word.

Parameters:

GRMap

Returns:

GlobalReplaceMap

void replaceInAllFilesFromTSVfile()

This feature allows user to perform global replace by uploading a tsv file Here the function checks if the file being uploaded by the user is valid or invalid by calling checkForValidTSVfile() If it is valid then it maps the words in the file to global replace map and asks user whether to perform global replace or not If the user clicks on Ok then the words are globally replaced.

bool checkForValidTSVfile(QFile &file)

This function checks whether the tsv file uploaded for global replace is valid or not.

This function opens the file, and starts scanning it. A tsv file is a valid only when each and every line contains one tab space between text and no single spaces The function loops through each line checking for the above condition. If any line violates above condition then it returns false and terminates indicating that the file is invalid. If the scan is successful and every line satisfies the condition, it returns true and exits indicating that file is valid.

Parameters:

file

Returns:

bool

void globalReplacePreviewfn(QMap<QString, QString>, QVector<int>)

This feature allows user to view the changes in advance that are going to be done by global replace.

This function will fetch the required data and put in a window where the users will be able to see in a tabular format, the page name, the sentences where the global replace word is/are present and the same sentence after making the change. This allows the user to better make decisions whether to perform global replace or not

When the user saves the file, a dialog box for global replace appears with words to be selected and globally replaced. If no word is selected and preview button is clicked then a message will be shown that no word was selected.

If words are selected then all files in the project are scanned using dirIterator and the result is fetched by called getBeforeAndAfterWords() which returns the page name and the relevant sentences.

Once the data is fetched, we loop through the data and split the returned sentence in the following fashion:

  1. Before the change was made

  2. Same sentence after change

Then we initialize QStandardItem model and feed this data to it and also set the relevant headings to it

Parameters:
  • previewMap

  • allPages

QMap<QString, QStringList> getBeforeAndAfterWords(QString fPath, QMap<QString, QString> globalReplacementMap)

This function is used by MainWindow::globalReplacePreviewfn() for fetching the context sentences where the global replace is to be applied.

The function first opens the file passed in parameter fPath and opens the stream. Then it runs a for loop wherein we loop through the global replace word map and otain the key and value and store them as oldword and newword respectively

We run a regex which will allow us to get handful of words before and after the replaced word which will be shown in the preview dialog box.

We run the regex for occurances wherein we capture the matched pattern and replace the old word with the new word, and return both the sentences along with the file name.

Parameters:
  • fPath

  • globalReplacementMap

void on_actionUpload_triggered()

When uploading any file or folder this function is called which calls replaceInAllFilesFromTSVfile function.

void on_justify_triggered()

This function checks if page is opened in readonly mode if false then it allows the user to change the alignment of the text in the current opened page or tab.

void on_actionFont_Color_triggered()

This function checks if page is opened in readonly mode if false then it allows the user to select a color for the font and then changes the text font color in the page.

void on_actionBold_triggered()

Sets the font weight to bold.

void SaveFile_GUI_Preprocessing()

This function saves the changes made in current page opened in textbrowser.

void SaveFile_GUI_Postprocessing()

This function saves the changes made in current page opened in textbrowser and after selcting the loaction to save the file this funtion convert all html output to plain text then perform saving.

void GlobalReplace()

This function runs the comparison check on the previously saved file and current document for getting the changed words for global replace.

void stopSpinning()

This function stops the sppiner whenever called.

void on_lineEditSearch_textChanged(const QString &arg1)

This function is a part of Project File Search feature.

If set is very large then user can enter page number or any keyword related to file name and get it filtered. The tool will show him that page and thus he will be able to open more easily.

This function scans the whole files and stores in a list. Whenever the user types on the search text box it will check the keyword to match in the list. The respective files are highlighted.

Parameters:

arg1

void on_action1_triggered()

Opens up the project 1 in recent project list.

void on_action2_triggered()

Opens up the project 2 in recent project list.

void on_action3_triggered()

Opens up the project 3 in recent project list.

void on_actionCheck_for_Updates_triggered()

Checks for the update of the following File from Github-Repo.

Timer is set to 5000ms which starts the sprite animation. If the animation is already running, calling this method has no effect. Stores the response from github as string. Compares Latest Version to the Current version. If found Same then functions is returned. Latest Version is download if Current version is not equal to Latest Version. (Later) Button is also set if user does not want to upgrade this time.

void closeProgressBar()

This function closes the progress bar.

void setProgressBarPerc(int)

Sets the progress bar value to the passed value.

Parameters:

value

QString toDevanagari(string text)

Converts a text to Devanagari script text.

Parameters:

text

Returns:

Devanagari text

void on_find_clicked()

Finds a word in the textbrowser.

void on_actionPDF_Preview_triggered()

Previews the current file as PDF.

Uses Qt’s QPrintPreviewDialog for showing preview

void print(QPrinter *printer)

Prints the file into PDF.

  1. Traverses all the files in the current role folder

  2. Merges the content of those html files into one

  3. Forward this merged file to the QPrinter for printing the file by the given printer

Parameters:

printer

void on_actionChange_Role_triggered()

Changes the role of the user.

provides application settings. prefix of the current group is set to(SETROLE)

void bboxInsertion(QFile *f = nullptr)

Inserts bbox into the saved file(DEPRECATED) but used in Find & Replace module.

Parameters:

f

void finishedPdfCreation(int exitCode, QProcess::ExitStatus exitStatus)

Function is called When PDF Creation is successfull.

  1. Compares exitcode to zero(0).

  2. If found True message is set to(PDF created Successfully)

  3. if exit code is EQUAL to -1,255,9 then PDF creation was Stopped by user.

  4. if other cases failed then PDF creation was unsuccessfull.

  5. File is Closed.

  6. Message Box of Title is Previewed.

Parameters:
  • exitCode

  • exitStatus

void SearchOnGoogle()

selected text is searched over google to find it’s meaning

void GoogleTranslation()

selected Text translation is searched over google.

void insertImageAction()

Image is inserted in the opened file.

  1. File Dialog is opened,giving user choice to choose the images from their PC.

  2. if image file is empty then fucntion terminates.

  3. File information is stored(File Path)

  4. Image height and Width is set.

void on_actionLogin_triggered()

authenticate function is called.

User is redirected to Google login page

void on_actionLogout_triggered()

Function is executed when user logouts.

  1. Logout button is not visible

  2. login button is previewed so that user can login.

void on_actionClone_Repository_triggered()

This function helps user to clone repositories from their account.

Checks if user is already logined or not. If not then user is made to login POST request is send to udaaniitb.aicte-india.org to get the files. Json Object File is read and converted to Json Array. “validate.json” is removed from output Table is formed to preview how many file does user have in their repository

void on_actionClose_project_triggered()

Closes the current opened Project.

Checks wheather if projected is opened or not.If not Function terminates Clears Tree view,Current browser,graphicsView. All buttons which were enabled during the Open project are closed,Like Zoom,Compare Corrector output,save etc. Dictornary is cleared

void on_actionMerge_Cells_triggered()

Merges the cells selected in the table.

Tables are manipulated using QTextTable module from Qt.

void on_actionSplit_Cell_triggered()

Splits the current cell into the rows and columns specified by the user.

Tables are manipulated using QTextTable module from Qt.

void on_actionInsert_Bulleted_List_triggered()

Adds the bulleted list to the text browser.

Shows the radio buttons to chose the list type to be added

See also

insertList

void on_actionInsert_Numbered_List_triggered()

Adds the Numbered list to the text browser.

Shows the radio buttons to chose the list type to be added

See also

insertList

void insertList(QTextListFormat::Style styleIndex)

Acts as a helper for adding ordered and unordered lists.

Inserts the list according to the styleIndex provided

Parameters:

styleIndex

void on_actionInsert_Equation_triggered()

Inserts the equation as an image in the text browser at cursor position.

This function calls the equation editor class and passes the browser pointer, pwd, and “0”.

0 denotes that new equation needs to be inserted(If path is passed instead of 0, then selected equation is edited).

void on_actionEdit_Equation_triggered()

Edits the equation using Equation editor.

This function checks if the user has selected any image or not. If image is selected then it calls the equation editor and passes pwd, browser pointer, & path to MathBran notation of selected equation.

void on_actionExit_triggered()

Application is exited and Closed.

void on_sanButton_toggled(bool checked)

Toggles the dict view to the Sanskrit SLP Dict.

Parameters:

checked

void on_hinButton_toggled(bool checked)

Toggles the dict view to the Hindi SLP Dict.

Parameters:

checked

void on_actionTwo_Column_triggered()

MainWindow::on_actionTwo_Column_triggered.

When Two column Layout button is clicked, this function is called. This function creates a table with two columns and one row, then puts the browser data in first column.

It will not be shown as table to user. User can see two column data with vertical line in between.

User can take cursor to text editor, go to “View > Layout > Two Column Layout” to use this feature.

Author

Sadam

void on_pushButton_3_clicked()

MainWindow::on_pushButton_3_clicked.

This function rotates the graphics view by 90 degree which contains the original image of the page.

void on_actionUser_Guide_triggered()

MainWindow::on_actionUser_Guide_triggered.

Redirects user to OCR Tool User guide.

void preprocessing()

MainWindow::preprocessing.

This function is called when is html file is loaded for the first timne in tool.

This functions scans the non-english text and removes the dangling mathra(if any) by converting text to slnp first followed by converting the previous output to devanagari.

This function is called once in a lifetime(per page).

void on_pushButton_4_clicked()

MainWindow::on_pushButton_4_clicked.

User needs to select a language from language drop down menu(Language in which user will record an audio).

When “Speech to text” button is clicked, this functon is called. This function records the user audio and shows status on the same button.

“Speech to text” status means user can start recording. “Stop ?” means audio recording is in progress and user can stop it by clicking the “Stop ?” button.

“Processing …” means the user input is in process and the requested audio will be converted into text and pasted at cursor position. Text is inserted at cursor position

and status of button is changed back to “Speech to text”.