summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/flickr/content/Slider.qml2
-rw-r--r--doc/src/snippets/declarative/drag.qml6
-rw-r--r--examples/declarative/dial/dial.qml2
-rw-r--r--examples/declarative/minehunt/Description.qml2
-rw-r--r--examples/declarative/mouseregion/mouse.qml3
-rw-r--r--examples/declarative/slideswitch/Switch.qml2
-rw-r--r--examples/declarative/velocity/Day.qml2
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp40
-rw-r--r--src/declarative/fx/qfxmouseregion.h16
-rw-r--r--src/declarative/fx/qfxmouseregion_p.h1
10 files changed, 47 insertions, 29 deletions
diff --git a/demos/declarative/flickr/content/Slider.qml b/demos/declarative/flickr/content/Slider.qml
index a2ec420..24f6f90 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.minimumX: 2; drag.maximumX: Slider.xMax+2
+ drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: Slider.xMax+2
onPositionChanged: { value = (maximum - minimum) * (Handle.x-2) / Slider.xMax + minimum; }
}
}
diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml
index 2191b6f..8b1765b 100644
--- a/doc/src/snippets/declarative/drag.qml
+++ b/doc/src/snippets/declarative/drag.qml
@@ -9,9 +9,9 @@ Rect {
MouseRegion {
anchors.fill: parent
drag.target: pic
- drag.axis: "x"
- drag.xmin: 0
- drag.xmax: blurtest.width-pic.width
+ drag.axis: "XAxis"
+ drag.minimumX: 0
+ drag.maximumX: blurtest.width-pic.width
}
}
}
diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml
index 75bd9b1..75bd65c 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.minimumX: 2; drag.maximumX: 128
+ drag.target: parent; drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: 128
}
}
}
diff --git a/examples/declarative/minehunt/Description.qml b/examples/declarative/minehunt/Description.qml
index cf02bff..2bc182f 100644
--- a/examples/declarative/minehunt/Description.qml
+++ b/examples/declarative/minehunt/Description.qml
@@ -7,7 +7,7 @@ Item {
MouseRegion {
anchors.fill: parent
drag.target: Page
- drag.axis: "xy"
+ drag.axis: "XandYAxis"
drag.minimumX: 0
drag.maximumX: 1000
drag.minimumY: 0
diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml
index 34c6e66..0cb8bb9 100644
--- a/examples/declarative/mouseregion/mouse.qml
+++ b/examples/declarative/mouseregion/mouse.qml
@@ -8,6 +8,7 @@ Rect {
color: "red"
Text { text: "Click"; anchors.centerIn: parent }
MouseRegion {
+ hoverEnabled: true
onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
@@ -24,7 +25,7 @@ Rect {
Text { text: "Drag"; anchors.centerIn: parent }
MouseRegion {
drag.target: parent
- drag.axis: "x"
+ drag.axis: "XAxis"
drag.minimumX: 0
drag.maximumX: 150
onPressed: { print('press') }
diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml
index b5de9ec..b476be2 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.minimumX: 1; drag.maximumX: 78
+ drag.target: Knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
}
states: [
State {
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index c959b0c..d67eabe 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -70,7 +70,7 @@ Rect {
onClicked: { MyText.focus = true }
anchors.fill: parent
drag.target: StickyPage
- drag.axis: "xy"
+ drag.axis: "XandYAxis"
drag.minimumY: 0
drag.maximumY: 500
drag.minimumX: 0
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index 514701d..2a198f2 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -51,7 +51,7 @@ static const int PressAndHoldDelay = 800;
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Drag,QFxDrag)
QFxDrag::QFxDrag(QObject *parent)
-: QObject(parent), _target(0), _xmin(0), _xmax(0), _ymin(0), _ymax(0)
+: QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0)
{
}
@@ -69,12 +69,12 @@ void QFxDrag::setTarget(QFxItem *t)
_target = t;
}
-QString QFxDrag::axis() const
+QFxDrag::Axis QFxDrag::axis() const
{
return _axis;
}
-void QFxDrag::setAxis(const QString &a)
+void QFxDrag::setAxis(QFxDrag::Axis a)
{
_axis = a;
}
@@ -138,7 +138,7 @@ void QFxDrag::setYmax(qreal m)
example extended so as to give a different color when you right click.
\snippet doc/src/snippets/declarative/mouseregion.qml 1
- For basic key handling, see \l KeyActions.
+ For basic key handling, see the \l {Keys}{Keys attached property}.
MouseRegion is an invisible item: it is never painted.
@@ -287,8 +287,8 @@ void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
else {
d->longPress = false;
d->saveEvent(event);
- d->dragX = drag()->axis().contains(QLatin1String("x"));
- d->dragY = drag()->axis().contains(QLatin1String("y"));
+ d->dragX = drag()->axis() & QFxDrag::XAxis;
+ d->dragY = drag()->axis() & QFxDrag::YAxis;
d->dragged = false;
d->start = event->pos();
d->startScene = event->scenePos();
@@ -447,10 +447,22 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event)
}
/*!
+ \qmlproperty bool hoverEnabled
+ This property holds whether hover events are handled.
+
+ By default, mouse events are only handled in response to a button event, or when a button is
+ pressed. Hover enables handling of all mouse events even when no mouse button is
+ pressed.
+
+ This property affects the containsMouse property and the onEntered, onExited and onPositionChanged signals.
+*/
+
+/*!
\qmlproperty bool MouseRegion::containsMouse
This property holds whether the mouse is currently inside the mouse region.
- \warning This property is only partially implemented -- it is only valid when the mouse is pressed, and not for hover events.
+ \warning This property is only partially implemented -- it is only valid when the mouse is moved over the
+ region. If the region moves under the mouse, \e containsMouse will not change.
*/
bool QFxMouseRegion::hovered() const
{
@@ -540,18 +552,18 @@ QFxDrag *QFxMouseRegion::drag()
/*!
\qmlproperty Item MouseRegion::drag.target
- \qmlproperty string MouseRegion::drag.axis
- \qmlproperty real MouseRegion::drag.xmin
- \qmlproperty real MouseRegion::drag.xmax
- \qmlproperty real MouseRegion::drag.ymin
- \qmlproperty real MouseRegion::drag.ymax
+ \qmlproperty Axis MouseRegion::drag.axis
+ \qmlproperty real MouseRegion::drag.minimumX
+ \qmlproperty real MouseRegion::drag.maximumX
+ \qmlproperty real MouseRegion::drag.minimumY
+ \qmlproperty real MouseRegion::drag.maximumY
drag provides a convenient way to make an item draggable.
\list
\i \c target specifies the item to drag.
- \i \c axis specifies whether dragging can be done horizontally (x), vertically (y), or both (x,y)
- \i the min and max properties limit how far the target can be dragged along the corresponding axes.
+ \i \c axis specifies whether dragging can be done horizontally (XAxis), vertically (YAxis), or both (XandYAxis)
+ \i the minimum and maximum properties limit how far the target can be dragged along the corresponding axes.
\endlist
The following example uses drag to reduce the opacity of an image as it moves to the right:
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index f2d22d3..84bb493 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -54,21 +54,26 @@ class Q_DECLARATIVE_EXPORT QFxDrag : public QObject
{
Q_OBJECT
+ Q_ENUMS(Axis)
Q_PROPERTY(QFxItem *target READ target WRITE setTarget)
- Q_PROPERTY(QString axis READ axis WRITE setAxis) //### enum
+ Q_PROPERTY(Axis axis READ axis WRITE setAxis)
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();
QFxItem *target() const;
void setTarget(QFxItem *);
- QString axis() const;
- void setAxis(const QString &);
+
+ enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
+ Axis axis() const;
+ void setAxis(Axis);
+
qreal xmin() const;
void setXmin(qreal);
qreal xmax() const;
@@ -80,7 +85,7 @@ public:
private:
QFxItem *_target;
- QString _axis;
+ Axis _axis;
qreal _xmin;
qreal _xmax;
qreal _ymin;
@@ -100,8 +105,9 @@ class Q_DECLARATIVE_EXPORT QFxMouseRegion : public QFxItem
Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged)
+ Q_PROPERTY(bool hoverEnabled READ acceptHoverEvents WRITE setAcceptHoverEvents)
Q_PROPERTY(QFxDrag *drag READ drag) //### add flicking to QFxDrag or add a QFxFlick ???
- //### trackingEnabled?
+
public:
QFxMouseRegion(QFxItem *parent=0);
~QFxMouseRegion();
diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h
index 1501a81..d981b85 100644
--- a/src/declarative/fx/qfxmouseregion_p.h
+++ b/src/declarative/fx/qfxmouseregion_p.h
@@ -74,7 +74,6 @@ public:
{
Q_Q(QFxMouseRegion);
q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setAcceptHoverEvents(true);
}
void saveEvent(QGraphicsSceneMouseEvent *event) {