Added ConfigProvider class to allow window to reload config

This commit is contained in:
Albert S. 2019-06-03 07:42:02 +02:00
orang tua 1dc7ef935d
melakukan 67be2dbeaa
2 mengubah file dengan 43 tambahan dan 0 penghapusan

25
configprovider.cpp Normal file
Melihat File

@ -0,0 +1,25 @@
#include "configprovider.h"
ConfigProvider::ConfigProvider(QString configDirPath, QSettings &settings)
{
this->settings = &settings;
this->configDirPath = configDirPath;
}
QVector<EntryConfig> ConfigProvider::getUserEntries()
{
ConfigReader reader({this->configDirPath});
return reader.readConfig();
}
QVector<EntryConfig> ConfigProvider::getSystemEntries()
{
QStringList systemApplicationsPaths = settings->value("sysAppsPaths", "/usr/share/applications/").toStringList();
ConfigReader systemConfigReader(systemApplicationsPaths);
return systemConfigReader.readConfig();
}
bool ConfigProvider::singleInstanceMode()
{
return settings->value("singleInstance", true).toBool();
}

18
configprovider.h Normal file
Melihat File

@ -0,0 +1,18 @@
#ifndef CONFIGPROVIDER_H
#define CONFIGPROVIDER_H
#include <QSettings>
#include "config.h"
class ConfigProvider
{
private:
QSettings *settings;
QString configDirPath;
public:
ConfigProvider(QString configDirPath, QSettings &settings);
QVector<EntryConfig> getUserEntries();
QVector<EntryConfig> getSystemEntries();
bool singleInstanceMode();
};
#endif // CONFIGPROVIDER_H