aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-09 16:25:58 +0200
committerGunnar Sletta <gunnar.sletta@jollamobile.com>2014-05-10 11:53:47 +0200
commit66646dd8c37adb488a79ab274b2396a649674e6d (patch)
treeb0f5ac752a52cec3de1d47692e09295197622dcd /src/quick/items/qquickitem.cpp
parentda15ea0f3b5805db657f13060c21efa78f10cde2 (diff)
parentd82a17b929dd88fe76258b0f801beaa1b2ee343e (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: .qmake.conf src/plugins/accessible/quick/quick.pro src/quick/items/qquickpincharea.cpp src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp src/quick/scenegraph/qsgthreadedrenderloop.cpp Manually adjusted for TestHTTPServer constructor change: tests/auto/quick/qquickimage/tst_qquickimage.cpp Change-Id: I5e58a7c08ea92d6fc5e3bce98571c54f7b2ce08f
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r--src/quick/items/qquickitem.cpp276
1 files changed, 180 insertions, 96 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 2c89c32b45..03a78895cf 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -924,276 +924,354 @@ bool QQuickKeysAttached::isConnected(const char *signalName)
*/
/*!
- \qmlsignal QtQuick::Keys::onPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::pressed(KeyEvent event)
- This handler is called when a key has been pressed. The \a event
+ This signal is emitted when a key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onReleased(KeyEvent event)
+ \qmlsignal QtQuick::Keys::released(KeyEvent event)
- This handler is called when a key has been released. The \a event
+ This signal is emitted when a key has been released. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onReleased.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit0Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit0Pressed(KeyEvent event)
- This handler is called when the digit '0' has been pressed. The \a event
+ This signal is emitted when the digit '0' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit0Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit1Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit1Pressed(KeyEvent event)
- This handler is called when the digit '1' has been pressed. The \a event
+ This signal is emitted when the digit '1' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit1Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit2Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit2Pressed(KeyEvent event)
- This handler is called when the digit '2' has been pressed. The \a event
+ This signal is emitted when the digit '2' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit2Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit3Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit3Pressed(KeyEvent event)
- This handler is called when the digit '3' has been pressed. The \a event
+ This signal is emitted when the digit '3' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit3Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit4Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit4Pressed(KeyEvent event)
- This handler is called when the digit '4' has been pressed. The \a event
+ This signal is emitted when the digit '4' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit4Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit5Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit5Pressed(KeyEvent event)
- This handler is called when the digit '5' has been pressed. The \a event
+ This signal is emitted when the digit '5' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit5Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit6Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit6Pressed(KeyEvent event)
- This handler is called when the digit '6' has been pressed. The \a event
+ This signal is emitted when the digit '6' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit6Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit7Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit7Pressed(KeyEvent event)
- This handler is called when the digit '7' has been pressed. The \a event
+ This signal is emitted when the digit '7' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit7Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit8Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit8Pressed(KeyEvent event)
- This handler is called when the digit '8' has been pressed. The \a event
+ This signal is emitted when the digit '8' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit8Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDigit9Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::digit9Pressed(KeyEvent event)
- This handler is called when the digit '9' has been pressed. The \a event
+ This signal is emitted when the digit '9' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDigit9Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onLeftPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::leftPressed(KeyEvent event)
- This handler is called when the Left arrow has been pressed. The \a event
+ This signal is emitted when the Left arrow has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onLeftPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onRightPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::rightPressed(KeyEvent event)
- This handler is called when the Right arrow has been pressed. The \a event
+ This signal is emitted when the Right arrow has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onRightPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onUpPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::upPressed(KeyEvent event)
- This handler is called when the Up arrow has been pressed. The \a event
+ This signal is emitted when the Up arrow has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onUpPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDownPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::downPressed(KeyEvent event)
- This handler is called when the Down arrow has been pressed. The \a event
+ This signal is emitted when the Down arrow has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDownPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onTabPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::tabPressed(KeyEvent event)
- This handler is called when the Tab key has been pressed. The \a event
+ This signal is emitted when the Tab key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onTabPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onBacktabPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::backtabPressed(KeyEvent event)
- This handler is called when the Shift+Tab key combination (Backtab) has
+ This signal is emitted when the Shift+Tab key combination (Backtab) has
been pressed. The \a event parameter provides information about the event.
+
+ The corresponding handler is \c onBacktabPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onAsteriskPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::asteriskPressed(KeyEvent event)
- This handler is called when the Asterisk '*' has been pressed. The \a event
+ This signal is emitted when the Asterisk '*' has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onAsteriskPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onEscapePressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::escapePressed(KeyEvent event)
- This handler is called when the Escape key has been pressed. The \a event
+ This signal is emitted when the Escape key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onEscapePressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onReturnPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::returnPressed(KeyEvent event)
- This handler is called when the Return key has been pressed. The \a event
+ This signal is emitted when the Return key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onReturnPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onEnterPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::enterPressed(KeyEvent event)
- This handler is called when the Enter key has been pressed. The \a event
+ This signal is emitted when the Enter key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onEnterPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onDeletePressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::deletePressed(KeyEvent event)
- This handler is called when the Delete key has been pressed. The \a event
+ This signal is emitted when the Delete key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onDeletePressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onSpacePressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::spacePressed(KeyEvent event)
- This handler is called when the Space key has been pressed. The \a event
+ This signal is emitted when the Space key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onSpacePressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onBackPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::backPressed(KeyEvent event)
- This handler is called when the Back key has been pressed. The \a event
+ This signal is emitted when the Back key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onBackPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onCancelPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::cancelPressed(KeyEvent event)
- This handler is called when the Cancel key has been pressed. The \a event
+ This signal is emitted when the Cancel key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onCancelPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onSelectPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::selectPressed(KeyEvent event)
- This handler is called when the Select key has been pressed. The \a event
+ This signal is emitted when the Select key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onSelectPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onYesPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::yesPressed(KeyEvent event)
- This handler is called when the Yes key has been pressed. The \a event
+ This signal is emitted when the Yes key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onYesPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onNoPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::noPressed(KeyEvent event)
- This handler is called when the No key has been pressed. The \a event
+ This signal is emitted when the No key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onNoPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onContext1Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::context1Pressed(KeyEvent event)
- This handler is called when the Context1 key has been pressed. The \a event
+ This signal is emitted when the Context1 key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onContext1Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onContext2Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::context2Pressed(KeyEvent event)
- This handler is called when the Context2 key has been pressed. The \a event
+ This signal is emitted when the Context2 key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onContext2Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onContext3Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::context3Pressed(KeyEvent event)
- This handler is called when the Context3 key has been pressed. The \a event
+ This signal is emitted when the Context3 key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onContext3Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onContext4Pressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::context4Pressed(KeyEvent event)
- This handler is called when the Context4 key has been pressed. The \a event
+ This signal is emitted when the Context4 key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onContext4Pressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onCallPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::callPressed(KeyEvent event)
- This handler is called when the Call key has been pressed. The \a event
+ This signal is emitted when the Call key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onCallPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onHangupPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::hangupPressed(KeyEvent event)
- This handler is called when the Hangup key has been pressed. The \a event
+ This signal is emitted when the Hangup key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onHangupPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onFlipPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::flipPressed(KeyEvent event)
- This handler is called when the Flip key has been pressed. The \a event
+ This signal is emitted when the Flip key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onFlipPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onMenuPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::menuPressed(KeyEvent event)
- This handler is called when the Menu key has been pressed. The \a event
+ This signal is emitted when the Menu key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onMenuPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onVolumeUpPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::volumeUpPressed(KeyEvent event)
- This handler is called when the VolumeUp key has been pressed. The \a event
+ This signal is emitted when the VolumeUp key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onVolumeUpPressed.
*/
/*!
- \qmlsignal QtQuick::Keys::onVolumeDownPressed(KeyEvent event)
+ \qmlsignal QtQuick::Keys::volumeDownPressed(KeyEvent event)
- This handler is called when the VolumeDown key has been pressed. The \a event
+ This signal is emitted when the VolumeDown key has been pressed. The \a event
parameter provides information about the event.
+
+ The corresponding handler is \c onVolumeDownPressed.
*/
QQuickKeysAttached::QQuickKeysAttached(QObject *parent)
@@ -1256,7 +1334,7 @@ void QQuickKeysAttached::keyPressed(QKeyEvent *event, bool post)
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *i = d->targets.at(ii);
if (i && i->isVisible()) {
- d->item->window()->sendEvent(i, event);
+ QCoreApplication::sendEvent(i, event);
if (event->isAccepted()) {
d->inPress = false;
return;
@@ -1298,7 +1376,7 @@ void QQuickKeysAttached::keyReleased(QKeyEvent *event, bool post)
for (int ii = 0; ii < d->targets.count(); ++ii) {
QQuickItem *i = d->targets.at(ii);
if (i && i->isVisible()) {
- d->item->window()->sendEvent(i, event);
+ QCoreApplication::sendEvent(i, event);
if (event->isAccepted()) {
d->inRelease = false;
return;
@@ -1604,8 +1682,8 @@ void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus)
thumb is to only use classes with the "QSG" prefix inside the
QQuickItem::updatePaintNode() function.
- To read more about how the scene graph rendering works, see
- \l{Scene Graph and Rendering}
+ \note All classes with QSG prefix should be used solely on the scene graph's
+ rendering thread. See \l {Scene Graph and Rendering} for more information.
\section1 Custom QPainter Items
@@ -1667,12 +1745,12 @@ void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus)
\section2 Key Handling
Key handling is available to all Item-based visual types via the \l Keys
- attached property. The \e Keys attached property provides basic handlers
- such as \l {Keys::}{onPressed} and \l {Keys}{::onReleased}, as well as
- handlers for specific keys, such as \l {Keys::}{onSpacePressed}. The
+ attached property. The \e Keys attached property provides basic signals
+ such as \l {Keys::}{pressed} and \l {Keys::}{released}, as well as
+ signals for specific keys, such as \l {Keys::}{spacePressed}. The
example below assigns \l {Keyboard Focus in Qt Quick}{keyboard focus} to
- the item and handles the left key via the general \e onPressed handler
- and the return key via the onReturnPressed handler:
+ the item and handles the left key via the general \c onPressed handler
+ and the return key via the \c onReturnPressed handler:
\qml
import QtQuick 2.0
@@ -2055,8 +2133,6 @@ bool QQuickItemPrivate::qt_tab_all_widgets()
*/
bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item)
{
- bool result = true;
-
if (!item->window())
return false;
@@ -2064,14 +2140,13 @@ bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item)
return true;
#ifndef QT_NO_ACCESSIBILITY
- result = false;
if (QObject *acc = qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)) {
int role = acc->property("role").toInt();
if (role == QAccessible::EditableText
|| role == QAccessible::Table
|| role == QAccessible::List
|| role == QAccessible::SpinBox) {
- result = true;
+ return true;
} else if (role == QAccessible::ComboBox) {
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(item);
return iface->state().editable;
@@ -2079,7 +2154,11 @@ bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item)
}
#endif
- return result;
+ QVariant readonly = item->property("readOnly");
+ if (readonly.isValid() && !readonly.toBool() && item->property("text").isValid())
+ return true;
+
+ return false;
}
/*!
@@ -3348,6 +3427,9 @@ void QQuickItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo
in this function. Similarly for signals, these will be emitted on the render
thread and will thus often be delivered via queued connections.
+ \note All classes with QSG prefix should be used solely on the scene graph's
+ rendering thread. See \l {Scene Graph and Rendering} for more information.
+
\sa QSGMaterial, QSGSimpleMaterial, QSGGeometryNode, QSGGeometry,
QSGFlatColorMaterial, QSGTextureMaterial, QSGNode::markDirty()
*/
@@ -6319,10 +6401,12 @@ void QQuickItem::setFocus(bool focus, Qt::FocusReason reason)
while (scope && !scope->isFocusScope() && scope->parentItem())
scope = scope->parentItem();
if (d->window) {
- if (focus)
- QQuickWindowPrivate::get(d->window)->setFocusInScope(scope, this, reason);
- else
- QQuickWindowPrivate::get(d->window)->clearFocusInScope(scope, this, reason);
+ if (reason != Qt::PopupFocusReason) {
+ if (focus)
+ QQuickWindowPrivate::get(d->window)->setFocusInScope(scope, this, reason);
+ else
+ QQuickWindowPrivate::get(d->window)->clearFocusInScope(scope, this, reason);
+ }
} else {
// do the focus changes from setFocusInScope/clearFocusInScope that are
// unrelated to a window