-
Notifications
You must be signed in to change notification settings - Fork 1
/
prefs.cc
66 lines (48 loc) · 1.33 KB
/
prefs.cc
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
#include "prefs.hh"
#include "str.hxx"
#include <QStandardPaths>
#include "io/io.hh"
namespace cornus::prefs {
QString GetBookmarksFileName() {
static const QString s = prefs::BookmarksFileName
+ QString::number(prefs::BookmarksFormatVersion);
return s;
}
QString GetBookmarksFilePath()
{
return prefs::QueryAppConfigPath() + '/' + GetBookmarksFileName();
}
QString GetMediaFilePath() {
QString dir = QueryAppConfigPath();
if (!dir.endsWith('/'))
dir.append('/');
return dir + str::MediaDirName;
}
QString QueryAppConfigPath()
{
static QString dir_path = QString();
if (!dir_path.isEmpty())
return dir_path;
QString config_path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
if (!config_path.endsWith('/'))
config_path.append('/');
if (!io::EnsureDir(config_path, prefs::AppConfigName))
return QString();
dir_path = config_path + prefs::AppConfigName;
return dir_path;
}
QString QueryMimeConfigDirPath()
{
static QString dir_path = QString();
if (!dir_path.isEmpty())
return dir_path;
QString config_path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
if (!config_path.endsWith('/'))
config_path.append('/');
if (!io::EnsureDir(config_path, prefs::MimeConfigDir)) {
return QString();
}
dir_path = config_path + prefs::MimeConfigDir;
return dir_path;
}
}