#ifndef SETTINGCONFIG_H
#define SETTINGCONFIG_H

#include <QVariant>
#include <QSettings>
#include <QApplication>

class SettingConfig : public QObject
{
public:
    ~SettingConfig() {};
    SettingConfig(const SettingConfig&)=delete;
    SettingConfig& operator=(const SettingConfig&)=delete;

    static SettingConfig& getInstance() {
        static SettingConfig instance;
        return instance;
    }

    /**
     * @brief get
     * @param nodeName
     * @param keyName
     * @return QVariant
     * @title
     */
    QVariant getProperty(QString nodeName, QString keyName);
    QVariant getProperty(QString nodeName, QString keyName, QString defaultValue);
    void setProperty(QString nodeName, QString keyName, QString value);
    void init();

    /******** 以下为需要的各类参数 ********/
    qint32 BAUD_RATE;

    qint16 WINDOW_WIDTH;
    qint16 WINDOW_HEIGHT;

    qint8 NEED_KAFKA;
    QString KAFKA_BROKERS;
    QString KAFKA_DATA_TOPIC;
    QString KAFKA_MSG_TOPIC;
    QString KAFKA_STATUS_TOPIC;
    qint8 NEED_SASL;
    QString SASL_USERNAME;
    QString SASL_PASSWORD;

    QString CLIENT_ID;
    QString APP_KEY;
    QString DEV_TYPES;
    QString SYSTEM;
    QString WORK_TYPE;
    qint8 MASTER;
    qint8 DISPLAY_COUNT;
    quint16 SERVER_PORT;
    qint8 RESIDUAL_CALC_SEC;

    QString BASE_URL;

    QString BASE_LOG_PATH;

private:
    SettingConfig();

    QString filename;
    QSettings * setting;
};

#endif // SETTINGCONFIG_H
