Added ConfigProvider class to allow window to reload config
This commit is contained in:
parent
1dc7ef935d
commit
67be2dbeaa
25
configprovider.cpp
Normal file
25
configprovider.cpp
Normal 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
18
configprovider.h
Normal 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
|
Loading…
Reference in New Issue
Block a user