fix dashboard display and player switch

This commit is contained in:
Benjamin Palko 2025-08-27 16:24:16 -04:00
parent 0a33022c6a
commit d42b7cb612
2 changed files with 46 additions and 41 deletions

View file

@ -7,57 +7,61 @@ import qs.services
import qs.widgets import qs.widgets
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell.Widgets
StyledDrawer { StyledDrawer {
id: root id: root
visible: Visibility.dashboard visible: Visibility.dashboard
margins: 20 WrapperRectangle {
contentItem: ColumnLayout { color: Theme.palette.base300
radius: 8
margin: 20
ColumnLayout {
RowLayout {
Layout.alignment: Qt.AlignHCenter
RowLayout { StyledButton {
Layout.alignment: Qt.AlignHCenter id: previousPlayerButton
visible: Mpris.players.length > 1
StyledButton { content: LucideIcon {
id: previousPlayerButton color: previousPlayerButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
visible: Mpris.players.length > 1 text: Icons.chevronLeft
content: LucideIcon { }
color: previousPlayerButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent onClicked: {
text: Icons.chevronLeft Mpris.previousPlayer();
} }
onClicked: { }
Mpris.previousPlayer();
} StyledText {
} text: {
if (Mpris.active?.identity) {
StyledText { const words = Mpris.active?.identity.split("-");
text: { const capitalized = words.map(val => String(val).charAt(0).toUpperCase() + String(val).slice(1));
if (Mpris.active?.identity) { return capitalized.join(" ");
const words = Mpris.active?.identity.split("-"); }
const capitalized = words.map(val => String(val).charAt(0).toUpperCase() + String(val).slice(1)); return Mpris.active?.desktopEntry ?? Mpris.active?.dbusName ?? "unknown";
return capitalized.join(" "); }
font.pixelSize: 20
}
StyledButton {
id: nextPlayerButton
visible: Mpris.players.length > 1
content: LucideIcon {
color: nextPlayerButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.chevronRight
}
onClicked: {
Mpris.nextPlayer();
} }
return Mpris.active?.desktopEntry ?? Mpris.active?.dbusName ?? "unknown";
} }
font.pixelSize: 20
} }
StyledButton { MprisController {
id: nextPlayerButton player: Mpris.active
visible: Mpris.players.length > 1
content: LucideIcon {
color: nextPlayerButton.containsMouse ? Theme.palette.primarycontent : Theme.palette.basecontent
text: Icons.chevronRight
}
onClicked: {
Mpris.nextPlayer();
}
} }
} }
MprisController {
player: Mpris.active
}
} }
} }

View file

@ -20,13 +20,14 @@ Singleton {
if (players.length == 0) { if (players.length == 0) {
return; return;
} }
properties.currentIndex = properties.currentIndex + 1 % players.length; properties.currentIndex = (properties.currentIndex + 1) % players.length;
} }
function previousPlayer() { function previousPlayer() {
if (players.length == 0) { if (players.length == 0) {
return; return;
} }
properties.currentIndex = properties.currentIndex - 1 % players.length; const newIndex = properties.currentIndex - 1;
properties.currentIndex = newIndex >= 0 ? newIndex : players.length - 1;
} }
} }