File indexing completed on 2024-04-14 16:00:15
0001 #pragma once 0002 0003 #include <QObject> 0004 #include <QMap> 0005 0006 class QJSEngine; 0007 class QQmlEngine; 0008 class QQuickView; 0009 0010 /** 0011 * @brief Singleton helper for qml interface 0012 * 0013 */ 0014 class Util : public QObject { 0015 Q_OBJECT 0016 0017 Q_PROPERTY(QString code READ code NOTIFY codeChanged) 0018 0019 public: 0020 /** 0021 * @brief Return the code 0022 * 0023 * @return QString 0024 */ 0025 QString code() const; 0026 0027 /** 0028 * @brief Get code via std::string 0029 * 0030 * @return QString 0031 */ 0032 std::string codeEMS() const; 0033 0034 /** 0035 * @brief Set the code 0036 * 0037 * @param code 0038 */ 0039 void setCode(const QString& code); 0040 0041 /** 0042 * @brief Set the code via std::string 0043 * 0044 * @param code 0045 */ 0046 void setCodeEMS(const std::string& code); 0047 0048 /** 0049 * @brief Return Util pointer 0050 * 0051 * @return Util* 0052 */ 0053 static Util* self(); 0054 ~Util(); 0055 0056 /** 0057 * @brief Return a pointer of this singleton to the qml register function 0058 * 0059 * @param engine 0060 * @param scriptEngine 0061 * @return QObject* 0062 */ 0063 static QObject* qmlSingletonRegister(QQmlEngine* engine, QJSEngine* scriptEngine); 0064 0065 signals: 0066 void codeChanged(); 0067 0068 private: 0069 Q_DISABLE_COPY(Util) 0070 /** 0071 * @brief Construct a new Util object 0072 * 0073 */ 0074 Util() = default; 0075 0076 QString _code; 0077 };