-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathConfigModel.h
More file actions
195 lines (161 loc) · 3.98 KB
/
ConfigModel.h
File metadata and controls
195 lines (161 loc) · 3.98 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// src/ConfigModel.h
//----------------------------------
// RP Soundboard Source Code
// Copyright (c) 2015 Marius Graefe
// All rights reserved
// Contact: rp_soundboard@mgraefe.de
//----------------------------------
#pragma once
#include <vector>
#include <array>
#include "SoundInfo.h"
#include "Theme.h"
#include <QString>
#include <memory>
#include <set>
#include "common.h"
class ConfigModel
{
public:
enum notifications_e
{
NOTIFY_SET_SOUND,
NOTIFY_SET_ROWS,
NOTIFY_SET_COLS,
NOTIFY_SET_VOLUME_LOCAL,
NOTIFY_SET_VOLUME_REMOTE,
NOTIFY_SET_PLAYBACK_LOCAL,
NOTIFY_SET_MUTE_MYSELF_DURING_PB,
NOTIFY_SET_WINDOW_SIZE,
NOTIFY_SET_BUBBLE_BUTTONS_BUILD,
NOTIFY_SET_BUBBLE_STOP_BUILD,
NOTIFY_SET_BUBBLE_COLS_BUILD,
NOTIFY_SET_SHOW_HOTKEYS_ON_BUTTONS,
NOTIFY_SET_HOTKEYS_ENABLED,
NOTIFY_SET_NEXT_UPDATE_CHECK,
NOTIFY_SET_THEME_MODE,
};
class Observer
{
public:
virtual ~Observer() {}
virtual void notify(ConfigModel& model, notifications_e what, int data) = 0;
};
public:
ConfigModel();
void readConfig(const QString& file = QString());
void writeConfig(const QString& file = QString());
void notifyAllEvents();
static QString GetConfigPath();
static QString GetFullConfigPath();
QString getFileName(int itemId) const;
void setFileName(int itemId, const QString& fn);
const SoundInfo* getSoundInfo(int itemId) const;
void setSoundInfo(int itemId, const SoundInfo& info);
inline int getRows() const
{
return m_rows[m_activeConfig];
}
void setRows(int n);
inline int getCols() const
{
return m_cols[m_activeConfig];
}
void setCols(int n);
inline int getVolumeLocal() const
{
return m_volumeLocal;
}
void setVolumeLocal(int val);
inline int getVolumeRemote() const
{
return m_volumeRemote;
}
void setVolumeRemote(int val);
inline bool getPlaybackLocal() const
{
return m_playbackLocal;
}
void setPlaybackLocal(bool val);
inline bool getMuteMyselfDuringPb() const
{
return m_muteMyselfDuringPb;
}
void setMuteMyselfDuringPb(bool val);
void getWindowSize(int* width, int* height) const;
void setWindowSize(int width, int height);
inline int getBubbleButtonsBuild() const
{
return m_bubbleButtonsBuild;
}
void setBubbleButtonsBuild(int build);
inline int getBubbleStopBuild() const
{
return m_bubbleStopBuild;
}
void setBubbleStopBuild(int build);
inline int getBubbleColsBuild() const
{
return m_bubbleColsBuild;
}
void setBubbleColsBuild(int build);
inline bool getShowHotkeysOnButtons() const
{
return m_showHotkeysOnButtons;
}
void setShowHotkeysOnButtons(bool show);
inline bool getHotkeysEnabled() const
{
return m_hotkeysEnabled;
}
void setHotkeysEnabled(bool enabled);
void addObserver(Observer* obs);
void remObserver(Observer* obs);
void setConfiguration(int config);
int getConfiguration();
const std::vector<SoundInfo>& sounds() const
{
return m_sounds[m_activeConfig];
}
int numSounds() const
{
return (int)sounds().size();
}
uint getNextUpdateCheck() const
{
return m_nextUpdateCheck;
}
void setNextUpdateCheck(uint time);
ThemeMode getThemeMode() const
{
return m_themeMode;
}
void setThemeMode(ThemeMode mode);
private:
std::vector<SoundInfo>& sounds()
{
return m_sounds[m_activeConfig];
}
void notify(notifications_e what, int data);
std::vector<SoundInfo> getInitialSounds();
std::vector<SoundInfo> readConfiguration(QSettings& settings, const QString& name);
void writeConfiguration(QSettings& settings, const QString& name, const std::vector<SoundInfo>& sounds);
std::vector<Observer*> m_obs;
std::array<std::vector<SoundInfo>, NUM_CONFIGS> m_sounds;
int m_activeConfig;
std::array<int, NUM_CONFIGS> m_rows;
std::array<int, NUM_CONFIGS> m_cols;
int m_volumeLocal;
int m_volumeRemote;
bool m_playbackLocal;
bool m_muteMyselfDuringPb;
int m_windowWidth;
int m_windowHeight;
int m_bubbleButtonsBuild;
int m_bubbleStopBuild;
int m_bubbleColsBuild;
bool m_showHotkeysOnButtons;
bool m_hotkeysEnabled;
uint m_nextUpdateCheck;
ThemeMode m_themeMode;
};