main() function for klatexformula [NOT part of klfapp] More...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.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.
main() function for klatexformula [NOT part of klfapp]
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 |
Definition at line 80 of file main.cpp.
Referenced by main_get_input().
#define KLF_RESOURCES_ENVNAM "KLF_RESOURCES" |
Definition at line 75 of file main.cpp.
Referenced by main_load_extra_resources().
anonymous enum |
bool __klf_parse_bool_arg | ( | const char * | arg, |
bool | defaultvalue | ||
) |
Definition at line 1285 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 512 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 277 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 769 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, QDir::entryInfoList(), 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::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 358 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 375 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 386 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 434 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(), QStringList::split(), QFileInfo::suffix(), and QProcess::systemEnvironment().
Referenced by main().
void main_load_plugins | ( | QApplication * | app, |
KLFMainWin * | mainWin | ||
) |
Definition at line 547 of file main.cpp.
References QDir::absoluteFilePath(), KLFSysInfo::arch(), KLFPluginInfo::author, QMap::contains(), QFile::copy(), KLFPluginInfo::description, QDir::entryList(), QDir::exists(), QFile::exists(), QFileInfo::fileName(), KLFPluginInfo::fname, KLFPluginInfo::fpath, KLFConfig::getPluginConfigAccess(), KLFConfig::globalShareDir, KLFConfig::homeConfigDirPlugins, KLFPluginGenericInterface::initialize(), KLFPluginInfo::instance, QPluginLoader::instance(), KLFAddOnInfo::PluginSysInfo::isCompatibleWithCurrentSystem(), QFileInfo::isDir(), QString::isEmpty(), QDateTime::isNull(), klf_addons, KLF_DEBUG_BLOCK, KLF_DLL_EXT_LIST, KLF_FUNC_NAME, klf_plugins, klfconfig, klfDbg, klfVersionCompare(), QFileInfo::lastModified(), QPluginLoader::load(), QDir::mkpath(), KLFPluginInfo::name, KLFSysInfo::osString(), KLFPluginGenericInterface::pluginAuthor(), KLFConfig::pluginConfig, KLFPluginGenericInterface::pluginDefaultLoadEnable(), KLFPluginGenericInterface::pluginDescription(), KLFPluginGenericInterface::pluginName(), KLFConfig::Plugins, KLFPluginGenericInterface::pluginTitle(), QFile::remove(), QFile::setPermissions(), KLFPluginInfo::title, and QDateTime::toString().
Referenced by main().
FILE* main_msg_get_fp_arg | ( | const char * | arg | ) |
Definition at line 1257 of file main.cpp.
Referenced by main_parse_options().
void main_parse_options | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 1305 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 429 of file main.cpp.
References KLFBackend::saveOutputToFile().
Referenced by main().
void main_setup_app | ( | QCoreApplication * | a | ) |
Definition at line 731 of file main.cpp.
References QCoreApplication::addLibraryPath(), klf_share_dir_abspath(), klfDbg, and QCoreApplication::libraryPaths().
Referenced by main().
char** klf_args |
Definition at line 126 of file main.cpp.
Referenced by main(), and main_parse_options().
FILE* klf_fp_tty = NULL [static] |
Definition at line 274 of file main.cpp.
Referenced by klf_qt_message().
bool klf_fp_tty_failed = false [static] |
Definition at line 275 of file main.cpp.
Referenced by klf_qt_message().
FILE* klf_qt_msg_fp = NULL [static] |
Definition at line 271 of file main.cpp.
Referenced by klf_qt_message(), and main().
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 185 of file main.cpp.
Referenced by main_parse_options().
bool opt_base64arg = false |
Definition at line 94 of file main.cpp.
Referenced by main_parse_options().
int opt_bborderoffset = -1 |
Definition at line 112 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_bgcolor = NULL |
Definition at line 98 of file main.cpp.
Referenced by main(), and main_parse_options().
bool opt_daemonize = false |
Definition at line 104 of file main.cpp.
Referenced by main(), and main_parse_options().
bool opt_dbus_export_mainwin = false |
Definition at line 105 of file main.cpp.
Referenced by main(), and main_parse_options().
int opt_dpi = -1 |
Definition at line 99 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_dvips |
Definition at line 116 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_epstopdf |
Definition at line 118 of file main.cpp.
Referenced by main(), and main_parse_options().
struct { ... } opt_error [static] |
Referenced by __klf_parse_bool_arg(), main(), and main_parse_options().
char* opt_fgcolor = NULL |
Definition at line 97 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_format = NULL |
Definition at line 96 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_gs |
Definition at line 117 of file main.cpp.
Referenced by main(), and main_parse_options().
FILE* opt_help_fp = stderr |
Definition at line 121 of file main.cpp.
Referenced by main(), and main_parse_options().
bool opt_help_requested = false |
Definition at line 120 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_input = NULL |
Definition at line 90 of file main.cpp.
Referenced by main(), and main_parse_options().
int opt_interactive = -1 |
Definition at line 89 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_latex |
Definition at line 115 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_latexinput = NULL |
Definition at line 91 of file main.cpp.
Referenced by main(), and main_parse_options().
int opt_lborderoffset = -1 |
Definition at line 109 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_mathmode = NULL |
Definition at line 100 of file main.cpp.
Referenced by main(), and main_parse_options().
bool opt_noeval = false |
Definition at line 93 of file main.cpp.
Referenced by main(), and main_parse_options().
int opt_outlinefonts = -1 |
Definition at line 108 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_output = NULL |
Definition at line 95 of file main.cpp.
Referenced by main(), and main_parse_options().
int opt_paste = -1 |
Definition at line 92 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_preamble = NULL |
Definition at line 101 of file main.cpp.
Referenced by main(), and main_parse_options().
bool opt_quiet = false |
Definition at line 102 of file main.cpp.
Referenced by klf_qt_message(), main(), and main_parse_options().
int opt_rborderoffset = -1 |
Definition at line 111 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_redirect_debug = NULL |
Definition at line 103 of file main.cpp.
Referenced by main(), and main_parse_options().
bool opt_skip_plugins = false |
Definition at line 106 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_strdup_free_list[64] = { NULL } |
Definition at line 133 of file main.cpp.
Referenced by main(), main_cleanup(), and main_parse_options().
int opt_strdup_free_list_n = 0 |
Definition at line 134 of file main.cpp.
Referenced by main(), main_cleanup(), and main_parse_options().
int opt_tborderoffset = -1 |
Definition at line 110 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_tempdir |
Definition at line 114 of file main.cpp.
Referenced by main(), and main_parse_options().
char* opt_version_format = "KLatexFormula: Version %k using Qt %q\n" |
Definition at line 124 of file main.cpp.
Referenced by main(), and main_parse_options().
FILE* opt_version_fp = stderr |
Definition at line 123 of file main.cpp.
Referenced by main(), and main_parse_options().
bool opt_version_requested = false |
Definition at line 122 of file main.cpp.
Referenced by main(), and main_parse_options().
int qt_argc |
Definition at line 128 of file main.cpp.
Referenced by main(), and main_parse_options().
char* qt_argv[1024] |
Definition at line 129 of file main.cpp.
Referenced by main(), and main_parse_options().