File indexing completed on 2024-04-28 11:20:47

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2011 Alexander Rieder <alexanderrieder@gmail.com>
0004 */
0005 
0006 #ifndef _LATEXRENDERER_H
0007 #define _LATEXRENDERER_H
0008 
0009 #include <QObject>
0010 #include "cantor_export.h"
0011 
0012 namespace Cantor{
0013 class LatexRendererPrivate;
0014 
0015 class CANTOR_EXPORT LatexRenderer : public QObject
0016 {
0017   Q_OBJECT
0018   public:
0019     enum Method{ LatexMethod = 0, MmlMethod = 1};
0020     enum EquationType{ InlineEquation = 0, FullEquation = 1, CustomEquation = 2};
0021     explicit LatexRenderer( QObject* parent = nullptr);
0022     ~LatexRenderer() override;
0023 
0024     QString latexCode() const;
0025     void setLatexCode(const QString& src);
0026     QString header() const;
0027     void addHeader(const QString& header);
0028     void setHeader(const QString& header);
0029     Method method() const;
0030     void setMethod( Method method);
0031     void setEquationOnly(bool isEquationOnly);
0032     bool isEquationOnly() const;
0033     void setEquationType(EquationType type);
0034     EquationType equationType() const;
0035 
0036     QString errorMessage() const;
0037     bool renderingSuccessful() const;
0038 
0039     QString imagePath() const;
0040     QString uuid() const;
0041 
0042     static QString genUuid();
0043 
0044     static bool isLatexAvailable();
0045 
0046   Q_SIGNALS:
0047     void done();
0048     void error();
0049 
0050   public Q_SLOTS:
0051     bool render();
0052 
0053     void renderBlocking();
0054 
0055   private:
0056     void setErrorMessage(const QString& msg);
0057 
0058   private Q_SLOTS:
0059     bool renderWithLatex();
0060     bool renderWithMml();
0061     void convertToPs();
0062     void convertingDone();
0063 
0064   private:
0065     LatexRendererPrivate* d;
0066 };
0067 }
0068 #endif /* _LATEXRENDERER_H */