/home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_gui/include/items/textitem.h Source File

MathVizAnimator: /home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_gui/include/items/textitem.h Source File
MathVizAnimator  0.0.1
textitem.h
1 /* mathvizanimator
2  * Copyright (C) 2023 codingwithmagga
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef LIBS_MVA_GUI_INCLUDE_ITEMS_TEXTITEM_H_
19 #define LIBS_MVA_GUI_INCLUDE_ITEMS_TEXTITEM_H_
20 
21 #include <QDir>
22 #include <QFileInfo>
23 #include <QObject>
24 #include <QStandardPaths>
25 
26 #include "abstractitem.h"
27 #include "svg_creator.h"
28 
29 class TextItem : public AbstractItem {
30  Q_OBJECT
31  QML_ELEMENT
32 
33  // TODO(codingwithmagga): Relocate to a SvgHandler class or LatexHandler or
34  // similar
35  Q_PROPERTY(QString latexSource READ latexSource WRITE setLatexSource NOTIFY latexSourceChanged)
36 
37  Q_PROPERTY(QString svgFile READ svgFile WRITE setSvgFile NOTIFY svgFileChanged)
38  Q_PROPERTY(qreal scaleText READ scaleText WRITE setScaleText NOTIFY scaleTextChanged)
39 
40  public:
41  explicit TextItem(BasicItem* parent = nullptr);
42 
43  QString svgFile() const { return m_svg_file.absoluteFilePath(); }
44  void setSvgFile(const QFileInfo& newSvgFile);
45  void setSvgFile(const QString& newSvgFile);
46 
47  void paint(QPainter* painter) override;
48 
49  QString latexSource() const;
50  void setLatexSource(const QString& newLatexSource);
51 
52  qreal scaleText() const;
53  void setScaleText(qreal newScaleText);
54 
55  QStringList editableProperties() const override;
56  QStringList editablePropertiesParent() const override;
57 
58  signals:
59  void latexSourceChanged(const QString& new_latex_source);
60  void svgFileChanged(const QFileInfo& new_svg_file);
61  void scaleTextChanged(const qreal new_scale_text);
62 
63  private slots:
64  void svgCreationFinished(const QFileInfo& svg_file);
65 
66  private:
67  void removeUnusedLatexFiles(const QString& hash);
68 
69  SVGCreator m_svg_creator;
70 
71  QFileInfo m_svg_file = QFileInfo("://templates/placeholder.svg");
72  QString m_latex_source;
73  qreal m_scale_text = 1.0;
74 
75  // TODO(codingwithmagga): Relocate to a SvgHandler class or LatexHandler or
76  // similar
77  QDir m_svg_location;
78  QString m_latex_path;
79  QString m_dvisvgm_path;
80 };
81 
82 #endif // LIBS_MVA_GUI_INCLUDE_ITEMS_TEXTITEM_H_
An abstract class representing a visible item like a circle or a rectangle.
Definition: abstractitem.h:56
Definition: basic_item.h:28
The SVGCreator class handles the creation of SVG files from LaTeX input.
Definition: svg_creator.h:33
Definition: textitem.h:29
QStringList editablePropertiesParent() const override
Returns the parents properties which can be edited by the user in a QStringList.
Definition: textitem.cpp:140
QStringList editableProperties() const override
Returns the properties which can be edited by the user in a QStringList.
Definition: textitem.cpp:130