Commit 540f598c authored by Ismael Asensio's avatar Ismael Asensio

[mediacontroller] Use icon tabs to select player

Show the available players as an icon row of tabs instead of a
combobox. The player name is shown in a tooltip on hover.
parent a451464a
......@@ -464,31 +464,36 @@ PlasmaComponents3.Page {
RowLayout {
anchors.fill: parent
PlasmaComponents3.ComboBox {
PlasmaComponents3.TabBar {
id: playerSelector
position: PlasmaComponents3.TabBar.Footer
Layout.fillWidth: true
Layout.leftMargin: units.gridUnit*2
Layout.rightMargin: units.gridUnit*2
id: playerCombo
textRole: "text"
visible: model.length > 2 // more than one player, @multiplex is always there
model: root.mprisSourcesModel
onModelChanged: {
// if model changes, ComboBox resets, so we try to find the current player again...
for (var i = 0, length = model.length; i < length; ++i) {
if (model[i].source === mpris2Source.current) {
currentIndex = i
break
implicitHeight: contentHeight
Repeater {
id: playerList
model: root.mprisSourcesModel
delegate: PlasmaComponents3.TabButton {
icon.name: modelData["icon"]
icon.height: PlasmaCore.Units.iconSizes.smallMedium
Accessible.name: modelData["text"]
PlasmaComponents3.ToolTip {
text: modelData["text"]
}
onClicked: {
disablePositionUpdate = true
mpris2Source.current = modelData["source"];
disablePositionUpdate = false
}
}
}
onActivated: {
disablePositionUpdate = true
// ComboBox has currentIndex and currentText, why doesn't it have currentItem/currentModelValue?
mpris2Source.current = model[index].source
disablePositionUpdate = false
onModelChanged: {
playerSelector.currentIndex = model.findIndex(
(data) => { return data.source === mpris2Source.current }
)
}
}
}
}
......
......@@ -293,7 +293,7 @@ Item {
model.push({
'text': mpris2Source.data[source]["Identity"],
'icon': mpris2Source.data[source]["Desktop Icon Name"] || mpris2Source.data[source]["Desktop Entry"] || source,
'icon': mpris2Source.data[source]["Desktop Icon Name"] || mpris2Source.data[source]["DesktopEntry"] || "emblem-music-symbolic",
'source': source
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment