<commit_before>#include "configuration.h"
#include "globalobject.h"
#include <QSettings>
#include <QDateTime>
#include <QDir>
#include <QDesktopServices>

GlobalObject* GlobalObject::sharedInstance()
{
    static GlobalObject* _globalInstance = NULL;
    if (_globalInstance) {
        return _globalInstance;
    }
    // Create the global object
    _globalInstance = new GlobalObject();
    return _globalInstance;
}

GlobalObject::GlobalObject()
{

}

GlobalObject::~GlobalObject()
{
}

void GlobalObject::loadSettings()
{
    QSettings settings;
    settings.beginGroup("GLOBAL_SETTINGS");
    m_appDataDirectory = settings.value("APP_DATA_DIRECTORY", defaultAppDataDirectory()).toString();
    m_logDirectory = settings.value("LOG_DIRECTORY", defaultLogDirectory()).toString();
    m_MAVLinklogDirectory = settings.value("MAVLINK_LOG_DIRECTORY", defaultMAVLinkLogDirectory()).toString();
    m_parameterDirectory = settings.value("PARAMETER_DIRECTORY", defaultMAVLinkLogDirectory()).toString();

    //    autoReconnect = settings.value("AUTO_RECONNECT", autoReconnect).toBool();
    //    currentStyle = (QGC_MAINWINDOW_STYLE)settings.value("CURRENT_STYLE", currentStyle).toInt();
    //    lowPowerMode = settings.value("LOW_POWER_MODE", lowPowerMode).toBool();

    settings.endGroup();
}

void GlobalObject::saveSettings()
{
    QSettings settings;
    settings.beginGroup("GLOBAL_SETTINGS");
    settings.setValue("APP_DATA_DIRECTORY", m_appDataDirectory);
    settings.setValue("LOG_DIRECTORY", m_logDirectory);
    settings.setValue("MAVLINK_LOG_DIRECTORY", m_MAVLinklogDirectory);
    settings.setValue("PARAMETER_DIRECTORY", m_parameterDirectory);

    //    settings.setValue("AUTO_RECONNECT", autoReconnect);
    //    settings.setValue("CURRENT_STYLE", currentStyle);
    //    settings.setValue("LOW_POWER_MODE", lowPowerMode);

    settings.sync();
}

QString GlobalObject::fileNameAsTime()
{
    QDateTime timeNow;
    timeNow = timeNow.currentDateTime();
    return "/" + timeNow.toString("yyyy-MM-dd hh-mm-ss") + MAVLINK_LOGFILE_EXT;
}

bool GlobalObject::makeDirectory(const QString& dir)
{
    QDir newDir(dir);
    if (!newDir.exists()){
        return newDir.mkdir(dir);
    }
    return true;
}

//
// App Data Directory
//

QString GlobalObject::defaultAppDataDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString appHomeDir = homeDir + APP_DATA_DIRECTORY;
    return appHomeDir;
}

QString GlobalObject::appDataDirectory()
{
    return m_appDataDirectory;
}

void GlobalObject::setAppDataDirectory(const QString &dir)
{
    m_appDataDirectory = dir;
}

//
// Log Data Directory
//

QString GlobalObject::defaultLogDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString logHomeDir = homeDir + APP_DATA_DIRECTORY + LOG_DIRECTORY;
    return logHomeDir;
}

QString GlobalObject::logDirectory()
{
    return m_logDirectory;
}

void GlobalObject::setLogDirectory(const QString &dir)
{
    m_logDirectory = dir;
}

//
// MAVLink Log Data Directory
//

QString GlobalObject::defaultMAVLinkLogDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString logHomeDir = homeDir + APP_DATA_DIRECTORY + MAVLINK_LOG_DIRECTORY;
    return logHomeDir;
}

QString GlobalObject::MAVLinkLogDirectory()
{
    return m_MAVLinklogDirectory;
}

void GlobalObject::setMAVLinkLogDirectory(const QString &dir)
{
    m_MAVLinklogDirectory = dir;
}

//
// Parameter Data Directory
//

QString GlobalObject::defaultParameterDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString paramHomeDir = homeDir + PARAMETER_DIRECTORY;
    return paramHomeDir;
}

QString GlobalObject::parameterDirectory()
{
    return m_parameterDirectory;
}

void GlobalObject::setParameterDirectory(const QString &dir)
{
    m_parameterDirectory = dir;
}
<commit_msg>Fix parameter directory method returning incorrect data<commit_after>#include "configuration.h"
#include "globalobject.h"
#include <QSettings>
#include <QDateTime>
#include <QDir>
#include <QDesktopServices>

GlobalObject* GlobalObject::sharedInstance()
{
    static GlobalObject* _globalInstance = NULL;
    if (_globalInstance) {
        return _globalInstance;
    }
    // Create the global object
    _globalInstance = new GlobalObject();
    return _globalInstance;
}

GlobalObject::GlobalObject()
{

}

GlobalObject::~GlobalObject()
{
}

void GlobalObject::loadSettings()
{
    QSettings settings;
    settings.beginGroup("GLOBAL_SETTINGS");
    m_appDataDirectory = settings.value("APP_DATA_DIRECTORY", defaultAppDataDirectory()).toString();
    m_logDirectory = settings.value("LOG_DIRECTORY", defaultLogDirectory()).toString();
    m_MAVLinklogDirectory = settings.value("MAVLINK_LOG_DIRECTORY", defaultMAVLinkLogDirectory()).toString();
    m_parameterDirectory = settings.value("PARAMETER_DIRECTORY", defaultParameterDirectory()).toString();

    //    autoReconnect = settings.value("AUTO_RECONNECT", autoReconnect).toBool();
    //    currentStyle = (QGC_MAINWINDOW_STYLE)settings.value("CURRENT_STYLE", currentStyle).toInt();
    //    lowPowerMode = settings.value("LOW_POWER_MODE", lowPowerMode).toBool();

    settings.endGroup();
}

void GlobalObject::saveSettings()
{
    QSettings settings;
    settings.beginGroup("GLOBAL_SETTINGS");
    settings.setValue("APP_DATA_DIRECTORY", m_appDataDirectory);
    settings.setValue("LOG_DIRECTORY", m_logDirectory);
    settings.setValue("MAVLINK_LOG_DIRECTORY", m_MAVLinklogDirectory);
    settings.setValue("PARAMETER_DIRECTORY", m_parameterDirectory);

    //    settings.setValue("AUTO_RECONNECT", autoReconnect);
    //    settings.setValue("CURRENT_STYLE", currentStyle);
    //    settings.setValue("LOW_POWER_MODE", lowPowerMode);

    settings.sync();
}

QString GlobalObject::fileNameAsTime()
{
    QDateTime timeNow;
    timeNow = timeNow.currentDateTime();
    return "/" + timeNow.toString("yyyy-MM-dd hh-mm-ss") + MAVLINK_LOGFILE_EXT;
}

bool GlobalObject::makeDirectory(const QString& dir)
{
    QDir newDir(dir);
    if (!newDir.exists()){
        return newDir.mkdir(dir);
    }
    return true;
}

//
// App Data Directory
//

QString GlobalObject::defaultAppDataDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString appHomeDir = homeDir + APP_DATA_DIRECTORY;
    return appHomeDir;
}

QString GlobalObject::appDataDirectory()
{
    return m_appDataDirectory;
}

void GlobalObject::setAppDataDirectory(const QString &dir)
{
    m_appDataDirectory = dir;
}

//
// Log Data Directory
//

QString GlobalObject::defaultLogDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString logHomeDir = homeDir + APP_DATA_DIRECTORY + LOG_DIRECTORY;
    return logHomeDir;
}

QString GlobalObject::logDirectory()
{
    return m_logDirectory;
}

void GlobalObject::setLogDirectory(const QString &dir)
{
    m_logDirectory = dir;
}

//
// MAVLink Log Data Directory
//

QString GlobalObject::defaultMAVLinkLogDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString logHomeDir = homeDir + APP_DATA_DIRECTORY + MAVLINK_LOG_DIRECTORY;
    return logHomeDir;
}

QString GlobalObject::MAVLinkLogDirectory()
{
    return m_MAVLinklogDirectory;
}

void GlobalObject::setMAVLinkLogDirectory(const QString &dir)
{
    m_MAVLinklogDirectory = dir;
}

//
// Parameter Data Directory
//

QString GlobalObject::defaultParameterDirectory()
{
    QString homeDir = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
    QString paramHomeDir = homeDir + APP_DATA_DIRECTORY + PARAMETER_DIRECTORY;
    return paramHomeDir;
}

QString GlobalObject::parameterDirectory()
{
    return m_parameterDirectory;
}

void GlobalObject::setParameterDirectory(const QString &dir)
{
    m_parameterDirectory = dir;
}

{'fraction_non_alphanumeric': 0.1128428927680798, 'fraction_numerical': 0.0, 'mean_word_length': 5.222653219550039, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6231953', 'n_tokens_mistral': 2398, 'n_tokens_neox': 2414, 'n_words': 409}