Skip to content

Commit

Permalink
Handling accidental double-taps on buttons with MMSingleClickMouseArea (
Browse files Browse the repository at this point in the history
#3532)

* updating all versions after release

* MMSingleClickMouseArea draft

* code adjustments

* preventing click from propagating to the background

* adding new SingleClickMouseArea to photo procedures

* new component description and added to gallery qrc, timer set to 2 seconds

* how-to use new component

* version fix

* post review fixes

* small code layout fix

* MMSingleClickMouseArea on openLinkedFeature

* adding MMSingleClickMouseArea to MMPhoto
  • Loading branch information
VitorVieiraZ authored Jul 19, 2024
1 parent 9f3ac1b commit 619d682
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(MM_QML
components/MMText.qml
components/MMToolbar.qml
components/MMToolbarButton.qml
components/MMSingleClickMouseArea.qml
components/private/MMBaseInput.qml
components/private/MMBaseSingleLineInput.qml
components/private/MMToolbarLongButton.qml
Expand Down
4 changes: 2 additions & 2 deletions app/qml/components/MMPhoto.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ Image {
}
}

MouseArea {
MMSingleClickMouseArea {
anchors.fill: parent
onClicked: root.clicked(root.photoUrl)
onSingleClicked: root.clicked(root.photoUrl)
}

onStatusChanged: {
Expand Down
38 changes: 38 additions & 0 deletions app/qml/components/MMSingleClickMouseArea.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

import QtQuick

/**
* MMSingleClickMouseArea enhances MouseArea by preventing multiple clicks within a
* specified time frame, ensuring consistent behavior and avoiding unintended actions
* Similar to MouseArea, but it should be used with onSingleClicked signal handling instead of onClicked
*/

MouseArea {
id: root

signal singleClicked()

onClicked: {
if ( timer.running ) {
mouse.accepted = true;
return;
}

singleClicked()
timer.start()
}

Timer {
id: timer
interval: 2000
repeat: false
}
}
8 changes: 4 additions & 4 deletions app/qml/form/components/photo/MMPhotoAttachment.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ Rectangle {
}
}

MouseArea {
MMComponents.MMSingleClickMouseArea{
anchors.fill: parent
onClicked: root.capturePhotoClicked()
onSingleClicked: root.capturePhotoClicked()
}
}

Expand Down Expand Up @@ -102,9 +102,9 @@ Rectangle {
}
}

MouseArea {
MMComponents.MMSingleClickMouseArea{
anchors.fill: parent
onClicked: root.chooseFromGalleryClicked()
onSingleClicked: root.chooseFromGalleryClicked()
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/qml/form/editors/MMFormGalleryEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ MMPrivateComponents.MMBaseInput {
size: __style.icon32
}

MouseArea {
MMComponents.MMSingleClickMouseArea {
anchors.fill: parent
onClicked: {
onSingleClicked: {
root.createLinkedFeature( root._fieldFeatureLayerPair, root._fieldAssociatedRelation )
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/qml/form/editors/MMFormRelationEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ MMPrivateComponents.MMBaseInput {
height: width
}

MouseArea {
MMComponents.MMSingleClickMouseArea{
anchors.fill: parent
onClicked: {
onSingleClicked: {
root.forceActiveFocus() // clear focus from all elements to prevent freezing #3483
root.createLinkedFeature( root._fieldFeatureLayerPair, root._fieldAssociatedRelation )
}
Expand Down Expand Up @@ -135,9 +135,9 @@ MMPrivateComponents.MMBaseInput {
verticalAlignment: Text.AlignVCenter
}

MouseArea {
MMComponents.MMSingleClickMouseArea {
anchors.fill: parent
onClicked: root.openLinkedFeature( model.FeaturePair )
onSingleClicked: root.openLinkedFeature( model.FeaturePair )
}

onVisibleChanged: root.recalculateVisibleItems()
Expand Down
1 change: 1 addition & 0 deletions gallery/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<file>../app/qml/components/MMDrawer.qml</file>
<file>../app/qml/components/MMDrawerHeader.qml</file>
<file>../app/qml/components/MMBusyIndicator.qml</file>
<file>../app/qml/components/MMSingleClickMouseArea.qml</file>
<file>../app/qml/account/components/MMAccountPageItem.qml</file>
<file>../app/qml/account/components/MMIconCheckBoxHorizontal.qml</file>
<file>../app/qml/account/components/MMIconCheckBoxVertical.qml</file>
Expand Down

1 comment on commit 619d682

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.7.642511 just submitted!

Please sign in to comment.