chore: only enable portable mode support for windows

This commit is contained in:
Gary Wang 2020-08-10 23:41:59 +08:00
parent f3b3ad7b8a
commit 3b94eecde2
2 changed files with 6 additions and 0 deletions

View File

@ -71,6 +71,10 @@ if (WIN32)
TARGET ${EXE_NAME}
PROPERTY WIN32_EXECUTABLE true
)
target_compile_definitions(${EXE_NAME} PRIVATE
FLAG_PORTABLE_MODE_SUPPORT=1
)
endif ()
# Helper macros for install settings

View File

@ -67,12 +67,14 @@ Settings::Settings()
{
QString configPath;
#ifdef FLAG_PORTABLE_MODE_SUPPORT
QString portableConfigDirPath = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("data");
QFileInfo portableConfigDirInfo(portableConfigDirPath);
if (portableConfigDirInfo.exists() && portableConfigDirInfo.isDir() && portableConfigDirInfo.isWritable()) {
// we can use it.
configPath = portableConfigDirPath;
}
#endif // FLAG_PORTABLE_MODE_SUPPORT
// %LOCALAPPDATA% under Windows.
if (configPath.isEmpty()) {