summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-10-05 11:08:32 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-05 18:25:09 +0200
commit88ffab79cb4d03b56fe780652b8aa79310733030 (patch)
tree4ec329c76e856bf0a14bf2213366e8130ec67b06 /src/gui
parenta4a94544f27a66ea1189a3a5927ed2dafc28f88c (diff)
QtGui: Add command line arguments to the platform plugin.
Set -platformargument foo[=bar] as a dynamic property on the native interface. Change-Id: Ica8b25478da0ce9508b90370f15812fd11ff5d13 Reviewed-on: http://codereview.qt-project.org/6031 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qguiapplication.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 986fc5c11d..ee923ba095 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -47,6 +47,7 @@
#include "qfont.h"
#include "qplatformfontdatabase_qpa.h"
#include "qplatformwindow_qpa.h"
+#include "qplatformnativeinterface_qpa.h"
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/private/qcoreapplication_p.h>
@@ -218,8 +219,19 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
}
-static void init_platform(QString name, const QString &platformPluginPath)
+static void init_platform(const QString &pluginArgument, const QString &platformPluginPath)
{
+ // Split into platform name and arguments
+ QString name;
+ QStringList arguments;
+ foreach (const QString &token, pluginArgument.split(QLatin1Char(':'))) {
+ if (name.isEmpty()) {
+ name = token;
+ } else {
+ arguments.push_back(token);
+ }
+ }
+
if (name.isEmpty()) {
const QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
#if defined(Q_OS_MAC)
@@ -248,6 +260,20 @@ static void init_platform(QString name, const QString &platformPluginPath)
fatalMessage.append(key + QLatin1Char('\n'));
}
qFatal("%s", fatalMessage.toLocal8Bit().constData());
+ return;
+ }
+ // Set arguments as dynamic properties on the native interface as
+ // boolean 'foo' or strings: 'foo=bar'
+ if (!arguments.isEmpty()) {
+ QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface();
+ foreach (const QString &argument, arguments) {
+ const int equalsPos = argument.indexOf(QLatin1Char('='));
+ const QByteArray name =
+ equalsPos != -1 ? argument.left(equalsPos).toAscii() : argument.toAscii();
+ const QVariant value =
+ equalsPos != -1 ? QVariant(argument.mid(equalsPos + 1)) : QVariant(true);
+ nativeInterface->setProperty(name.constData(), value);
+ }
}
}