Add QGuiApplication::platformName.

Store the name of the QPA plugin as platformName.

Change-Id: Id87cab2a189743c0dd727c86080f7d4595a852bb
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-03-14 14:51:19 +01:00 committed by Qt by Nokia
parent 7f09f36873
commit 259332e655
3 changed files with 22 additions and 2 deletions

View 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);

View 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

View File

@ -146,6 +146,7 @@ public:
static QGuiApplicationPrivate *instance() { return self; }
static QString *platform_name;
static bool app_do_modal;
static Qt::MouseButtons buttons;