QML UI: Add support for single-press context menu
This commit is contained in:
parent
16dfe8aa5b
commit
1949c00816
3 changed files with 15 additions and 1 deletions
|
@ -5,6 +5,9 @@ import 'config.js' as Config
|
|||
SelectableItem {
|
||||
id: episodeItem
|
||||
|
||||
// Show context menu when single-touching the icon
|
||||
singlePressContextMenuLeftBorder: title.x
|
||||
|
||||
height: Config.listItemHeight
|
||||
|
||||
Rectangle {
|
||||
|
@ -44,6 +47,7 @@ SelectableItem {
|
|||
}
|
||||
|
||||
Text {
|
||||
id: title
|
||||
text: modelData.qtitle
|
||||
color: modelData.qdownloading?'#8ae234':(modelData.qplaying?'#729fcf':(modelData.qnew?"white":"#888"))
|
||||
font.pixelSize: episodeItem.height * .35
|
||||
|
|
|
@ -6,6 +6,9 @@ import 'config.js' as Config
|
|||
SelectableItem {
|
||||
id: podcastItem
|
||||
|
||||
// Show context menu when single-touching the count or cover art
|
||||
singlePressContextMenuLeftBorder: titleBox.x
|
||||
|
||||
Text {
|
||||
id: counterText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
|
@ -8,6 +8,11 @@ Item {
|
|||
signal selected(variant item)
|
||||
signal contextMenu(variant item)
|
||||
|
||||
/* The width of the area from the left edge that when
|
||||
* pressed will signal contextMenu instead of selected.
|
||||
*/
|
||||
property int singlePressContextMenuLeftBorder: 0
|
||||
|
||||
height: Config.listItemHeight
|
||||
width: parent.width
|
||||
|
||||
|
@ -32,7 +37,9 @@ Item {
|
|||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (mouse.button == Qt.LeftButton) {
|
||||
if (mouse.x <= selectableItem.singlePressContextMenuLeftBorder) {
|
||||
selectableItem.contextMenu(modelData)
|
||||
} else if (mouse.button == Qt.LeftButton) {
|
||||
selectableItem.selected(modelData)
|
||||
} else if (mouse.button == Qt.RightButton) {
|
||||
selectableItem.contextMenu(modelData)
|
||||
|
|
Loading…
Reference in a new issue