mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 07:03:08 +00:00
mediacontrolwidget: make playerItem loadable
This commit is contained in:
parent
443662d2fd
commit
1ebd1ecefc
1 changed files with 90 additions and 84 deletions
|
|
@ -62,103 +62,109 @@ Item {
|
||||||
Repeater {
|
Repeater {
|
||||||
model: mpris2Source.mprisSourcesModel
|
model: mpris2Source.mprisSourcesModel
|
||||||
|
|
||||||
delegate: Components.BaseItem {
|
delegate: Loader {
|
||||||
id: playerItem
|
active: modelData
|
||||||
|
|
||||||
property string source: modelData.source
|
asynchronous: true
|
||||||
|
|
||||||
padding: root.padding
|
sourceComponent: Components.BaseItem {
|
||||||
implicitHeight: root.contentHeight + root.padding * 2
|
id: playerItem
|
||||||
implicitWidth: root.width
|
|
||||||
|
|
||||||
background: BlurredBackground {
|
|
||||||
imageSource: mpris2Source.albumArt(playerItem.source)
|
|
||||||
}
|
|
||||||
|
|
||||||
contentItem: PlasmaCore.ColorScope {
|
|
||||||
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
|
||||||
width: playerItem.width - playerItem.leftPadding - playerItem.rightPadding
|
|
||||||
|
|
||||||
RowLayout {
|
property string source: modelData.source
|
||||||
id: controlsRow
|
|
||||||
width: parent.width
|
padding: root.padding
|
||||||
height: parent.height
|
implicitHeight: root.contentHeight + root.padding * 2
|
||||||
spacing: 0
|
implicitWidth: root.width
|
||||||
|
|
||||||
|
background: BlurredBackground {
|
||||||
|
imageSource: mpris2Source.albumArt(playerItem.source)
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: PlasmaCore.ColorScope {
|
||||||
|
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
|
width: playerItem.width - playerItem.leftPadding - playerItem.rightPadding
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: controlsRow
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
enabled: mpris2Source.canControl(playerItem.source)
|
enabled: mpris2Source.canControl(playerItem.source)
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: albumArt
|
id: albumArt
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
source: mpris2Source.albumArt(playerItem.source)
|
source: mpris2Source.albumArt(playerItem.source)
|
||||||
sourceSize.height: height
|
sourceSize.height: height
|
||||||
visible: status === Image.Loading || status === Image.Ready
|
visible: status === Image.Loading || status === Image.Ready
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
Layout.leftMargin: albumArt.visible ? Kirigami.Units.largeSpacing : 0
|
|
||||||
Layout.fillWidth: true
|
|
||||||
spacing: Kirigami.Units.smallSpacing
|
|
||||||
|
|
||||||
Components.MarqueeLabel {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
inputText: mpris2Source.track(playerItem.source) || i18n("No media playing")
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
font.pointSize: PlasmaCore.Theme.defaultFont.pointSize
|
|
||||||
color: "white"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Components.MarqueeLabel {
|
ColumnLayout {
|
||||||
|
Layout.leftMargin: albumArt.visible ? Kirigami.Units.largeSpacing : 0
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
// if no artist is given, show player name instead
|
Components.MarqueeLabel {
|
||||||
inputText: mpris2Source.artist(playerItem.source) || modelData.application || ""
|
Layout.fillWidth: true
|
||||||
textFormat: Text.PlainText
|
|
||||||
font.pointSize: PlasmaCore.Theme.smallestFont.pointSize
|
inputText: mpris2Source.track(playerItem.source) || i18n("No media playing")
|
||||||
opacity: 0.9
|
textFormat: Text.PlainText
|
||||||
color: "white"
|
font.pointSize: PlasmaCore.Theme.defaultFont.pointSize
|
||||||
|
color: "white"
|
||||||
|
}
|
||||||
|
|
||||||
|
Components.MarqueeLabel {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
// if no artist is given, show player name instead
|
||||||
|
inputText: mpris2Source.artist(playerItem.source) || modelData.application || ""
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
font.pointSize: PlasmaCore.Theme.smallestFont.pointSize
|
||||||
|
opacity: 0.9
|
||||||
|
color: "white"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaComponents3.ToolButton {
|
PlasmaComponents3.ToolButton {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
|
|
||||||
enabled: mpris2Source.canGoBack(playerItem.source)
|
enabled: mpris2Source.canGoBack(playerItem.source)
|
||||||
icon.name: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward"
|
icon.name: LayoutMirroring.enabled ? "media-skip-forward" : "media-skip-backward"
|
||||||
icon.width: PlasmaCore.Units.iconSizes.small
|
icon.width: PlasmaCore.Units.iconSizes.small
|
||||||
icon.height: PlasmaCore.Units.iconSizes.small
|
icon.height: PlasmaCore.Units.iconSizes.small
|
||||||
onClicked: mpris2Source.goPrevious(playerItem.source)
|
onClicked: mpris2Source.goPrevious(playerItem.source)
|
||||||
visible: mpris2Source.canGoBack(playerItem.source) || mpris2Source.canGoNext(playerItem.source)
|
visible: mpris2Source.canGoBack(playerItem.source) || mpris2Source.canGoNext(playerItem.source)
|
||||||
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Previous track")
|
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Previous track")
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents3.ToolButton {
|
PlasmaComponents3.ToolButton {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
|
|
||||||
icon.name: mpris2Source.isPlaying(playerItem.source) ? "media-playback-pause" : "media-playback-start"
|
icon.name: mpris2Source.isPlaying(playerItem.source) ? "media-playback-pause" : "media-playback-start"
|
||||||
icon.width: PlasmaCore.Units.iconSizes.small
|
icon.width: PlasmaCore.Units.iconSizes.small
|
||||||
icon.height: PlasmaCore.Units.iconSizes.small
|
icon.height: PlasmaCore.Units.iconSizes.small
|
||||||
onClicked: mpris2Source.playPause(playerItem.source)
|
onClicked: mpris2Source.playPause(playerItem.source)
|
||||||
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Play or Pause media")
|
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Play or Pause media")
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents3.ToolButton {
|
PlasmaComponents3.ToolButton {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
|
|
||||||
enabled: mpris2Source.canGoBack(playerItem.source)
|
enabled: mpris2Source.canGoBack(playerItem.source)
|
||||||
icon.name: LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward"
|
icon.name: LayoutMirroring.enabled ? "media-skip-backward" : "media-skip-forward"
|
||||||
icon.width: PlasmaCore.Units.iconSizes.small
|
icon.width: PlasmaCore.Units.iconSizes.small
|
||||||
icon.height: PlasmaCore.Units.iconSizes.small
|
icon.height: PlasmaCore.Units.iconSizes.small
|
||||||
onClicked: mpris2Source.goNext(playerItem.source)
|
onClicked: mpris2Source.goNext(playerItem.source)
|
||||||
visible: mpris2Source.canGoBack(playerItem.source) || mpris2Source.canGoNext(playerItem.source)
|
visible: mpris2Source.canGoBack(playerItem.source) || mpris2Source.canGoNext(playerItem.source)
|
||||||
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Next track")
|
Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Next track")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue