#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <time.h>
#include <signal.h>
#include <QApplication>
#include <QDebug>
#include <QTranslator>
#include <QFileInfo>
#include <QDir>
#include <QResource>
#include <QProcess>
#include <QPluginLoader>
#include <QMessageBox>
#include <QLibraryInfo>
#include <QMetaType>
#include <QClipboard>
#include <QFontDatabase>
#include <klfbackend.h>
#include <klfutil.h>
#include <klfcolorchooser.h>
#include "klflib.h"
#include "klflibdbengine.h"
#include "klfliblegacyengine.h"
#include "klflibview.h"
#include "klfmain.h"
#include "klfconfig.h"
#include "klfmainwin.h"
#include "klfdbus.h"
#include "klfpluginiface.h"

Go to the source code of this file.
NOTE: If this file appears in the klfapp library documentation, it is to be noted that all definitions contained in this file are compiled SEPARATELY into klatexformula itself, and NOT into the klfapp library. In other words, the functions defined here are NOT available in the klfapp API.
The documentation for this file is just provided for convenient source browsing. It is not meant to be part of a public API.
Definition in file main.cpp.
| #define EXIT_ERR_FILEINPUT 100 |
| #define KLF_RESOURCES_ENVNAM "KLF_RESOURCES" |
| anonymous enum |
| static bool __klf_parse_bool_arg | ( | const char * | arg, | |
| bool | defaultvalue | |||
| ) | [static] |
Definition at line 1307 of file main.cpp.
References QRegExp::exactMatch(), KLF_FUNC_NAME, and opt_error.
Referenced by main_parse_options().
| void dumpDir | ( | const QDir & | d, | |
| int | indent = 0 | |||
| ) |
Definition at line 527 of file main.cpp.
References QDir::absoluteFilePath(), and QDir::entryList().
Referenced by main_load_extra_resources().
| void klf_qt_message | ( | QtMsgType | type, | |
| const char * | msg | |||
| ) |
Definition at line 278 of file main.cpp.
References QMessageBox::critical(), QString::fromLocal8Bit(), QMessageBox::information(), klf_fp_tty, klf_fp_tty_failed, klf_qt_msg_fp, opt_quiet, QObject::tr(), and QMessageBox::warning().
Referenced by main().
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 784 of file main.cpp.
References __klf_init_the_macpasteboardmime(), QFontDatabase::addApplicationFont(), KLFMainWin::alterSetting(), KLFMainWin::altersetting_BBorderOffset, KLFMainWin::altersetting_Dvips, KLFMainWin::altersetting_Epstopdf, KLFMainWin::altersetting_Gs, KLFMainWin::altersetting_Latex, KLFMainWin::altersetting_LBorderOffset, KLFMainWin::altersetting_OutlineFonts, KLFMainWin::altersetting_RBorderOffset, KLFMainWin::altersetting_TBorderOffset, KLFMainWin::altersetting_TempDir, QCoreApplication::applicationFilePath(), KLFConfig::applicationFont, KLFConfig::BackendSettings, KLFBackend::klfSettings::bborderoffset, KLFBackend::klfInput::bg_color, KLFConfig::colorChooseWidgetCustom, KLFConfig::colorChooseWidgetRecent, QDateTime::currentDateTime(), QDir::currentPath(), KLFConfig::detectMissingSettings(), KLFBackend::klfInput::dpi, KLFBackend::klfSettings::dvipsexec, KLFBackend::klfSettings::epstopdfexec, KLFBackend::klfOutput::errorstr, KLFDBusAppInterface::evaluateAndSave(), QApplication::exec(), KLFConfig::execDvips, KLFConfig::execEpstopdf, KLFConfig::execGs, KLFConfig::execLatex, EXIT_ERR_OPT, KLFBackend::klfInput::fg_color, format, QString::fromLatin1(), QString::fromLocal8Bit(), QString::fromUtf8(), KLFBackend::getLatexFormula(), KLFBackend::klfSettings::gsexec, QMetaObject::invokeMethod(), QString::isEmpty(), QString::isNull(), QDBusAbstractInterface::isValid(), klf_args, KLF_ASSERT_NOT_NULL, KLF_FUNC_NAME, klf_qt_message(), klf_qt_msg_fp, klf_reload_translations(), klfconfig, klfDbg, klfDbgT, klfFindTranslatedDataFile(), KLFBackend::klfInput::latex, KLFBackend::klfSettings::latexexec, KLFBackend::klfSettings::lborderoffset, KLFConfig::loadDefaults(), KLFConfig::locale, main_cleanup(), main_exit(), main_get_input(), main_load_extra_resources(), main_load_plugins(), main_parse_options(), main_save(), main_setup_app(), KLFBackend::klfInput::mathmode, KLFConfig::maxUserColors, QString::number(), QFile::open(), KLFDBusAppInterface::openFiles(), opt_bborderoffset, opt_bgcolor, opt_daemonize, opt_dbus_export_mainwin, opt_dpi, opt_dvips, opt_epstopdf, opt_error, opt_fgcolor, opt_format, opt_gs, opt_help_fp, opt_help_requested, opt_input, opt_interactive, opt_latex, opt_latexinput, opt_lborderoffset, opt_mathmode, opt_noeval, opt_outlinefonts, opt_output, opt_paste, opt_preamble, opt_quiet, opt_rborderoffset, opt_redirect_debug, opt_skip_plugins, opt_strdup_free_list, opt_strdup_free_list_n, opt_tborderoffset, opt_tempdir, opt_version_format, opt_version_fp, opt_version_requested, KLFBackend::klfSettings::outlineFonts, KLFBackend::klfInput::preamble, qt_argc, qt_argv, KLFDBusAppInterface::raiseWindow(), KLFBackend::klfSettings::rborderoffset, KLFConfig::readFromConfig(), KLFMainWin::refreshWindowSizes(), QDBusConnection::registerObject(), QDBusConnection::registerService(), QString::replace(), QColor::rgb(), QColor::rgba(), QDBusConnection::sessionBus(), KLFDBusAppInterface::setAlterSetting_i(), KLFDBusAppInterface::setAlterSetting_s(), KLFColorChooser::setColorList(), QApplication::setFont(), KLFDBusAppInterface::setInputData(), QColor::setNamedColor(), KLFColorChooseWidget::setRecentCustomColors(), QColor::setRgb(), KLFColorChooser::setUserMaxColors(), QWidget::show(), signal_act(), KLFMainWin::slotEvaluateAndSave(), KLFMainWin::slotSetBgColor(), KLFMainWin::slotSetDPI(), KLFMainWin::slotSetFgColor(), KLFMainWin::slotSetLatex(), KLFMainWin::slotSetMathMode(), KLFMainWin::slotSetPreamble(), QProcess::startDetached(), KLFMainWin::startupFinished(), KLFBackend::klfOutput::status, KLFBackend::klfSettings::tborderoffset, KLFConfig::tempDir, KLFBackend::klfSettings::tempdir, QString::toLocal8Bit(), QObject::tr(), KLFConfig::UI, KLFConfig::userColorList, and KLFConfig::useSystemAppFont.
| void main_cleanup | ( | ) |
Free some memory we have persistently allocated
Definition at line 373 of file main.cpp.
References QDir::absoluteFilePath(), QDir::entryList(), KLFConfig::homeConfigDirPlugins, klfconfig, opt_strdup_free_list, opt_strdup_free_list_n, and QFile::remove().
Referenced by main(), and main_exit().
| void main_exit | ( | int | code | ) |
Perform clean-up and exit()
Definition at line 390 of file main.cpp.
References main_cleanup().
Referenced by main(), and main_get_input().
| QString main_get_input | ( | char * | input, | |
| char * | latexinput, | |||
| int | paste | |||
| ) |
Determine from where to get input (direct input, from file, stdin) and read latex code; return the latex code as QString.
We can count on a QCoreApplication or QApplication running.
Definition at line 401 of file main.cpp.
References QApplication::clipboard(), EXIT_ERR_FILEINPUT, QString::fromLocal8Bit(), main_exit(), QFile::open(), QFile::setFileName(), and QObject::tr().
Referenced by main().
| void main_load_extra_resources | ( | ) |
Definition at line 449 of file main.cpp.
References QFileInfo::canonicalFilePath(), QStringList::contains(), dumpDir(), QDir::entryInfoList(), QStringList::filter(), KLFAddOnInfo::fpath(), KLFConfig::globalShareDir, KLFConfig::homeConfigDirRCCResources, QFileInfo::isDir(), QFileInfo::isFile(), QString::isNull(), QStringList::join(), klf_addons, klf_addons_canimport, KLF_DEBUG_BLOCK, KLF_FUNC_NAME, KLF_PATH_SEP, KLF_RESOURCES_ENVNAM, klfconfig, klfDbg, klfPrefixedPath(), QString::split(), QFileInfo::suffix(), and QProcess::systemEnvironment().
Referenced by main().
| void main_load_plugins | ( | QApplication * | app, | |
| KLFMainWin * | mainWin | |||
| ) |
Definition at line 562 of file main.cpp.
References QDir::absoluteFilePath(), KLFSysInfo::arch(), KLFPluginInfo::author, QMap::contains(), QFile::copy(), KLFPluginInfo::description, QDir::entryList(), QFile::exists(), KLFPluginInfo::fname, KLFPluginInfo::fpath, KLFConfig::getPluginConfigAccess(), KLFConfig::globalShareDir, KLFConfig::homeConfigDirPlugins, KLFPluginGenericInterface::initialize(), KLFPluginInfo::instance, QPluginLoader::instance(), KLFAddOnInfo::PluginSysInfo::isCompatibleWithCurrentSystem(), QString::isEmpty(), QDateTime::isNull(), klf_addons, KLF_DEBUG_BLOCK, KLF_DLL_EXT_LIST, KLF_FUNC_NAME, klf_plugins, klfconfig, klfDbg, klfVersionCompare(), QPluginLoader::load(), KLFPluginInfo::name, KLFSysInfo::osString(), KLFPluginGenericInterface::pluginAuthor(), KLFConfig::pluginConfig, KLFPluginGenericInterface::pluginDefaultLoadEnable(), KLFPluginGenericInterface::pluginDescription(), KLFPluginGenericInterface::pluginName(), KLFConfig::Plugins, KLFPluginGenericInterface::pluginTitle(), QFile::remove(), QFile::setPermissions(), KLFPluginInfo::title, QDateTime::toString(), and QPluginLoader::unload().
Referenced by main().
| FILE* main_msg_get_fp_arg | ( | const char * | arg | ) |
| void main_parse_options | ( | int | argc, | |
| char * | argv[] | |||
| ) |
Definition at line 1327 of file main.cpp.
References __klf_parse_bool_arg(), QByteArray::constData(), QByteArray::fromBase64(), klf_args, klfcmdl_optlist, main_msg_get_fp_arg(), OPT_BASE64ARG, opt_base64arg, opt_bborderoffset, OPT_BBORDEROFFSET, opt_bgcolor, OPT_BGCOLOR, opt_daemonize, OPT_DAEMONIZE, opt_dbus_export_mainwin, OPT_DBUS_EXPORT_MAINWIN, opt_dpi, OPT_DPI, opt_dvips, OPT_DVIPS, opt_epstopdf, OPT_EPSTOPDF, opt_error, opt_fgcolor, OPT_FGCOLOR, opt_format, OPT_FORMAT, opt_gs, OPT_GS, OPT_HELP, opt_help_fp, opt_help_requested, opt_input, OPT_INPUT, opt_interactive, OPT_INTERACTIVE, opt_latex, OPT_LATEX, opt_latexinput, OPT_LATEXINPUT, opt_lborderoffset, OPT_LBORDEROFFSET, opt_mathmode, OPT_MATHMODE, opt_noeval, OPT_NOEVAL, opt_outlinefonts, OPT_OUTLINEFONTS, opt_output, OPT_OUTPUT, opt_paste, OPT_PASTE_CLIPBOARD, OPT_PASTE_SELECTION, opt_preamble, OPT_PREAMBLE, OPT_QTOPT, opt_quiet, OPT_QUIET, opt_rborderoffset, OPT_RBORDEROFFSET, opt_redirect_debug, OPT_REDIRECT_DEBUG, opt_skip_plugins, OPT_SKIP_PLUGINS, opt_strdup_free_list, opt_strdup_free_list_n, opt_tborderoffset, OPT_TBORDEROFFSET, opt_tempdir, OPT_TEMPDIR, OPT_VERSION, opt_version_format, opt_version_fp, opt_version_requested, qt_argc, qt_argv, and QObject::tr().
Referenced by main().
| void main_save | ( | KLFBackend::klfOutput | klfoutput, | |
| const QString & | f_output, | |||
| QString | format | |||
| ) |
Saves a klfbackend result (KLFBackend::klfOutput) to a file or stdout with given format. format is guessed if not provided, and defaults to PNG.
Definition at line 444 of file main.cpp.
References KLFBackend::saveOutputToFile().
Referenced by main().
| void main_setup_app | ( | QCoreApplication * | a | ) |
Definition at line 746 of file main.cpp.
References QCoreApplication::addLibraryPath(), klf_share_dir_abspath(), klfDbg, and QCoreApplication::libraryPaths().
Referenced by main().
| char** klf_args |
FILE* klf_fp_tty = NULL [static] |
bool klf_fp_tty_failed = false [static] |
FILE* klf_qt_msg_fp = NULL [static] |
struct option klfcmdl_optlist[] [static] |
A List of command-line options klatexformula accepts.
NOTE: Remember to forward any NEW OPTIONS to the daemonized process when the new option is used with --daemonize (!) (search for opt_daemonize).
Definition at line 186 of file main.cpp.
Referenced by main_parse_options().
| bool opt_base64arg = false |
| int opt_bborderoffset = -1 |
| char* opt_bgcolor = NULL |
| bool opt_daemonize = false |
| bool opt_dbus_export_mainwin = false |
| int opt_dpi = -1 |
| char* opt_dvips |
| char* opt_epstopdf |
struct { ... } opt_error [static] |
Referenced by __klf_parse_bool_arg(), main(), and main_parse_options().
| char* opt_fgcolor = NULL |
| char* opt_format = NULL |
| char* opt_gs |
| FILE* opt_help_fp = stderr |
| bool opt_help_requested = false |
| char* opt_input = NULL |
| int opt_interactive = -1 |
| char* opt_latex |
| char* opt_latexinput = NULL |
| int opt_lborderoffset = -1 |
| char* opt_mathmode = NULL |
| bool opt_noeval = false |
| int opt_outlinefonts = -1 |
| char* opt_output = NULL |
| int opt_paste = -1 |
| char* opt_preamble = NULL |
| bool opt_quiet = false |
Definition at line 103 of file main.cpp.
Referenced by klf_qt_message(), main(), and main_parse_options().
| int opt_rborderoffset = -1 |
| char* opt_redirect_debug = NULL |
| bool opt_skip_plugins = false |
| char* opt_strdup_free_list[64] = { NULL } |
Definition at line 134 of file main.cpp.
Referenced by main(), main_cleanup(), and main_parse_options().
| int opt_strdup_free_list_n = 0 |
Definition at line 135 of file main.cpp.
Referenced by main(), main_cleanup(), and main_parse_options().
| int opt_tborderoffset = -1 |
| char* opt_tempdir |
| char* opt_version_format = (char*)"KLatexFormula: Version %k using Qt %q\n" |
| FILE* opt_version_fp = stderr |
| bool opt_version_requested = false |
| int qt_argc |
| char* qt_argv[1024] |