-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappsettings.cpp
More file actions
60 lines (50 loc) · 1.47 KB
/
Copy pathappsettings.cpp
File metadata and controls
60 lines (50 loc) · 1.47 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
/***************************************************************************************************
*
* FILE: appsettings.cpp
*
* CREATED: 03-08-2010
*
* AUTHOR: Benjamin Caspari (becaspari@googlemail.com)
*
* PURPOSE: Sigleton class to store and load application wide settings
*
* Licensed under the GPL
*
***************************************************************************************************/
#include "appsettings.h"
#include <QCoreApplication>
#include <QDir>
#include <QStandardPaths>
#include <QDebug>
bool AppSettings::init()
{
QCoreApplication::setOrganizationName(DEF_ORGANIZATION);
QCoreApplication::setOrganizationDomain(DEF_ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationName(DEF_APPLICATION_NAME);
getInstance().m_settingsDirectory = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
QDir dir(getInstance().m_settingsDirectory);
if (!dir.mkpath(getInstance().m_settingsDirectory))
{
qCritical() << "Failed to create directory "
<< QDir::toNativeSeparators(getInstance().m_settingsDirectory);
return false;
}
else
{
qDebug() << "Using config directory "
<< QDir::toNativeSeparators(getInstance().m_settingsDirectory);
}
return true;
}
AppSettings &AppSettings::getInstance()
{
static AppSettings instance;
return instance;
}
AppSettings::AppSettings()
{
}
const QString &AppSettings::settingsDirectory()
{
return getInstance().m_settingsDirectory;
}