mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-28 06:33:09 +00:00
widgets/mediacontrols: Add ability to activate source app on tap
This commit is contained in:
parent
5a9099bd84
commit
f3a4913147
4 changed files with 102 additions and 85 deletions
|
|
@ -11,7 +11,9 @@ import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string imageSource
|
property string imageSource
|
||||||
|
property bool darken: false
|
||||||
|
|
||||||
// clip corners so that the image has rounded corners
|
// clip corners so that the image has rounded corners
|
||||||
layer.enabled: true
|
layer.enabled: true
|
||||||
|
|
@ -39,7 +41,7 @@ Item {
|
||||||
// ensure text is readable
|
// ensure text is readable
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
color: Qt.rgba(0, 0, 0, 0.6)
|
color: Qt.rgba(0, 0, 0, root.darken ? 0.8 : 0.6)
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply lighten, saturate and blur effect
|
// apply lighten, saturate and blur effect
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ PlasmaCore.DataSource {
|
||||||
model.push({
|
model.push({
|
||||||
'application': playerData["Identity"],
|
'application': playerData["Identity"],
|
||||||
'source': source,
|
'source': source,
|
||||||
|
'desktopEntry': playerData["DesktopEntry"]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import QtQuick.Controls 2.15 as QQC2
|
||||||
|
|
||||||
import org.kde.kirigami 2.12 as Kirigami
|
import org.kde.kirigami 2.12 as Kirigami
|
||||||
|
|
||||||
|
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 3.0 as PlasmaComponents3
|
import org.kde.plasma.components 3.0 as PlasmaComponents3
|
||||||
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||||
|
|
@ -67,103 +68,116 @@ Item {
|
||||||
|
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
|
|
||||||
sourceComponent: Components.BaseItem {
|
sourceComponent: MouseArea {
|
||||||
id: playerItem
|
id: mouseArea
|
||||||
|
implicitHeight: playerItem.implicitHeight
|
||||||
|
implicitWidth: playerItem.implicitWidth
|
||||||
|
|
||||||
property string source: modelData.source
|
onClicked: {
|
||||||
|
MobileShell.ShellUtil.launchApp(modelData.desktopEntry + ".desktop");
|
||||||
padding: root.padding
|
MobileShell.TopPanelControls.closeActionDrawer();
|
||||||
implicitHeight: root.contentHeight + root.padding * 2
|
|
||||||
implicitWidth: root.width
|
|
||||||
|
|
||||||
background: BlurredBackground {
|
|
||||||
imageSource: mpris2Source.albumArt(playerItem.source)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: PlasmaCore.ColorScope {
|
Components.BaseItem {
|
||||||
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
id: playerItem
|
||||||
width: playerItem.width - playerItem.leftPadding - playerItem.rightPadding
|
anchors.fill: parent
|
||||||
|
|
||||||
RowLayout {
|
property string source: modelData.source
|
||||||
id: controlsRow
|
|
||||||
width: parent.width
|
|
||||||
height: parent.height
|
|
||||||
spacing: 0
|
|
||||||
|
|
||||||
enabled: mpris2Source.canControl(playerItem.source)
|
padding: root.padding
|
||||||
|
implicitHeight: root.contentHeight + root.padding * 2
|
||||||
|
implicitWidth: root.width
|
||||||
|
|
||||||
Image {
|
background: BlurredBackground {
|
||||||
id: albumArt
|
darken: mouseArea.pressed
|
||||||
Layout.preferredWidth: height
|
imageSource: mpris2Source.albumArt(playerItem.source)
|
||||||
Layout.fillHeight: true
|
}
|
||||||
asynchronous: true
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
source: mpris2Source.albumArt(playerItem.source)
|
|
||||||
sourceSize.height: height
|
|
||||||
visible: status === Image.Loading || status === Image.Ready
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
contentItem: PlasmaCore.ColorScope {
|
||||||
Layout.leftMargin: albumArt.visible ? Kirigami.Units.largeSpacing : 0
|
colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
|
||||||
Layout.fillWidth: true
|
width: playerItem.width - playerItem.leftPadding - playerItem.rightPadding
|
||||||
spacing: Kirigami.Units.smallSpacing
|
|
||||||
|
|
||||||
Components.MarqueeLabel {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
id: controlsRow
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
inputText: mpris2Source.track(playerItem.source) || i18n("No media playing")
|
enabled: mpris2Source.canControl(playerItem.source)
|
||||||
textFormat: Text.PlainText
|
|
||||||
font.pointSize: PlasmaCore.Theme.defaultFont.pointSize
|
Image {
|
||||||
color: "white"
|
id: albumArt
|
||||||
|
Layout.preferredWidth: height
|
||||||
|
Layout.fillHeight: true
|
||||||
|
asynchronous: true
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
source: mpris2Source.albumArt(playerItem.source)
|
||||||
|
sourceSize.height: height
|
||||||
|
visible: status === Image.Loading || status === Image.Ready
|
||||||
}
|
}
|
||||||
|
|
||||||
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")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ ContainmentLayoutManager.ItemContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeScreenLib.DesktopModel.setMinimizedDelegate(index, delegate);
|
HomeScreenLib.DesktopModel.setMinimizedDelegate(index, delegate);
|
||||||
HomeScreenLib.DesktopModel.runApplication(modelData.applicationStorageId);
|
MobileShell.ShellUtil.launchApp(modelData.applicationStorageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property bool applicationRunning: model.applicationRunning
|
readonly property bool applicationRunning: model.applicationRunning
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue