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
11namespace tbq
12{
13
14class TOOLBOXQT_EXPORT SettingsIni final
15{
16public:
17 using CbHook = std::function<bool(const QFileInfo &fileInfo)>;
18
19public:
20 explicit SettingsIni();
21
22public:
23 bool loadSettings(const QFileInfo &fileInfo);
24 QFileInfo getPath() const;
25
26 void groupBegin(TOOLBOXQT_QTCOMPAT_STR_VIEW keyGroup);
27 void groupEnd();
28
29 void setValue(TOOLBOXQT_QTCOMPAT_STR_VIEW key, const QVariant &value);
30 QVariant getValue(TOOLBOXQT_QTCOMPAT_STR_VIEW key, const QVariant &defaultValue = QVariant()) const;
31
32public:
33 void setHooksPreLoadSettings(CbHook hookPreload);
34 void setHooksPostLoadSettings(CbHook hookPostload);
35
36private:
37 static bool defaultHook(const QFileInfo &fileInfo);
38
39private:
40 std::unique_ptr<QSettings> m_settings;
41
42 CbHook m_hookPreload;
43 CbHook m_hookPostLoad;
44};
45
46} // namespace tbq
47
48#endif // TBQ_CORE_SETTINGSINI_H
Class used to manage INI configuration file.
Definition settingsini.h:15
std::function< bool(const QFileInfo &fileInfo)> CbHook
Custom callback hook use to implement custom behaviour.
Definition settingsini.h:17
Namespace used for ToolBoxQt library.
Definition array2d.h:12