From 259332e6553f01d438fdff56e22c37eaeb3920e3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 14 Mar 2012 14:51:19 +0100 Subject: [PATCH] Add QGuiApplication::platformName. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store the name of the QPA plugin as platformName. Change-Id: Id87cab2a189743c0dd727c86080f7d4595a852bb Reviewed-by: Samuel Rødal --- src/gui/kernel/qguiapplication.cpp | 19 ++++++++++++++++++- src/gui/kernel/qguiapplication.h | 4 +++- src/gui/kernel/qguiapplication_p.h | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 26690c78cf..77b69af3eb 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -110,6 +110,7 @@ enum ApplicationResourceFlags static unsigned applicationResourceFlags = 0; +QString *QGuiApplicationPrivate::platform_name = 0; bool QGuiApplicationPrivate::app_do_modal = false; QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette @@ -361,6 +362,9 @@ QGuiApplication::~QGuiApplication() #ifndef QT_NO_CURSOR d->cursor_list.clear(); #endif + + delete QGuiApplicationPrivate::platform_name; + QGuiApplicationPrivate::platform_name = 0; } QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) @@ -470,6 +474,17 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos) return 0; } +/*! + \property QGuiApplication::platformName + \brief The name of the underlying platform plugin. + \since 5.0 +*/ + +QString QGuiApplication::platformName() +{ + return QGuiApplicationPrivate::platform_name ? + *QGuiApplicationPrivate::platform_name : QString(); +} static void init_platform(const QString &pluginArgument, const QString &platformPluginPath) { @@ -509,7 +524,9 @@ static void init_platform(const QString &pluginArgument, const QString &platform // Create the platform integration. QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath); - if (!QGuiApplicationPrivate::platform_integration) { + if (QGuiApplicationPrivate::platform_integration) { + QGuiApplicationPrivate::platform_name = new QString(name); + } else { QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); QString fatalMessage = QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name); diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h index 6fdbb000fe..cc7dea422f 100644 --- a/src/gui/kernel/qguiapplication.h +++ b/src/gui/kernel/qguiapplication.h @@ -75,7 +75,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication { Q_OBJECT Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection) - + Q_PROPERTY(QString platformName READ platformName STORED false) Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed) public: @@ -86,6 +86,8 @@ public: static QWindowList topLevelWindows(); static QWindow *topLevelAt(const QPoint &pos); + static QString platformName(); + #ifdef QT_DEPRECATED static QT_DEPRECATED QWindow *activeWindow() { return focusWindow(); } #endif diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index d9477a3e9e..f30a2bb5a0 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -146,6 +146,7 @@ public: static QGuiApplicationPrivate *instance() { return self; } + static QString *platform_name; static bool app_do_modal; static Qt::MouseButtons buttons;