diff options
Diffstat (limited to 'src/corelib/io/qstandardpaths_mac.cpp')
-rw-r--r-- | src/corelib/io/qstandardpaths_mac.cpp | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/src/corelib/io/qstandardpaths_mac.cpp b/src/corelib/io/qstandardpaths_mac.cpp index 2890ead48a..53dfdaa392 100644 --- a/src/corelib/io/qstandardpaths_mac.cpp +++ b/src/corelib/io/qstandardpaths_mac.cpp @@ -90,6 +90,13 @@ OSType translateLocation(QStandardPaths::StandardLocation type) } } +static bool qsp_testMode = false; + +void QStandardPaths::enableTestMode(bool testMode) +{ + qsp_testMode = testMode; +} + /* Constructs a full unicode path from a FSRef. */ @@ -101,6 +108,16 @@ static QString getFullPath(const FSRef &ref) return QString(); } +static void appendOrganizationAndApp(QString &path) +{ + const QString org = QCoreApplication::organizationName(); + if (!org.isEmpty()) + path += QLatin1Char('/') + org; + const QString appName = QCoreApplication::applicationName(); + if (!appName.isEmpty()) + path += QLatin1Char('/') + appName; +} + static QString macLocation(QStandardPaths::StandardLocation type, short domain) { // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html @@ -111,17 +128,36 @@ static QString macLocation(QStandardPaths::StandardLocation type, short domain) QString path = getFullPath(ref); - if (type == QStandardPaths::DataLocation || type == QStandardPaths::CacheLocation) { - if (!QCoreApplication::organizationName().isEmpty()) - path += QLatin1Char('/') + QCoreApplication::organizationName(); - if (!QCoreApplication::applicationName().isEmpty()) - path += QLatin1Char('/') + QCoreApplication::applicationName(); - } - return path; + if (type == QStandardPaths::DataLocation || type == QStandardPaths::CacheLocation) + appendOrganizationAndApp(path); + return path; } QString QStandardPaths::writableLocation(StandardLocation type) { + if (qsp_testMode) { + const QString qttestDir = QDir::homePath() + QLatin1String("/.qttest"); + QString path; + switch (type) { + case GenericDataLocation: + case DataLocation: + path = qttestDir + QLatin1String("/Application Support"); + if (type == DataLocation) + appendOrganizationAndApp(path); + return path; + case GenericCacheLocation: + case CacheLocation: + path = qttestDir + QLatin1String("/Cache"); + if (type == CacheLocation) + appendOrganizationAndApp(path); + return path; + case ConfigLocation: + return qttestDir + QLatin1String("/Preferences"); + default: + break; + } + } + switch (type) { case HomeLocation: return QDir::homePath(); |