From 28f92d37842ef087ab4f35ae7018b6366d0044e9 Mon Sep 17 00:00:00 2001 From: Arttu Tarkiainen Date: Fri, 28 Jun 2019 13:13:28 +0300 Subject: Change ApplicationsDir variable on macOS to return "/Applications" QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation) first element returns $HOME/Applications, as being user writable it has a higher priority. Change the variable to return system wide /Applications as it is a more expected default. Add the user-specific applications directory as its own variable, and make associated documentation changes. Task-number: QTIFW-1011 Change-Id: Ia81a1f5dafdea8665d5f9fc1df3799e59858e5aa Reviewed-by: Katja Marttila --- doc/scripting.qdoc | 6 ++++++ src/libs/installer/packagemanagercoredata.cpp | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/scripting.qdoc b/doc/scripting.qdoc index 708345c7d..e7e398c61 100644 --- a/doc/scripting.qdoc +++ b/doc/scripting.qdoc @@ -269,6 +269,12 @@ See also the table that lists examples of \l {Applications-directory-on-Windows} {applications directories on Windows}. + \row + \li ApplicationsDirUser + \li Applications directory for user-specific programs. This is useful on macOS, + on other platforms it is the same as \c ApplicationsDir. + + For example, \c {$HOME/Applications} on macOS. \row \li ApplicationsDirX86 \li Applications Directory for 32 bit programs. This is useful on Windows, diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp index ebacbf938..41c6f111c 100644 --- a/src/libs/installer/packagemanagercoredata.cpp +++ b/src/libs/installer/packagemanagercoredata.cpp @@ -111,10 +111,18 @@ void PackageManagerCoreData::setDynamicPredefinedVariables() SHGetFolderPath(nullptr, CSIDL_PROGRAM_FILES, nullptr, 0, buffer); dir = QString::fromWCharArray(buffer); #elif defined (Q_OS_OSX) - dir = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(0); + dir = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(1); + if (dir.isEmpty()) + dir = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(0); #endif m_variables.insert(QLatin1String("ApplicationsDir"), dir); + QString dirUser = dir; +#ifdef Q_OS_MACOS + dirUser = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).value(0); +#endif + m_variables.insert(QLatin1String("ApplicationsDirUser"), dirUser); + QString dirX86 = dir; QString dirX64 = dir; #ifdef Q_OS_WIN -- cgit v1.2.3