Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize pressed state legend items by using a ripple element #4435

Merged
merged 6 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/qml/FeatureForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ Page {
Loader {
id: attributeEditorLoader

height: childrenRect.height
anchors { left: parent.left; right: parent.right }

//disable widget if it's:
Expand Down
43 changes: 22 additions & 21 deletions src/qml/Legend.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Controls.Material 2.14
import QtQuick.Controls.Material.impl 2.14
import QtQuick.Layouts 1.14
import QtQml.Models 2.14

import org.qgis 1.0
import org.qfield 1.0
Expand All @@ -28,22 +29,22 @@ ListView {
property string itemType: Type
property string layerType: LayerType
property bool isSelectedLayer: ( itemType === "layer" && vectorLayer != null && vectorLayer == currentLayer )
property bool isPressed: false

id: rectangle
width: parent ? parent.width : undefined
height: line.height + 7
state: "default"
color: isSelectedLayer ? Theme.mainColor : "transparent"

states: [
State {
name: "default"
PropertyChanges { target: rectangle; color: isSelectedLayer ? Theme.mainColor : "transparent" }
},
State {
name: "pressed"
PropertyChanges { target: rectangle; color: Theme.controlBorderColor }
}
]
Ripple {
clip: true
width: parent.width
height: parent.height
pressed: parent.isPressed
anchor: parent
active: parent.isPressed
color: Material.rippleColor
}

Row {
id: line
Expand Down Expand Up @@ -196,7 +197,7 @@ ListView {
}

Rectangle {
visible: Type == 'layer' && !IsValid
visible: Type === 'layer' && !IsValid
height: 24
width: 24
anchors.verticalCenter: parent.verticalCenter
Expand All @@ -217,7 +218,7 @@ ListView {

property Item pressedItem

onClicked: {
onClicked: (mouse) => {
var item = legend.itemAt(legend.contentX + mouse.x, legend.contentY + mouse.y)
if (!item) return;

Expand All @@ -236,14 +237,14 @@ ListView {
}
}
}
onPressed: {
onPressed: (mouse) => {
var item = legend.itemAt(legend.contentX + mouse.x, legend.contentY + mouse.y)
if (item && item.itemType) {
pressedItem = item;
pressedItem.state = "pressed"
pressedItem.isPressed = true
}
}
onDoubleClicked: {
onDoubleClicked: (mouse) => {
var item = legend.itemAt(legend.contentX + mouse.x, legend.contentY + mouse.y)
if (item) {
var itemIndex = legend.model.index(item.itemRow, 0)
Expand All @@ -262,17 +263,17 @@ ListView {
}
onCanceled: {
if (pressedItem) {
pressedItem.state = "default"
pressedItem.isPressed = false
pressedItem = null
}
}
onReleased: {
onReleased: (mouse) => {
if (pressedItem) {
if (mouse.button == Qt.RightButton) {
if (mouse.button === Qt.RightButton) {
pressAndHold(mouse)
}

pressedItem.state = "default"
pressedItem.isPressed = false
pressedItem = null
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/qml/QFieldCloudScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ Page {
MouseArea {
property Item pressedItem
anchors.fill: parent
onClicked: {
onClicked: (mouse) => {
var item = table.itemAt(
table.contentX + mouse.x,
table.contentY + mouse.y
Expand All @@ -434,7 +434,7 @@ Page {
}
}
}
onPressed: {
onPressed: (mouse) => {
var item = table.itemAt(
table.contentX + mouse.x,
table.contentY + mouse.y
Expand All @@ -457,7 +457,7 @@ Page {
}
}

onPressAndHold: {
onPressAndHold: (mouse) => {
var item = table.itemAt(
table.contentX + mouse.x,
table.contentY + mouse.y
Expand Down
12 changes: 6 additions & 6 deletions src/qml/WelcomeScreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ Page {
MouseArea {
property Item pressedItem
anchors.fill: parent
onClicked: {
onClicked: (mouse) => {
var item = table.itemAt(mouse.x, mouse.y)
if (item) {
if ( item.type == 1 && cloudConnection.hasToken && cloudConnection.status !== QFieldCloudConnection.LoggedIn ) {
Expand All @@ -544,7 +544,7 @@ Page {
iface.loadFile(item.path,item.title)
}
}
onPressed: {
onPressed: (mouse) => {
var item = table.itemAt(mouse.x, mouse.y)
if (item) {
pressedItem = item.children[0].children[1].children[0];
Expand All @@ -563,7 +563,7 @@ Page {
pressedItem = null
}
}
onPressAndHold: {
onPressAndHold: (mouse) => {
var item = table.itemAt(mouse.x, mouse.y)
if (item) {
recentProjectActions.recentProjectPath = item.path;
Expand Down Expand Up @@ -724,15 +724,15 @@ Page {
onReleased: mouse.accepted = false
onDoubleClicked: mouse.accepted = false
onPressAndHold: mouse.accepted = false
onClicked: {
onClicked: (mouse) => {
burstSomeSparkles(mouse.x, mouse.y)
mouse.accepted = false
}
onPressed: {
onPressed: (mouse) => {
burstSomeSparkles(mouse.x, mouse.y)
mouse.accepted = false
}
onPositionChanged: {
onPositionChanged: (mouse) => {
burstSomeSparkles(mouse.x, mouse.y)
mouse.accepted = false
}
Expand Down
5 changes: 2 additions & 3 deletions src/qml/qgismobileapp.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,6 @@ ApplicationWindow {
overlayFeatureFormDrawer.featureModel.resetAttributes()
overlayFeatureFormDrawer.open()
overlayFeatureFormDrawer.state = "Add"
overlayFeatureFormDrawer.featureForm.reset()
}
else
{
Expand Down Expand Up @@ -2914,7 +2913,7 @@ ApplicationWindow {
enabled: !parent.activeFocus

//onPressed because onClicked shall be handled in underlying MouseArea
onPressed: {
onPressed: (mouse) => {
parent.focus=true
mouse.accepted=false
}
Expand Down Expand Up @@ -3445,7 +3444,7 @@ ApplicationWindow {
anchors.fill: parent
enabled: barcodeReader.visible

onClicked: {
onClicked: (mouse) => {
// Needed to avoid people interacting with the UI while the barcode reader is visible
// (e.g. close the feature form while scanning a code to fill an attribute)
return;
Expand Down
Loading