KLatexFormula Documentation

Structure of KLatexFormula Application and Libraries

KLatexFormula, beyond being a graphical application, provides a couple libraries which may be used in other programs.

klftools: Tools library

Dependencies: Qt5

The klftools Library is a collection of tools that were written for KLatexFormula. However they could be in principle useful in other Qt5 applications, and hence they were collected in a separate library.

Features include:

  • A search bar (KLFSearchBar), with an abstract search interface so that you can search pretty much anything

  • A full-featured color selection widget, respectively color selection dialog

  • A “please wait” popup widget, more splash-screen oriented than progress-dialog oriented, inviting the user to be patient (KLFPleaseWaitPopup)

  • A grid flow layout (KLFGridFlowLayout): a widget layout that displays widgets in a grid; unlike QGridLayout (where you have to specify explicit coordinates) widgets are just inserted left to right, breaking into new lines after a certain number of columns

  • A path chooser widget (KLFPathChooser): lets the user input a location with a line edit and a “browse” button

  • A pixmap button (KLFPixmapButton): displays a pixmap instead of a label on a QPushButton without having to hack with setIcon() and setIconSize()

  • KLFProgressReporter and KLFProgressDialog: allows to send progress information for whoever is interested, and display that progress information in a QProgressDialog-subclass

  • KLFPropertizedObject: implements a properties engine for common objects. This works like QObject properties, but with some fundamental differences, see the documentation for this class in the APIs

  • KLFFactory{Base|Manager}: common functions for class instance factories

  • klfMatch(), klfDataToEscaped(), klfVariantToText(), klf{Load|Save}Variant{Map|List}ToXML(), klfUrlCompare(), klfVariantListToList(), …: all functions that you would wish to feature in Qt itself but which you have not found in Qt ;) [Note: I wrote these a while ago, so some of this functionality might have been introduced in Qt over the years.]

    • klfMatch(): perform general string or value matching, supporting exact match, contains, regexp, wildcard, etc. in the same idea as QAbstractItemModel::match()

    • klfDataToEscaped(): just \-escapes binary data into ascii-compatible data

    • klfVariantToText()/klfVariantFromText(): saves/loads QVariant’s as human-read/writable (but also machine parsable) text. This does not save type information, which is assumed to be known when reading back the variant

    • klfSaveVariantMapToXML()/klfSaveVariantListToXML(): read/write XML with QVariantMap’s and QVariantList’s in XML, each variant item is written with klfVariantToText()

    • klfUrlCompare(): compares URLs, especially query items

    • klfVariantListToList<Type>() converts a QVariantList into a QList<Type>.

See the API documentation here.

klfbackend: Backend library

Dependencies: Qt5, klftools

The core of KLatexFormula’s functionality is provided by the library klfbackend. This library provides a few very basic functions useful for the whole of KLatexFormula package (common declarations), a few general utilities, and one function called getLatexFormula() which takes care of running latex, dvips, gs and epstopdf to get a QImage, PS, PNG, PDF, etc., data from a given latex expression and various input settings. This library is also capable of running backend engine user scripts.

This library is intended of course for use in KLatexFormula itself, but of course anyone wishing to add to his/her program the functionality of converting latex expressions to images can link the program to the KLFBackend library. A utility to detect where latex/dvips/gs are is provided, with a few hard-coded standard paths, with the option to look into more paths. At the end, this functionality amounts to very little code in your program.

The klfbackend library depends on some utilities which are defined in the klftools library. If you don’t want to add the klftools dependency to your program, link to klfbackend_auto instead (see below).

Main Features:

  • getLatexFormula(): compile a latex equation into several graphics formats, including PNG, PS and PDF.

  • detectSettings(): auto-detect the location of latex, dvips and gs, and see which formats are supported by ghostscript.

  • KLFBlockProcess, KLFFilterProcess: run a separate process designed to transform some input into some output.

  • KLFUserScriptInfo: deal with klatexformula user scripts.

See the API documentation here.

klfbackend_auto: Autonomous klfbackend library

Dependencies: Qt5

This is the same as the klfbackend library, except it includes the (relatively few) sources from klftools that are required.

Link to this library if you would like to compile latex equations in your program with klfbackend but you don’t need klftools.

If you link to klfbackend_auto, then do not link to klfbackend or klftools (you’ll get duplicate symbol definitions).

KLatexFormula does not require klfbackend_auto.

libklftoolsdesplugin: Qt5 designer plugin for klftools

Dependencies: Qt5 incl. Qt5 Designer libraries, klftools

This library is a plugin for Qt5 Designer, giving you full access to klftools custom widgets in your UI forms. For example, there’s a search bar, a pixmap button, etc.

Your libraries do not have to link to this library. KLatexFormula does not depend on this library either.

klatexformula: The Main Application

Dependencies: Qt5, klftools, klfbackend

The actual KLatexFormula application provides all the graphical user interface, the library, the symbols palette, etc.