#include "SettingConfig.h"

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

    PORT_NAMES = getProperty("com", "portNames").toString();
    BAUD_RATE = getProperty("com", "baudRate").toUInt();
    DEV_CODES = getProperty("com", "devCodes").toString();

    NEED_KAFKA = getProperty("kafka", "needKafka").toUInt();
    KAFKA_BROKERS = getProperty("kafka", "brokers").toString();
    KAFKA_DATA_TOPIC = getProperty("kafka", "dataTopic").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;
}
