summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2018-12-22 18:06:26 +0100
committerAleks Kissinger <aleks0@gmail.com>2018-12-22 18:06:38 +0100
commitc93f003ce683fca7896cbbadb6375b929d22fe6d (patch)
tree1c2067f77c29491d5ee08ad6f1954210cdb8b33b
parent873316d120e185fcbc59b468961faebf33adf9af (diff)
latex running feedback and better search for pdflatex
-rw-r--r--images/dialog-accept.svg63
-rw-r--r--images/dialog-error.svg316
-rw-r--r--images/loader.gifbin0 -> 1456 bytes
-rw-r--r--images/loader@2x.gifbin0 -> 1456 bytes
-rw-r--r--src/gui/latexprocess.cpp30
-rw-r--r--src/gui/previewwindow.cpp41
-rw-r--r--src/gui/previewwindow.h11
-rw-r--r--src/gui/previewwindow.ui34
-rw-r--r--src/tikzit.cpp18
-rw-r--r--tikzit.qrc4
10 files changed, 500 insertions, 17 deletions
diff --git a/images/dialog-accept.svg b/images/dialog-accept.svg
new file mode 100644
index 0000000..287b11e
--- /dev/null
+++ b/images/dialog-accept.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg id="svg1306" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="48px" width="48px" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <defs id="defs1308">
+ <radialGradient id="radialGradient3976" gradientUnits="userSpaceOnUse" cy="40" cx="23.857" gradientTransform="matrix(1 0 0 .5 0 20)" r="17.143">
+ <stop id="stop4128" offset="0"/>
+ <stop id="stop4130" stop-opacity="0" offset="1"/>
+ </radialGradient>
+ <linearGradient id="linearGradient3980" y2="-8.5627" gradientUnits="userSpaceOnUse" x2="20.065" y1="53.836" x1="43.936">
+ <stop id="stop2481" stop-color="#ffe69b" offset="0"/>
+ <stop id="stop2483" stop-color="#fff" offset="1"/>
+ </linearGradient>
+ <linearGradient id="linearGradient3982" y2="15.815" gradientUnits="userSpaceOnUse" x2="20.917" gradientTransform="matrix(1.003 0 0 1.003 -.071859 .019684)" y1="33.955" x1="21.994">
+ <stop id="stop3959" stop-color="#fffeff" stop-opacity=".33333" offset="0"/>
+ <stop id="stop3961" stop-color="#fffeff" stop-opacity=".21569" offset="1"/>
+ </linearGradient>
+ </defs>
+ <metadata id="metadata1311">
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Rodney Dawes</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:contributor>
+ <cc:Agent>
+ <dc:title>Jakub Steiner, Garrett LeSage</dc:title>
+ </cc:Agent>
+ </dc:contributor>
+ <cc:license rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/"/>
+ <dc:title/>
+ </cc:Work>
+ <cc:License rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Notice"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/Attribution"/>
+ <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
+ <cc:requires rdf:resource="http://web.resource.org/cc/ShareAlike"/>
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g id="layer2">
+ <path id="path6548" opacity=".6" style="color:#000000" d="m41 40a17.143 8.5714 0 1 1 -34.286 0 17.143 8.5714 0 1 1 34.286 0z" transform="matrix(1.0706 0 0 .525 -.89276 22.5)" display="block" fill="url(#radialGradient3976)"/>
+ </g>
+ <g id="layer1">
+ <g id="g4006">
+ <path id="path1314" d="m46.857 23.929c0 12.9-10.457 23.357-23.357 23.357s-23.357-10.457-23.357-23.357 10.457-23.357 23.357-23.357 23.357 10.457 23.357 23.357z" transform="matrix(.92049 0 0 .92049 2.3685 .97408)" stroke="#4e9a06" stroke-width="1.0864" fill="#73d216"/>
+ <path id="path3560" opacity=".34659" d="m49.902 26.635c0 13.25-10.741 23.991-23.991 23.991s-23.991-10.741-23.991-23.991 10.741-23.991 23.991-23.991 23.991 10.741 23.991 23.991z" fill-opacity="0" transform="matrix(.85609 0 0 .85609 1.8183 .19777)" stroke="url(#linearGradient3980)" stroke-width="1.1681"/>
+ </g>
+ </g>
+ <g id="layer3">
+ <g id="text4967" fill="#eeeeec" stroke="#eeeeec">
+ <path id="path4984" style="" d="m14.707 25.178c0.62921 0.000015 1.1052 0.5163 1.4278 1.5489 0.64534 1.9361 1.1052 2.9041 1.3794 2.9041 0.20973 0.000012 0.42753-0.16133 0.65342-0.48402 4.5336-7.2602 8.7284-13.133 12.584-17.618 1.0003-1.1616 2.5895-1.7424 4.7676-1.7425 0.51625 0.0000313 0.86313 0.048433 1.0406 0.1452 0.17744 0.096834 0.26618 0.21784 0.26621 0.36301-0.000033 0.2259-0.26624 0.66959-0.79863 1.331-6.2277 7.4861-12.004 15.392-17.328 23.717-0.37109 0.58082-1.1294 0.87124-2.2749 0.87123-1.1617 0.000005-1.8473-0.0484-2.0571-0.1452-0.54856-0.242-1.1939-1.4762-1.9361-3.7027-0.83897-2.4685-1.2585-4.0173-1.2584-4.6466-0.000008-0.67761 0.56468-1.331 1.6941-1.9603 0.69375-0.3872 1.3068-0.5808 1.8393-0.58082"/>
+ </g>
+ </g>
+ <g id="layer4">
+ <path id="path3955" fill="url(#linearGradient3982)" d="m43.429 21.8c0 10.863-10.386-6.285-18.731 0.388-8.151 6.517-20.659 12.227-20.659 1.364 0.0004-11.118 8.722-21.431 19.585-21.431 10.863-0.0002 19.805 8.816 19.805 19.679z"/>
+ </g>
+</svg>
diff --git a/images/dialog-error.svg b/images/dialog-error.svg
new file mode 100644
index 0000000..9071b53
--- /dev/null
+++ b/images/dialog-error.svg
@@ -0,0 +1,316 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="48px"
+ height="48px"
+ id="svg1306"
+ sodipodi:version="0.32"
+ inkscape:version="0.43+devel"
+ sodipodi:docbase="/home/garrett/Source/tango-icon-theme/scalable/status"
+ sodipodi:docname="dialog-error.svg">
+ <defs
+ id="defs1308">
+ <linearGradient
+ id="linearGradient3957">
+ <stop
+ style="stop-color:#fffeff;stop-opacity:0.33333334;"
+ offset="0"
+ id="stop3959" />
+ <stop
+ style="stop-color:#fffeff;stop-opacity:0.21568628;"
+ offset="1"
+ id="stop3961" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient2536">
+ <stop
+ style="stop-color:#a40000;stop-opacity:1;"
+ offset="0"
+ id="stop2538" />
+ <stop
+ style="stop-color:#ff1717;stop-opacity:1;"
+ offset="1"
+ id="stop2540" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient2479">
+ <stop
+ style="stop-color:#ffe69b;stop-opacity:1;"
+ offset="0"
+ id="stop2481" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:1;"
+ offset="1"
+ id="stop2483" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient4126"
+ inkscape:collect="always">
+ <stop
+ id="stop4128"
+ offset="0"
+ style="stop-color:#000000;stop-opacity:1;" />
+ <stop
+ id="stop4130"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:0;" />
+ </linearGradient>
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4126"
+ id="radialGradient2169"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1.000000,0.000000,0.000000,0.500000,1.899196e-14,20.00000)"
+ cx="23.857143"
+ cy="40.000000"
+ fx="23.857143"
+ fy="40.000000"
+ r="17.142857" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2479"
+ id="linearGradient2485"
+ x1="43.93581"
+ y1="53.835983"
+ x2="20.064686"
+ y2="-8.5626707"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2536"
+ id="linearGradient2542"
+ x1="36.917976"
+ y1="66.288063"
+ x2="19.071495"
+ y2="5.5410109"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2536"
+ id="linearGradient3046"
+ gradientUnits="userSpaceOnUse"
+ x1="36.917976"
+ y1="66.288063"
+ x2="19.071495"
+ y2="5.5410109" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2479"
+ id="linearGradient3048"
+ gradientUnits="userSpaceOnUse"
+ x1="43.93581"
+ y1="53.835983"
+ x2="20.064686"
+ y2="-8.5626707" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2536"
+ id="linearGradient3064"
+ gradientUnits="userSpaceOnUse"
+ x1="36.917976"
+ y1="66.288063"
+ x2="19.071495"
+ y2="5.5410109" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2479"
+ id="linearGradient3066"
+ gradientUnits="userSpaceOnUse"
+ x1="43.93581"
+ y1="53.835983"
+ x2="20.064686"
+ y2="-8.5626707" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3957"
+ id="linearGradient3963"
+ x1="21.993773"
+ y1="33.955299"
+ x2="20.917078"
+ y2="15.814602"
+ gradientUnits="userSpaceOnUse" />
+ <radialGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4126"
+ id="radialGradient3976"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(1,0,0,0.5,1.893048e-14,20)"
+ cx="23.857143"
+ cy="40.000000"
+ fx="23.857143"
+ fy="40.000000"
+ r="17.142857" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2536"
+ id="linearGradient3978"
+ gradientUnits="userSpaceOnUse"
+ x1="36.917976"
+ y1="66.288063"
+ x2="19.071495"
+ y2="5.5410109" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient2479"
+ id="linearGradient3980"
+ gradientUnits="userSpaceOnUse"
+ x1="43.93581"
+ y1="53.835983"
+ x2="20.064686"
+ y2="-8.5626707" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3957"
+ id="linearGradient3982"
+ gradientUnits="userSpaceOnUse"
+ x1="21.993773"
+ y1="33.955299"
+ x2="20.917078"
+ y2="15.814602" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="0.21568627"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="27.043297"
+ inkscape:cy="20.463852"
+ inkscape:current-layer="layer2"
+ showgrid="true"
+ inkscape:grid-bbox="true"
+ inkscape:document-units="px"
+ inkscape:window-width="925"
+ inkscape:window-height="846"
+ inkscape:window-x="234"
+ inkscape:window-y="52"
+ inkscape:showpageshadow="false"
+ fill="#ef2929"
+ gridempspacing="4" />
+ <metadata
+ id="metadata1311">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>Rodney Dawes</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:contributor>
+ <cc:Agent>
+ <dc:title>Jakub Steiner, Garrett LeSage</dc:title>
+ </cc:Agent>
+ </dc:contributor>
+ <cc:license
+ rdf:resource="http://creativecommons.org/licenses/by-sa/2.0/" />
+ <dc:title>Dialog Error</dc:title>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Reproduction" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Distribution" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/Notice" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/Attribution" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+ <cc:requires
+ rdf:resource="http://web.resource.org/cc/ShareAlike" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:groupmode="layer"
+ id="layer2"
+ inkscape:label="Shadow">
+ <path
+ inkscape:r_cy="true"
+ inkscape:r_cx="true"
+ transform="matrix(1.070555,0,0,0.525,-0.892755,22.5)"
+ d="M 41 40 A 17.142857 8.5714283 0 1 1 6.7142868,40 A 17.142857 8.5714283 0 1 1 41 40 z"
+ sodipodi:ry="8.5714283"
+ sodipodi:rx="17.142857"
+ sodipodi:cy="40"
+ sodipodi:cx="23.857143"
+ id="path6548"
+ style="opacity:0.6;color:#000000;fill:url(#radialGradient3976);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:block;overflow:visible"
+ sodipodi:type="arc" />
+ </g>
+ <g
+ id="layer1"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer">
+ <g
+ id="g4006">
+ <path
+ transform="matrix(0.920488,0,0,0.920488,2.368532,0.97408)"
+ d="M 46.857143 23.928572 A 23.357143 23.357143 0 1 1 0.1428566,23.928572 A 23.357143 23.357143 0 1 1 46.857143 23.928572 z"
+ sodipodi:ry="23.357143"
+ sodipodi:rx="23.357143"
+ sodipodi:cy="23.928572"
+ sodipodi:cx="23.5"
+ id="path1314"
+ style="fill:url(#linearGradient3978);fill-opacity:1;fill-rule:nonzero;stroke:#b20000;stroke-width:1.08638;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc"
+ inkscape:r_cx="true"
+ inkscape:r_cy="true" />
+ <path
+ transform="matrix(0.856093,0,0,0.856093,1.818275,0.197769)"
+ d="M 49.901535 26.635273 A 23.991123 23.991123 0 1 1 1.9192886,26.635273 A 23.991123 23.991123 0 1 1 49.901535 26.635273 z"
+ sodipodi:ry="23.991123"
+ sodipodi:rx="23.991123"
+ sodipodi:cy="26.635273"
+ sodipodi:cx="25.910412"
+ id="path3560"
+ style="opacity:0.34659089;fill:#cc0000;fill-opacity:0;stroke:url(#linearGradient3980);stroke-width:1.16809607;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ sodipodi:type="arc"
+ inkscape:r_cx="true"
+ inkscape:r_cy="true" />
+ </g>
+ </g>
+ <g
+ inkscape:groupmode="layer"
+ id="layer3"
+ inkscape:label="Error Box">
+ <rect
+ inkscape:r_cy="true"
+ inkscape:r_cx="true"
+ style="fill:#efefef;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.73876643;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.8627451"
+ id="rect2070"
+ width="27.836435"
+ height="7.1735945"
+ x="10.078821"
+ y="19.164932"
+ transform="matrix(1.005876,0,0,1.115201,-0.138045,-2.372708)" />
+ </g>
+ <g
+ inkscape:groupmode="layer"
+ id="layer4"
+ inkscape:label="Glossy Shine">
+ <path
+ transform="matrix(1.002994,0,0,1.002994,-7.185874e-2,1.968356e-2)"
+ sodipodi:nodetypes="czssc"
+ id="path3955"
+ d="M 43.370686,21.715486 C 43.370686,32.546102 33.016357,15.449178 24.695948,22.101874 C 16.569626,28.599385 4.0989837,34.292422 4.0989837,23.461806 C 4.0989837,12.377753 12.79438,2.0948032 23.625,2.0948032 C 34.455619,2.0948032 43.370686,10.884868 43.370686,21.715486 z "
+ style="fill:url(#linearGradient3982);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dashoffset:0;stroke-opacity:1"
+ inkscape:r_cx="true"
+ inkscape:r_cy="true" />
+ </g>
+</svg>
diff --git a/images/loader.gif b/images/loader.gif
new file mode 100644
index 0000000..078b55f
--- /dev/null
+++ b/images/loader.gif
Binary files differ
diff --git a/images/loader@2x.gif b/images/loader@2x.gif
new file mode 100644
index 0000000..078b55f
--- /dev/null
+++ b/images/loader@2x.gif
Binary files differ
diff --git a/src/gui/latexprocess.cpp b/src/gui/latexprocess.cpp
index 20b22a4..82c1c5b 100644
--- a/src/gui/latexprocess.cpp
+++ b/src/gui/latexprocess.cpp
@@ -4,6 +4,7 @@
#include <QDebug>
#include <QStandardPaths>
#include <QTemporaryDir>
+#include <QStringList>
LatexProcess::LatexProcess(PreviewWindow *preview, QObject *parent) : QObject(parent)
{
@@ -23,6 +24,7 @@ LatexProcess::LatexProcess(PreviewWindow *preview, QObject *parent) : QObject(pa
void LatexProcess::makePreview(QString tikz)
{
+ _preview->setStatus(PreviewWindow::Running);
_output->clear();
if (!_workingDir.isValid()) {
@@ -38,8 +40,28 @@ void LatexProcess::makePreview(QString tikz)
QString pdflatex = QStandardPaths::findExecutable("pdflatex");
if (pdflatex.isEmpty()) {
- _output->appendPlainText("pdflatex NOT FOUND, ABORTING.\n");
- return;
+ // if pdflatex is not in PATH, we are probably on mac or windows, so try common
+ // install directories.
+ _output->appendPlainText("NOT FOUND IN PATH, TRYING:");
+
+ QStringList texDirs;
+ // common macOS tex directories:
+ texDirs << "/Library/TeX/texbin";
+ texDirs << "/usr/texbin";
+ texDirs << "/usr/local/bin";
+ texDirs << "/sw/bin";
+
+ // common windows tex directories
+ texDirs << "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin";
+ texDirs << "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64";
+
+ _output->appendPlainText(texDirs.join(":"));
+ pdflatex = QStandardPaths::findExecutable("pdflatex", texDirs);
+
+ if (pdflatex.isEmpty()) {
+ _output->appendPlainText("pdflatex NOT FOUND, ABORTING.\n");
+ return;
+ }
}
_output->appendPlainText("FOUND: " + pdflatex + "\n");
@@ -66,7 +88,7 @@ void LatexProcess::makePreview(QString tikz)
tex << "\n\n\\end{document}\n";
f.close();
- _proc->start(pdflatex, QStringList() << "preview.tex");
+ _proc->start(pdflatex, QStringList() << "-interaction=nonstopmode" << "preview.tex");
}
@@ -90,9 +112,11 @@ void LatexProcess::finished(int exitCode)
QString pdf = _workingDir.path() + "/preview.pdf";
_output->appendPlainText("\n\nSUCCESSFULLY GENERATED: " + pdf + "\n");
_preview->setPdf(pdf);
+ _preview->setStatus(PreviewWindow::Success);
emit previewFinished();
} else {
_output->appendPlainText("\n\npdflatex RETURNED AN ERROR\n");
+ _preview->setStatus(PreviewWindow::Failed);
emit previewFinished();
}
}
diff --git a/src/gui/previewwindow.cpp b/src/gui/previewwindow.cpp
index 724a951..726ec8a 100644
--- a/src/gui/previewwindow.cpp
+++ b/src/gui/previewwindow.cpp
@@ -15,6 +15,7 @@
#include <QStandardPaths>
#include <QMessageBox>
#include <cmath>
+#include <QMovie>
PreviewWindow::PreviewWindow(QWidget *parent) :
QDialog(parent),
@@ -31,10 +32,15 @@ PreviewWindow::PreviewWindow(QWidget *parent) :
_doc = nullptr;
_page = nullptr;
- //setPdf("/home/aleks/ak-algebras.pdf");
- //qDebug() << "preview dir:" << preparePreview("foo");
+ _loader = new QLabel(this);
+ _loader->setMinimumSize(QSize(16,16));
+ _loader->setMaximumSize(QSize(16,16));
+ ui->tabWidget->tabBar()->setTabButton(1, QTabBar::RightSide, _loader);
+ connect(ui->tabWidget, SIGNAL(currentChanged(int)),
+ this, SLOT(render()));
+
render();
}
@@ -76,6 +82,37 @@ QPlainTextEdit *PreviewWindow::outputTextEdit()
return ui->output;
}
+void PreviewWindow::setStatus(PreviewWindow::Status status)
+{
+ QMovie *oldMovie = _loader->movie();
+ if (status == PreviewWindow::Running) {
+ // loader.gif and loader@2x.gif derived from:
+ // https://commons.wikimedia.org/wiki/Throbbers#/media/File:Linux_Ubuntu_Loader.gif
+ // licensed GNU Free Documentation License v1.2
+ QMovie *movie = new QMovie(
+ (devicePixelRatioF() > 1.0) ? ":images/loader@2x.gif" : ":images/loader.gif",
+ QByteArray(), _loader);
+ _loader->setPixmap(QPixmap());
+ _loader->setMovie(movie);
+ movie->start();
+ } else if (status == PreviewWindow::Success) {
+ _loader->setMovie(nullptr);
+ QPixmap accept(":images/dialog-accept.svg");
+ accept.setDevicePixelRatio(devicePixelRatio());
+ _loader->setPixmap(accept);
+ } else if (status == PreviewWindow::Failed) {
+ _loader->setMovie(nullptr);
+ QPixmap error(":images/dialog-error.svg");
+ error.setDevicePixelRatio(devicePixelRatio());
+ _loader->setPixmap(error);
+ }
+
+ if (oldMovie != nullptr) oldMovie->deleteLater();
+
+
+ _loader->repaint();
+}
+
void PreviewWindow::closeEvent(QCloseEvent *e) {
QSettings settings("tikzit", "tikzit");
settings.setValue("geometry-preview", saveGeometry());
diff --git a/src/gui/previewwindow.h b/src/gui/previewwindow.h
index c850ce9..a937263 100644
--- a/src/gui/previewwindow.h
+++ b/src/gui/previewwindow.h
@@ -1,7 +1,9 @@
#ifndef PREVIEWWINDOW_H
#define PREVIEWWINDOW_H
+
#include <QDialog>
+#include <QLabel>
#include <QPlainTextEdit>
#include <poppler/qt5/poppler-qt5.h>
@@ -14,11 +16,18 @@ class PreviewWindow : public QDialog
Q_OBJECT
public:
+ enum Status {
+ Running, Success, Failed
+ };
explicit PreviewWindow(QWidget *parent = nullptr);
~PreviewWindow();
void setPdf(QString file);
QString preparePreview(QString tikz);
QPlainTextEdit *outputTextEdit();
+ void setStatus(Status status);
+
+public slots:
+ void render();
protected:
void resizeEvent(QResizeEvent *e);
@@ -27,9 +36,9 @@ protected:
private:
Ui::PreviewWindow *ui;
- void render();
Poppler::Document *_doc;
Poppler::Page *_page;
+ QLabel *_loader;
};
#endif // PREVIEWWINDOW_H
diff --git a/src/gui/previewwindow.ui b/src/gui/previewwindow.ui
index 394fc41..7da886a 100644
--- a/src/gui/previewwindow.ui
+++ b/src/gui/previewwindow.ui
@@ -14,16 +14,46 @@
<string>Preview</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>3</number>
+ </property>
+ <property name="topMargin">
+ <number>3</number>
+ </property>
+ <property name="rightMargin">
+ <number>3</number>
+ </property>
+ <property name="bottomMargin">
+ <number>3</number>
+ </property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
+ <property name="documentMode">
+ <bool>false</bool>
+ </property>
+ <property name="tabsClosable">
+ <bool>false</bool>
+ </property>
<widget class="QWidget" name="pdfTab">
<attribute name="title">
<string>PDF</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy">
@@ -40,8 +70,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>561</width>
- <height>413</height>
+ <width>591</width>
+ <height>448</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
diff --git a/src/tikzit.cpp b/src/tikzit.cpp
index 39a2924..e12053b 100644
--- a/src/tikzit.cpp
+++ b/src/tikzit.cpp
@@ -31,14 +31,13 @@
#include <QVersionNumber>
#include <QNetworkAccessManager>
-
// application-level instance of Tikzit
Tikzit *tikzit;
// font to use for node labels
QFont Tikzit::LABEL_FONT("Courrier", 9);
-Tikzit::Tikzit() : _styleFile("[no styles]"), _activeWindow(0)
+Tikzit::Tikzit() : _styleFile("[no styles]"), _activeWindow(nullptr)
{
}
@@ -116,7 +115,7 @@ void Tikzit::init()
QVariant check = settings.value("check-for-updates");
if (check.isNull()) {
- int resp = QMessageBox::question(0,
+ int resp = QMessageBox::question(nullptr,
tr("Check for updates"),
tr("Would you like TikZiT to check for updates automatically?"
" (You can always change this later in the Help menu.)"),
@@ -213,7 +212,7 @@ void Tikzit::newTikzStyles()
w->tikzScene()->reloadStyles();
}
} else {
- QMessageBox::warning(0,
+ QMessageBox::warning(nullptr,
"Could not write to style file.",
"Could not write to: '" + fileName + "'. Check file permissions or choose a new location.");
}
@@ -252,7 +251,7 @@ void Tikzit::removeWindow(MainWindow *w)
_windows.removeAll(w);
if (_activeWindow == w) {
if (_windows.isEmpty()) {
- _activeWindow = 0;
+ _activeWindow = nullptr;
// TODO: check if we should quit when last window closed
quit();
} else _activeWindow = _windows[0];
@@ -262,7 +261,7 @@ void Tikzit::removeWindow(MainWindow *w)
void Tikzit::open()
{
QSettings settings("tikzit", "tikzit");
- QString fileName = QFileDialog::getOpenFileName(0,
+ QString fileName = QFileDialog::getOpenFileName(nullptr,
tr("Open File"),
settings.value("previous-file-path").toString(),
tr("TiKZ Files (*.tikz)"),
@@ -293,7 +292,7 @@ void Tikzit::open(QString fileName)
void Tikzit::openTikzStyles() {
QSettings settings("tikzit", "tikzit");
- QString fileName = QFileDialog::getOpenFileName(0,
+ QString fileName = QFileDialog::getOpenFileName(nullptr,
tr("Open File"),
settings.value("previous-tikzstyles-path").toString(),
tr("TiKZ Style Files (*.tikzstyles)"),
@@ -326,7 +325,7 @@ bool Tikzit::loadStyles(QString fileName)
}
return true;
} else {
- QMessageBox::warning(0,
+ QMessageBox::warning(nullptr,
"Bad style file.",
"Bad style file: '" + fileName + "'. Check the file is properly formatted and try to load it again.");
return false;
@@ -334,7 +333,8 @@ bool Tikzit::loadStyles(QString fileName)
} else {
//settings.setValue("previous-tikzstyles-file", "");
- QMessageBox::warning(0, "Style file not found.", "Could not open style file: '" + fileName + "'.");
+ QMessageBox::warning(nullptr,
+ "Style file not found.", "Could not open style file: '" + fileName + "'.");
return false;
}
}
diff --git a/tikzit.qrc b/tikzit.qrc
index 32bdfc8..4b4defb 100644
--- a/tikzit.qrc
+++ b/tikzit.qrc
@@ -9,6 +9,10 @@
<file>images/tikzit.png</file>
<file>images/text-x-generic_with_pencil.svg</file>
<file>tex/sample/tikzit.sty</file>
+ <file>images/loader.gif</file>
+ <file>images/loader@2x.gif</file>
+ <file>images/dialog-accept.svg</file>
+ <file>images/dialog-error.svg</file>
</qresource>
<qresource prefix="/qt/etc">
<file>qt.conf</file>