31 #include <ui_klfprogerr.h>
32 #include <ui_klfmainwin.h>
49 #define DEBUG_GEOM_ARGS(g) (g).topLeft().x(), (g).topLeft().y(), (g).size().width(), (g).size().height()
54 QRect g = w->frameGeometry();
56 QRect g = w->geometry();
79 u =
new Ui::KLFProgErr;
81 setObjectName(
"KLFProgErr");
83 u->txtError->setText(errtext);
104 :
QThread(parent), _input(input), _settings(settings), _lwidth(labelwidth), _lheight(labelheight),
105 _hasnewinfo(false), _abort(false)
154 img = img.
scaled(
QSize(lwid, lhgt), Qt::KeepAspectRatio, Qt::SmoothTransformation);
189 int lwidth,
int lheight)
193 if (lwidth > 0)
_lwidth = lwidth;
194 if (lheight > 0)
_lheight = lheight;
207 u =
new Ui::KLFMainWin;
209 setObjectName(
"KLFMainWin");
214 QApplication::instance()->installEventFilter(
this);
235 u->frmOutput->setEnabled(
false);
240 u->aDPI1200->setData(1200);
244 u->aDPI600->setData(600);
248 u->aDPI300->setData(300);
252 u->aDPI150->setData(150);
255 u->btnDPIPresets->setMenu(DPIPresets);
258 connect(
u->txtLatex->syntaxHighlighter(), SIGNAL(newSymbolTyped(
const QString&)),
259 this, SLOT(slotNewSymbolTyped(
const QString&)));
267 connect(
u->lblOutput, SIGNAL(labelDrag()),
this, SLOT(
slotDrag()));
269 connect(
u->btnShowBigPreview, SIGNAL(clicked()),
273 h =
u->btnDrag->sizeHint().height();
u->btnDrag->setFixedHeight(h - 5);
274 h =
u->btnCopy->sizeHint().height();
u->btnCopy->setFixedHeight(h - 5);
275 h =
u->btnSave->sizeHint().height();
u->btnSave->setFixedHeight(h - 5);
294 mExportMsgLabel->setProperty(
"defaultPalette", QVariant::fromValue<QPalette>(pal));
296 lyt->
addItem(
new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding), 0, 1, 2, 1);
306 u->frmDetails->hide();
308 u->txtLatex->installEventFilter(
this);
309 u->txtLatex->setMainWinDataOpener(
this);
313 u->btnEvaluate->installEventFilter(
this);
316 u->btnDrag->installEventFilter(
this);
317 u->btnCopy->installEventFilter(
this);
321 Qt::ApplicationShortcut);
347 connect(synthighlighttimer, SIGNAL(timeout()),
u->txtLatex->syntaxHighlighter(), SLOT(refreshAll()));
348 connect(synthighlighttimer, SIGNAL(timeout()),
u->txtPreamble->syntaxHighlighter(), SLOT(refreshAll()));
349 synthighlighttimer->
start(250);
352 u->cbxMarginsUnit->setCurrentUnitAbbrev(
"pt");
365 connect(
u->aClearLatex, SIGNAL(triggered()),
this, SLOT(
slotClearLatex()));
366 connect(
u->aClearAll, SIGNAL(triggered()),
this, SLOT(
slotClearAll()));
367 connect(
u->btnEvaluate, SIGNAL(clicked()),
this, SLOT(
slotEvaluate()));
368 connect(
u->btnSymbols, SIGNAL(toggled(
bool)),
this, SLOT(
slotSymbols(
bool)));
369 connect(
u->btnLibrary, SIGNAL(toggled(
bool)),
this, SLOT(
slotLibrary(
bool)));
371 connect(
u->btnCopy, SIGNAL(clicked()),
this, SLOT(
slotCopy()));
372 connect(
u->btnDrag, SIGNAL(released()),
this, SLOT(
slotDrag()));
373 connect(
u->btnSave, SIGNAL(clicked()),
this, SLOT(
slotSave()));
374 connect(
u->btnSettings, SIGNAL(clicked()),
this, SLOT(
slotSettings()));
375 connect(
u->btnSaveStyle, SIGNAL(clicked()),
this, SLOT(
slotSaveStyle()));
377 connect(
u->btnQuit, SIGNAL(clicked()),
this, SLOT(
quit()));
388 connect(
u->btnHelp, SIGNAL(clicked()),
this, SLOT(
showAbout()));
396 connect(
u->txtLatex, SIGNAL(textChanged()),
this,
400 connect(
u->cbxMathMode, SIGNAL(editTextChanged(
const QString&)),
402 Qt::QueuedConnection);
404 Qt::QueuedConnection);
406 Qt::QueuedConnection);
408 Qt::QueuedConnection);
410 Qt::QueuedConnection);
452 mHelpLinkActions << HelpLinkAction(
"/popup_close",
this,
"slotPopupClose",
false);
453 mHelpLinkActions << HelpLinkAction(
"/popup",
this,
"slotPopupAction",
true);
454 mHelpLinkActions << HelpLinkAction(
"/settings",
this,
"showSettingsHelpLinkAction",
true);
458 tr(
"Your executable paths (latex, dvips, gs) seem not to be detected properly. "
459 "Please adjust the settings in the <a href=\"klfaction:/settings?control="
460 "ExecutablePaths\">settings dialog</a>.",
461 "[[additional text in what's-new-dialog in case of bad detected settings. this "
462 "is HTML formatted text.]]")
468 addWhatsNewText(
"<p>"+tr(
"LaTeX' Computer Modern Sans Serif font is used as the <b>default application font</b>."
469 " Don't like it? <a href=\"%1\">Choose your preferred application font</a>.")
470 .arg(
"klfaction:/settings?control=AppFonts") +
"</p>");
485 u->retranslateUi(
this);
488 u->lblPromptMain->setToolTip(tr(
"KLatexFormula %1").arg(
QString::fromUtf8(KLF_VERSION_STRING)));
534 actionGroup->setExclusive(
true);
536 for (k = 0; k < eplist.
size(); ++k) {
538 action->setText(eplist[k].description());
539 action->
setData(eplist[k].profileName());
540 action->setCheckable(
true);
544 smapper->
setMapping(action, eplist[k].profileName());
545 connect(action, SIGNAL(triggered()), smapper, SLOT(map()));
550 u->btnSetExportProfile->setMenu(menu);
557 bool curstate_shown =
u->frmDetails->isVisible();
558 u->frmDetails->show();
562 if (curstate_shown) {
564 u->frmDetails->show();
567 u->frmDetails->hide();
575 u->btnClearAll->setVisible(!lo);
576 u->btnClearLatex->setVisible(lo);
721 connect(a, SIGNAL(triggered()),
this, SLOT(slotLoadStyleAct()));
738 if (kdehome.size() == 0) {
741 QString kdehomeval = kdehome[0];
748 return QString::null;
756 QFile fsty(styfname);
757 if ( ! fsty.
open(QIODevice::ReadOnly) )
765 &readHeader, &readCompatKLFVersion);
773 tr(
"The style file found was created by a more recent version "
774 "of KLatexFormula.\n"
775 "The process of style loading may fail.")
794 for (k = 0; k < styfnamecandidates.size(); ++k) {
795 QString fn = styfnamecandidates[k];
809 KLFStyle s1(tr(
"Default"), qRgb(0, 0, 0), qRgba(255, 255, 255, 0),
"\\[ ... \\]",
"", 600);
827 if ( ! f.
open(QIODevice::WriteOnly) ) {
867 importfname =
":/data/defaultlibrary.klf";
875 localliburl.
addQueryItem(
"klfDefaultSubResource",
"History");
884 if (localLibFactory == NULL) {
885 qWarning()<<
KLF_FUNC_NAME<<
": Can't find library resource engine factory for scheme "<<localliburl.
scheme()<<
"!";
886 qFatal(
"%s: Can't find library resource engine factory for scheme '%s'!",
891 param[
"Filename"] = localliburl.
path();
893 param[
"klfDefaultSubResourceTitle"] = tr(
"History",
"[[default sub-resource title for history]]");
896 qWarning()<<
KLF_FUNC_NAME<<
": Can't create resource engine for library, of scheme "<<localliburl.
scheme()<<
"! "
897 <<
"Create parameters are "<<param;
898 qFatal(
"%s: Can't create resource engine for library!",
KLF_FUNC_NAME);
904 tr(
"Archive",
"[[default sub-resource title for archive sub-resource]]"));
921 qWarning()<<
"KLFMainWin::loadLibrary(): Can't open local history resource!\n\tURL="<<localliburl
922 <<
"\n\tNot good! Expect crash!";
930 klfDbg(
"Importing library from "<<importfname) ;
937 pdlg.setAutoClose(
false);
938 pdlg.setAutoReset(
false);
945 scheme =
"klf+legacy";
951 if (factory == NULL) {
952 qWarning()<<
"KLFMainWin::loadLibrary(): Can't find factory for URL="<<importliburl<<
"!";
957 klfDbg(
"\tImporting sub-resources: "<<subResList ) ;
959 for (j = 0; j < subResList.size(); ++j) {
960 QString subres = subResList[j];
961 pdlg.
setDescriptiveText(tr(
"Importing Library from previous version of KLatexFormula ... "
963 .arg(j+1).arg(subResList.size()).arg(subResList[j]));
966 klfDbg(
"Got "<<allentries.
size()<<
" entries from sub-resource "<<subres);
969 for (k = 0; k < allentries.
size(); ++k) {
970 insertentries << allentries[k].entry;
986 qWarning()<<
"KLFMainWin::loadLibrary(): Can't open local history resource!\n\tURL="<<localliburl
987 <<
"\n\tExpect Crash!";
994 for (k = 0; k < subresources.size(); ++k) {
998 QUrl url = localliburl;
1000 url.
addQueryItem(
"klfDefaultSubResource", subresources[k]);
1003 QString sr = subresources[k].toLower();
1004 if (sr ==
"history" || sr == tr(
"History").toLower())
1006 if (sr ==
"archive" || sr == tr(
"Archive").toLower())
1017 klfDbg(
"No saved library browser state found ("<<fname<<
")");
1022 if ( ! f.
open(QIODevice::ReadOnly) ) {
1023 qWarning()<<
"Can't open file "<<fname<<
" for loading library browser state";
1031 if (rootNode.
nodeName() !=
"klflibbrowserstate") {
1032 qWarning()<<
"Invalid root node in file "<<fname<<
" !";
1036 QVariantMap vstatemap;
1039 if ( e.isNull() || n.
nodeType() != QDomNode::ElementNode )
1041 if ( e.nodeName() ==
"statemap" ) {
1046 qWarning(
"%s: Ignoring unrecognized node `%s' in file %s.",
KLF_FUNC_NAME,
1047 qPrintable(e.nodeName()), qPrintable(fname));
1060 if ( ! f.
open(QIODevice::WriteOnly) ) {
1061 qWarning()<<
"Can't open file "<<fname<<
" for saving library browser state";
1071 rootNode.appendChild(statemapNode);
1072 doc.appendChild(rootNode);
1078 void KLFMainWin::slotOpenHistoryLibraryResource()
1086 qWarning()<<
KLF_FUNC_NAME<<
": Can't open local history resource!";
1106 u->frmOutput->setEnabled(
false);
1109 u->txtLatex->setFocus();
1114 u->btnLibrary->setChecked(on);
1123 QString preambletext =
u->txtPreamble->toPlainText();
1125 for (k = 0; k < cmds.size(); ++k) {
1133 c1.setPosition(
u->txtLatex->textCursor().position());
1134 c1.insertText(s.
symbol+
"\n");
1135 c1.deletePreviousChar();
1140 u->txtLatex->setFocus();
1145 u->txtLatex->insertDelimiter(delim, charsBack);
1150 QString *guiText,
bool wantHtmlText)
1152 if (missingCmds == NULL) {
1156 if (guiText == NULL) {
1161 missingCmds->clear();
1172 klfDbg(
"Got symbol for "<<symbol<<
"; cmds is "<<cmds);
1173 if (cmds.isEmpty()) {
1177 QString curpreambletext =
u->txtPreamble->toPlainText();
1179 bool moreDefinitions =
false;
1181 for (k = 0; k < cmds.size(); ++k) {
1182 if (curpreambletext.
indexOf(cmds[k]) >= 0)
1185 missingCmds->append(cmds[k]);
1187 QRegExp rx(
"\\\\usepackage.*\\{(\\w+)\\}");
1188 klfDbg(
" regexp="<<rx.
pattern()<<
"; cmd for symbol: "<<cmds[k].trimmed());
1190 packages << rx.
cap(1);
1193 moreDefinitions =
true;
1200 if (packages.size()) {
1201 if (packages.size() == 1)
1202 requiredtext += tr(
"package %1",
1203 "[[part of popup text, if one package only]]").
arg(packages[0]);
1205 requiredtext += tr(
"packages %1",
1206 "[[part of popup text, if multiple packages]]").
arg(packages.
join(
", "));
1208 if (moreDefinitions)
1209 requiredtext += packages.size()
1210 ? tr(
" and <i>some more definitions</i>",
1211 "[[part of hint popup text, when packages also need to be included]]")
1212 : tr(
"<i>some definitions</i>",
1213 "[[part of hint popup text, when no packages need to be included]]");
1217 *guiText = requiredtext;
1220 void KLFMainWin::slotNewSymbolTyped(
const QString& symbol)
1241 QUrl urlactionClose = urlaction;
1243 urlactionClose.
addQueryItem(
"removeMessageKey", msgkey);
1247 tr(
"Symbol <tt>%3</tt> may require <a href=\"%1\">%2</a>.")
1248 .arg(urlaction.
toEncoded(), requiredtext, symbol) );
1252 void KLFMainWin::slotPopupClose()
1259 void KLFMainWin::slotPopupAction(
const QUrl& url)
1267 klfDbg(
"ensuring CMDS="<<cmds);
1269 for (k = 0; k < cmds.size(); ++k) {
1278 slotPopupAcceptAll();
1296 void KLFMainWin::slotPopupAcceptAll()
1304 for (k = 0; k < keys.size(); ++k) {
1306 if (s.
startsWith(
"preambleCmdStringList:")) {
1307 QByteArray data = s.
mid(strlen(
"preambleCmdStringList:")).toLatin1();
1310 for (k = 0; k < cmds.size(); ++k) {
1328 QString text = latexEdit->toPlainText();
1331 QRegExp rxSym(
"\\\\(\\w+|.)");
1335 int len = rxSym.matchedLength();
1342 aInsCmds->setText(tr(
"Include missing definitions for %1").arg(symbol));
1344 connect(aInsCmds, SIGNAL(triggered()),
this, SLOT(slotInsertMissingPackagesFromActionSender()));
1345 *actionList << aInsCmds;
1350 tr(
"Insert Symbol ...",
"[[context menu entry]]"), latexEdit);
1351 connect(insertSymbolAction, SIGNAL(triggered()),
this, SLOT(
slotSymbols()));
1352 *actionList << insertSymbolAction;
1356 void KLFMainWin::slotInsertMissingPackagesFromActionSender()
1366 for (k = 0; k < cmds.size(); ++k) {
1375 u->btnSymbols->setChecked(on);
1395 klfDbg(
": link="<<link ) ;
1402 klfDbg(
": Link is "<<link<<
"; scheme="<<link.
scheme()<<
"; path="<<link.
path()
1405 if (link.
scheme() ==
"http") {
1410 if (link.
scheme() ==
"klfaction") {
1412 bool calledOne =
false;
1420 Qt::QueuedConnection, Q_ARG(
QUrl, link));
1424 Qt::QueuedConnection);
1430 qWarning()<<
KLF_FUNC_NAME<<
": no action found for link="<<link;
1434 qWarning()<<
KLF_FUNC_NAME<<
"("<<link<<
"): Unrecognized link scheme!";
1452 KLF_ASSERT_NOT_NULL( outputsaver,
"Refusing to register NULL Output Saver object!",
return ) ;
1464 KLF_ASSERT_NOT_NULL( dataopener,
"Refusing to register NULL Data Opener object!",
return ) ;
1487 if (stylelist.
indexOf(qtstyle) == -1) {
1488 qWarning(
"Bad Style: %s. List of possible styles are:", qPrintable(qtstyle));
1490 for (k = 0; k < stylelist.size(); ++k)
1491 qWarning(
"\t%s", qPrintable(stylelist[k]));
1498 qWarning(
"Can't instantiate style %s!", qPrintable(qtstyle));
1502 qApp->setStyle( s );
1532 if (e->
type() == QEvent::ApplicationFontChange) {
1533 klfDbg(
"Application font change.") ;
1544 if (e->type() == QEvent::ChildAdded && child->
isWidgetType()) {
1546 if (w->windowFlags() & Qt::Window) {
1550 klfDbg(
": Added child "<<w<<
" ("<<w->objectName()<<
")" ) ;
1552 }
else if (e->type() == QEvent::ChildRemoved && child->
isWidgetType()) {
1556 klfDbg(
": Removing child "<<w<<
" ("<<w->objectName()<<
")"
1557 <<
" at position k="<<k ) ;
1562 QWidget::childEvent(e);
1569 if (obj ==
u->txtLatex) {
1570 if (e->
type() == QEvent::KeyPress) {
1572 if (ke->
key() == Qt::Key_Return &&
1573 (QApplication::keyboardModifiers() == Qt::ShiftModifier ||
1574 QApplication::keyboardModifiers() == Qt::ControlModifier)) {
1578 if (
mPopup != NULL && ke->
key() == Qt::Key_Return &&
1579 QApplication::keyboardModifiers() == Qt::AltModifier) {
1580 slotPopupAcceptAll();
1583 if (
mPopup != NULL && ke->
key() == Qt::Key_Escape) {
1587 if (ke->
key() == Qt::Key_F9) {
1589 u->tabsOptions->setCurrentWidget(
u->tabLatexImage);
1590 u->txtPreamble->setFocus();
1595 if (obj ==
u->txtLatex || obj ==
u->btnEvaluate) {
1596 if (e->
type() == QEvent::KeyPress) {
1599 if (seq.
matches(QKeySequence::Copy)) {
1603 if (
u->txtLatex->textCursor().hasSelection()) {
1604 u->txtLatex->copy();
1621 if (e->
type() == QEvent::Hide && !((
QHideEvent*)e)->spontaneous()) {
1625 }
else if (e->
type() == QEvent::Show && !((
QShowEvent*)e)->spontaneous()) {
1640 if ( obj == QApplication::instance() && e->
type() == QEvent::FileOpen ) {
1647 if ( (obj ==
u->btnCopy || obj ==
u->btnDrag) && e->
type() == QEvent::ToolTip ) {
1649 if (obj ==
u->btnCopy) {
1650 tooltipText = tr(
"Copy the formula to the clipboard. Current export profile: %1")
1652 }
else if (obj ==
u->btnDrag) {
1653 tooltipText = tr(
"Click and keep mouse button pressed to drag your formula to another application. "
1654 "Current export profile: %1")
1661 return QWidget::eventFilter(obj, e);
1671 setStyleSheet(styleSheet());
1679 status[
this] = isVisible();
1689 status[
this] = visibleStatus;
1705 if ( ! e->spontaneous() ) {
1725 if ( ! e->spontaneous() ) {
1743 int fadepercent = (100 * remaining / total) * 3;
1744 if (fadepercent < 100 && fadepercent >= 0) {
1747 c.setAlpha(c.alpha() * fadepercent / 100);
1751 pal.
setColor(QPalette::WindowText, c2);
1755 remaining -= interval;
1756 if (remaining < 0) {
1812 return u->txtLatex->syntaxHighlighter();
1816 return u->txtPreamble->syntaxHighlighter();
1838 if (reallyinputchanged) {
1845 u->txtLatex->setFont(f);
1849 u->txtPreamble->setFont(f);
1854 klfDbg(
"preview.size=" << preview.
size()<<
" latexerror=" << latexerror);
1859 u->lblOutput->displayError(
false);
1861 u->lblOutput->display(preview, preview,
false);
1870 input.
latex =
u->txtLatex->toPlainText();
1871 if (
u->chkMathMode->isChecked()) {
1872 input.
mathmode =
u->cbxMathMode->currentText();
1873 if (
final &&
u->cbxMathMode->findText(input.
mathmode) == -1) {
1874 u->cbxMathMode->addItem(input.
mathmode);
1880 input.
preamble =
u->txtPreamble->toPlainText();
1881 input.
fg_color =
u->colFg->color().rgb();
1882 if (
u->chkBgTransparent->isChecked() ==
false)
1883 input.
bg_color =
u->colBg->color().rgb();
1885 input.
bg_color = qRgba(255, 255, 255, 0);
1887 input.
dpi =
u->spnDPI->value();
1897 u->btnEvaluate->setEnabled(
false);
1904 if (
u->gbxOverrideMargins->isChecked()) {
1916 bool showSettingsPaths =
false;
1921 comment =
"\n"+tr(
"Are you sure you configured your system paths correctly in the settings dialog ?");
1922 showSettingsPaths =
true;
1925 u->lblOutput->displayClear();
1926 u->frmOutput->setEnabled(
false);
1927 if (showSettingsPaths) {
1934 u->frmOutput->setEnabled(
false);
1955 Qt::SmoothTransformation);
1958 u->lblOutput->display(sc.
toImage(), tooltipimg,
true);
1959 u->frmOutput->setEnabled(
true);
1964 bool needInsertThisEntry =
true;
1981 needInsertThisEntry =
false;
1984 if (needInsertThisEntry) {
1986 bool result = (eid >= 0);
1989 tr(
"Can't add the item to history library because the history "
1990 "resource is locked. Do you want to unlock it?"),
1991 QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
1992 if (r == QMessageBox::Yes) {
2003 tr(
"Can't add the item to history library because the history "
2004 "sub-resource is locked. Do you want to unlock it?"),
2005 QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
2006 if (r == QMessageBox::Yes) {
2013 qWarning(
"KLFMainWin::slotEvaluate: History resource is READ-ONLY !! Should NOT!");
2015 tr(
"Can't add the item to history library because the history "
2016 "resource is opened in read-only mode. This should not happen! "
2017 "You will need to manually copy and paste your Latex code somewhere "
2018 "else to save it."),
2019 QMessageBox::Ok, QMessageBox::Ok);
2022 qWarning(
"KLFMainWin::slotEvaluate: History resource couldn't be written!");
2024 tr(
"An error occurred when trying to write the new entry into the "
2026 "You will need to manually copy and paste your Latex code somewhere "
2027 "else to save it."),
2028 QMessageBox::Ok, QMessageBox::Ok);
2033 u->btnEvaluate->setEnabled(
true);
2034 u->btnEvaluate->setFocus();
2039 u->txtLatex->clearLatex();
2050 klfDbg(
"showlib="<<showlib) ;
2069 if (
u->frmDetails->isVisible()) {
2070 u->frmDetails->hide();
2073 u->btnExpand->setIcon(
QIcon(
":/pics/switchexpanded.png"));
2076 u->frmDetails->show();
2078 u->btnExpand->setIcon(
QIcon(
":/pics/switchshrinked.png"));
2083 if (
u->frmDetails->isVisible() == expanded)
2092 u->txtLatex->setLatex(latex);
2097 u->chkMathMode->setChecked(mathmode.
simplified() !=
"...");
2099 u->cbxMathMode->setEditText(mathmode);
2104 u->txtPreamble->setLatex(preamble);
2114 QString preambletext =
u->txtPreamble->toPlainText();
2115 if (preambletext.
indexOf(line) == -1) {
2117 if (preambletext.
length() > 0 &&
2118 preambletext[preambletext.
length()-1] !=
'\n')
2122 preambletext += addtext;
2130 u->spnDPI->setValue(DPI);
2135 u->colFg->setColor(fg);
2145 u->colBg->setColor(bg);
2151 bgcolor.
setRgb(255, 255, 255, 0);
2159 if (
u->txtLatex->toPlainText().isEmpty() )
2182 for (i = 0; i < a.size(); ++i)
2183 for (j = 0; j < b.size(); ++j)
2192 klfDbg(
"file name="<<fileName) ;
2197 klfDbg(
"cannot open file.") ;
2208 klfDbg(
"cannot open data.") ;
2215 klfDbg(
"mime data. formats="<<formats) ;
2224 klfDbg(
"cannot open data: no appropriate opener found.") ;
2246 klfDbg(
"file list="<<fileList) ;
2249 for (k = 0; k < fileList.size(); ++k) {
2250 result = result &&
openFile(fileList[k]);
2251 klfDbg(
"Opened file "<<fileList[k]<<
": result="<<result) ;
2263 if (openerFound != NULL)
2264 *openerFound =
false;
2268 if (openerFound != NULL)
2269 *openerFound =
true;
2271 klfDbg(
"Opening mimetype "<<mimetype) ;
2297 bool imported =
false;
2298 for (k = 0; k < files.size(); ++k) {
2300 imported = imported || ok;
2301 klfDbg(
"imported file "<<files[k]<<
": imported status is now "<<imported) ;
2303 if (showLibrary && imported)
2311 klfDbg(
"fname="<<fname<<
"; showLibrary="<<showLibrary) ;
2315 klfDbg(
"Can't guess scheme for file "<<fname) ;
2319 klfDbg(
"url to open is "<<url) ;
2321 if ( subreslist.isEmpty() ) {
2322 klfDbg(
"no sub-resources...") ;
2326 klfDbg(
"subreslist is "<<subreslist);
2327 bool loaded =
false;
2329 for (k = 0; k < subreslist.size(); ++k) {
2331 url2.
addQueryItem(
"klfDefaultSubResource", subreslist[k]);
2333 loaded = loaded || thisloaded;
2335 if (showLibrary && loaded)
2406 img = img.
scaled(sz, Qt::KeepAspectRatio, Qt::SmoothTransformation);
2415 QRect bb = painter.
boundingRect(rall, Qt::AlignBottom|Qt::AlignRight, exportProfileText);
2420 painter.
drawText(rall, Qt::AlignBottom|Qt::AlignRight, exportProfileText);
2433 drag->exec(Qt::CopyAction);
2439 extern void klfWinClipboardCopy(HWND h,
const QStringList& wintypes,
2450 for (k = 0; k < mimetypes.size(); ++k) {
2451 QString mimetype = mimetypes[k];
2456 if (exporter == NULL) {
2457 qWarning()<<
KLF_FUNC_NAME<<
": Can't find exporter for type "<<mimetype
2458 <<
", winformat="<<wintype<<
".";
2462 wintypes << wintype;
2466 klfWinClipboardCopy(
winId(), wintypes, datalist);
2480 static QString selectedfilter;
2488 if (f ==
"jpg" || f ==
"jpeg" || f ==
"png" || f ==
"pdf" || f ==
"eps")
2490 QString s = tr(
"%1 Image (*.%2)").
arg(f).arg(f);
2491 filterformatlist << s;
2492 formatlist.push_back(f);
2493 formatsByFilterName[s] = f;
2501 for (j = 0; j < xoformats.size(); ++j) {
2503 pOutputSavers[k]->formatFilePatterns(xoformats[j]).join(
" "));
2504 filterformatlist << f;
2505 externFormatsByFilterName[f] = xoformats[j];
2511 s = tr(
"EPS PostScript (*.eps)");
2512 filterformatlist.push_front(s);
2513 formatlist.push_front(
"eps");
2514 formatsByFilterName[s] =
"eps";
2515 s = tr(
"PDF Portable Document Format (*.pdf)");
2516 filterformatlist.push_front(s);
2517 formatlist.push_front(
"pdf");
2518 formatsByFilterName[s] =
"pdf";
2519 s = tr(
"Standard JPEG Image (*.jpg *.jpeg)");
2520 filterformatlist.push_front(s);
2521 formatlist.push_front(
"jpeg");
2522 formatlist.push_front(
"jpg");
2523 formatsByFilterName[s] =
"jpeg";
2524 selectedfilter = s = tr(
"Standard PNG Image (*.png)");
2525 filterformatlist.push_front(s);
2526 formatlist.push_front(
"png");
2527 formatsByFilterName[s] =
"png";
2529 QString filterformat = filterformatlist.
join(
";;");
2532 QString suggestion = suggestfname;
2536 suggestion = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
2545 if ( externFormatsByFilterName.
contains(selectedfilter) ) {
2547 QString key = externFormatsByFilterName[selectedfilter];
2548 if ( ! externSaverByKey.
contains(key) ) {
2549 qWarning()<<
KLF_FUNC_NAME<<
": Internal error: externSaverByKey() does not contain key="<<key
2550 <<
": "<<externSaverByKey;
2554 if (saver == NULL) {
2555 qWarning()<<
KLF_FUNC_NAME<<
": Internal error: saver is NULL!";
2560 qWarning()<<
KLF_FUNC_NAME<<
": saver failed to save format "<<key<<
".";
2566 if ( fi.
suffix().length() == 0 ) {
2568 if ( ! formatsByFilterName.
contains(selectedfilter) && ! externFormatsByFilterName.
contains(selectedfilter) ) {
2569 qWarning(
"%s: ERROR: Unknown format filter selected: `%s'! Assuming PNG!\n",
KLF_FUNC_NAME,
2570 qPrintable(selectedfilter));
2573 format = formatsByFilterName[selectedfilter];
2575 fname +=
"."+format;
2579 tr(
"The file <b>%1</b> already exists.\nOverwrite?").arg(fname),
2580 QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::No);
2581 if (r == QMessageBox::Yes) {
2583 }
else if (r == QMessageBox::No) {
2598 msgbox.setIcon(QMessageBox::Warning);
2600 msgbox.setText(tr(
"Extension <b>%1</b> not recognized.").arg(fi.
suffix().toUpper()));
2601 msgbox.setInformativeText(tr(
"Press \"Change\" to change the file name, or \"Use PNG\" to save as PNG."));
2603 msgbox.
addButton(png, QMessageBox::AcceptRole);
2605 msgbox.
addButton(chg, QMessageBox::ActionRole);
2607 msgbox.
addButton(cancel, QMessageBox::RejectRole);
2621 format = formatlist[index];
2638 u->txtLatex->setFocus();
2644 u->txtLatex->selectAll();
2649 if ( !
u->btnShowBigPreview->isEnabled() )
2653 tr(
"<p>%1</p><p align=\"right\" style=\"font-size: %2pt; font-style: italic;\">"
2654 "This preview can be opened with the <strong>F2</strong> key. Hit "
2655 "<strong>Esc</strong> to close.</p>")
2656 .
arg(
u->lblOutput->bigPreviewText())
2657 .arg(
QFontInfo(qApp->font()).pointSize()-1);
2676 sty.
name = QString::null;
2678 QColor bgc =
u->colBg->color();
2679 sty.
bg_color = qRgba(bgc.
red(), bgc.
green(), bgc.
blue(),
u->chkBgTransparent->isChecked() ? 0 : 255 );
2680 sty.
mathmode = (
u->chkMathMode->isChecked() ?
u->cbxMathMode->currentText() :
"...");
2681 sty.
preamble =
u->txtPreamble->toPlainText();
2682 sty.
dpi =
u->spnDPI->value();
2684 if (
u->gbxOverrideMargins->isChecked()) {
2696 return u->txtLatex->font();
2700 return u->txtPreamble->font();
2703 void KLFMainWin::slotLoadStyleAct()
2716 u->colFg->setColor(cfg);
2717 u->colBg->setColor(cbg);
2718 u->chkBgTransparent->setChecked(qAlpha(style.
bg_color) == 0);
2721 u->cbxMathMode->setEditText(style.
mathmode);
2723 u->spnDPI->setValue(style.
dpi);
2726 u->gbxOverrideMargins->setChecked(
true);
2732 u->gbxOverrideMargins->setChecked(
false);
2748 tr(
"Enter new style name:"));
2755 for (
int kl = 0; found_i == -1 && kl <
_styles.
size(); ++kl) {
2760 tr(
"Style name already exists. Do you want to overwrite?"),
2761 QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, QMessageBox::No);
2763 case QMessageBox::No:
2766 case QMessageBox::Yes: