forked from 2600hz/kazoo-popup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.cpp
47 lines (39 loc) · 1.06 KB
/
defaults.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
#include "defaults.h"
#include <QString>
#include <QStandardPaths>
#include <QApplication>
#include <QDir>
#ifdef Q_OS_MAC
# include <QProcess>
#endif
static const char * const kLogsDirName = "logs";
QString dataDirPath()
{
QString appDirPath("%1/%2");
appDirPath = appDirPath.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation),
qApp->applicationName());
QDir appDir(appDirPath);
if (!appDir.exists())
appDir.mkpath(appDirPath);
#ifdef Q_OS_MAC
if (!appDir.exists("settings.ini"))
QProcess::startDetached("sh", QStringList() << "-c" << "cp '" + qApp->applicationDirPath() + "/settings.ini' '" + appDirPath + "/settings.ini'");
#endif
return appDirPath;
}
QString logsDirPath()
{
QString path = dataDirPath();
QDir dataDir(path);
if (!dataDir.exists(kLogsDirName))
dataDir.mkdir(kLogsDirName);
return QString("%1/%2/").arg(path, kLogsDirName);
}
QString detectPlatform()
{
#ifdef Q_OS_WIN
return "win";
#elif defined Q_OS_MAC
return "mac";
#endif
}