Compare commits
2 commits
cd11aac847
...
c3a1bb4553
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3a1bb4553 | ||
|
|
a7e916519f |
6 changed files with 61 additions and 95 deletions
|
|
@ -5,7 +5,6 @@ import Quickshell
|
||||||
import "components"
|
import "components"
|
||||||
import "components/bluetooth"
|
import "components/bluetooth"
|
||||||
import "components/hyprland"
|
import "components/hyprland"
|
||||||
import "components/mpris"
|
|
||||||
import "components/tray"
|
import "components/tray"
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
|
|
|
||||||
48
modules/bar/components/Mpris.qml
Normal file
48
modules/bar/components/Mpris.qml
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
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
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
import "../../../../config/"
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
12
services/Mpris.qml
Normal file
12
services/Mpris.qml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
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