summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2011-01-06 09:30:18 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2011-01-07 07:58:37 (GMT)
commite24d7c9cab4a50fe682478d43ac74e867666d48b (patch)
treec6f8d0213631db68178d6115a9c7cd7df833e958 /src/gui/kernel/qplatformintegrationfactory_qpa.cpp
parentcc8877068dc6ae8f3142ffec0b85f6fbac4a0d81 (diff)
downloadQt-e24d7c9cab4a50fe682478d43ac74e867666d48b.zip
Qt-e24d7c9cab4a50fe682478d43ac74e867666d48b.tar.gz
Qt-e24d7c9cab4a50fe682478d43ac74e867666d48b.tar.bz2
Lighthouse: Support external plugins.
Add -platformpluginpath command line option that spesifies an additional directory to scan for plugins. Also read QT_QPA_PLATFORM_PLUGIN_PATH. QlatformIntegrationFacgtory::create() now tries to load the plugin from the external path first. Similarly, keys() returns the keys from the extra path in addition to the "internal" keys API changes: QPlatformIntegration::create() and keys() now take an optional const QString &platformPluginPath. New file: externalplugin.pri, contains instructions and a base setup for building external plugins.
Diffstat (limited to 'src/gui/kernel/qplatformintegrationfactory_qpa.cpp')
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
index 9122e1a..17a130d 100644
--- a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
@@ -52,15 +52,27 @@ QT_BEGIN_NAMESPACE
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif
-QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key)
+QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
{
QPlatformIntegration *ret = 0;
QStringList paramList = key.split(QLatin1Char(':'));
QString platform = paramList.takeFirst().toLower();
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ // Try loading the plugin from platformPluginPath first:
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ if (QPlatformIntegrationFactoryInterface *factory =
+ qobject_cast<QPlatformIntegrationFactoryInterface*>(directLoader()->instance(platform)))
+ ret = factory->create(key, paramList);
+
+ if (ret)
+ return ret;
+ }
if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform)))
ret = factory->create(platform, paramList);
#endif
@@ -74,10 +86,19 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key)
\sa create()
*/
-QStringList QPlatformIntegrationFactory::keys()
+QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
{
#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- QStringList list = loader()->keys();
+ QStringList list;
+
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ foreach (const QString &key, directLoader()->keys()) {
+ list += key + QString(QLatin1String(" (from %1)")).arg(platformPluginPath);
+ }
+ }
+
+ list += loader()->keys();
#else
QStringList list;
#endif