Update Application.cpp, Settings.cpp, and Settings.h

This commit is contained in:
Martin Marmsoler 2023-02-17 16:11:06 +01:00
parent 9227b8af82
commit e37ad4f1b7
3 changed files with 20 additions and 14 deletions

View File

@ -102,6 +102,7 @@ Application::Application(int &argc, char **argv, bool haltOnParseError)
// Register types that are queued at runtime.
qRegisterMetaType<git::Id>();
qDebug() << QString("Root dir: %1").arg(Settings::rootDir().absolutePath());
qDebug() << QString("App dir: %1").arg(Settings::appDir().absolutePath());
qDebug() << QString("Doc dir: %1").arg(Settings::docDir().absolutePath());
qDebug() << QString("Conf dir: %1").arg(Settings::confDir().absolutePath());

View File

@ -45,14 +45,6 @@ QVariant lookup(const QVariantMap &root, const QString &key) {
}
QString promptKey(Prompt::Kind kind) { return Prompt::key(kind); }
QDir rootDir() {
QDir dir(QCoreApplication::applicationDirPath());
dir.cdUp();
return dir;
}
} // namespace
Settings::Settings(QObject *parent) : QObject(parent) {
@ -204,6 +196,13 @@ void Settings::setLastPath(const QString &lastPath) {
setValue(kLastPathKey, lastPath);
}
QDir Settings::rootDir() {
QDir dir(QCoreApplication::applicationDirPath());
dir.cdUp();
return dir;
}
QDir Settings::appDir() {
QDir dir(QCoreApplication::applicationDirPath());
@ -224,8 +223,9 @@ QDir Settings::confDir() {
QDir dir(SRC_CONF_DIR);
#else
QDir dir = rootDir();
if (!dir.cd("Gittyup"))
dir = QDir(CONF_DIR);
if (!dir.cd("Gittyup")) {
dir.cd(CONF_DIR);
}
#endif
return dir;
}
@ -235,8 +235,10 @@ QDir Settings::l10nDir() {
QDir dir = QDir(SRC_L10N_DIR);
#else
QDir dir = confDir();
if (!dir.cd("l10n"))
dir = QDir(L10N_DIR); // For debugging search in source dir
if (!dir.cd("l10n")) {
dir = rootDir();
dir.cd(L10N_DIR);
}
#endif
return dir;
}
@ -252,8 +254,10 @@ QDir Settings::lexerDir() {
QDir dir(SRC_SCINTILLUA_LEXERS_DIR);
#else
QDir dir = confDir();
if (!dir.cd("lexers"))
dir = QDir(SCINTILLUA_LEXERS_DIR);
if (!dir.cd("lexers")) {
dir = rootDir();
dir.cd(SCINTILLUA_LEXERS_DIR);
}
#endif
return dir;
}

View File

@ -45,6 +45,7 @@ public:
void setLastPath(const QString &lastPath);
// settings directories
static QDir rootDir();
static QDir appDir();
static QDir docDir();
static QDir confDir();