From 88ffab79cb4d03b56fe780652b8aa79310733030 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 5 Oct 2011 11:08:32 +0200 Subject: QtGui: Add command line arguments to the platform plugin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Oliver Wolff Reviewed-by: Samuel Rødal --- src/gui/kernel/qguiapplication.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/gui') 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 #include @@ -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); + } } } -- cgit v1.2.3