-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppConfiguration.cpp
48 lines (41 loc) · 1.36 KB
/
AppConfiguration.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
40
41
42
43
44
45
46
47
48
#include "AppConfiguration.hpp"
#include <QApplication>
#include <QSettings>
#ifdef __ANDROID__
#include <QStandardPaths>
#endif
//----------------------------------------------------------------------------------------------
AppConfiguration::AppConfiguration(QObject* a_Parent)
: QObject(a_Parent)
{ }
#ifdef __ANDROID__
//----------------------------------------------------------------------------------------------
void AppConfiguration::setupData()
{ // under Android (and probably iOSx and Windows Phone), we need to set that location automatically
m_DataDir = QStandardPaths::standardLocations(QStandardPaths::HomeLocation)[0];
}
#else
//----------------------------------------------------------------------------------------------
void AppConfiguration::setupData()
{
QSettings settings;
settings.beginGroup("Data");
m_DataDir = settings.value("DataDir").toString();
settings.endGroup();
}
#endif
//----------------------------------------------------------------------------------------------
void AppConfiguration::setup()
{
setupData();
}
//----------------------------------------------------------------------------------------------
void AppConfiguration::setDataDir(const QUrl& a_Value)
{
m_DataDir = a_Value;
emit dataDirChanged();
QSettings settings;
settings.beginGroup("Data");
settings.setValue("DataDir", m_DataDir);
settings.endGroup();
}