Allow QStandardPaths (Mac, Windows, Unix) to be bootstrapped

This allows using QStandardPaths in one of the bootstrapped tools, if
required for a future need.

The Blackberry version appears to be usable in bootstrapped mode
already.

Change-Id: Ia4e9b9564395d2e151f8ac229ac2a2aa2982e92f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: David Faure (KDE) <faure@kde.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Thiago Macieira 2012-10-26 13:13:03 -07:00 committed by The Qt Project
parent 300534fc21
commit a025a2fcfa
4 changed files with 30 additions and 2 deletions

View File

@ -44,8 +44,11 @@
#include <qdir.h>
#include <qfileinfo.h>
#include <qhash.h>
#ifndef QT_BOOTSTRAPPED
#include <qobject.h>
#include <qcoreapplication.h>
#endif
#ifndef QT_NO_STANDARDPATHS
@ -300,7 +303,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
an empty QString if no relevant location can be found.
*/
#ifndef Q_OS_MAC
#if !defined(Q_OS_MAC) && !defined(QT_BOOTSTRAPPED)
QString QStandardPaths::displayName(StandardLocation type)
{
switch (type) {

View File

@ -42,7 +42,10 @@
#include "qstandardpaths.h"
#include <qdir.h>
#include <private/qcore_mac_p.h>
#ifndef QT_BOOTSTRAPPED
#include <qcoreapplication.h>
#endif
#include <ApplicationServices/ApplicationServices.h>
@ -101,12 +104,16 @@ static QString getFullPath(const FSRef &ref)
static void appendOrganizationAndApp(QString &path)
{
#ifndef QT_BOOTSTRAPPED
const QString org = QCoreApplication::organizationName();
if (!org.isEmpty())
path += QLatin1Char('/') + org;
const QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty())
path += QLatin1Char('/') + appName;
#else
Q_UNUSED(path);
#endif
}
static QString macLocation(QStandardPaths::StandardLocation type, short domain)
@ -180,6 +187,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
return dirs;
}
#ifndef QT_BOOTSTRAPPED
QString QStandardPaths::displayName(StandardLocation type)
{
if (QStandardPaths::HomeLocation == type)
@ -197,5 +205,6 @@ QString QStandardPaths::displayName(StandardLocation type)
return static_cast<QString>(displayName);
}
#endif
QT_END_NAMESPACE

View File

@ -44,23 +44,30 @@
#include <qfile.h>
#include <qhash.h>
#include <qtextstream.h>
#include <qcoreapplication.h>
#include <private/qfilesystemengine_p.h>
#include <errno.h>
#include <stdlib.h>
#ifndef QT_BOOTSTRAPPED
#include <qcoreapplication.h>
#endif
#ifndef QT_NO_STANDARDPATHS
QT_BEGIN_NAMESPACE
static void appendOrganizationAndApp(QString &path)
{
#ifndef QT_BOOTSTRAPPED
const QString org = QCoreApplication::organizationName();
if (!org.isEmpty())
path += QLatin1Char('/') + org;
const QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty())
path += QLatin1Char('/') + appName;
#else
Q_UNUSED(path);
#endif
}
QString QStandardPaths::writableLocation(StandardLocation type)
@ -141,6 +148,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
break;
}
#ifndef QT_BOOTSTRAPPED
// http://www.freedesktop.org/wiki/Software/xdg-user-dirs
QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
if (xdgConfigHome.isEmpty())
@ -199,6 +207,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
}
}
}
#endif
QString path;
switch (type) {

View File

@ -44,7 +44,10 @@
#include <qdir.h>
#include <private/qsystemlibrary_p.h>
#include <qstringlist.h>
#ifndef QT_BOOTSTRAPPED
#include <qcoreapplication.h>
#endif
#include <qt_windows.h>
#include <shlobj.h>
@ -107,12 +110,14 @@ QString QStandardPaths::writableLocation(StandardLocation type)
result = convertCharArray(path);
if (isTestModeEnabled())
result += QLatin1String("/qttest");
#ifndef QT_BOOTSTRAPPED
if (type != GenericDataLocation) {
if (!QCoreApplication::organizationName().isEmpty())
result += QLatin1Char('/') + QCoreApplication::organizationName();
if (!QCoreApplication::applicationName().isEmpty())
result += QLatin1Char('/') + QCoreApplication::applicationName();
}
#endif
break;
case DesktopLocation:
@ -189,10 +194,12 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
if (SHGetSpecialFolderPath(0, path, CSIDL_COMMON_APPDATA, FALSE)) {
QString result = convertCharArray(path);
if (type != GenericDataLocation) {
#ifndef QT_BOOTSTRAPPED
if (!QCoreApplication::organizationName().isEmpty())
result += QLatin1Char('/') + QCoreApplication::organizationName();
if (!QCoreApplication::applicationName().isEmpty())
result += QLatin1Char('/') + QCoreApplication::applicationName();
#endif
}
dirs.append(result);
}