From d272b9197c9cc40ac50a1cfa2703c648c962f0f2 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 18 Aug 2009 08:19:16 +1000 Subject: No need to copy pixmap. --- src/declarative/fx/qfximage.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index ec3fdab..61c1411 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -258,77 +258,75 @@ void QFxImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) if (d->smooth) p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - QPixmap pix = d->pix; - - if (width() != pix.width() || height() != pix.height()) { + if (width() != d->pix.width() || height() != d->pix.height()) { if (d->fillMode >= Tile) { p->save(); p->setClipRect(0, 0, width(), height(), Qt::IntersectClip); if (d->fillMode == Tile) { - const int pw = pix.width(); - const int ph = pix.height(); + const int pw = d->pix.width(); + const int ph = d->pix.height(); int yy = 0; while(yy < height()) { int xx = 0; while(xx < width()) { - p->drawPixmap(xx, yy, pix); + p->drawPixmap(xx, yy, d->pix); xx += pw; } yy += ph; } } else if (d->fillMode == TileVertically) { - const int ph = pix.height(); + const int ph = d->pix.height(); int yy = 0; while(yy < height()) { - p->drawPixmap(QRect(0, yy, width(), ph), pix); + p->drawPixmap(QRect(0, yy, width(), ph), d->pix); yy += ph; } } else { - const int pw = pix.width(); + const int pw = d->pix.width(); int xx = 0; while(xx < width()) { - p->drawPixmap(QRect(xx, 0, pw, height()), pix); + p->drawPixmap(QRect(xx, 0, pw, height()), d->pix); xx += pw; } } p->restore(); } else { - qreal widthScale = width() / qreal(pix.width()); - qreal heightScale = height() / qreal(pix.height()); + qreal widthScale = width() / qreal(d->pix.width()); + qreal heightScale = height() / qreal(d->pix.height()); QTransform scale; if (d->fillMode == PreserveAspectFit) { if (widthScale < heightScale) { heightScale = widthScale; - scale.translate(0, (height() - heightScale * pix.height()) / 2); + scale.translate(0, (height() - heightScale * d->pix.height()) / 2); } else if(heightScale < widthScale) { widthScale = heightScale; - scale.translate((width() - widthScale * pix.width()) / 2, 0); + scale.translate((width() - widthScale * d->pix.width()) / 2, 0); } } else if (d->fillMode == PreserveAspectCrop) { if (widthScale < heightScale) { widthScale = heightScale; - scale.translate((width() - widthScale * pix.width()) / 2, 0); + scale.translate((width() - widthScale * d->pix.width()) / 2, 0); } else if(heightScale < widthScale) { heightScale = widthScale; - scale.translate(0, (height() - heightScale * pix.height()) / 2); + scale.translate(0, (height() - heightScale * d->pix.height()) / 2); } } scale.scale(widthScale, heightScale); QTransform old = p->transform(); p->setWorldTransform(scale * old); - p->drawPixmap(0, 0, pix); + p->drawPixmap(0, 0, d->pix); p->setWorldTransform(old); } } else { - p->drawPixmap(0, 0, pix); + p->drawPixmap(0, 0, d->pix); } if (d->smooth) { -- cgit v0.12 From c9f4ad424949085209acda6cff07babbe8d29001 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 18 Aug 2009 10:22:01 +1000 Subject: Change Item.contents to Item.childrenRect. --- examples/declarative/clock/display.qml | 4 +- .../1_Drawing_and_animation.qml | 2 +- .../tutorials/contacts/2_Reuse/2_Reuse.qml | 2 +- .../contacts/3_Collections/3_Collections.qml | 4 +- examples/declarative/xmldata/daringfireball.qml | 2 +- examples/declarative/xmldata/yahoonews.qml | 2 +- src/declarative/fx/qfxitem.cpp | 54 ++++++++++------------ src/declarative/fx/qfxitem.h | 37 ++------------- src/declarative/fx/qfxitem_p.h | 27 +++++++++++ 9 files changed, 62 insertions(+), 72 deletions(-) diff --git a/examples/declarative/clock/display.qml b/examples/declarative/clock/display.qml index cd6dcf7..00af9b3 100644 --- a/examples/declarative/clock/display.qml +++ b/examples/declarative/clock/display.qml @@ -1,7 +1,7 @@ import Qt 4.6 Rect { - width: contents.width - height: contents.height + width: childrenRect.width + height: childrenRect.height Clock { id: Clock } } diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml index a70ef16..1087d6a 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml @@ -7,7 +7,7 @@ Rect { color: "white" VerticalPositioner { id: layout - width: contents.width + width: childrenRect.width GroupBox { contents: "1/RemoveButton.qml" label: "Rectangle Component" diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml index 7ac513e..70b8b95 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml @@ -9,7 +9,7 @@ Rect { id: layout columns: 2 rows: 4 - width: contents.width + width: childrenRect.width GroupBox { contents: "1/ContactField.qml" label: "Loading: simple" diff --git a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml index d61705c..5a22b1c 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml @@ -13,8 +13,8 @@ Rect { // component removes focus from any previous element GridPositioner { id: layout - width: contents.width - height: contents.height + width: childrenRect.width + height: childrenRect.height GroupBox { contents: "1/ContactView.qml" label: "list only" diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml index 4fb12af..a93483e 100644 --- a/examples/declarative/xmldata/daringfireball.qml +++ b/examples/declarative/xmldata/daringfireball.qml @@ -26,7 +26,7 @@ Rect { Component { id: feedDelegate Item { - height: contents.height + 20 + height: childrenRect.height + 20 Text { x: 10 id: TitleText diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index 156eb31..22586b8 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -66,7 +66,7 @@ Rect { states: [ State { name: "Details" - SetProperties { target: Wrapper; height: contents.height + 10 } + SetProperties { target: Wrapper; height: childrenRect.height + 10 } SetProperties { target: Description; opacity: 1 } } ] diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 0b86a54..f5f502c 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -69,7 +69,6 @@ QT_BEGIN_NAMESPACE #define FLT_MAX 1E+37 #endif -QML_DEFINE_NOCREATE_TYPE(QFxContents) QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Item,QFxItem) QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform); @@ -210,40 +209,30 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation) */ -QFxContents::QFxContents() : m_height(0), m_width(0) +QFxContents::QFxContents() : m_x(0), m_y(0), m_width(0), m_height(0) { } /*! - \qmlproperty qreal Item::contents.width - \qmlproperty qreal Item::contents.height + \qmlproperty qreal Item::childrenRect.x + \qmlproperty qreal Item::childrenRect.y + \qmlproperty qreal Item::childrenRect.width + \qmlproperty qreal Item::childrenRect.height - The contents properties allow an item access to the size of its + The childrenRect properties allow an item access to the geometry of its children. This property is useful if you have an item that needs to be sized to fit its children. */ -/*! - \property QFxContents::height - \brief The height of the contents. -*/ -qreal QFxContents::height() const +QRectF QFxContents::rectF() const { - return m_height; -} - -/*! - \property QFxContents::width - \brief The width of the contents. -*/ -qreal QFxContents::width() const -{ - return m_width; + return QRectF(m_x, m_y, m_width, m_height); } //TODO: optimization: only check sender(), if there is one void QFxContents::calcHeight() { + qreal oldy = m_y; qreal oldheight = m_height; qreal top = FLT_MAX; @@ -258,15 +247,18 @@ void QFxContents::calcHeight() if (y < top) top = y; } + if (!children.isEmpty()) + m_y = top; m_height = qMax(bottom - top, qreal(0.0)); - if (m_height != oldheight) - emit heightChanged(); + if (m_height != oldheight || m_y != oldy) + emit rectChanged(); } //TODO: optimization: only check sender(), if there is one void QFxContents::calcWidth() { + qreal oldx = m_x; qreal oldwidth = m_width; qreal left = FLT_MAX; @@ -281,10 +273,12 @@ void QFxContents::calcWidth() if (x < left) left = x; } + if (!children.isEmpty()) + m_x = left; m_width = qMax(right - left, qreal(0.0)); - if (m_width != oldwidth) - emit widthChanged(); + if (m_width != oldwidth || m_x != oldx) + emit rectChanged(); } void QFxContents::setItem(QFxItem *item) @@ -298,6 +292,7 @@ void QFxContents::setItem(QFxItem *item) connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight())); connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth())); connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth())); + connect(this, SIGNAL(rectChanged()), m_item, SIGNAL(childrenRectChanged())); } calcHeight(); @@ -1285,13 +1280,12 @@ QmlList *QFxItem::data() } /*! - \property QFxItem::contents - \brief An object that knows about the size of an item's children. + \property QFxItem::childrenRect + \brief The geometry of an item's children. - contents provides an easy way to access the (collective) width and - height of the item's children. + childrenRect provides an easy way to access the (collective) position and size of the item's children. */ -QFxContents *QFxItem::contents() +QRectF QFxItem::childrenRect() { Q_D(QFxItem); if (!d->_contents) { @@ -1299,7 +1293,7 @@ QFxContents *QFxItem::contents() d->_contents->setParent(this); d->_contents->setItem(this); } - return d->_contents; + return d->_contents->rectF(); } bool QFxItem::clip() const diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index d8fb983..3485985 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -57,37 +57,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QGraphicsTransform; - -class QFxItem; -class Q_DECLARATIVE_EXPORT QFxContents : public QObject -{ - Q_OBJECT - Q_PROPERTY(qreal height READ height NOTIFY heightChanged) - Q_PROPERTY(qreal width READ width NOTIFY widthChanged) -public: - QFxContents(); - - qreal height() const; - - qreal width() const; - - void setItem(QFxItem *item); - -public Q_SLOTS: - void calcHeight(); - void calcWidth(); - -Q_SIGNALS: - void heightChanged(); - void widthChanged(); - -private: - QFxItem *m_item; - qreal m_height; - qreal m_width; -}; - class QmlState; class QFxAnchorLine; class QmlTransition; @@ -109,7 +78,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) - Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT FINAL) + Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL) Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine right READ right CONSTANT FINAL) @@ -147,7 +116,7 @@ public: QmlList *resources(); QFxAnchors *anchors(); - QFxContents *contents(); + QRectF childrenRect(); bool clip() const; void setClip(bool); @@ -190,6 +159,7 @@ Q_SIGNALS: void yChanged(); void widthChanged(); void heightChanged(); + void childrenRectChanged(); void baselineOffsetChanged(); void stateChanged(const QString &); void focusChanged(); @@ -251,7 +221,6 @@ QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QFxItem *item); QT_END_NAMESPACE -QML_DECLARE_TYPE(QFxContents) QML_DECLARE_TYPE(QFxItem) QML_DECLARE_TYPE(QGraphicsTransform) QML_DECLARE_TYPE(QGraphicsScale) diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 0e916b2..1d4bef3 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -69,6 +69,32 @@ QT_BEGIN_NAMESPACE class QNetworkReply; class QFxKeysAttached; +//### merge into private? +class QFxContents : public QObject +{ + Q_OBJECT +public: + QFxContents(); + + QRectF rectF() const; + + void setItem(QFxItem *item); + +public Q_SLOTS: + void calcHeight(); + void calcWidth(); + +Q_SIGNALS: + void rectChanged(); + +private: + QFxItem *m_item; + qreal m_x; + qreal m_y; + qreal m_width; + qreal m_height; +}; + class QFxItemPrivate : public QGraphicsItemPrivate { Q_DECLARE_PUBLIC(QFxItem) @@ -200,4 +226,5 @@ public: }; QT_END_NAMESPACE + #endif // QFXITEM_P_H -- cgit v0.12 From 8f5e72298fc4b8a5838bee1291a2cc422750b6b8 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 18 Aug 2009 10:43:02 +1000 Subject: MouseRegion API changes following review. --- demos/declarative/flickr/content/Slider.qml | 2 +- examples/declarative/dial/dial.qml | 2 +- examples/declarative/minehunt/Description.qml | 8 ++--- examples/declarative/mouseregion/mouse.qml | 4 +-- examples/declarative/scrollbar/display.qml | 2 ++ examples/declarative/slideswitch/Switch.qml | 2 +- examples/declarative/velocity/Day.qml | 8 ++--- src/declarative/fx/qfxmouseregion.cpp | 46 ++++++++++++++++++++++++--- src/declarative/fx/qfxmouseregion.h | 26 +++++++++------ src/declarative/fx/qfxmouseregion_p.h | 2 +- 10 files changed, 74 insertions(+), 28 deletions(-) diff --git a/demos/declarative/flickr/content/Slider.qml b/demos/declarative/flickr/content/Slider.qml index 51385bc..a2ec420 100644 --- a/demos/declarative/flickr/content/Slider.qml +++ b/demos/declarative/flickr/content/Slider.qml @@ -29,7 +29,7 @@ Item { MouseRegion { anchors.fill: parent; drag.target: parent - drag.axis: "x"; drag.xmin: 2; drag.xmax: Slider.xMax+2 + drag.axis: "x"; drag.minimumX: 2; drag.maximumX: Slider.xMax+2 onPositionChanged: { value = (maximum - minimum) * (Handle.x-2) / Slider.xMax + minimum; } } } diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml index 3773bcc..75bd9b1 100644 --- a/examples/declarative/dial/dial.qml +++ b/examples/declarative/dial/dial.qml @@ -26,7 +26,7 @@ Rect { } MouseRegion { anchors.fill: parent - drag.target: parent; drag.axis: "x"; drag.xmin: 2; drag.xmax: 128 + drag.target: parent; drag.axis: "x"; drag.minimumX: 2; drag.maximumX: 128 } } } diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml index 9ad6522..cf02bff 100644 --- a/examples/declarative/minehunt/Description.qml +++ b/examples/declarative/minehunt/Description.qml @@ -8,10 +8,10 @@ Item { anchors.fill: parent drag.target: Page drag.axis: "xy" - drag.xmin: 0 - drag.xmax: 1000 - drag.ymin: 0 - drag.ymax: 1000 + drag.minimumX: 0 + drag.maximumX: 1000 + drag.minimumY: 0 + drag.maximumY: 1000 } Rect { radius: 10 diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml index d9db106..34c6e66 100644 --- a/examples/declarative/mouseregion/mouse.qml +++ b/examples/declarative/mouseregion/mouse.qml @@ -25,8 +25,8 @@ Rect { MouseRegion { drag.target: parent drag.axis: "x" - drag.xmin: 0 - drag.xmax: 150 + drag.minimumX: 0 + drag.maximumX: 150 onPressed: { print('press') } onReleased: { print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') } onClicked: { print('click' + '(wasHeld: ' + mouse.wasHeld + ')') } diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index 03a40d3..d8bd187 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -44,6 +44,7 @@ Rect { height: View.height-12 anchors.right: View.right } + /* ScrollBar { id: SBH opacity: 0 @@ -54,4 +55,5 @@ Rect { width: View.width-12 anchors.bottom: View.bottom } + */ } diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml index 91627c7..b5de9ec 100644 --- a/examples/declarative/slideswitch/Switch.qml +++ b/examples/declarative/slideswitch/Switch.qml @@ -36,7 +36,7 @@ Item { anchors.fill: Knob onClicked: { toggle() } onReleased: { dorelease() } - drag.target: Knob; drag.axis: "x"; drag.xmin: 1; drag.xmax: 78 + drag.target: Knob; drag.axis: "x"; drag.minimumX: 1; drag.maximumX: 78 } states: [ State { diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index 59a31af..c959b0c 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -71,10 +71,10 @@ Rect { anchors.fill: parent drag.target: StickyPage drag.axis: "xy" - drag.ymin: 0 - drag.ymax: 500 - drag.xmin: 0 - drag.xmax: 400 + drag.minimumY: 0 + drag.maximumY: 500 + drag.minimumX: 0 + drag.maximumX: 400 } } } diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp index 42e024d..22d64cb 100644 --- a/src/declarative/fx/qfxmouseregion.cpp +++ b/src/declarative/fx/qfxmouseregion.cpp @@ -296,7 +296,10 @@ bool QFxMouseRegion::isEnabled() const void QFxMouseRegion::setEnabled(bool a) { Q_D(QFxMouseRegion); - d->absorb = a; + if (a != d->absorb) { + d->absorb = a; + emit enabledChanged(); + } } void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event) @@ -473,9 +476,9 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event) \warning This property is only partially implemented -- it is only valid when the mouse is pressed, and not for hover events. */ -bool QFxMouseRegion::hovered() +bool QFxMouseRegion::hovered() const { - Q_D(QFxMouseRegion); + Q_D(const QFxMouseRegion); return d->hovered; } @@ -483,9 +486,9 @@ bool QFxMouseRegion::hovered() \qmlproperty bool MouseRegion::pressed This property holds whether the mouse region is currently pressed. */ -bool QFxMouseRegion::pressed() +bool QFxMouseRegion::pressed() const { - Q_D(QFxMouseRegion); + Q_D(const QFxMouseRegion); return d->pressed; } @@ -499,6 +502,39 @@ void QFxMouseRegion::setHovered(bool h) } } +/*! + \qmlproperty Qt::MouseButtons MouseRegion::acceptedButtons + This property holds the mouse buttons that the mouse region reacts to. + + The available buttons are: + \list + \o Qt.LeftButton + \o Qt.RightButton + \o Qt.MiddleButton + \endlist + + To accept more than one button the flags can be combined with the + "|" (or) operator: + + \code + MouseRegion { acceptedButtons: Qt.LeftButton | Qt.RightButton } + \endcode + + The default is to accept the Left button. +*/ +Qt::MouseButtons QFxMouseRegion::acceptedButtons() const +{ + return acceptedMouseButtons(); +} + +void QFxMouseRegion::setAcceptedButtons(Qt::MouseButtons buttons) +{ + if (buttons != acceptedMouseButtons()) { + setAcceptedMouseButtons(buttons); + emit acceptedButtonsChanged(); + } +} + void QFxMouseRegion::setPressed(bool p) { Q_D(QFxMouseRegion); diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h index 418434a..f2d22d3 100644 --- a/src/declarative/fx/qfxmouseregion.h +++ b/src/declarative/fx/qfxmouseregion.h @@ -55,11 +55,12 @@ class Q_DECLARATIVE_EXPORT QFxDrag : public QObject Q_OBJECT Q_PROPERTY(QFxItem *target READ target WRITE setTarget) - Q_PROPERTY(QString axis READ axis WRITE setAxis) - Q_PROPERTY(qreal xmin READ xmin WRITE setXmin) - Q_PROPERTY(qreal xmax READ xmax WRITE setXmax) - Q_PROPERTY(qreal ymin READ ymin WRITE setYmin) - Q_PROPERTY(qreal ymax READ ymax WRITE setYmax) + Q_PROPERTY(QString axis READ axis WRITE setAxis) //### enum + Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin) + Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax) + Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin) + Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax) + //### consider drag and drop public: QFxDrag(QObject *parent=0); ~QFxDrag(); @@ -97,8 +98,10 @@ class Q_DECLARATIVE_EXPORT QFxMouseRegion : public QFxItem Q_PROPERTY(qreal mouseY READ mouseY NOTIFY positionChanged) Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged) Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) - Q_PROPERTY(QFxDrag *drag READ drag) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged) + Q_PROPERTY(QFxDrag *drag READ drag) //### add flicking to QFxDrag or add a QFxFlick ??? + //### trackingEnabled? public: QFxMouseRegion(QFxItem *parent=0); ~QFxMouseRegion(); @@ -109,17 +112,22 @@ public: bool isEnabled() const; void setEnabled(bool); - bool hovered(); - bool pressed(); + bool hovered() const; + bool pressed() const; void setHovered(bool); void setPressed(bool); + Qt::MouseButtons acceptedButtons() const; + void setAcceptedButtons(Qt::MouseButtons buttons); + QFxDrag *drag(); Q_SIGNALS: void hoveredChanged(); void pressedChanged(); + void enabledChanged(); + void acceptedButtonsChanged(); void positionChanged(QFxMouseEvent *mouse); void pressed(QFxMouseEvent *mouse); diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h index f03c334..1501a81 100644 --- a/src/declarative/fx/qfxmouseregion_p.h +++ b/src/declarative/fx/qfxmouseregion_p.h @@ -73,7 +73,7 @@ public: void init() { Q_Q(QFxMouseRegion); - q->setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); + q->setAcceptedMouseButtons(Qt::LeftButton); q->setAcceptHoverEvents(true); } -- cgit v0.12