mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-03 02:51:46 +00:00
MediaMini: added RMB/MMB to control Next/Previous media/song
This commit is contained in:
@@ -31,6 +31,8 @@ Row {
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: mediaMini
|
||||
|
||||
// Let the Rectangle size itself based on its content (the Row)
|
||||
width: row.width + Style.marginM * scaling * 2
|
||||
|
||||
@@ -40,6 +42,13 @@ Row {
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
// Used to anchor the tooltip, so the tooltip does not move when the content expands
|
||||
Item {
|
||||
id: anchor
|
||||
height: parent.height
|
||||
width: 200 * scaling
|
||||
}
|
||||
|
||||
Item {
|
||||
id: mainContainer
|
||||
anchors.fill: parent
|
||||
@@ -159,8 +168,46 @@ Row {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: MediaService.playPause()
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
MediaService.playPause()
|
||||
} else if (mouse.button == Qt.RightButton) {
|
||||
MediaService.next()
|
||||
// Need to hide the tooltip instantly
|
||||
tooltip.visible = false
|
||||
} else if (mouse.button == Qt.MiddleButton) {
|
||||
MediaService.previous()
|
||||
// Need to hide the tooltip instantly
|
||||
tooltip.visible = false
|
||||
}
|
||||
}
|
||||
|
||||
onEntered: {
|
||||
if (tooltip.text !== "") {
|
||||
tooltip.show()
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
tooltip.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NTooltip {
|
||||
id: tooltip
|
||||
text: {
|
||||
var str = ""
|
||||
if (MediaService.canGoNext) {
|
||||
str += "Right click for next\n"
|
||||
}
|
||||
if (MediaService.canGoPrevious) {
|
||||
str += "Middle click for previous\n"
|
||||
}
|
||||
return str
|
||||
}
|
||||
target: anchor
|
||||
positionAbove: Settings.data.bar.position === "bottom"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user