-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.h
53 lines (48 loc) · 1.69 KB
/
settings.h
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
#pragma once
#include <string>
#include <filesystem>
#include "lib/json.hpp"
namespace fs = std::filesystem;
using json = nlohmann::json;
class Settings {
public:
Settings();
void loadSettings();
void saveSettings();
void checkSettingsFile();
json& getSettings() { return settings; }
float getSplitPos() const { return splitPos; }
void setSplitPos(float pos) {
splitPos = pos;
settings["splitPos"] = pos;
settingsChanged = true;
}
bool hasSettingsChanged() const { return settingsChanged; }
void resetSettingsChanged() { settingsChanged = false; }
std::string getCurrentTheme() const { return settings["theme"].get<std::string>(); }
bool hasThemeChanged() const { return themeChanged; }
void resetThemeChanged() { themeChanged = false; }
std::string getCurrentFont() const { return settings["font"].get<std::string>(); }
bool hasFontChanged() const { return fontChanged; }
void resetFontChanged() { fontChanged = false; }
float getFontSize() const { return settings["fontSize"].get<float>(); }
void setFontSize(float size) {
if (settings["fontSize"].get<float>() != size) {
settings["fontSize"] = size;
fontSizeChanged = true;
settingsChanged = true;
}
}
bool hasFontSizeChanged() const { return fontSizeChanged; }
void resetFontSizeChanged() { fontSizeChanged = false; }
private:
json settings;
std::string settingsPath;
float splitPos;
fs::file_time_type lastSettingsModification;
bool settingsChanged = false;
bool themeChanged = false;
bool fontChanged = false;
bool fontSizeChanged = false;
};
extern Settings gSettings;