Add QGuiApplication::platformName.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Wed, 14 Mar 2012 13:51:19 +0000 (14:51 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 14 Mar 2012 17:35:25 +0000 (18:35 +0100)
Store the name of the QPA plugin as platformName.

Change-Id: Id87cab2a189743c0dd727c86080f7d4595a852bb
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/gui/kernel/qguiapplication.cpp
src/gui/kernel/qguiapplication.h
src/gui/kernel/qguiapplication_p.h

index 26690c7..77b69af 100644 (file)
@@ -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);
index 6fdbb00..cc7dea4 100644 (file)
@@ -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
index d9477a3..f30a2bb 100644 (file)
@@ -146,6 +146,7 @@ public:
 
     static QGuiApplicationPrivate *instance() { return self; }
 
+    static QString *platform_name;
     static bool app_do_modal;
 
     static Qt::MouseButtons buttons;