#include "SettingConfig.h"

SettingConfig::SettingConfig()
{
    filename = QApplication::applicationDirPath() + "/conf/config.ini";
    setting = new QSettings(this->filename, QSettings::IniFormat);

    BAUD_RATE = getProperty("com", "baudRate").toInt();

    NEED_KAFKA = getProperty("kafka", "needKafka").toInt();
    KAFKA_BROKERS = getProperty("kafka", "brokers").toString();
    KAFKA_DATA_TOPIC = getProperty("kafka", "dataTopic").toString();
    NEED_SASL = getProperty("kafka", "needSasl").toInt();
    SASL_USERNAME = getProperty("kafka", "saslUsername").toString();
    SASL_PASSWORD = getProperty("kafka", "saslPassword").toString();

    CLIENT_ID = getProperty("client", "clientId").toString();
    APP_KEY = getProperty("client", "appKey").toString();

    BASE_URL = getProperty("http", "baseUrl").toString();

    BASE_LOG_PATH = getProperty("log", "basePath").toString();
}


QVariant SettingConfig::getProperty(QString nodeName, QString keyName) {
    QVariant var = this->setting->value(QString("/%1/%2").arg(nodeName).arg(keyName));
    return var;
}
