Toolbox Qt
Loading...
Searching...
No Matches
settingsini.h
1#ifndef TBQ_CORE_SETTINGSINI_H
2#define TBQ_CORE_SETTINGSINI_H
3
4#include "toolboxqt/toolboxqt_global.h"
5
6#include <QFileInfo>
7#include <QSettings>
8
9#include <memory>
10
11#define mSettings tbq::SettingsIni::instance()
12
13namespace tbq
14{
15
16class TOOLBOXQT_EXPORT SettingsIni final
17{
18 TOOLBOXQT_DISABLE_COPY_MOVE(SettingsIni)
19
20public:
21 using CbHook = std::function<bool(const QFileInfo &fileInfo)>;
22
23public:
24 static SettingsIni& instance();
25
26private:
27 explicit SettingsIni();
28
29public:
30 bool loadSettings(const QFileInfo &fileInfo);
31 QFileInfo getPath() const;
32
33 void groupBegin(TB_QTCOMPAT_STR_VIEW keyGroup);
34 void groupEnd();
35
36 void setValue(TB_QTCOMPAT_STR_VIEW key, const QVariant &value);
37 QVariant getValue(TB_QTCOMPAT_STR_VIEW key, const QVariant &defaultValue = QVariant()) const;
38
39public:
40 void setHooksPreLoadSettings(CbHook hookPreload);
41 void setHooksPostLoadSettings(CbHook hookPostload);
42
43private:
44 static bool defaultHook(const QFileInfo &fileInfo);
45
46private:
47 std::unique_ptr<QSettings> m_settings;
48
49 CbHook m_hookPreload;
50 CbHook m_hookPostLoad;
51};
52
53} // namespace tbq
54
55#endif // TBQ_CORE_SETTINGSINI_H
Class used to manage INI configuration file.
Definition: settingsini.h:17
std::function< bool(const QFileInfo &fileInfo)> CbHook
Custom callback hook use to implement custom behaviour.
Definition: settingsini.h:21