Skip to content

Commit 231812a

Browse files
committed
Enable right click
1 parent 6dd6ae9 commit 231812a

File tree

10 files changed

+91
-14
lines changed

10 files changed

+91
-14
lines changed

gui/controls2/Alarms.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ MusicPage {
113113
signal editNew
114114
onEditNew: dialogAlarm.open(model, true, index)
115115

116-
onClicked: {
116+
onClick: {
117117
alarmList.focusIndex = index;
118118
dialogAlarm.open(model);
119119
}

gui/controls2/Index.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ MusicPage {
5757
property bool held: false
5858
onPressAndHold: held = true
5959
onReleased: held = false
60-
onClicked: clickItem(model)
60+
onClick: clickItem(model)
6161

6262
color: listItem.held ? "lightgrey" : "transparent"
6363
noCover: ""

gui/controls2/MusicServices.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ MusicPage {
7070
imageSources: [{art: model.type === "65031" ? "qrc:/images/tunein.png" : model.icon}]
7171
description: qsTr("Service")
7272

73-
onClicked: {
73+
onClick: {
7474
stackView.push("qrc:/controls2/Service.qml",
7575
{
7676
"isListView": isListView,

gui/controls2/Service.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ MusicPage {
156156
property bool held: false
157157
onPressAndHold: held = true
158158
onReleased: held = false
159-
onClicked: {
159+
onClick: {
160160
clickItem(model)
161161
}
162162

gui/controls2/ThisDevice.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ MusicPage {
7777
property bool held: false
7878
onPressAndHold: held = true
7979
onReleased: held = false
80-
onClicked: clickItem(model)
80+
onClick: clickItem(model)
8181

8282
color: listItem.held ? "lightgrey" : "transparent"
8383
noCover: ""

gui/controls2/Zones.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ MusicPage {
9393
color: "transparent"
9494
description: qsTr("Zone")
9595

96-
onClicked: {
96+
onClick: {
9797
connectZone(model.name)
9898
}
9999
onAction3Pressed: {

gui/controls2/components/Delegates/DragMusicListItem.qml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,31 @@ MouseArea {
7979
property real lastX: -1
8080
property real lastY: -1
8181

82+
acceptedButtons: Qt.RightButton | Qt.LeftButton
83+
8284
onPressed: {
85+
if (mouse.button == Qt.RightButton) {
86+
return;
87+
}
88+
8389
lastX = mouse.x
8490
lastY = mouse.y
8591
}
8692

8793
onPressAndHold: {
94+
if (mouse.button == Qt.RightButton) {
95+
return;
96+
}
97+
8898
dragArea.sourceIndex = DelegateModel.itemsIndex
8999
if (reorderable)
90100
held = true
91101
}
92102
onReleased: {
103+
if (mouse.button == Qt.RightButton) {
104+
return;
105+
}
106+
93107
if (held) {
94108
held = false;
95109
} else {
@@ -101,6 +115,14 @@ MouseArea {
101115
}
102116
}
103117
}
118+
onClicked: {
119+
if (mouse.button == Qt.RightButton) {
120+
row.openMenu(this, mouse.x, mouse.y);
121+
mouse.accepted = true;
122+
return;
123+
}
124+
mouse.accepted = false;
125+
}
104126

105127
Rectangle {
106128
id: content

gui/controls2/components/Delegates/MusicListItem.qml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,35 @@ MouseArea {
7070
property real lastX: -1
7171
property real lastY: -1
7272

73+
acceptedButtons: Qt.RightButton | Qt.LeftButton
74+
7375
onPressed: {
76+
if (mouse.button == Qt.RightButton) {
77+
return;
78+
}
7479
lastX = mouse.x
7580
lastY = mouse.y
7681
}
7782

7883
onReleased: {
84+
if (mouse.button == Qt.RightButton) {
85+
return;
86+
}
7987
var diffX = mouse.x - lastX;
8088
if (Math.abs(diffX) > units.gu(15)) {
8189
swipe();
8290
} else {
8391
click();
8492
}
8593
}
94+
onClicked: {
95+
if (mouse.button == Qt.RightButton) {
96+
row.openMenu(this, mouse.x, mouse.y);
97+
mouse.accepted = true;
98+
return;
99+
}
100+
mouse.accepted = false;
101+
}
86102

87103
Rectangle {
88104
id: content

gui/controls2/components/Delegates/SelectMusicListItem.qml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,30 @@ MouseArea {
109109
property real lastX: -1
110110
property real lastY: -1
111111

112+
acceptedButtons: Qt.RightButton | Qt.LeftButton
113+
112114
onPressed: {
115+
if (mouse.button == Qt.RightButton) {
116+
return;
117+
}
113118
lastX = mouse.x
114119
lastY = mouse.y
115120
}
116121

117122
onPressAndHold: {
123+
if (mouse.button == Qt.RightButton) {
124+
return;
125+
}
118126
if (state !== "selection") {
119127
dragArea.sourceIndex = DelegateModel.itemsIndex
120128
if (reorderable)
121129
held = true
122130
}
123131
}
124132
onReleased: {
133+
if (mouse.button == Qt.RightButton) {
134+
return;
135+
}
125136
if (state !== "selection") {
126137
if (held) {
127138
held = false;
@@ -133,6 +144,8 @@ MouseArea {
133144
click();
134145
}
135146
}
147+
} else {
148+
click();
136149
}
137150
}
138151

@@ -191,6 +204,15 @@ MouseArea {
191204
}
192205
}
193206

207+
onClicked: {
208+
if (mouse.button === Qt.RightButton) {
209+
row.openMenu(this, mouse.x, mouse.y);
210+
mouse.accepted = true;
211+
return;
212+
}
213+
mouse.accepted = false;
214+
}
215+
194216
onHeldChanged: {
195217
if (!held && sourceIndex !== targetIndex) {
196218
reorder(sourceIndex, targetIndex);

gui/controls2/components/MusicRow.qml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ Row {
5454

5555
signal imageError(var index)
5656

57+
function openMenu(parent, x, y) {
58+
if (optionsMenu.count === 0) {
59+
return;
60+
}
61+
var isEmpty = true;
62+
for (var i=0; i<optionsMenu.count; i++) {
63+
if (optionsMenu.contentData[i].enabled) {
64+
isEmpty = false;
65+
break;
66+
}
67+
}
68+
if (isEmpty) {
69+
return;
70+
}
71+
72+
optionsMenu.popup(parent, x, y);
73+
}
74+
5775
spacing: units.gu(1)
5876

5977
state: "default"
@@ -261,14 +279,7 @@ Row {
261279
anchors.centerIn: parent
262280
source: "qrc:/images/contextual-menu.svg"
263281

264-
onClicked: optionsMenu.open()
265-
266-
Menu {
267-
id: optionsMenu
268-
width: implicitWidth * units.scaleFactor
269-
x: parent.width - width
270-
transformOrigin: Menu.TopRight
271-
}
282+
onClicked: optionsMenu.popup(this, 0, 0)
272283
}
273284
}
274285

@@ -309,4 +320,10 @@ Row {
309320
}
310321
}
311322

323+
Menu {
324+
id: optionsMenu
325+
width: implicitWidth * units.scaleFactor
326+
x: parent.width - width
327+
transformOrigin: Menu.TopRight
328+
}
312329
}

0 commit comments

Comments
 (0)