diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-11 06:36:42 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-11 06:36:42 (GMT) |
commit | bb37512280e5710c1c395056bbecf4f0e4289fb9 (patch) | |
tree | 80b284f85dcd18ccb03d748dbca0467a525a0338 | |
parent | 3f85913faf5694e4a0ebd612921e4eeeb4fc9e25 (diff) | |
parent | b3526f5edf6425289ef2aa5c8adfc89892817ac0 (diff) | |
download | Qt-bb37512280e5710c1c395056bbecf4f0e4289fb9.zip Qt-bb37512280e5710c1c395056bbecf4f0e4289fb9.tar.gz Qt-bb37512280e5710c1c395056bbecf4f0e4289fb9.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts:
tests/auto/declarative/qmlbindengine/tst_qmlbindengine.cpp
-rw-r--r-- | demos/declarative/flickr/content/MediaLineEdit.qml | 1 | ||||
-rw-r--r-- | demos/declarative/webbrowser/content/RectSoftShadow.qml | 2 | ||||
-rw-r--r-- | demos/declarative/webbrowser/content/pics/footer.sci | 6 | ||||
-rw-r--r-- | demos/declarative/webbrowser/webbrowser.qml | 4 | ||||
-rw-r--r-- | src/declarative/canvas/qsimplecanvas_graphicsview.cpp | 1 | ||||
-rw-r--r-- | src/declarative/canvas/qsimplecanvasitem.cpp | 33 | ||||
-rw-r--r-- | src/declarative/fx/qfxanchors.cpp | 344 | ||||
-rw-r--r-- | src/declarative/fx/qfxanchors.h | 30 | ||||
-rw-r--r-- | src/declarative/fx/qfxanchors_p.h | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxpainteditem.cpp | 8 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit.cpp | 30 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit.h | 4 | ||||
-rw-r--r-- | src/declarative/fx/qfxtextedit_p.h | 1 | ||||
-rw-r--r-- | src/gui/graphicsview/qgraphicsscene.cpp | 4 | ||||
-rw-r--r-- | tests/auto/declarative/anchors/tst_anchors.cpp | 2 |
15 files changed, 312 insertions, 162 deletions
diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml index 37caf24..691bb5b 100644 --- a/demos/declarative/flickr/content/MediaLineEdit.qml +++ b/demos/declarative/flickr/content/MediaLineEdit.qml @@ -89,6 +89,7 @@ Item { id: Editor font.bold: true color: "white" + highlightColor: "green" width: 0 clip: true anchors.left: Label.right diff --git a/demos/declarative/webbrowser/content/RectSoftShadow.qml b/demos/declarative/webbrowser/content/RectSoftShadow.qml index 5817f00..1734433 100644 --- a/demos/declarative/webbrowser/content/RectSoftShadow.qml +++ b/demos/declarative/webbrowser/content/RectSoftShadow.qml @@ -24,7 +24,7 @@ Item { source: "pics/softshadow-bottom.png" x: 0 y: parent.height - width: webview.width*webview.scale + width: WebView.width*WebView.scale height: 16 } } diff --git a/demos/declarative/webbrowser/content/pics/footer.sci b/demos/declarative/webbrowser/content/pics/footer.sci new file mode 100644 index 0000000..be1d086 --- /dev/null +++ b/demos/declarative/webbrowser/content/pics/footer.sci @@ -0,0 +1,6 @@ +gridLeft: 5 +gridTop: 0 +gridBottom: 0 +gridRight: 5 +imageFile: footer.png + diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index c754543..4b03b63 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -73,7 +73,7 @@ Item { color: "white" styleColor: "black" - style: Raised + style: "Raised" font.family: "Helvetica" font.size: 10 @@ -85,7 +85,7 @@ Item { anchors.rightMargin: 4 anchors.top: Header.top anchors.topMargin: 4 - hAlign: AlignHCenter + hAlign: "AlignHCenter" } Item { width: parent.width diff --git a/src/declarative/canvas/qsimplecanvas_graphicsview.cpp b/src/declarative/canvas/qsimplecanvas_graphicsview.cpp index 5c6f2f5..dd4012b 100644 --- a/src/declarative/canvas/qsimplecanvas_graphicsview.cpp +++ b/src/declarative/canvas/qsimplecanvas_graphicsview.cpp @@ -110,6 +110,7 @@ void QSimpleGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) p = p->parent(); } owner->mouseReleaseEvent(event); + ungrabMouse(); } void QSimpleGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) diff --git a/src/declarative/canvas/qsimplecanvasitem.cpp b/src/declarative/canvas/qsimplecanvasitem.cpp index 90ee688..12c725c 100644 --- a/src/declarative/canvas/qsimplecanvasitem.cpp +++ b/src/declarative/canvas/qsimplecanvasitem.cpp @@ -104,48 +104,58 @@ bool QSimpleCanvasItem::mouseFilter(QGraphicsSceneMouseEvent *) return false; } -void QSimpleCanvasItem::mousePressEvent(QGraphicsSceneMouseEvent *) +void QSimpleCanvasItem::mousePressEvent(QGraphicsSceneMouseEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *) +void QSimpleCanvasItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) +void QSimpleCanvasItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::mouseMoveEvent(QGraphicsSceneMouseEvent *) +void QSimpleCanvasItem::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::hoverEnterEvent(QGraphicsSceneHoverEvent *) +void QSimpleCanvasItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *) +void QSimpleCanvasItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) { + e->ignore(); } void QSimpleCanvasItem::mouseUngrabEvent() { } -void QSimpleCanvasItem::keyPressEvent(QKeyEvent *) +void QSimpleCanvasItem::keyPressEvent(QKeyEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::keyReleaseEvent(QKeyEvent *) +void QSimpleCanvasItem::keyReleaseEvent(QKeyEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::focusOutEvent(QFocusEvent *) +void QSimpleCanvasItem::focusOutEvent(QFocusEvent *e) { + e->ignore(); } -void QSimpleCanvasItem::focusInEvent(QFocusEvent *) +void QSimpleCanvasItem::focusInEvent(QFocusEvent *e) { + e->ignore(); } void QSimpleCanvasItem::activePanelInEvent() @@ -156,8 +166,9 @@ void QSimpleCanvasItem::activePanelOutEvent() { } -void QSimpleCanvasItem::inputMethodEvent(QInputMethodEvent *) +void QSimpleCanvasItem::inputMethodEvent(QInputMethodEvent *e) { + e->ignore(); } QVariant QSimpleCanvasItem::inputMethodQuery(Qt::InputMethodQuery) const diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index f570663..53d0187 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -43,9 +43,10 @@ #include "qfxitem.h" #include <QDebug> #include <QtDeclarative/qmlinfo.h> - +#include <QtDeclarative/qmlbindablevalue.h> QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QFxAnchors,Anchors); //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? @@ -227,7 +228,7 @@ void QFxAnchors::setCenteredIn(QFxItem* c) setVerticalCenter(c->verticalCenter()); } -void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge, const char *slotString) +void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge) { //### should we do disconnects first? (will it be called more than once?) Q_Q(QFxAnchors); @@ -235,7 +236,7 @@ void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge, const char *sl switch(edge.anchorLine) { case QFxAnchorLine::Bottom: case QFxAnchorLine::VCenter: - QObject::connect(edge.item, SIGNAL(heightChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(heightChanged()), q, SLOT(updateVerticalAnchors())); break; case QFxAnchorLine::Top: //no connection needed default: @@ -244,13 +245,13 @@ void QFxAnchorsPrivate::connectVHelper(const QFxAnchorLine &edge, const char *sl } else if (edge.item->itemParent() == item->itemParent()) { //siblings switch(edge.anchorLine) { case QFxAnchorLine::Top: - QObject::connect(edge.item, SIGNAL(topChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(topChanged()), q, SLOT(updateVerticalAnchors())); break; case QFxAnchorLine::Bottom: - QObject::connect(edge.item, SIGNAL(bottomChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(bottomChanged()), q, SLOT(updateVerticalAnchors())); break; case QFxAnchorLine::VCenter: - QObject::connect(edge.item, SIGNAL(vcenterChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(vcenterChanged()), q, SLOT(updateVerticalAnchors())); break; default: break; @@ -267,49 +268,44 @@ void QFxAnchors::connectVAnchors() return; if (d->usedAnchors & HasTopAnchor) { - const char *slotStr = SLOT(updateTopAnchor()); - //Handle stretching connections (if we have multiple horizontal anchors) QFxAnchorLine *edge = 0; if (d->usedAnchors & HasBottomAnchor) { edge = &d->bottom; - connect(this, SIGNAL(bottomMarginChanged()), this, slotStr); + connect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors())); } else if (d->usedAnchors & HasVCenterAnchor) { edge = &d->vCenter; - connect(this, SIGNAL(verticalCenterOffsetChanged()), this, slotStr); + connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors())); } if (edge) { //we need to stretch - d->connectVHelper(*edge, slotStr); + d->connectVHelper(*edge); } //Handle top - d->connectVHelper(d->top, slotStr); - connect(this, SIGNAL(topMarginChanged()), this, slotStr); - updateTopAnchor(); + d->connectVHelper(d->top); + connect(this, SIGNAL(topMarginChanged()), this, SLOT(updateVerticalAnchors())); + updateVerticalAnchors(); } else if (d->usedAnchors & HasBottomAnchor) { - const char *slotStr = SLOT(updateBottomAnchor()); - //Handle stretching connections (if we have multiple horizontal anchors) if (d->usedAnchors & HasVCenterAnchor) { - d->connectVHelper(d->vCenter, slotStr); - connect(this, SIGNAL(verticalCenterOffsetChanged()), this, slotStr); + d->connectVHelper(d->vCenter); + connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors())); } //Handle bottom - d->connectVHelper(d->bottom, slotStr); - connect(this, SIGNAL(bottomMarginChanged()), this, slotStr); - updateBottomAnchor(); + d->connectVHelper(d->bottom); + connect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors())); + updateVerticalAnchors(); } else if (d->usedAnchors & HasVCenterAnchor) { //Handle vCenter - const char *slotStr = SLOT(updateVCenterAnchor()); - d->connectVHelper(d->vCenter, slotStr); - connect(this, SIGNAL(verticalCenterOffsetChanged()), this, slotStr); - updateVCenterAnchor(); + d->connectVHelper(d->vCenter); + connect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors())); + updateVerticalAnchors(); } } -void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge, const char *slotString) +void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge) { //### should we do disconnects first? (will it be called more than once?) Q_Q(QFxAnchors); @@ -317,7 +313,7 @@ void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge, const char *sl switch(edge.anchorLine) { case QFxAnchorLine::Right: case QFxAnchorLine::HCenter: - QObject::connect(edge.item, SIGNAL(widthChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(widthChanged()), q, SLOT(updateHorizontalAnchors())); break; case QFxAnchorLine::Left: //no connection needed default: @@ -326,13 +322,13 @@ void QFxAnchorsPrivate::connectHHelper(const QFxAnchorLine &edge, const char *sl } else if (edge.item->itemParent() == item->itemParent()) { //siblings switch(edge.anchorLine) { case QFxAnchorLine::Left: - QObject::connect(edge.item, SIGNAL(leftChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(leftChanged()), q, SLOT(updateHorizontalAnchors())); break; case QFxAnchorLine::Right: - QObject::connect(edge.item, SIGNAL(rightChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(rightChanged()), q, SLOT(updateHorizontalAnchors())); break; case QFxAnchorLine::HCenter: - QObject::connect(edge.item, SIGNAL(hcenterChanged()), q, slotString); + QObject::connect(edge.item, SIGNAL(hcenterChanged()), q, SLOT(updateHorizontalAnchors())); break; default: break; @@ -349,45 +345,40 @@ void QFxAnchors::connectHAnchors() return; if (d->usedAnchors & HasLeftAnchor) { - const char *slotStr = SLOT(updateLeftAnchor()); - //Handle stretching connections (if we have multiple horizontal anchors) QFxAnchorLine *edge = 0; if (d->usedAnchors & HasRightAnchor) { edge = &d->right; - connect(this, SIGNAL(rightMarginChanged()), this, slotStr); + connect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors())); } else if (d->usedAnchors & HasHCenterAnchor) { edge = &d->hCenter; - connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, slotStr); + connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors())); } if (edge) { //we need to stretch - d->connectHHelper(*edge, slotStr); + d->connectHHelper(*edge); } //Handle left - d->connectHHelper(d->left, slotStr); - connect(this, SIGNAL(leftMarginChanged()), this, slotStr); - updateLeftAnchor(); + d->connectHHelper(d->left); + connect(this, SIGNAL(leftMarginChanged()), this, SLOT(updateHorizontalAnchors())); + updateHorizontalAnchors(); } else if (d->usedAnchors & HasRightAnchor) { - const char *slotStr = SLOT(updateRightAnchor()); - //Handle stretching connections (if we have multiple horizontal anchors) if (d->usedAnchors & HasHCenterAnchor) { - d->connectHHelper(d->hCenter, slotStr); - connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, slotStr); + d->connectHHelper(d->hCenter); + connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors())); } //Handle right - d->connectHHelper(d->right, slotStr); - connect(this, SIGNAL(rightMarginChanged()), this, slotStr); - updateRightAnchor(); + d->connectHHelper(d->right); + connect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors())); + updateHorizontalAnchors(); } else if (d->usedAnchors & HasHCenterAnchor) { //Handle hCenter - const char *slotStr = SLOT(updateHCenterAnchor()); - d->connectHHelper(d->hCenter, slotStr); - connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, slotStr); - updateHCenterAnchor(); + d->connectHHelper(d->hCenter); + connect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors())); + updateHorizontalAnchors(); } } @@ -420,13 +411,12 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1, return invalid; } -void QFxAnchors::updateTopAnchor() +void QFxAnchors::updateVerticalAnchors() { Q_D(QFxAnchors); - if (d->usedAnchors & HasTopAnchor) { - if (!d->updatingVerticalAnchor) { - d->updatingVerticalAnchor = true; - + if (!d->updatingVerticalAnchor) { + d->updatingVerticalAnchor = true; + if (d->usedAnchors & HasTopAnchor) { //Handle stretching bool invalid = true; int height = 0; @@ -445,22 +435,8 @@ void QFxAnchors::updateTopAnchor() } else if (d->top.item->itemParent() == d->item->itemParent()) { d->item->setY(position(d->top.item, d->top.anchorLine) + d->topMargin); } - - d->updatingVerticalAnchor = false; - } else { - qmlInfo(d->item) << "Anchor loop detected on vertical anchor."; - } - } -} - -void QFxAnchors::updateBottomAnchor() -{ - Q_D(QFxAnchors); - if (d->usedAnchors & HasBottomAnchor) { - if (!d->updatingVerticalAnchor) { - d->updatingVerticalAnchor = true; - - //Handle stretching (top + bottom case is handled in updateLeftAnchor) + } else if (d->usedAnchors & HasBottomAnchor) { + //Handle stretching (top + bottom case is handled above) if (d->usedAnchors & HasVCenterAnchor) { int height = 0; bool invalid = d->calcStretch(d->vCenter, d->bottom, d->vCenterOffset, -d->bottomMargin, @@ -476,21 +452,9 @@ void QFxAnchors::updateBottomAnchor() d->item->setY(position(d->bottom.item, d->bottom.anchorLine) - d->item->height() - d->bottomMargin); } - d->updatingVerticalAnchor = false; - } else { - qmlInfo(d->item) << "Anchor loop detected on vertical anchor."; - } - } -} -void QFxAnchors::updateVCenterAnchor() -{ - Q_D(QFxAnchors); - if (d->usedAnchors & HasVCenterAnchor) { - if (!d->updatingVerticalAnchor) { - d->updatingVerticalAnchor = true; - - //(stetching handled in other update functions) + } else if (d->usedAnchors & HasVCenterAnchor) { + //(stetching handled above) //Handle vCenter if (d->vCenter.item == d->item->itemParent()) { @@ -499,21 +463,70 @@ void QFxAnchors::updateVCenterAnchor() } else if (d->vCenter.item->itemParent() == d->item->itemParent()) { d->item->setY(position(d->vCenter.item, d->vCenter.anchorLine) - d->item->height()/2 + d->vCenterOffset); } - - d->updatingVerticalAnchor = false; - } else { - qmlInfo(d->item) << "Anchor loop detected on vertical anchor."; } + d->updatingVerticalAnchor = false; + } else { + qmlInfo(d->item) << "Anchor loop detected on vertical anchor."; } } -void QFxAnchors::updateLeftAnchor() +void QFxAnchors::updateHorizontalAnchors() { Q_D(QFxAnchors); - if (d->usedAnchors & HasLeftAnchor) { - if (!d->updatingHorizontalAnchor) { - d->updatingHorizontalAnchor = true; + if (!d->updatingHorizontalAnchor) { + d->updatingHorizontalAnchor = true; + //alternate implementation (needs performance testing) + /*switch(d->usedAnchors & QFxAnchors::Horizontal_Mask) { + case 0x03: //(HasLeftAnchor | HasRightAnchor) + { + int width = 0; + if (!d->calcStretch(d->left, d->right, d->leftMargin, -d->rightMargin, QFxAnchorLine::Left, width)) + d->item->setWidth(width); + //fall though + } + case 0x11: //(HasLeftAnchor | HasHCenterAnchor) + { + if (d->usedAnchors & HasHCenterAnchor) { + int width = 0; + if (!d->calcStretch(d->left, d->hCenter, d->leftMargin, d->hCenterOffset, QFxAnchorLine::Left, width)) + d->item->setWidth(width*2); + } + //fall though + } + case HasLeftAnchor: + if (d->left.item == d->item->itemParent()) { + d->item->setX(adjustedPosition(d->left.item, d->left.anchorLine) + d->leftMargin); + } else if (d->left.item->itemParent() == d->item->itemParent()) { + d->item->setX(position(d->left.item, d->left.anchorLine) + d->leftMargin); + } + break; + case 0x12: //(HasRightAnchor | HasHCenterAnchor) + { + int width = 0; + if (!d->calcStretch(d->hCenter, d->right, d->hCenterOffset, -d->rightMargin, QFxAnchorLine::Left, width)) + d->item->setWidth(width*2); + //fall though + } + case HasRightAnchor: + if (d->right.item == d->item->itemParent()) { + d->item->setX(adjustedPosition(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin); + } else if (d->right.item->itemParent() == d->item->itemParent()) { + d->item->setX(position(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin); + } + break; + case HasHCenterAnchor: + if (d->hCenter.item == d->item->itemParent()) { + d->item->setX(adjustedPosition(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset); + } else if (d->hCenter.item->itemParent() == d->item->itemParent()) { + d->item->setX(position(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset); + } + break; + default: + break; + }*/ + + if (d->usedAnchors & HasLeftAnchor) { //Handle stretching bool invalid = true; int width = 0; @@ -532,21 +545,7 @@ void QFxAnchors::updateLeftAnchor() } else if (d->left.item->itemParent() == d->item->itemParent()) { d->item->setX(position(d->left.item, d->left.anchorLine) + d->leftMargin); } - - d->updatingHorizontalAnchor = false; - } else { - qmlInfo(d->item) << "Anchor loop detected on horizontal anchor."; - } - } -} - -void QFxAnchors::updateRightAnchor() -{ - Q_D(QFxAnchors); - if (d->usedAnchors & HasRightAnchor) { - if (!d->updatingHorizontalAnchor) { - d->updatingHorizontalAnchor = true; - + } else if (d->usedAnchors & HasRightAnchor) { //Handle stretching (left + right case is handled in updateLeftAnchor) if (d->usedAnchors & HasHCenterAnchor) { int width = 0; @@ -562,32 +561,18 @@ void QFxAnchors::updateRightAnchor() } else if (d->right.item->itemParent() == d->item->itemParent()) { d->item->setX(position(d->right.item, d->right.anchorLine) - d->item->width() - d->rightMargin); } - - d->updatingHorizontalAnchor = false; - } else { - qmlInfo(d->item) << "Anchor loop detected on horizontal anchor."; - } - } -} - -void QFxAnchors::updateHCenterAnchor() -{ - Q_D(QFxAnchors); - if (d->usedAnchors & HasHCenterAnchor) { - if (!d->updatingHorizontalAnchor) { - d->updatingHorizontalAnchor = true; - + } else if (d->usedAnchors & HasHCenterAnchor) { //Handle hCenter if (d->hCenter.item == d->item->itemParent()) { d->item->setX(adjustedPosition(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset); } else if (d->hCenter.item->itemParent() == d->item->itemParent()) { d->item->setX(position(d->hCenter.item, d->hCenter.anchorLine) - d->item->width()/2 + d->hCenterOffset); } - - d->updatingHorizontalAnchor = false; - } else { - qmlInfo(d->item) << "Anchor loop detected on horizontal anchor."; } + + d->updatingHorizontalAnchor = false; + } else { + qmlInfo(d->item) << "Anchor loop detected on horizontal anchor."; } } @@ -610,6 +595,24 @@ void QFxAnchors::setTop(const QFxAnchorLine &edge) d->top = edge; } +void QFxAnchors::resetTop() +{ + Q_D(QFxAnchors); + + //update flags + d->usedAnchors &= ~HasTopAnchor; + + //clear binding + QmlMetaProperty prop(this, "top"); + prop.binding()->clearExpression(); + + //disconnect signal/slot connections as needed + disconnect(this, SIGNAL(topMarginChanged()), this, SLOT(updateVerticalAnchors())); + disconnect(d->top.item, 0, this, 0); + + updateVerticalAnchors(); +} + QFxAnchorLine QFxAnchors::bottom() const { Q_D(const QFxAnchors); @@ -627,7 +630,24 @@ void QFxAnchors::setBottom(const QFxAnchorLine &edge) d->checkVValid(); d->bottom = edge; +} + +void QFxAnchors::resetBottom() +{ + Q_D(QFxAnchors); + + //update flags + d->usedAnchors &= ~HasBottomAnchor; + + //clear binding + QmlMetaProperty prop(this, "bottom"); + prop.binding()->clearExpression(); + + //disconnect signal/slot connections as needed + disconnect(this, SIGNAL(bottomMarginChanged()), this, SLOT(updateVerticalAnchors())); + disconnect(d->bottom.item, 0, this, 0); + updateVerticalAnchors(); } QFxAnchorLine QFxAnchors::verticalCenter() const @@ -649,6 +669,24 @@ void QFxAnchors::setVerticalCenter(const QFxAnchorLine &edge) d->vCenter = edge; } +void QFxAnchors::resetVerticalCenter() +{ + Q_D(QFxAnchors); + + //update flags + d->usedAnchors &= ~HasVCenterAnchor; + + //clear binding + QmlMetaProperty prop(this, "verticalCenter"); + prop.binding()->clearExpression(); + + //disconnect signal/slot connections as needed + disconnect(this, SIGNAL(verticalCenterOffsetChanged()), this, SLOT(updateVerticalAnchors())); + disconnect(d->vCenter.item, 0, this, 0); + + updateVerticalAnchors(); +} + QFxAnchorLine QFxAnchors::left() const { Q_D(const QFxAnchors); @@ -668,6 +706,24 @@ void QFxAnchors::setLeft(const QFxAnchorLine &edge) d->left = edge; } +void QFxAnchors::resetLeft() +{ + Q_D(QFxAnchors); + + //update flags + d->usedAnchors &= ~HasLeftAnchor; + + //clear binding + QmlMetaProperty prop(this, "left"); + prop.binding()->clearExpression(); + + //disconnect signal/slot connections as needed + disconnect(this, SIGNAL(leftMarginChanged()), this, SLOT(updateHorizontalAnchors())); + disconnect(d->left.item, 0, this, 0); + + updateHorizontalAnchors(); +} + QFxAnchorLine QFxAnchors::right() const { Q_D(const QFxAnchors); @@ -685,7 +741,24 @@ void QFxAnchors::setRight(const QFxAnchorLine &edge) d->checkHValid(); d->right = edge; +} + +void QFxAnchors::resetRight() +{ + Q_D(QFxAnchors); + //update flags + d->usedAnchors &= ~HasRightAnchor; + + //clear binding + QmlMetaProperty prop(this, "right"); + prop.binding()->clearExpression(); + + //disconnect signal/slot connections as needed + disconnect(this, SIGNAL(rightMarginChanged()), this, SLOT(updateHorizontalAnchors())); + disconnect(d->right.item, 0, this, 0); + + updateHorizontalAnchors(); } QFxAnchorLine QFxAnchors::horizontalCenter() const @@ -707,6 +780,24 @@ void QFxAnchors::setHorizontalCenter(const QFxAnchorLine &edge) d->hCenter = edge; } +void QFxAnchors::resetHorizontalCenter() +{ + Q_D(QFxAnchors); + + //update flags + d->usedAnchors &= ~HasHCenterAnchor; + + //clear binding + QmlMetaProperty prop(this, "horizontalCenter"); + prop.binding()->clearExpression(); + + //disconnect signal/slot connections as needed + disconnect(this, SIGNAL(horizontalCenterOffsetChanged()), this, SLOT(updateHorizontalAnchors())); + disconnect(d->hCenter.item, 0, this, 0); + + updateHorizontalAnchors(); +} + int QFxAnchors::leftMargin() const { Q_D(const QFxAnchors); @@ -902,4 +993,5 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const return true; } + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 3a250b9..5a8cc1a 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -84,12 +84,12 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject { Q_OBJECT - Q_PROPERTY(QFxAnchorLine left READ left WRITE setLeft); - Q_PROPERTY(QFxAnchorLine right READ right WRITE setRight); - Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter); - Q_PROPERTY(QFxAnchorLine top READ top WRITE setTop); - Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom); - Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter); + Q_PROPERTY(QFxAnchorLine left READ left WRITE setLeft RESET resetLeft); + Q_PROPERTY(QFxAnchorLine right READ right WRITE setRight RESET resetRight); + Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter); + Q_PROPERTY(QFxAnchorLine top READ top WRITE setTop RESET resetTop); + Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom); + Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter); Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged); Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged); Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()); @@ -109,27 +109,35 @@ public: HasBottomAnchor = 0x08, HasHCenterAnchor = 0x10, HasVCenterAnchor = 0x20, - HasBaselineAnchor = 0x40 + HasBaselineAnchor = 0x40, + Horizontal_Mask = HasLeftAnchor | HasRightAnchor | HasHCenterAnchor, + Vertical_Mask = HasTopAnchor | HasBottomAnchor | HasVCenterAnchor | HasBaselineAnchor }; Q_DECLARE_FLAGS(UsedAnchors, UsedAnchor); QFxAnchorLine left() const; void setLeft(const QFxAnchorLine &edge); + Q_INVOKABLE void resetLeft(); //### temporarily invokable for testing QFxAnchorLine right() const; void setRight(const QFxAnchorLine &edge); + void resetRight(); QFxAnchorLine horizontalCenter() const; void setHorizontalCenter(const QFxAnchorLine &edge); + void resetHorizontalCenter(); QFxAnchorLine top() const; void setTop(const QFxAnchorLine &edge); + void resetTop(); QFxAnchorLine bottom() const; void setBottom(const QFxAnchorLine &edge); + void resetBottom(); QFxAnchorLine verticalCenter() const; void setVerticalCenter(const QFxAnchorLine &edge); + void resetVerticalCenter(); int leftMargin() const; void setLeftMargin(int); @@ -172,12 +180,8 @@ Q_SIGNALS: private Q_SLOTS: void fillChanged(); - void updateLeftAnchor(); - void updateRightAnchor(); - void updateHCenterAnchor(); - void updateTopAnchor(); - void updateBottomAnchor(); - void updateVCenterAnchor(); + void updateHorizontalAnchors(); + void updateVerticalAnchors(); private: //### should item be a friend? (and make some of the public methods private or protected) diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index 76f83a8..82c2086 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -77,8 +77,8 @@ public: bool checkVValid() const; bool checkHAnchorValid(QFxAnchorLine anchor) const; bool checkVAnchorValid(QFxAnchorLine anchor) const; - void connectHHelper(const QFxAnchorLine &anchorLine, const char *slotString); - void connectVHelper(const QFxAnchorLine &anchorLine, const char *slotString); + void connectHHelper(const QFxAnchorLine &anchorLine); + void connectVHelper(const QFxAnchorLine &anchorLine); bool calcStretch(const QFxAnchorLine &edge1, const QFxAnchorLine &edge2, int offset1, int offset2, QFxAnchorLine::AnchorLine line, int &stretch); QFxItem *item; diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 950b468..4d2e327 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -252,9 +252,7 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) const QRectF clipf = p.sceneClipRect; #endif - qreal hscale = widthValid() ? qreal(width()) / content.width() : heightValid() ? qreal(height()) / content.height() : 1.0; - qreal vscale = heightValid() ? qreal(height()) / content.height() : widthValid() ? qreal(width()) / content.width() : 1.0; - const QRect clip = mapFromScene(QRectF(clipf.x()/hscale,clipf.y()/vscale,clipf.width()/hscale,clipf.height()/vscale)).toRect(); + const QRect clip = mapFromScene(clipf).toRect(); QRegion topaint(clip); topaint &= content; @@ -272,7 +270,7 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) for (int i=0; i<d->imagecache.count(); ++i) { QRect area = d->imagecache[i]->area; if (topaint.contains(area)) { - QRectF target(area.x()*hscale, area.y()*vscale, area.width()*hscale, area.height()*vscale); + QRectF target(area.x(), area.y(), area.width(), area.height()); p.drawImage(target.toRect(), d->imagecache[i]->image); topaint -= area; d->imagecache[i]->age=0; @@ -324,7 +322,7 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) newitem->image.setImage(img); #endif d->imagecache.append(newitem); - QRectF target(r.x()*hscale, r.y()*vscale, r.width()*hscale, r.height()*vscale); + QRectF target(r.x(), r.y(), r.width(), r.height()); p.drawImage(target.toRect(), newitem->image); } } diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 42f5743..74c9b5b 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -292,6 +292,36 @@ void QFxTextEdit::setColor(const QColor &color) } /*! + \qmlproperty color TextEdit::highlightColor + + The text highlight color, used behind selections. +*/ + +/*! + \property QFxTextEdit::highlightColor + \brief the text edit's default text highlight color +*/ +QColor QFxTextEdit::highlightColor() const +{ + Q_D(const QFxTextEdit); + return d->highlightColor; +} + +void QFxTextEdit::setHighlightColor(const QColor &color) +{ + Q_D(QFxTextEdit); + if (d->highlightColor == color) + return; + + clearCache(); + d->highlightColor = color; + QPalette pal = d->control->palette(); + pal.setColor(QPalette::Highlight, color); + d->control->setPalette(pal); + update(); +} + +/*! \qmlproperty enumeration TextEdit::hAlign \qmlproperty enumeration TextEdit::vAlign diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index 068a25a..5d95cd1 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -69,6 +69,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) Q_PROPERTY(QmlFont * font READ font) Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) @@ -111,6 +112,9 @@ public: QColor color() const; void setColor(const QColor &c); + QColor highlightColor() const; + void setHighlightColor(const QColor &c); + HAlignment hAlign() const; void setHAlign(HAlignment align); diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h index f4591f5..dd2a1bf 100644 --- a/src/declarative/fx/qfxtextedit_p.h +++ b/src/declarative/fx/qfxtextedit_p.h @@ -80,6 +80,7 @@ public: QString text; QmlFont font; QColor color; + QColor highlightColor; QString style; QColor styleColor; bool imgDirty; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 69e08d1..bc5c091 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1329,7 +1329,9 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // check if the item we are sending to are disabled (before we send the event) bool disabled = !item->isEnabled(); bool isWindow = item->isWindow(); - if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick && item != lastMouseGrabberItem) { + if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick + && item != lastMouseGrabberItem && lastMouseGrabberItem) + { // If this item is different from the item that received the last // mouse event, and mouseEvent is a doubleclick event, then the // event is converted to a press. Known limitation: diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index 7d920af..683a7b9 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -37,7 +37,7 @@ void tst_anchors::loops() view->setUrl(QUrl("file://" SRCDIR "/data/loop2.qml")); - //### ignoreMessage doesn't seem to work + //### ignoreMessage doesn't seem to work here //QTest::ignoreMessage(QtWarningMsg, "QML QFxImage (unknown location): Anchor loop detected on horizontal anchor."); //QTest::ignoreMessage(QtWarningMsg, "QML QFxImage (unknown location): Anchor loop detected on horizontal anchor."); view->execute(); |