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