Compare commits
No commits in common. "c3a1bb4553069a55ed4167c11d4fcfc21ea0fbe7" and "cd11aac847e7affa826b27708f9fb0b350421cb0" have entirely different histories.
c3a1bb4553
...
cd11aac847
6 changed files with 95 additions and 61 deletions
|
|
@ -5,6 +5,7 @@ import Quickshell
|
|||
import "components"
|
||||
import "components/bluetooth"
|
||||
import "components/hyprland"
|
||||
import "components/mpris"
|
||||
import "components/tray"
|
||||
|
||||
Scope {
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import qs.config
|
||||
import qs.services
|
||||
import qs.widgets
|
||||
import QtQuick
|
||||
|
||||
StyledButton {
|
||||
id: root
|
||||
|
||||
onClicked: {
|
||||
if (!Mpris.active.canTogglePlaying) {
|
||||
return;
|
||||
}
|
||||
if (Mpris.active.isPlaying) {
|
||||
Mpris.active.pause();
|
||||
} else {
|
||||
Mpris.active.play();
|
||||
}
|
||||
}
|
||||
|
||||
content: StyledText {
|
||||
id: text
|
||||
text: `${Mpris.active?.isPlaying ? "" : ""} ${Mpris.active?.trackTitle} - ${Mpris.active?.trackArtist}`
|
||||
|
||||
font.pixelSize: Dimensions.mpris.fontSize
|
||||
|
||||
states: State {
|
||||
name: "hovered"
|
||||
when: root.containsMouse
|
||||
PropertyChanges {
|
||||
text {
|
||||
color: Theme.palette.base300
|
||||
}
|
||||
}
|
||||
}
|
||||
transitions: Transition {
|
||||
from: ""
|
||||
to: "hovered"
|
||||
reversible: true
|
||||
ColorAnimation {
|
||||
properties: "color"
|
||||
duration: 200
|
||||
easing.type: Easing.InOutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import qs.config
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Hyprland
|
||||
import "../../../../config/"
|
||||
|
||||
RowLayout {
|
||||
id: root
|
||||
|
|
|
|||
29
modules/bar/components/mpris/Mpris.qml
Normal file
29
modules/bar/components/mpris/Mpris.qml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import Quickshell.Services.Mpris
|
||||
import QtQuick
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property int currentIndex: 0
|
||||
property var players: Mpris.players
|
||||
|
||||
Repeater {
|
||||
id: players
|
||||
model: Mpris.players.values.filter(item => item != null)
|
||||
|
||||
Player {
|
||||
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
visible: index === root.currentIndex && modelData.canControl
|
||||
|
||||
onNextPlayer: {
|
||||
currentIndex = (currentIndex + 1) % players.count;
|
||||
}
|
||||
onPreviousPlayer: {
|
||||
currentIndex = (currentIndex - 1 + players.count) % players.count;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
64
modules/bar/components/mpris/Player.qml
Normal file
64
modules/bar/components/mpris/Player.qml
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import qs.config
|
||||
import qs.widgets
|
||||
import Quickshell.Services.Mpris
|
||||
import QtQuick
|
||||
|
||||
Loader {
|
||||
id: root
|
||||
required property MprisPlayer modelData
|
||||
required property int index
|
||||
|
||||
signal nextPlayer
|
||||
signal previousPlayer
|
||||
|
||||
sourceComponent: player
|
||||
property Component player: StyledButton {
|
||||
id: button
|
||||
|
||||
onClicked: {
|
||||
if (!root.modelData.canTogglePlaying) {
|
||||
return;
|
||||
}
|
||||
if (root.modelData.isPlaying) {
|
||||
root.modelData.pause();
|
||||
} else {
|
||||
root.modelData.play();
|
||||
}
|
||||
}
|
||||
|
||||
onWheel: event => {
|
||||
if (event.angleDelta.y > 0) {
|
||||
root.nextPlayer();
|
||||
} else if (event.angleDelta.y < 0) {
|
||||
root.previousPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
content: StyledText {
|
||||
id: text
|
||||
text: `${root.modelData.isPlaying ? "" : ""} ${root.modelData.trackTitle} - ${root.modelData.trackArtist}`
|
||||
|
||||
font.pixelSize: Dimensions.mpris.fontSize
|
||||
|
||||
states: State {
|
||||
name: "hovered"
|
||||
when: button.containsMouse
|
||||
PropertyChanges {
|
||||
text {
|
||||
color: Theme.palette.base300
|
||||
}
|
||||
}
|
||||
}
|
||||
transitions: Transition {
|
||||
from: ""
|
||||
to: "hovered"
|
||||
reversible: true
|
||||
ColorAnimation {
|
||||
properties: "color"
|
||||
duration: 200
|
||||
easing.type: Easing.InOutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Mpris
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property list<MprisPlayer> players: Mpris.players.values
|
||||
property MprisPlayer active: players.filter(player => player.isPlaying)[0] ?? players[0]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue