aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-01-25 15:14:27 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-01-28 09:29:39 +0000
commit2ed9dc9cbb6fbf3a68780b48a456ce3ef9bf82c0 (patch)
tree46621e3d80423c47f0b6d9b0f6d083824da95390
parent147c215ec9174c394bcaa2c33760df735f4d1ebf (diff)
AbstractButton: remove the mouse params from signals
If we ever want to expose these, the name would be something else than "mouse"... :) Change-Id: Ie9dad16e84708059fd0b43d4764925db7b014d64 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r--src/imports/controls/plugins.qmltypes20
-rw-r--r--src/imports/templates/plugins.qmltypes174
-rw-r--r--src/templates/qquickabstractbutton.cpp56
-rw-r--r--src/templates/qquickabstractbutton_p.h9
-rw-r--r--src/templates/qquickswitch.cpp5
-rw-r--r--tests/auto/controls/data/tst_button.qml76
-rw-r--r--tests/auto/menu/tst_menu.cpp2
7 files changed, 29 insertions, 313 deletions
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes
index bbccc210..d52c6153 100644
--- a/src/imports/controls/plugins.qmltypes
+++ b/src/imports/controls/plugins.qmltypes
@@ -29,23 +29,11 @@ Module {
Property { name: "autoRepeat"; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
Property { name: "label"; type: "QQuickItem"; isPointer: true }
- Signal {
- name: "pressed"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
- Signal {
- name: "released"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
+ Signal { name: "pressed" }
+ Signal { name: "released" }
Signal { name: "canceled" }
- Signal {
- name: "clicked"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
- Signal {
- name: "doubleClicked"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
+ Signal { name: "clicked" }
+ Signal { name: "doubleClicked" }
Method { name: "toggle" }
}
Component {
diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes
index 3c0592a8..67058870 100644
--- a/src/imports/templates/plugins.qmltypes
+++ b/src/imports/templates/plugins.qmltypes
@@ -23,23 +23,11 @@ Module {
Property { name: "autoRepeat"; type: "bool" }
Property { name: "indicator"; type: "QQuickItem"; isPointer: true }
Property { name: "label"; type: "QQuickItem"; isPointer: true }
- Signal {
- name: "pressed"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
- Signal {
- name: "released"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
+ Signal { name: "pressed" }
+ Signal { name: "released" }
Signal { name: "canceled" }
- Signal {
- name: "clicked"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
- Signal {
- name: "doubleClicked"
- Parameter { name: "mouse"; type: "QQuickMouseEvent"; isPointer: true }
- }
+ Signal { name: "clicked" }
+ Signal { name: "doubleClicked" }
Method { name: "toggle" }
}
Component {
@@ -262,160 +250,6 @@ Module {
Signal { name: "implicitHeightChanged2"; revision: 1 }
}
Component {
- name: "QQuickItem"
- defaultProperty: "data"
- prototype: "QObject"
- Enum {
- name: "TransformOrigin"
- values: {
- "TopLeft": 0,
- "Top": 1,
- "TopRight": 2,
- "Left": 3,
- "Center": 4,
- "Right": 5,
- "BottomLeft": 6,
- "Bottom": 7,
- "BottomRight": 8
- }
- }
- Property { name: "parent"; type: "QQuickItem"; isPointer: true }
- Property { name: "data"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true }
- Property { name: "x"; type: "double" }
- Property { name: "y"; type: "double" }
- Property { name: "z"; type: "double" }
- Property { name: "width"; type: "double" }
- Property { name: "height"; type: "double" }
- Property { name: "opacity"; type: "double" }
- Property { name: "enabled"; type: "bool" }
- Property { name: "visible"; type: "bool" }
- Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true }
- Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true }
- Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true }
- Property { name: "state"; type: "string" }
- Property { name: "childrenRect"; type: "QRectF"; isReadonly: true }
- Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true }
- Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true }
- Property { name: "baselineOffset"; type: "double" }
- Property { name: "clip"; type: "bool" }
- Property { name: "focus"; type: "bool" }
- Property { name: "activeFocus"; type: "bool"; isReadonly: true }
- Property { name: "activeFocusOnTab"; revision: 1; type: "bool" }
- Property { name: "rotation"; type: "double" }
- Property { name: "scale"; type: "double" }
- Property { name: "transformOrigin"; type: "TransformOrigin" }
- Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true }
- Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true }
- Property { name: "smooth"; type: "bool" }
- Property { name: "antialiasing"; type: "bool" }
- Property { name: "implicitWidth"; type: "double" }
- Property { name: "implicitHeight"; type: "double" }
- Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true }
- Signal {
- name: "childrenRectChanged"
- Parameter { type: "QRectF" }
- }
- Signal {
- name: "baselineOffsetChanged"
- Parameter { type: "double" }
- }
- Signal {
- name: "stateChanged"
- Parameter { type: "string" }
- }
- Signal {
- name: "focusChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "activeFocusChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "activeFocusOnTabChanged"
- revision: 1
- Parameter { type: "bool" }
- }
- Signal {
- name: "parentChanged"
- Parameter { type: "QQuickItem"; isPointer: true }
- }
- Signal {
- name: "transformOriginChanged"
- Parameter { type: "TransformOrigin" }
- }
- Signal {
- name: "smoothChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "antialiasingChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "clipChanged"
- Parameter { type: "bool" }
- }
- Signal {
- name: "windowChanged"
- revision: 1
- Parameter { name: "window"; type: "QQuickWindow"; isPointer: true }
- }
- Method { name: "update" }
- Method {
- name: "grabToImage"
- revision: 2
- type: "bool"
- Parameter { name: "callback"; type: "QJSValue" }
- Parameter { name: "targetSize"; type: "QSize" }
- }
- Method {
- name: "grabToImage"
- revision: 2
- type: "bool"
- Parameter { name: "callback"; type: "QJSValue" }
- }
- Method {
- name: "contains"
- type: "bool"
- Parameter { name: "point"; type: "QPointF" }
- }
- Method {
- name: "mapFromItem"
- Parameter { type: "QQmlV4Function"; isPointer: true }
- }
- Method {
- name: "mapToItem"
- Parameter { type: "QQmlV4Function"; isPointer: true }
- }
- Method { name: "forceActiveFocus" }
- Method {
- name: "forceActiveFocus"
- Parameter { name: "reason"; type: "Qt::FocusReason" }
- }
- Method {
- name: "nextItemInFocusChain"
- revision: 1
- type: "QQuickItem*"
- Parameter { name: "forward"; type: "bool" }
- }
- Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" }
- Method {
- name: "childAt"
- type: "QQuickItem*"
- Parameter { name: "x"; type: "double" }
- Parameter { name: "y"; type: "double" }
- }
- }
- Component {
name: "QQuickItemDelegate"
defaultProperty: "data"
prototype: "QQuickAbstractButton"
diff --git a/src/templates/qquickabstractbutton.cpp b/src/templates/qquickabstractbutton.cpp
index fe39a4e5..664efce5 100644
--- a/src/templates/qquickabstractbutton.cpp
+++ b/src/templates/qquickabstractbutton.cpp
@@ -67,21 +67,15 @@ static const int AUTO_REPEAT_INTERVAL = 100;
*/
/*!
- \qmlsignal Qt.labs.controls::AbstractButton::pressed(MouseEvent mouse)
+ \qmlsignal Qt.labs.controls::AbstractButton::pressed()
This signal is emitted when the button is interactively pressed by the user.
-
- The mouse parameter provides information about the press, including the x
- and y position and which button was pressed.
*/
/*!
- \qmlsignal Qt.labs.controls::AbstractButton::released(MouseEvent mouse)
+ \qmlsignal Qt.labs.controls::AbstractButton::released()
This signal is emitted when the button is interactively released by the user.
-
- The mouse parameter provides information about the click, including the x
- and y position of the release of the click, and whether the click was held.
*/
/*!
@@ -93,21 +87,15 @@ static const int AUTO_REPEAT_INTERVAL = 100;
*/
/*!
- \qmlsignal Qt.labs.controls::AbstractButton::clicked(MouseEvent mouse)
+ \qmlsignal Qt.labs.controls::AbstractButton::clicked()
This signal is emitted when the button is interactively clicked by the user.
-
- The mouse parameter provides information about the click, including the x
- and y position of the release of the click, and whether the click was held.
*/
/*!
- \qmlsignal Qt.labs.controls::AbstractButton::doubleClicked(MouseEvent mouse)
+ \qmlsignal Qt.labs.controls::AbstractButton::doubleClicked()
This signal is emitted when the button is interactively double clicked by the user.
-
- The mouse parameter provides information about the click, including the x
- and y position of the release of the click, and whether the click was held.
*/
QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() :
@@ -461,9 +449,7 @@ void QQuickAbstractButton::keyPressEvent(QKeyEvent *event)
d->repeatButton = Qt::NoButton;
}
- QQuickMouseEvent me(d->pressPoint.x(), d->pressPoint.y(), Qt::NoButton, QGuiApplication::mouseButtons(), event->modifiers());
- emit pressed(&me);
- event->setAccepted(me.isAccepted());
+ emit pressed();
}
}
@@ -474,12 +460,9 @@ void QQuickAbstractButton::keyReleaseEvent(QKeyEvent *event)
if (event->key() == Qt::Key_Space) {
setPressed(false);
- QQuickMouseEvent mre(d->pressPoint.x(), d->pressPoint.y(), Qt::NoButton, QGuiApplication::mouseButtons(), event->modifiers());
- emit released(&mre);
- QQuickMouseEvent mce(d->pressPoint.x(), d->pressPoint.y(), Qt::NoButton, QGuiApplication::mouseButtons(), event->modifiers(), true /* isClick */);
- emit clicked(&mce);
+ emit released();
+ emit clicked();
nextCheckState();
- event->setAccepted(mre.isAccepted() || mce.isAccepted());
if (d->autoRepeat)
d->stopPressRepeat();
@@ -493,9 +476,7 @@ void QQuickAbstractButton::mousePressEvent(QMouseEvent *event)
setPressed(true);
d->pressPoint = event->pos();
- QQuickMouseEvent me(event->x(), event->y(), event->button(), event->buttons(), event->modifiers());
- emit pressed(&me);
- event->setAccepted(me.isAccepted());
+ emit pressed();
if (d->autoRepeat) {
d->startRepeatDelay();
@@ -521,11 +502,8 @@ void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event)
setPressed(false);
if (wasPressed) {
- QQuickMouseEvent mre(event->x(), event->y(), event->button(), event->buttons(), event->modifiers());
- emit released(&mre);
- QQuickMouseEvent mce(event->x(), event->y(), event->button(), event->buttons(), event->modifiers(), true /* isClick */);
- emit clicked(&mce);
- event->setAccepted(mre.isAccepted() || mce.isAccepted());
+ emit released();
+ emit clicked();
} else {
emit canceled();
}
@@ -540,10 +518,7 @@ void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event)
void QQuickAbstractButton::mouseDoubleClickEvent(QMouseEvent *event)
{
QQuickControl::mouseDoubleClickEvent(event);
-
- QQuickMouseEvent me(event->x(), event->y(), event->button(), event->buttons(), event->modifiers(), true /* isClick */);
- emit doubleClicked(&me);
- event->setAccepted(me.isAccepted());
+ emit doubleClicked();
}
void QQuickAbstractButton::mouseUngrabEvent()
@@ -564,12 +539,9 @@ void QQuickAbstractButton::timerEvent(QTimerEvent *event)
if (event->timerId() == d->delayTimer) {
d->startPressRepeat();
} else if (event->timerId() == d->repeatTimer) {
- QQuickMouseEvent mre(d->pressPoint.x(), d->pressPoint.y(), d->repeatButton, QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
- emit released(&mre);
- QQuickMouseEvent mce(d->pressPoint.x(), d->pressPoint.y(), d->repeatButton, QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers(), true /* isClick */);
- emit clicked(&mce);
- QQuickMouseEvent mpe(d->pressPoint.x(), d->pressPoint.y(), d->repeatButton, QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
- emit pressed(&mpe);
+ emit released();
+ emit clicked();
+ emit pressed();
}
}
diff --git a/src/templates/qquickabstractbutton_p.h b/src/templates/qquickabstractbutton_p.h
index e0296dc0..0dd94ff5 100644
--- a/src/templates/qquickabstractbutton_p.h
+++ b/src/templates/qquickabstractbutton_p.h
@@ -52,7 +52,6 @@
QT_BEGIN_NAMESPACE
-class QQuickMouseEvent;
class QQuickAbstractButtonPrivate;
class Q_LABSTEMPLATES_EXPORT QQuickAbstractButton : public QQuickControl
@@ -103,11 +102,11 @@ public Q_SLOTS:
void toggle();
Q_SIGNALS:
- void pressed(QQuickMouseEvent *mouse);
- void released(QQuickMouseEvent *mouse);
+ void pressed();
+ void released();
void canceled();
- void clicked(QQuickMouseEvent *mouse);
- void doubleClicked(QQuickMouseEvent *mouse);
+ void clicked();
+ void doubleClicked();
void textChanged();
void pressedChanged();
void checkedChanged();
diff --git a/src/templates/qquickswitch.cpp b/src/templates/qquickswitch.cpp
index 8544d7ca..f5c1a605 100644
--- a/src/templates/qquickswitch.cpp
+++ b/src/templates/qquickswitch.cpp
@@ -139,9 +139,8 @@ bool QQuickSwitchPrivate::handleMouseReleaseEvent(QQuickItem *child, QMouseEvent
child->setKeepMouseGrab(false);
event->accept();
} else {
- QQuickMouseEvent me(event->x(), event->y(), event->button(), event->buttons(), event->modifiers(), true /* isClick */);
- emit q->clicked(&me);
- event->setAccepted(me.isAccepted());
+ emit q->clicked();
+ event->accept();
q->toggle();
}
return true;
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index 1faf1956..45fad8cb 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -163,86 +163,10 @@ TestCase {
control.destroy()
}
- Component {
- id: eventButton
- Button {
- property var lastPress
- property var lastRelease
- property var lastClick
- property var lastDoubleClick
-
- function reset() {
- lastPress = undefined
- lastRelease = undefined
- lastClick = undefined
- lastDoubleClick = undefined
- }
-
- onPressed: { lastPress = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } }
- onReleased: { lastRelease = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } }
- onClicked: { lastClick = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } }
- onDoubleClicked: { lastDoubleClick = { x: mouse.x, y: mouse.y, button: mouse.button, buttons: mouse.buttons, modifiers: mouse.modifiers, wasHeld: mouse.wasHeld, isClick: mouse.isClick } }
- }
- }
-
function eventErrorMessage(actual, expected) {
return "actual event:" + JSON.stringify(actual) + ", expected event:" + JSON.stringify(expected)
}
- function test_events() {
- var control = eventButton.createObject(testCase)
- verify(control)
-
- control.forceActiveFocus()
- verify(control.activeFocus)
-
- mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton)
- var expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.LeftButton, buttons: Qt.LeftButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false }
- compare(control.lastPress, expected, eventErrorMessage(control.lastPress, expected))
- compare(control.lastRelease, undefined)
- compare(control.lastClick, undefined)
- compare(control.lastDoubleClick, undefined)
-
- control.reset()
-
- mouseMove(control, control.width / 3, control.height / 3, Qt.LeftButton)
- compare(control.lastPress, undefined)
- compare(control.lastRelease, undefined)
- compare(control.lastClick, undefined)
- compare(control.lastDoubleClick, undefined)
-
- control.reset()
-
- mouseRelease(control, control.width / 4, control.height / 4, Qt.LeftButton)
- compare(control.lastPress, undefined)
- expected = { x: Math.round(control.width / 4), y: Math.round(control.height / 4), button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false }
- compare(control.lastRelease, expected, eventErrorMessage(control.lastRelease, expected))
- expected = { x: Math.round(control.width / 4), y: Math.round(control.height / 4), button: Qt.LeftButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: true }
- compare(control.lastClick, expected, eventErrorMessage(control.lastClick, expected))
- compare(control.lastDoubleClick, undefined)
-
- control.reset()
-
- keyPress(Qt.Key_Space)
- expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.NoButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false }
- compare(control.lastPress, expected, eventErrorMessage(control.lastPress, expected))
- compare(control.lastRelease, undefined)
- compare(control.lastClick, undefined)
- compare(control.lastDoubleClick, undefined)
-
- control.reset()
-
- keyRelease(Qt.Key_Space)
- compare(control.lastPress, undefined)
- expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.NoButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: false }
- compare(control.lastRelease, expected, eventErrorMessage(control.lastRelease, expected))
- expected = { x: Math.round(control.width / 2), y: Math.round(control.height / 2), button: Qt.NoButton, buttons: Qt.NoButton, modifiers: Qt.NoModifier, wasHeld: false, isClick: true }
- compare(control.lastClick, expected, eventErrorMessage(control.lastClick, expected))
- compare(control.lastDoubleClick, undefined)
-
- control.destroy()
- }
-
SignalSpy { id: clickSpy; signalName: "clicked" }
function test_autoRepeat() {
diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp
index d072af4b..825867cf 100644
--- a/tests/auto/menu/tst_menu.cpp
+++ b/tests/auto/menu/tst_menu.cpp
@@ -89,7 +89,7 @@ void tst_menu::mouse()
QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem()));
QQuickItem *firstItem = menu->itemAt(0);
- QSignalSpy clickedSpy(firstItem, SIGNAL(clicked(QQuickMouseEvent*)));
+ QSignalSpy clickedSpy(firstItem, SIGNAL(clicked()));
QSignalSpy triggeredSpy(firstItem, SIGNAL(triggered()));
QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged()));