QInputPanel exposed as a property from QDeclarativeApplication
Task-number: QTBUG-21449 Change-Id: I437f80f4d1f0dbb3cb410940213eae50a4cef2cd Reviewed-on: http://codereview.qt-project.org/5852 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
47e1b91b47
commit
ae271cbe78
|
@ -286,6 +286,13 @@ of their use.
|
|||
\o Qt.RightToLeft - Text and graphics elements should be positioned
|
||||
from right to left.
|
||||
\endlist
|
||||
|
||||
\row
|
||||
\o \c application.inputPanel
|
||||
\o
|
||||
This read-only property allows access to application's QInputPanel object
|
||||
and all its properties and slots. See the QInputPanel documentation for
|
||||
further details.
|
||||
\endtable
|
||||
|
||||
The following example uses the \c application object to indicate
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "qdeclarativeapplication_p.h"
|
||||
#include <private/qobject_p.h>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QInputPanel>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -82,6 +83,11 @@ Qt::LayoutDirection QDeclarativeApplication::layoutDirection() const
|
|||
return d->layoutDirection;
|
||||
}
|
||||
|
||||
QObject *QDeclarativeApplication::inputPanel() const
|
||||
{
|
||||
return qApp ? qApp->inputPanel() : 0;
|
||||
}
|
||||
|
||||
bool QDeclarativeApplication::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
Q_UNUSED(obj)
|
||||
|
|
|
@ -58,12 +58,14 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeApplication : public QObject
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(bool active READ active NOTIFY activeChanged)
|
||||
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged)
|
||||
Q_PROPERTY(QObject *inputPanel READ inputPanel CONSTANT)
|
||||
|
||||
public:
|
||||
explicit QDeclarativeApplication(QObject *parent = 0);
|
||||
virtual ~QDeclarativeApplication();
|
||||
bool active() const;
|
||||
Qt::LayoutDirection layoutDirection() const;
|
||||
QObject *inputPanel() const;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include "private/qdeclarativexmllistmodel_p.h"
|
||||
#endif
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtGui/QInputPanel>
|
||||
|
||||
void QDeclarativeUtilModule::registerBaseTypes(const char *uri, int versionMajor, int versionMinor)
|
||||
{
|
||||
|
@ -76,7 +77,7 @@ void QDeclarativeUtilModule::registerBaseTypes(const char *uri, int versionMajor
|
|||
void QDeclarativeUtilModule::defineModule()
|
||||
{
|
||||
qmlRegisterUncreatableType<QDeclarativeApplication>("QtQuick",2,0,"Application", QDeclarativeApplication::tr("Application is an abstract class"));
|
||||
|
||||
qmlRegisterUncreatableType<QInputPanel>("QtQuick",2,0,"InputPanel", QInputPanel::tr("InputPanel is an abstract class"));
|
||||
qmlRegisterUncreatableType<QDeclarativeAbstractAnimation>("QtQuick",2,0,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class"));
|
||||
|
||||
qmlRegisterType<QDeclarativeBehavior>("QtQuick",2,0,"Behavior");
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <QtDeclarative/qdeclarativeengine.h>
|
||||
#include <QtDeclarative/qsgitem.h>
|
||||
#include <QtDeclarative/qsgview.h>
|
||||
#include <QtGui/qinputpanel.h>
|
||||
|
||||
class tst_qdeclarativeapplication : public QObject
|
||||
{
|
||||
|
@ -55,6 +56,7 @@ public:
|
|||
private slots:
|
||||
void active();
|
||||
void layoutDirection();
|
||||
void inputPanel();
|
||||
|
||||
private:
|
||||
QDeclarativeEngine engine;
|
||||
|
@ -120,6 +122,19 @@ void tst_qdeclarativeapplication::layoutDirection()
|
|||
QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
|
||||
}
|
||||
|
||||
void tst_qdeclarativeapplication::inputPanel()
|
||||
{
|
||||
QDeclarativeComponent component(&engine);
|
||||
component.setData("import QtQuick 2.0; Item { property variant inputPanel: Qt.application.inputPanel }", QUrl::fromLocalFile(""));
|
||||
QSGItem *item = qobject_cast<QSGItem *>(component.create());
|
||||
QVERIFY(item);
|
||||
QSGView view;
|
||||
item->setParentItem(view.rootObject());
|
||||
|
||||
// check that the inputPanel property maches with application's input panel
|
||||
QCOMPARE(qvariant_cast<QObject*>(item->property("inputPanel")), qApp->inputPanel());
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qdeclarativeapplication)
|
||||
|
||||
#include "tst_qdeclarativeapplication.moc"
|
||||
|
|
Loading…
Reference in New Issue