-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.cpp
39 lines (32 loc) · 932 Bytes
/
settings.cpp
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
#include "settings.h"
Settings::Settings()
:
m_settings(new QSettings("RadioPi", "RadioPi"))
{
m_keysToStrings.insert(Settings::Volume, "General/Volume");
m_keysToStrings.insert(Settings::StationNumber, "General/StationNumber");
}
Settings::~Settings()
{
m_settings.reset();
}
int Settings::readInt(Keys key)
{
Q_ASSERT(m_keysToStrings.contains(key));
return m_settings->value(m_keysToStrings.value(key)).toInt();
}
void Settings::writeInt(Keys key, int value)
{
Q_ASSERT(m_keysToStrings.contains(key));
m_settings->setValue(m_keysToStrings.value(key), value);
}
QString Settings::readString(Keys key)
{
Q_ASSERT(m_keysToStrings.contains(key));
return m_settings->value(m_keysToStrings.value(key)).toString();
}
void Settings::writeString(Keys key, const QString& value)
{
Q_ASSERT(m_keysToStrings.contains(key));
m_settings->setValue(m_keysToStrings.value(key), value);
}