Linux-specific: Optionally use XDG_CONFIG_HOME for config in Qt5 build

This commit is contained in:
fenuks 2021-11-01 11:20:15 +01:00 committed by Abs62
parent 5de5f18f48
commit f6742d8fb4

View file

@ -52,6 +52,14 @@ namespace
result = QDir::fromNativeSeparators( QString::fromWCharArray( _wgetenv( L"APPDATA" ) ) ); result = QDir::fromNativeSeparators( QString::fromWCharArray( _wgetenv( L"APPDATA" ) ) );
#else #else
char const * pathInHome = ".goldendict"; char const * pathInHome = ".goldendict";
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) && defined( HAVE_X11 )
// check if an old config dir is present, otherwise use standards-compliant location
if ( !result.exists( pathInHome ) )
{
result.setPath( QStandardPaths::writableLocation( QStandardPaths::ConfigLocation ) );
pathInHome = "goldendict";
}
#endif
#endif #endif
result.mkpath( pathInHome ); result.mkpath( pathInHome );