/home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_svg/include/svg_config.h Source File

MathVizAnimator: /home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/libs/mva_svg/include/svg_config.h Source File
MathVizAnimator  0.0.1
svg_config.h
1 /* mathvizanimator
2  * Copyright (C) 2024 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_SVG_INCLUDE_SVG_CONFIG_H_
19 #define LIBS_MVA_SVG_INCLUDE_SVG_CONFIG_H_
20 
21 #include <QCryptographicHash>
22 #include <QDir>
23 #include <QStandardPaths>
24 
34 class SVGConfig {
35  public:
41  {
42  static SVGConfig instance;
43  return instance;
44  }
45 
50  void setSVGDir(const QDir& svg_dir)
51  {
52  m_svg_dir = svg_dir;
53 
54  if (!m_svg_dir.exists()) {
55  m_svg_dir.mkpath(".");
56  }
57  }
58 
63  QDir svgDir() { return m_svg_dir; }
64 
70  static QString hash(const QString& text)
71  {
72  return QString(QCryptographicHash::hash(text.toUtf8(), QCryptographicHash::Md5).toHex());
73  }
74 
75  private:
76  SVGConfig() = default;
77  ~SVGConfig() = default;
78  SVGConfig(const SVGConfig&) = delete;
79  SVGConfig& operator=(const SVGConfig&) = delete;
80 
81  QDir m_svg_dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
82 };
83 
84 #endif // LIBS_MVA_SVG_INCLUDE_SVG_CONFIG_H_
The SVGConfig class manages the configuration related to SVG files.
Definition: svg_config.h:34
QDir svgDir()
Returns the directory where SVG files are stored.
Definition: svg_config.h:63
static QString hash(const QString &text)
Generates a hash value for the given text using MD5 algorithm.
Definition: svg_config.h:70
static SVGConfig & getInstance()
Returns the singleton instance of SVGConfig.
Definition: svg_config.h:40
void setSVGDir(const QDir &svg_dir)
Sets the directory for SVG files.
Definition: svg_config.h:50