diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG index 8cf36bb9b..4a31f822d 100755 --- a/resources/text/CHANGELOG +++ b/resources/text/CHANGELOG @@ -2,6 +2,7 @@ ————— Changed: +▪ (Linux only) Primary user data/config storage is now undex $HOME/.config. XDG_CONFIG_HOME variable is respected. If old user data is detected, then old user data path is used. ▪ RSS Guard now uses "_" character as localization file names separator. (issue #75) ▪ Localizations are now placed in "translations" subfolder instead of "l10n" subfolder. (issue #75) @@ -505,4 +506,4 @@ Added: Changed: ▪ Added newly-compiled SQL libraries - MariaDB, Postgre SQL. -▪ Updated bundled OpenSSL libraries for Windows portable version. \ No newline at end of file +▪ Updated bundled OpenSSL libraries for Windows portable version. diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index b1c86de8a..aa104bc3b 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -186,6 +186,24 @@ void Application::setMainForm(FormMain *main_form) { m_mainForm = main_form; } +#if defined(Q_OS_LINUX) +QString Application::getXdgConfigHomePath() { + // TODO: Return ".config" folder on Linux. + // XDG_CONFIG_HOME + // Where user-specific configurations should be written (analogous to /etc). + // Should default to $HOME/.config. + + const QString xdgConfigHome = qgetenv("XDG_CONFIG_HOME"); + + if (xdgConfigHome.isEmpty()) { + return qgetenv("HOME") + QDir::separator() + ".config"; + } + else { + return xdgConfigHome; + } +} +#endif + QString Application::tempFolderPath() { return IOFactory::getSystemFolder(QStandardPaths::TempLocation); } diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h index 5695597c1..4b1cd6f5f 100755 --- a/src/miscellaneous/application.h +++ b/src/miscellaneous/application.h @@ -84,6 +84,10 @@ class Application : public QtSingleApplication { QString documentsFolderPath(); QString homeFolderPath(); +#if defined(Q_OS_LINUX) + QString getXdgConfigHomePath(); +#endif + void setMainForm(FormMain *main_form); void backupDatabaseSettings(bool backup_database, bool backup_settings, diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index 38d9bf2c6..aa3a48fbf 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -322,8 +322,21 @@ QString Settings::getAppPathUserFolder() { return qApp->applicationDirPath() + QDir::separator() + QSL("data"); } + + QString Settings::getHomeUserFolder() { +#if defined(Q_OS_LINUX) + QString home_folder = qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QSL("data"); + + if (QDir().exists(home_folder)) { + return home_folder; + } + else { + return qApp->getXdgConfigHomePath() + QDir::separator() + QString(APP_LOW_NAME); + } +#else return qApp->homeFolderPath() + QDir::separator() + QString(APP_LOW_H_NAME) + QDir::separator() + QSL("data"); +#endif } Settings *Settings::setupSettings(QObject *parent) {