1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#include <QLibraryInfo>
30
QString Paths::app_path;
31
QString Paths::config_path;
33
void Paths::setAppPath(QString path) {
37
QString Paths::appPath() {
41
QString Paths::dataPath() {
43
QString path = QString(DATA_PATH);
53
QString Paths::translationPath() {
54
#ifdef TRANSLATION_PATH
55
QString path = QString(TRANSLATION_PATH);
59
return appPath() + "/translations";
61
return appPath() + "/translations";
65
QString Paths::docPath() {
67
QString path = QString(DOC_PATH);
71
return appPath() + "/docs";
73
return appPath() + "/docs";
77
QString Paths::themesPath() {
79
QString path = QString(THEMES_PATH);
83
return appPath() + "/themes";
85
return appPath() + "/themes";
89
QString Paths::shortcutsPath() {
91
QString path = QString(SHORTCUTS_PATH);
95
return appPath() + "/shortcuts";
97
return appPath() + "/shortcuts";
101
QString Paths::qtTranslationPath() {
102
return QLibraryInfo::location(QLibraryInfo::TranslationsPath);
105
QString Paths::doc(QString file, QString locale) {
106
if (locale.isEmpty()) {
107
locale = QLocale::system().name();
110
QString f = docPath() + "/" + locale + "/" + file;
111
qDebug("Helper:doc: checking '%s'", f.toUtf8().data());
112
if (QFile::exists(f)) return f;
114
if (locale.indexOf(QRegExp("_[A-Z]+")) != -1) {
115
locale.replace(QRegExp("_[A-Z]+"), "");
116
f = docPath() + "/" + locale + "/" + file;
117
qDebug("Helper:doc: checking '%s'", f.toUtf8().data());
118
if (QFile::exists(f)) return f;
121
f = docPath() + "/en/" + file;
125
void Paths::setConfigPath(QString path) {
129
QString Paths::configPath() {
130
if (!config_path.isEmpty()) {
137
const char * XDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME");
138
if (XDG_CONFIG_HOME!=NULL) {
139
qDebug("Paths::configPath: XDG_CONFIG_HOME: %s", XDG_CONFIG_HOME);
140
return QString(XDG_CONFIG_HOME) + "/smplayer";
143
return QDir::homePath() + "/.config/smplayer";
145
return QDir::homePath() + "/.smplayer";
151
QString Paths::iniPath() {
155
QString Paths::subtitleStyleFile() {
156
return configPath() + "/styles.ass";