This repository has been archived by the owner on Jan 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigmanager.hpp
95 lines (71 loc) · 1.91 KB
/
configmanager.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef CONFIGMANAGER_HPP
#define CONFIGMANAGER_HPP
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <Utils/medialibrarymodel.hpp>
#include <Sys/command.hpp>
// NOTE: the ConfigManager is not universal, it is part of this application !!
//
// MILESTONE:
// add ability to change values and write back to file
//
// TODO:
// handle boost exceptions
//
class ConfigManager
{
public:
explicit ConfigManager();
~ConfigManager();
enum class Key {
CmdAudio,
CmdVideo,
CmdModule,
CmdPlaylist,
CmdPlaylistFileLoad,
CmdSearch,
CmdBrowse,
CmdRandom,
CmdShuffle,
CmdRepeat,
CmdHistory,
CmdStatistics,
CmdExit,
CmdRescan,
LibRootPath,
LibAudioFormats,
LibVideoFormats,
LibModuleFormats,
LibPrefixDeletionPatterns,
PlayerAudio,
PlayerVideo,
PlayerModule,
ToolBrowser,
HistIgnore
};
QString value(Key) const;
bool boolean(Key) const;
QString playerFor(const QString &fileformat) const;
QString configDir() const;
private:
// create default config file
void createDefaultConfigFile();
// load default settings into the container
void loadDefaultSettings();
// load settings from file
void loadSettings();
// configuration directory
QString m_configdir;
// configuration file path
QString m_configfile;
// configuration container
boost::property_tree::ptree m_config;
// transform Key into string for boost ptree
static std::string keyStr(Key);
static std::string keyDefaultValue(Key);
// adds missing keys if config file lacks some of it
void addIfMissing(Key);
// maintain a pointer to the media library for command maintenance
MediaLibraryModel *ptr_media_model;
};
#endif // CONFIGMANAGER_HPP