forked from wario-land/WL4Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsUtils.cpp
More file actions
55 lines (50 loc) · 1.57 KB
/
SettingsUtils.cpp
File metadata and controls
55 lines (50 loc) · 1.57 KB
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
#include "SettingsUtils.h"
namespace SettingsUtils
{
// Global variables
QString ProgramSettingFilePath;
/// <summary>
/// Initialize ini file path and check the ini file.
/// </summary>
void InitProgramSetupPath(QCoreApplication &application)
{
ProgramSettingFilePath = application.applicationDirPath();
ProgramSettingFilePath += QString("/WL4Editor.ini");
// Check INI file
QFileInfo fileInfo(ProgramSettingFilePath);
if (!fileInfo.isFile())
{
QSettings WL4EditorIni(ProgramSettingFilePath, QSettings::IniFormat);
for (int i = 0; i < KeyStringSet.size(); i++)
WL4EditorIni.setValue(KeyStringSet[i], "");
}
}
/// <summary>
/// Set a Key in the ini file.
/// </summary>
/// <param name="key">
/// The key whose value to set.
/// </param>
/// <param name="value">
/// The new value of the Key.
/// </param>
void SetKey(IniKeys key, QString value)
{
QSettings WL4EditorIni(ProgramSettingFilePath, QSettings::IniFormat);
WL4EditorIni.setValue(KeyStringSet[key], value);
}
/// <summary>
/// Get a Key value from the ini file.
/// </summary>
/// <param name="key">
/// The key whose value to get.
/// </param>
/// <returns>
/// The value of the key.
/// </returns>
QString GetKey(IniKeys key)
{
QSettings WL4EditorIni(ProgramSettingFilePath, QSettings::IniFormat);
return WL4EditorIni.value(KeyStringSet[key]).toString();
}
} // namespace SettingsUtils