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
31 bool contains(TOOLBOXQT_QTCOMPAT_STR_VIEW key) const;
32 QVariant getValue(TOOLBOXQT_QTCOMPAT_STR_VIEW key, const QVariant &defaultValue = QVariant()) const;
33 QString getString(TOOLBOXQT_QTCOMPAT_STR_VIEW key, const QString &defaultValue = QString()) const;
34
35public:
36 void setHooksPreLoadSettings(CbHook hookPreload);
37 void setHooksPostLoadSettings(CbHook hookPostload);
38
39private:
40 static bool defaultHook(const QFileInfo &fileInfo);
41
42private:
43 std::unique_ptr<QSettings> m_settings;
44
45 CbHook m_hookPreload;
46 CbHook m_hookPostLoad;
47};
48
49} // namespace tbq
50
51#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