summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-07-21 02:23:15 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-07-26 07:08:07 (GMT)
commit056bbc32fd64f48851e6ad058c5e4c1372a96564 (patch)
treea76fc7d01d913e371c949d839d40d3f394960d55
parentacebca36dc84677bb0875297b1739e15025323bb (diff)
downloadQt-056bbc32fd64f48851e6ad058c5e4c1372a96564.zip
Qt-056bbc32fd64f48851e6ad058c5e4c1372a96564.tar.gz
Qt-056bbc32fd64f48851e6ad058c5e4c1372a96564.tar.bz2
QML focus API updates.
The wantsFocus property has been renamed to activeFocus, to better reflect its value. Reading and writing the focus property is also now consistent -- this property represents focus within a scope. Other small changes were made to keep things consistent with the new naming. Reviewed-by: Aaron Kennedy (cherry picked from commit 21806ff0921641b4e4d9d39721ab4ebeae74dddc)
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml2
-rw-r--r--demos/declarative/twitter/TwitterCore/Button.qml2
-rw-r--r--demos/declarative/webbrowser/content/UrlInput.qml2
-rw-r--r--doc/src/declarative/focus.qdoc8
-rw-r--r--examples/declarative/keyinteraction/focus/Core/GridMenu.qml6
-rw-r--r--examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml4
-rw-r--r--examples/declarative/keyinteraction/focus/Core/ListViews.qml8
-rw-r--r--examples/declarative/keyinteraction/focus/focus.qml4
-rw-r--r--examples/declarative/toys/dynamicscene/dynamicscene.qml1
-rw-r--r--src/declarative/QmlChanges.txt7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp95
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h8
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h9
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp42
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h4
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp44
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp12
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h1
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/chain.qml10
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml22
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test.qml14
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test2.qml10
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test3.qml2
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test4.qml14
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/data/test5.qml10
-rw-r--r--tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp131
-rw-r--r--tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp28
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml2
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp28
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp40
32 files changed, 330 insertions, 246 deletions
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
index 6109535..568666e 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
+++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -77,6 +77,6 @@ Item {
MouseArea {
anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 }
- onClicked: { textInput.forceFocus(); textInput.openSoftwareInputPanel(); }
+ onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); }
}
}
diff --git a/demos/declarative/twitter/TwitterCore/Button.qml b/demos/declarative/twitter/TwitterCore/Button.qml
index 9c90c2c..d326c64 100644
--- a/demos/declarative/twitter/TwitterCore/Button.qml
+++ b/demos/declarative/twitter/TwitterCore/Button.qml
@@ -80,7 +80,7 @@ Item {
},
State {
name: "Focused"
- when: container.focus == true
+ when: container.activeFocus == true
PropertyChanges { target: btnText; color: "#FFFFFF" }
}
]
diff --git a/demos/declarative/webbrowser/content/UrlInput.qml b/demos/declarative/webbrowser/content/UrlInput.qml
index 9992456..4f49821 100644
--- a/demos/declarative/webbrowser/content/UrlInput.qml
+++ b/demos/declarative/webbrowser/content/UrlInput.qml
@@ -69,7 +69,7 @@ Item {
TextInput {
id: urlText
horizontalAlignment: TextEdit.AlignLeft
- font.pixelSize: 14; focusOnPress: true
+ font.pixelSize: 14;
onTextChanged: container.urlChanged()
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index cc546c0..661930f 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -73,12 +73,12 @@ See also the \l {Keys}{Keys attached property} and \l {KeyNavigation}{KeyNavigat
\section1 Querying the Active Focus Item
Whether or not an \l Item has \e {active focus} can be queried through the
-property \c {Item::focus}. For example, here we have a \l Text
+property \c {Item::activeFocus}. For example, here we have a \l Text
element whose text is determined by whether or not it has \e {active focus}.
\code
Text {
- text: focus ? "I have active focus!" : "I do not have active focus"
+ text: activeFocus ? "I have active focus!" : "I do not have active focus"
}
\endcode
@@ -174,7 +174,7 @@ Rectangle {
The right hand side of the example shows the expanded code - the equivalent QML
without the use of the component \c {MyWidget}. From this, the problem is
evident - there are no less than three elements that have the \c {Item::focus}
-property set to true. Ultimately only one element can have focus, and the
+property set to true. Ultimately only one element can have keyboard focus, and the
system has to decide which on. In this case the first appearance of the
\c {Item::focus} property being set to true on line 4 is selected, and the value
of \c {Item::focus} in the other two instances is reverted back to false. This
@@ -233,7 +233,7 @@ and the others are unset, just like when there are no \e {focus scopes}.
\o When a \e {focus scope} receives \e {active focus}, the contained element with
\c {Item::focus} set (if any) also gets \e {active focus}. If this element is
also a \l FocusScope, the proxying behaviour continues. Both the
-\e {focus scope} and the sub-focused item will have \c {Item::focus} set.
+\e {focus scope} and the sub-focused item will have \c {Item::activeFocus} set.
\endlist
So far the example has the second component statically selected. It is trivial
diff --git a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
index 9a8d3f3..19f7235 100644
--- a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
+++ b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
@@ -43,7 +43,7 @@ import Qt 4.7
FocusScope {
property alias interactive: gridView.interactive
- onWantsFocusChanged: if (wantsFocus) mainView.state = ""
+ onActiveFocusChanged: if (activeFocus) mainView.state = ""
Rectangle {
anchors.fill: parent
@@ -84,12 +84,12 @@ FocusScope {
onClicked: {
GridView.view.currentIndex = index
- container.forceFocus()
+ container.forceActiveFocus()
}
}
states: State {
- name: "active"; when: container.focus == true
+ name: "active"; when: container.activeFocus
PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
}
diff --git a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
index cc13637..602b52b 100644
--- a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
+++ b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
@@ -69,12 +69,12 @@ Item {
onClicked: {
ListView.view.currentIndex = index
- container.forceFocus()
+ container.forceActiveFocus()
}
}
states: State {
- name: "active"; when: container.focus == true
+ name: "active"; when: container.activeFocus
PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
PropertyChanges { target: label; font.pixelSize: 16 }
}
diff --git a/examples/declarative/keyinteraction/focus/Core/ListViews.qml b/examples/declarative/keyinteraction/focus/Core/ListViews.qml
index 6f9ceb4..3d6ceab 100644
--- a/examples/declarative/keyinteraction/focus/Core/ListViews.qml
+++ b/examples/declarative/keyinteraction/focus/Core/ListViews.qml
@@ -43,11 +43,11 @@ import Qt 4.7
FocusScope {
clip: true
- onWantsFocusChanged: if (wantsFocus) mainView.state = "showListViews"
+ onActiveFocusChanged: if (activeFocus) mainView.state = "showListViews"
ListView {
id: list1
- y: wantsFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20
+ y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20
focus: true
KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2
model: 10; cacheBuffer: 200
@@ -60,7 +60,7 @@ FocusScope {
ListView {
id: list2
- y: wantsFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20
+ y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20
KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
model: 10; cacheBuffer: 200
delegate: ListViewDelegate {}
@@ -72,7 +72,7 @@ FocusScope {
ListView {
id: list3
- y: wantsFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20
+ y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20
KeyNavigation.up: gridMenu; KeyNavigation.left: list2
model: 10; cacheBuffer: 200
delegate: ListViewDelegate {}
diff --git a/examples/declarative/keyinteraction/focus/focus.qml b/examples/declarative/keyinteraction/focus/focus.qml
index 8b2af70..56fdffc 100644
--- a/examples/declarative/keyinteraction/focus/focus.qml
+++ b/examples/declarative/keyinteraction/focus/focus.qml
@@ -58,7 +58,7 @@ Rectangle {
width: parent.width; height: 320
focus: true
- interactive: parent.wantsFocus
+ interactive: parent.activeFocus
}
ListViews {
@@ -98,7 +98,7 @@ Rectangle {
states: State {
name: "contextMenuOpen"
- when: !mainView.wantsFocus
+ when: !mainView.activeFocus
PropertyChanges { target: contextMenu; x: 0; open: true }
PropertyChanges { target: mainView; x: 130 }
PropertyChanges { target: shade; opacity: 0.25 }
diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml
index 1edb841..2a22a5f 100644
--- a/examples/declarative/toys/dynamicscene/dynamicscene.qml
+++ b/examples/declarative/toys/dynamicscene/dynamicscene.qml
@@ -184,7 +184,6 @@ Item {
id: qmlText
anchors.fill: parent; anchors.margins: 5
readOnly: false
- focusOnPress: true
font.pixelSize: 14
wrapMode: TextEdit.WordWrap
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 6a2537b..6e07330 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -5,6 +5,13 @@ TextInput
- copy(), cut() and paste() functions added
Font.letterSpacing
- was percentage based. Now specified in pixels.
+Item
+ - wantsFocus renamed to activeFocus
+ - forceFocus() renamed to forceActiveFocus()
+ - focus now returns the scoped focus (i.e. focus read/write now manipulate
+ the same value)
+TextInput and TextEdit:
+ - focusOnPress renamed to activeFocusOnPress
=============================================================================
The changes below are pre Qt 4.7.0 beta 2
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index a229d4c..23735f2 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1430,7 +1430,7 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec
*/
/*!
- \fn void QDeclarativeItem::wantsFocusChanged(bool)
+ \fn void QDeclarativeItem::activeFocusChanged(bool)
\internal
*/
@@ -2356,12 +2356,12 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea
}
/*!
- \qmlmethod Item::forceFocus()
+ \qmlmethod Item::forceActiveFocus()
- Force the focus on the item.
- This method sets the focus on the item and makes sure that all the focus scopes higher in the object hierarchy are given focus.
+ Force active focus on the item.
+ This method sets focus on the item and makes sure that all the focus scopes higher in the object hierarchy are also given focus.
*/
-void QDeclarativeItem::forceFocus()
+void QDeclarativeItem::forceActiveFocus()
{
setFocus(true);
QGraphicsItem *parent = parentItem();
@@ -2398,8 +2398,19 @@ void QDeclarativeItemPrivate::focusChanged(bool flag)
{
Q_Q(QDeclarativeItem);
if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent)
- emit q->wantsFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange()
- emit q->focusChanged(flag);
+ emit q->activeFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange()
+
+ bool inScope = false;
+ QGraphicsItem *p = parent;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ inScope = true;
+ break;
+ }
+ p = p->parentItem();
+ }
+ if (!inScope)
+ emit q->focusChanged(flag);
}
/*! \internal */
@@ -2676,7 +2687,7 @@ bool QDeclarativeItem::sceneEvent(QEvent *event)
if (event->type() == QEvent::FocusIn ||
event->type() == QEvent::FocusOut) {
- d->focusChanged(hasFocus());
+ d->focusChanged(hasActiveFocus());
}
return rv;
}
@@ -3090,15 +3101,32 @@ void QDeclarativeItem::setSize(const QSizeF &size)
}
/*!
- \qmlproperty bool Item::wantsFocus
+ \qmlproperty bool Item::activeFocus
+
+ This property indicates whether the item has active focus.
+
+ An item with active focus will receive keyboard input,
+ or is a FocusScope ancestor of the item that will receive keyboard input.
- This property indicates whether the item has has an active focus request.
+ Usually, activeFocus is gained by setting focus on an item and its enclosing
+ FocusScopes. In the following example \c input will have activeFocus.
+ \qml
+ Rectangle {
+ FocusScope {
+ focus: true
+ TextInput {
+ id: input
+ focus: true
+ }
+ }
+ }
+ \endqml
- \sa {qmlfocus}{Keyboard Focus}
+ \sa focus, {qmlfocus}{Keyboard Focus}
*/
/*! \internal */
-bool QDeclarativeItem::wantsFocus() const
+bool QDeclarativeItem::hasActiveFocus() const
{
Q_D(const QDeclarativeItem);
return focusItem() == this ||
@@ -3108,16 +3136,51 @@ bool QDeclarativeItem::wantsFocus() const
/*!
\qmlproperty bool Item::focus
- This property indicates whether the item has keyboard input focus. Set this
- property to true to request focus.
+ This property indicates whether the item has focus within the enclosing focus scope. If true, this item
+ will gain active focus when the enclosing focus scope gains active focus.
+ In the following example, \c input will be given active focus when \c scope gains active focus.
+ \qml
+ Rectangle {
+ FocusScope {
+ id: scope
+ TextInput {
+ id: input
+ focus: true
+ }
+ }
+ }
+ \endqml
- \sa {qmlfocus}{Keyboard Focus}
+ For the purposes of this property, the top level item in the scene
+ is assumed to act like a focus scope, and to always have active focus
+ when the scene has focus. On a practical level, that means the following
+ QML will give active focus to \c input on startup.
+
+ \qml
+ Rectangle {
+ TextInput {
+ id: input
+ focus: true
+ }
+ }
+ \endqml
+
+ \sa activeFocus, {qmlfocus}{Keyboard Focus}
*/
/*! \internal */
bool QDeclarativeItem::hasFocus() const
{
- return QGraphicsItem::hasFocus();
+ Q_D(const QDeclarativeItem);
+ QGraphicsItem *p = d->parent;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ return p->focusScopeItem() == this;
+ }
+ p = p->parentItem();
+ }
+
+ return hasActiveFocus() ? true : (!QGraphicsItem::parentItem() ? true : false);
}
/*! \internal */
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 8878fa0..cd9b910 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -87,7 +87,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe
Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
- Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged)
+ Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged)
Q_PROPERTY(QDeclarativeListProperty<QGraphicsTransform> transform READ transform DESIGNABLE false FINAL)
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged)
Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint) // transformOriginPoint is read-only for Item
@@ -139,7 +139,7 @@ public:
QRectF boundingRect() const;
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
- bool wantsFocus() const;
+ bool hasActiveFocus() const;
bool hasFocus() const;
void setFocus(bool);
@@ -148,7 +148,7 @@ public:
Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, qreal x, qreal y) const;
Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, qreal x, qreal y) const;
- Q_INVOKABLE void forceFocus();
+ Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE QDeclarativeItem *childAt(qreal x, qreal y) const;
Q_SIGNALS:
@@ -157,7 +157,7 @@ Q_SIGNALS:
void baselineOffsetChanged(qreal);
void stateChanged(const QString &);
void focusChanged(bool);
- void wantsFocusChanged(bool);
+ void activeFocusChanged(bool);
void parentChanged(QDeclarativeItem *);
void transformOriginChanged(TransformOrigin);
void smoothChanged(bool);
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 84ae4ef..84b0f51 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -287,11 +287,18 @@ public:
virtual void subFocusItemChange()
{
if (flags & QGraphicsItem::ItemIsFocusScope || !parent)
- emit q_func()->wantsFocusChanged(subFocusItem != 0);
+ emit q_func()->activeFocusChanged(subFocusItem != 0);
//see also QDeclarativeItemPrivate::focusChanged
}
// Reimplemented from QGraphicsItemPrivate
+ virtual void focusScopeItemChange(bool isSubFocusItem)
+ {
+ emit q_func()->focusChanged(isSubFocusItem);
+ }
+
+
+ // Reimplemented from QGraphicsItemPrivate
virtual void siblingOrderChange()
{
Q_Q(QDeclarativeItem);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 5a42525..55b802f 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -622,7 +622,7 @@ void QDeclarativeTextEdit::moveCursorSelection(int pos)
\qmlproperty bool TextEdit::cursorVisible
If true the text edit shows a cursor.
- This property is set and unset when the text edit gets focus, but it can also
+ This property is set and unset when the text edit gets active focus, but it can also
be set directly (useful, for example, if a KeyProxy might forward keys to it).
*/
bool QDeclarativeTextEdit::isCursorVisible() const
@@ -781,9 +781,9 @@ QString QDeclarativeTextEdit::selectedText() const
}
/*!
- \qmlproperty bool TextEdit::focusOnPress
+ \qmlproperty bool TextEdit::activeFocusOnPress
- Whether the TextEdit should gain focus on a mouse press. By default this is
+ Whether the TextEdit should gain active focus on a mouse press. By default this is
set to true.
*/
bool QDeclarativeTextEdit::focusOnPress() const
@@ -798,13 +798,13 @@ void QDeclarativeTextEdit::setFocusOnPress(bool on)
if (d->focusOnPress == on)
return;
d->focusOnPress = on;
- emit focusOnPressChanged(d->focusOnPress);
+ emit activeFocusOnPressChanged(d->focusOnPress);
}
/*!
\qmlproperty bool TextEdit::persistentSelection
- Whether the TextEdit should keep the selection visible when it loses focus to another
+ Whether the TextEdit should keep the selection visible when it loses active focus to another
item in the scene. By default this is set to true;
*/
bool QDeclarativeTextEdit::persistentSelection() const
@@ -1104,15 +1104,15 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextEdit);
if (d->focusOnPress){
- bool hadFocus = hasFocus();
- forceFocus();
+ bool hadActiveFocus = hasActiveFocus();
+ forceActiveFocus();
if (d->showInputPanelOnFocus) {
- if (hasFocus() && hadFocus && !isReadOnly()) {
+ if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) {
// re-open input panel on press if already focused
openSoftwareInputPanel();
}
} else { // show input panel on click
- if (hasFocus() && !hadFocus) {
+ if (hasActiveFocus() && !hadActiveFocus) {
d->clickCausedFocus = true;
}
}
@@ -1427,10 +1427,10 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
By default the opening of input panels follows the platform style. On Symbian^1 and
Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms
- the panels are automatically opened when TextEdit element gains focus. Input panels are
- always closed if no editor owns focus.
+ the panels are automatically opened when TextEdit element gains active focus. Input panels are
+ always closed if no editor has active focus.
- You can disable the automatic behavior by setting the property \c focusOnPress to false
+ You can disable the automatic behavior by setting the property \c activeFocusOnPress to false
and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement
the behavior you want.
@@ -1441,12 +1441,12 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption()
TextEdit {
id: textEdit
text: "Hello world!"
- focusOnPress: false
+ activeFocusOnPress: false
MouseArea {
anchors.fill: parent
onClicked: {
- if (!textEdit.focus) {
- textEdit.focus = true;
+ if (!textEdit.activeFocus) {
+ textEdit.forceActiveFocus();
textEdit.openSoftwareInputPanel();
} else {
textEdit.focus = false;
@@ -1478,10 +1478,10 @@ void QDeclarativeTextEdit::openSoftwareInputPanel()
By default the opening of input panels follows the platform style. On Symbian^1 and
Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms
- the panels are automatically opened when TextEdit element gains focus. Input panels are
- always closed if no editor owns focus.
+ the panels are automatically opened when TextEdit element gains active focus. Input panels are
+ always closed if no editor has active focus.
- You can disable the automatic behavior by setting the property \c focusOnPress to false
+ You can disable the automatic behavior by setting the property \c activeFocusOnPress to false
and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement
the behavior you want.
@@ -1492,12 +1492,12 @@ void QDeclarativeTextEdit::openSoftwareInputPanel()
TextEdit {
id: textEdit
text: "Hello world!"
- focusOnPress: false
+ activeFocusOnPress: false
MouseArea {
anchors.fill: parent
onClicked: {
- if (!textEdit.focus) {
- textEdit.focus = true;
+ if (!textEdit.activeFocus) {
+ textEdit.forceActiveFocus();
textEdit.openSoftwareInputPanel();
} else {
textEdit.focus = false;
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index 279af78..68fde3d 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -85,7 +85,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
- Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
+ Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
@@ -216,7 +216,7 @@ Q_SIGNALS:
void readOnlyChanged(bool isReadOnly);
void cursorVisibleChanged(bool isCursorVisible);
void cursorDelegateChanged();
- void focusOnPressChanged(bool focusIsPressed);
+ void activeFocusOnPressChanged(bool activeFocusOnPressed);
void persistentSelectionChanged(bool isPersistentSelection);
void textMarginChanged(qreal textMargin);
void selectByMouseChanged(bool selectByMouse);
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 321b121..34f5897 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -375,14 +375,14 @@ void QDeclarativeTextInput::setMaxLength(int ml)
\qmlproperty bool TextInput::cursorVisible
Set to true when the TextInput shows a cursor.
- This property is set and unset when the TextInput gets focus, so that other
+ This property is set and unset when the TextInput gets active focus, so that other
properties can be bound to whether the cursor is currently showing. As it
gets set and unset automatically, when you set the value yourself you must
keep in mind that your value may be overwritten.
It can be set directly in script, for example if a KeyProxy might
forward keys to it and you desire it to look active when this happens
- (but without actually giving it the focus).
+ (but without actually giving it active focus).
It should not be set directly on the element, like in the below QML,
as the specified value will be overridden an lost on focus changes.
@@ -395,7 +395,7 @@ void QDeclarativeTextInput::setMaxLength(int ml)
\endcode
In the above snippet the cursor will still become visible when the
- TextInput gains focus.
+ TextInput gains active focus.
*/
bool QDeclarativeTextInput::isCursorVisible() const
{
@@ -510,9 +510,9 @@ QString QDeclarativeTextInput::selectedText() const
}
/*!
- \qmlproperty bool TextInput::focusOnPress
+ \qmlproperty bool TextInput::activeFocusOnPress
- Whether the TextInput should gain focus on a mouse press. By default this is
+ Whether the TextInput should gain active focus on a mouse press. By default this is
set to true.
*/
bool QDeclarativeTextInput::focusOnPress() const
@@ -529,7 +529,7 @@ void QDeclarativeTextInput::setFocusOnPress(bool b)
d->focusOnPress = b;
- emit focusOnPressChanged(d->focusOnPress);
+ emit activeFocusOnPressChanged(d->focusOnPress);
}
/*!
@@ -945,15 +945,15 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QDeclarativeTextInput);
if(d->focusOnPress){
- bool hadFocus = hasFocus();
- forceFocus();
+ bool hadActiveFocus = hasActiveFocus();
+ forceActiveFocus();
if (d->showInputPanelOnFocus) {
- if (hasFocus() && hadFocus && !isReadOnly()) {
+ if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) {
// re-open input panel on press if already focused
openSoftwareInputPanel();
}
} else { // show input panel on click
- if (hasFocus() && !hadFocus) {
+ if (hasActiveFocus() && !hadActiveFocus) {
d->clickCausedFocus = true;
}
}
@@ -1312,10 +1312,10 @@ void QDeclarativeTextInput::moveCursorSelection(int position)
By default the opening of input panels follows the platform style. On Symbian^1 and
Symbian^3 -based devices the panels are opened by clicking TextInput. On other platforms
- the panels are automatically opened when TextInput element gains focus. Input panels are
- always closed if no editor owns focus.
+ the panels are automatically opened when TextInput element gains active focus. Input panels are
+ always closed if no editor has active focus.
- . You can disable the automatic behavior by setting the property \c focusOnPress to false
+ . You can disable the automatic behavior by setting the property \c activeFocusOnPress to false
and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement
the behavior you want.
@@ -1326,12 +1326,12 @@ void QDeclarativeTextInput::moveCursorSelection(int position)
TextInput {
id: textInput
text: "Hello world!"
- focusOnPress: false
+ activeFocusOnPress: false
MouseArea {
anchors.fill: parent
onClicked: {
- if (!textInput.focus) {
- textInput.focus = true;
+ if (!textInput.activeFocus) {
+ textInput.forceActiveFocus()
textInput.openSoftwareInputPanel();
} else {
textInput.focus = false;
@@ -1363,10 +1363,10 @@ void QDeclarativeTextInput::openSoftwareInputPanel()
By default the opening of input panels follows the platform style. On Symbian^1 and
Symbian^3 -based devices the panels are opened by clicking TextInput. On other platforms
- the panels are automatically opened when TextInput element gains focus. Input panels are
- always closed if no editor owns focus.
+ the panels are automatically opened when TextInput element gains active focus. Input panels are
+ always closed if no editor has active focus.
- . You can disable the automatic behavior by setting the property \c focusOnPress to false
+ . You can disable the automatic behavior by setting the property \c activeFocusOnPress to false
and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement
the behavior you want.
@@ -1377,12 +1377,12 @@ void QDeclarativeTextInput::openSoftwareInputPanel()
TextInput {
id: textInput
text: "Hello world!"
- focusOnPress: false
+ activeFocusOnPress: false
MouseArea {
anchors.fill: parent
onClicked: {
- if (!textInput.focus) {
- textInput.focus = true;
+ if (!textInput.activeFocus) {
+ textInput.forceActiveFocus();
textInput.openSoftwareInputPanel();
} else {
textInput.focus = false;
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
index b1862c6..ba3f5b1 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h
@@ -87,7 +87,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativePaintedItem
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
- Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY focusOnPressChanged)
+ Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged)
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
@@ -211,7 +211,7 @@ Q_SIGNALS:
void echoModeChanged(EchoMode echoMode);
void passwordCharacterChanged();
void displayTextChanged();
- void focusOnPressChanged(bool focusOnPress);
+ void activeFocusOnPressChanged(bool activeFocusOnPress);
void autoScrollChanged(bool autoScroll);
void selectByMouseChanged(bool selectByMouse);
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 479a813..cd03eeb 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1149,6 +1149,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
parentFocusScopeItem = fsi;
p->d_ptr->focusScopeItem = 0;
+ fsi->d_ptr->focusScopeItemChange(false);
}
break;
}
@@ -1181,6 +1182,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
while (p) {
if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
p->d_ptr->focusScopeItem = newFocusScopeItem;
+ newFocusScopeItem->d_ptr->focusScopeItemChange(true);
// Ensure the new item is no longer the subFocusItem. The
// only way to set focus on a child of a focus scope is
// by setting focus on the scope itself.
@@ -5568,6 +5570,16 @@ void QGraphicsItemPrivate::subFocusItemChange()
/*!
\internal
+ Subclasses can reimplement this function to be notified when an item
+ becomes a focusScopeItem (or is no longer a focusScopeItem).
+*/
+void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem)
+{
+}
+
+/*!
+ \internal
+
Subclasses can reimplement this function to be notified when its
siblingIndex order is changed.
*/
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index f9f5d3d..fb6a407 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -482,6 +482,7 @@ public:
void clearSubFocus(QGraphicsItem *rootItem = 0);
void resetFocusProxy();
virtual void subFocusItemChange();
+ virtual void focusScopeItemChange(bool isSubFocusItem);
static void children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item);
static int children_count(QDeclarativeListProperty<QGraphicsObject> *list);
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml
index 6c39f20..42b50cf 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml
@@ -4,11 +4,11 @@ Rectangle {
id: root
width:300; height:400
- property bool focus1: root.wantsFocus
- property bool focus2: item1.wantsFocus
- property bool focus3: fs1.wantsFocus
- property bool focus4: fs2.wantsFocus
- property bool focus5: theItem.wantsFocus
+ property bool focus1: root.activeFocus
+ property bool focus2: item1.activeFocus
+ property bool focus3: fs1.activeFocus
+ property bool focus4: fs2.activeFocus
+ property bool focus5: theItem.activeFocus
Item {
id: item1
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml
index af9c420..9144854 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml
@@ -15,28 +15,28 @@ Rectangle {
height: 120; width: 420
color: "transparent"
- border.width: 5; border.color: firstScope.wantsFocus?"blue":"black"
+ border.width: 5; border.color: firstScope.activeFocus?"blue":"black"
Rectangle {
id: item1; objectName: "item1"
x: 10; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: wantsFocus?"blue":"black"
+ border.width: 5; border.color: activeFocus?"blue":"black"
focus: true
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
Rectangle {
id: item2; objectName: "item2"
x: 310; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: wantsFocus?"blue":"black"
+ border.width: 5; border.color: activeFocus?"blue":"black"
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
}
@@ -50,32 +50,32 @@ Rectangle {
y: 160; height: 120; width: 420
color: "transparent"
- border.width: 5; border.color: secondScope.wantsFocus?"blue":"black"
+ border.width: 5; border.color: secondScope.activeFocus?"blue":"black"
Rectangle {
id: item4; objectName: "item4"
x: 10; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: wantsFocus?"blue":"black"
+ border.width: 5; border.color: activeFocus?"blue":"black"
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
Rectangle {
id: item5; objectName: "item5"
x: 310; y: 10; width: 100; height: 100; color: "green"
- border.width: 5; border.color: wantsFocus?"blue":"black"
+ border.width: 5; border.color: activeFocus?"blue":"black"
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
}
}
}
Keys.onDigit4Pressed: item4.focus = true
- Keys.onDigit5Pressed: item5.forceFocus()
+ Keys.onDigit5Pressed: item5.forceActiveFocus()
}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
index aa43ba8..55be103 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test.qml
@@ -20,21 +20,21 @@ Rectangle {
color: "transparent"
border.width: 5
- border.color: myScope.wantsFocus?"blue":"black"
+ border.color: myScope.activeFocus?"blue":"black"
Rectangle {
id: item1; objectName: "item1"
x: 10; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
Keys.onDigit9Pressed: console.debug("Top Left");
KeyNavigation.right: item2
focus: true
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
@@ -43,13 +43,13 @@ Rectangle {
x: 310; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
KeyNavigation.left: item1
Keys.onDigit9Pressed: console.log("Top Right");
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
}
@@ -63,14 +63,14 @@ Rectangle {
x: 10; y: 300
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
Keys.onDigit9Pressed: console.log("Bottom Left");
KeyNavigation.up: myScope
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml
index 216277e..5ed701d 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml
@@ -10,27 +10,27 @@ Rectangle {
FocusScope {
y: 100
focus: true; objectName: "item1"
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true; objectName: "item2"
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true; objectName: "item3"
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true; objectName: "item4"
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true; objectName: "item5"
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
}
}
}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml
index 2ac0d18..c6d112f 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml
@@ -13,7 +13,7 @@ Rectangle {
ListElement { name: "4" }
ListElement { name: "5" }
ListElement { name: "6" }
- ListElement { name: "6" }
+ ListElement { name: "7" }
ListElement { name: "8" }
ListElement { name: "9" }
}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml
index 8862b39..3c6d3bd 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml
@@ -19,21 +19,21 @@ Rectangle {
color: "transparent"
border.width: 5
- border.color: myScope.wantsFocus?"blue":"black"
+ border.color: myScope.activeFocus?"blue":"black"
Rectangle {
id: item1; objectName: "item1"
x: 10; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
Keys.onDigit9Pressed: console.log("Error - Top Left");
KeyNavigation.right: item2
focus: true
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
@@ -42,13 +42,13 @@ Rectangle {
x: 310; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
KeyNavigation.left: item1
Keys.onDigit9Pressed: console.log("Error - Top Right");
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
}
@@ -62,14 +62,14 @@ Rectangle {
x: 10; y: 300
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
Keys.onDigit9Pressed: console.log("Error - Bottom Left");
KeyNavigation.up: myScope
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
index cdb5164..4417d5f 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
+++ b/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml
@@ -20,13 +20,13 @@ Rectangle {
color: "transparent"
border.width: 5
- border.color: myScope.wantsFocus?"blue":"black"
+ border.color: myScope.activeFocus?"blue":"black"
Rectangle {
x: 10; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: item1.wantsFocus?"blue":"black"
+ border.color: item1.activeFocus?"blue":"black"
}
TextEdit {
@@ -47,13 +47,13 @@ Rectangle {
x: 310; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
KeyNavigation.left: item1
Keys.onReturnPressed: console.log("Top Right");
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
- color: parent.focus?"red":"transparent"
+ color: parent.activeFocus?"red":"transparent"
}
}
}
@@ -66,7 +66,7 @@ Rectangle {
x: 10; y: 300
width: 100; height: 100; color: "green"
border.width: 5
- border.color: item3.wantsFocus?"blue":"black"
+ border.color: item3.activeFocus?"blue":"black"
}
TextEdit {
diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
index 2559087..b0c9c03 100644
--- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
+++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp
@@ -118,22 +118,22 @@ void tst_qdeclarativefocusscope::basic()
QVERIFY(view->hasFocus());
QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == true);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == true);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->wantsFocus() == false);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == true);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
delete view;
}
@@ -166,16 +166,11 @@ void tst_qdeclarativefocusscope::nested()
QVERIFY(view->hasFocus());
QVERIFY(view->scene()->hasFocus());
- QVERIFY(item1->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->wantsFocus() == true);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->wantsFocus() == true);
- QVERIFY(item3->hasFocus() == false);
- QVERIFY(item4->wantsFocus() == true);
- QVERIFY(item4->hasFocus() == false);
- QVERIFY(item5->wantsFocus() == true);
- QVERIFY(item5->hasFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(item4->hasActiveFocus() == true);
+ QVERIFY(item5->hasActiveFocus() == true);
delete view;
}
@@ -204,22 +199,22 @@ void tst_qdeclarativefocusscope::noFocus()
QVERIFY(view->hasFocus());
QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->wantsFocus() == false);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->wantsFocus() == false);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->wantsFocus() == false);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
delete view;
}
@@ -249,32 +244,32 @@ void tst_qdeclarativefocusscope::textEdit()
QVERIFY(view->hasFocus());
QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == true);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == true);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == true);
- QVERIFY(item3->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->wantsFocus() == false);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->hasFocus() == true);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
delete view;
}
@@ -308,28 +303,28 @@ void tst_qdeclarativefocusscope::forceFocus()
QVERIFY(view->hasFocus());
QVERIFY(view->scene()->hasFocus());
- QVERIFY(item0->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == true);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->wantsFocus() == false);
- QVERIFY(item4->hasFocus() == false);
- QVERIFY(item5->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_4);
- QVERIFY(item0->wantsFocus() == true);
- QVERIFY(item1->hasFocus() == true);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->wantsFocus() == false);
- QVERIFY(item4->hasFocus() == false);
- QVERIFY(item5->hasFocus() == false);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == false);
QTest::keyClick(view, Qt::Key_5);
- QVERIFY(item0->wantsFocus() == false);
- QVERIFY(item1->hasFocus() == false);
- QVERIFY(item2->hasFocus() == false);
- QVERIFY(item3->wantsFocus() == true);
- QVERIFY(item4->hasFocus() == false);
- QVERIFY(item5->hasFocus() == true);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == true);
delete view;
}
diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
index ffb2105..345ce38 100644
--- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
+++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
@@ -371,7 +371,7 @@ void tst_QDeclarativeItem::keyNavigation()
QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
QVERIFY(item);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
// right
QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
@@ -380,7 +380,7 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
QVERIFY(item);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
// down
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
@@ -389,7 +389,7 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item4");
QVERIFY(item);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
// left
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
@@ -398,7 +398,7 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item3");
QVERIFY(item);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
// up
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
@@ -407,7 +407,7 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
QVERIFY(item);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
// tab
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
@@ -416,7 +416,7 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item2");
QVERIFY(item);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
// backtab
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
@@ -425,7 +425,7 @@ void tst_QDeclarativeItem::keyNavigation()
item = findItem<QDeclarativeItem>(canvas->rootObject(), "item1");
QVERIFY(item);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
delete canvas;
}
@@ -618,21 +618,21 @@ void tst_QDeclarativeItem::mouseFocus()
QDeclarativeItem *item = findItem<QDeclarativeItem>(canvas->rootObject(), "declarativeItem");
QVERIFY(item);
- QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
+ QSignalSpy focusSpy(item, SIGNAL(activeFocusChanged(bool)));
QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos()));
QApplication::processEvents();
QCOMPARE(focusSpy.count(), 1);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
// make sure focusable graphics widget underneath does not steal focus
QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos()));
QApplication::processEvents();
QCOMPARE(focusSpy.count(), 1);
- QVERIFY(item->hasFocus());
+ QVERIFY(item->hasActiveFocus());
item->setFocus(false);
- QVERIFY(!item->hasFocus());
+ QVERIFY(!item->hasActiveFocus());
QCOMPARE(focusSpy.count(), 2);
item->setFocus(true);
QCOMPARE(focusSpy.count(), 3);
@@ -664,7 +664,7 @@ void tst_QDeclarativeItem::propertyChanges()
QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
- QSignalSpy wantsFocusSpy(parentItem, SIGNAL(wantsFocusChanged(bool)));
+ QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool)));
item->setParentItem(parentItem);
item->setWidth(100.0);
@@ -696,14 +696,14 @@ void tst_QDeclarativeItem::propertyChanges()
QVERIFY(childrenRectArguments.count() == 1);
QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
- QCOMPARE(item->hasFocus(), true);
+ QCOMPARE(item->hasActiveFocus(), true);
QCOMPARE(focusSpy.count(),1);
QList<QVariant> focusArguments = focusSpy.first();
QVERIFY(focusArguments.count() == 1);
QCOMPARE(focusArguments.at(0).toBool(), true);
+ QCOMPARE(parentItem->hasActiveFocus(), false);
QCOMPARE(parentItem->hasFocus(), false);
- QCOMPARE(parentItem->wantsFocus(), false);
QCOMPARE(wantsFocusSpy.count(),0);
delete canvas;
diff --git a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml
index 807eec9..8f9a7f2 100644
--- a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml
+++ b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml
@@ -5,6 +5,6 @@ Rectangle {
color: "red"
states: State {
name: "blue"
- PropertyChanges { target: myRectangle; colr: "blue"; wantsFocus: true }
+ PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true }
}
}
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 7bc4fd4..3b6a420 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -922,7 +922,7 @@ void tst_qdeclarativestates::propertyErrors()
QCOMPARE(rect->color(),QColor("red"));
QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"wantsFocus\"");
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\"");
QDeclarativeItemPrivate::get(rect)->setState("blue");
}
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index bc814e5..0723b36 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -597,7 +597,7 @@ void tst_qdeclarativetextedit::persistentSelection()
void tst_qdeclarativetextedit::focusOnPress()
{
{
- QString componentStr = "import Qt 4.7\nTextEdit { focusOnPress: true; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.7\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
@@ -606,7 +606,7 @@ void tst_qdeclarativetextedit::focusOnPress()
}
{
- QString componentStr = "import Qt 4.7\nTextEdit { focusOnPress: false; text: \"Hello World\" }";
+ QString componentStr = "import Qt 4.7\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }";
QDeclarativeComponent texteditComponent(&engine);
texteditComponent.setData(componentStr.toLatin1(), QUrl());
QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit*>(texteditComponent.create());
@@ -833,15 +833,15 @@ void tst_qdeclarativetextedit::navigation()
QDeclarativeItem *input = qobject_cast<QDeclarativeItem *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(input != 0);
- QTRY_VERIFY(input->hasFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == false);
+ QVERIFY(input->hasActiveFocus() == false);
simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == true);
+ QVERIFY(input->hasActiveFocus() == true);
simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == false);
+ QVERIFY(input->hasActiveFocus() == false);
simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == true);
+ QVERIFY(input->hasActiveFocus() == true);
}
void tst_qdeclarativetextedit::copyAndPaste() {
@@ -895,7 +895,7 @@ void tst_qdeclarativetextedit::readOnly()
QDeclarativeTextEdit *edit = qobject_cast<QDeclarativeTextEdit *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(edit != 0);
- QTRY_VERIFY(edit->hasFocus() == true);
+ QTRY_VERIFY(edit->hasActiveFocus() == true);
QVERIFY(edit->isReadOnly() == true);
QString initial = edit->text();
for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
@@ -982,7 +982,7 @@ void tst_qdeclarativetextedit::openInputPanelOnClick()
MyInputContext ic;
view.setInputContext(&ic);
QDeclarativeTextEdit edit;
- QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool)));
+ QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool)));
edit.setText("Hello world");
edit.setPos(0, 0);
scene.addItem(&edit);
@@ -1030,7 +1030,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
MyInputContext ic;
view.setInputContext(&ic);
QDeclarativeTextEdit edit;
- QSignalSpy focusOnPressSpy(&edit, SIGNAL(focusOnPressChanged(bool)));
+ QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool)));
edit.setText("Hello world");
edit.setPos(0, 0);
scene.addItem(&edit);
@@ -1052,7 +1052,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
// focus on press, input panel on focus
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
QApplication::processEvents();
- QVERIFY(edit.hasFocus());
+ QVERIFY(edit.hasActiveFocus());
QCOMPARE(ic.openInputPanelReceived, true);
ic.openInputPanelReceived = false;
@@ -1062,7 +1062,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
ic.openInputPanelReceived = false;
// if already focused, input panel can be opened on press
- QVERIFY(edit.hasFocus());
+ QVERIFY(edit.hasActiveFocus());
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos()));
QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, true);
@@ -1090,7 +1090,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
// no automatic input panel events should
- // be sent if focusOnPress is false
+ // be sent if activeFocusOnPress is false
edit.setFocusOnPress(false);
QCOMPARE(focusOnPressSpy.count(),1);
edit.setFocusOnPress(false);
@@ -1117,7 +1117,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus()
QCOMPARE(ic.closeInputPanelReceived, true);
ic.closeInputPanelReceived = false;
- // set focusOnPress back to true
+ // set activeFocusOnPress back to true
edit.setFocusOnPress(true);
QCOMPARE(focusOnPressSpy.count(),2);
edit.setFocusOnPress(true);
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 05dc50b..aceebf3 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -480,7 +480,7 @@ void tst_qdeclarativetextinput::maxLength()
}
textinputObject->setText("");
- QTRY_VERIFY(textinputObject->hasFocus() == true);
+ QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
for(int i=0; i<20; i++){
QCOMPARE(textinputObject->text().length(), qMin(i,10));
//simulateKey(canvas, Qt::Key_A);
@@ -501,7 +501,7 @@ void tst_qdeclarativetextinput::masks()
QVERIFY(canvas->rootObject() != 0);
QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
QVERIFY(textinputObject != 0);
- QTRY_VERIFY(textinputObject->hasFocus() == true);
+ QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
QVERIFY(textinputObject->text().length() == 0);
QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
for(int i=0; i<10; i++){
@@ -530,7 +530,7 @@ void tst_qdeclarativetextinput::validators()
QDeclarativeTextInput *intInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("intInput")));
QVERIFY(intInput);
intInput->setFocus(true);
- QTRY_VERIFY(intInput->hasFocus());
+ QTRY_VERIFY(intInput->hasActiveFocus());
QTest::keyPress(canvas, Qt::Key_1);
QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
QCOMPARE(intInput->text(), QLatin1String("1"));
@@ -551,7 +551,7 @@ void tst_qdeclarativetextinput::validators()
QDeclarativeTextInput *dblInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("dblInput")));
QTRY_VERIFY(dblInput);
dblInput->setFocus(true);
- QVERIFY(dblInput->hasFocus() == true);
+ QVERIFY(dblInput->hasActiveFocus() == true);
QTest::keyPress(canvas, Qt::Key_1);
QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
QCOMPARE(dblInput->text(), QLatin1String("1"));
@@ -580,7 +580,7 @@ void tst_qdeclarativetextinput::validators()
QDeclarativeTextInput *strInput = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("strInput")));
QTRY_VERIFY(strInput);
strInput->setFocus(true);
- QVERIFY(strInput->hasFocus() == true);
+ QVERIFY(strInput->hasActiveFocus() == true);
QTest::keyPress(canvas, Qt::Key_1);
QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10);
QCOMPARE(strInput->text(), QLatin1String(""));
@@ -628,7 +628,7 @@ void tst_qdeclarativetextinput::inputMethods()
QVERIFY(canvas->rootObject() != 0);
input->setFocus(true);
- QVERIFY(input->hasFocus() == true);
+ QVERIFY(input->hasActiveFocus() == true);
// test that input method event is committed
QInputMethodEvent event;
event.setCommitString( "My ", -12, 0);
@@ -655,11 +655,11 @@ void tst_qdeclarativetextinput::navigation()
QVERIFY(input != 0);
input->setCursorPosition(0);
- QTRY_VERIFY(input->hasFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == false);
+ QVERIFY(input->hasActiveFocus() == false);
simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == true);
+ QVERIFY(input->hasActiveFocus() == true);
//QT-2944: If text is selected, ensure we deselect upon cursor motion
input->setCursorPosition(input->text().length());
input->select(0,input->text().length());
@@ -667,11 +667,11 @@ void tst_qdeclarativetextinput::navigation()
simulateKey(canvas, Qt::Key_Right);
QVERIFY(input->selectionStart() == input->selectionEnd());
QVERIFY(input->selectionStart() == input->text().length());
- QVERIFY(input->hasFocus() == true);
+ QVERIFY(input->hasActiveFocus() == true);
simulateKey(canvas, Qt::Key_Right);
- QVERIFY(input->hasFocus() == false);
+ QVERIFY(input->hasActiveFocus() == false);
simulateKey(canvas, Qt::Key_Left);
- QVERIFY(input->hasFocus() == true);
+ QVERIFY(input->hasActiveFocus() == true);
// Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
input->setCursorPosition(2);
@@ -758,7 +758,7 @@ void tst_qdeclarativetextinput::readOnly()
QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(input != 0);
- QTRY_VERIFY(input->hasFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
QVERIFY(input->isReadOnly() == true);
QString initial = input->text();
for(int k=Qt::Key_0; k<=Qt::Key_Z; k++)
@@ -782,7 +782,7 @@ void tst_qdeclarativetextinput::echoMode()
QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
QVERIFY(input != 0);
- QTRY_VERIFY(input->hasFocus() == true);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
QString initial = input->text();
Qt::InputMethodHints ref;
QCOMPARE(initial, QLatin1String("ABCDefgh"));
@@ -875,7 +875,7 @@ void tst_qdeclarativetextinput::openInputPanelOnClick()
MyInputContext ic;
view.setInputContext(&ic);
QDeclarativeTextInput input;
- QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool)));
+ QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool)));
input.setText("Hello world");
input.setPos(0, 0);
scene.addItem(&input);
@@ -922,7 +922,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus()
MyInputContext ic;
view.setInputContext(&ic);
QDeclarativeTextInput input;
- QSignalSpy focusOnPressSpy(&input, SIGNAL(focusOnPressChanged(bool)));
+ QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool)));
input.setText("Hello world");
input.setPos(0, 0);
scene.addItem(&input);
@@ -944,7 +944,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus()
// focus on press, input panel on focus
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
QApplication::processEvents();
- QVERIFY(input.hasFocus());
+ QVERIFY(input.hasActiveFocus());
QCOMPARE(ic.openInputPanelReceived, true);
ic.openInputPanelReceived = false;
@@ -954,7 +954,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus()
ic.openInputPanelReceived = false;
// if already focused, input panel can be opened on press
- QVERIFY(input.hasFocus());
+ QVERIFY(input.hasActiveFocus());
QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos()));
QApplication::processEvents();
QCOMPARE(ic.openInputPanelReceived, true);
@@ -982,7 +982,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus()
QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled));
// no automatic input panel events should
- // be sent if focusOnPress is false
+ // be sent if activeFocusOnPress is false
input.setFocusOnPress(false);
QCOMPARE(focusOnPressSpy.count(),1);
input.setFocusOnPress(false);
@@ -1009,7 +1009,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus()
QCOMPARE(ic.closeInputPanelReceived, true);
ic.closeInputPanelReceived = false;
- // set focusOnPress back to true
+ // set activeFocusOnPress back to true
input.setFocusOnPress(true);
QCOMPARE(focusOnPressSpy.count(),2);
input.setFocusOnPress(true);