mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
@@ -10,6 +10,13 @@ BasePill {
|
||||
|
||||
readonly property MprisPlayer activePlayer: MprisController.activePlayer
|
||||
readonly property bool playerAvailable: activePlayer !== null
|
||||
readonly property bool __isChromeBrowser: {
|
||||
if (!activePlayer?.identity)
|
||||
return false;
|
||||
const id = activePlayer.identity.toLowerCase();
|
||||
return id.includes("chrome") || id.includes("chromium");
|
||||
}
|
||||
readonly property bool usePlayerVolume: activePlayer && activePlayer.volumeSupported && !__isChromeBrowser
|
||||
property bool compactMode: false
|
||||
property var widgetData: null
|
||||
readonly property int textWidth: {
|
||||
@@ -49,14 +56,8 @@ BasePill {
|
||||
|
||||
wheelEvent.accepted = true;
|
||||
|
||||
// If volume is not supported, return early to avoid error logs but accepting the scroll,
|
||||
// to keep the consistency of not scrolling workspaces when scrolling in the media widget.
|
||||
if (!activePlayer.volumeSupported) {
|
||||
return;
|
||||
}
|
||||
|
||||
const delta = wheelEvent.angleDelta.y;
|
||||
const currentVolume = (activePlayer.volume * 100) || 0;
|
||||
const currentVolume = usePlayerVolume ? (activePlayer.volume * 100) : ((AudioService.sink?.audio?.volume ?? 0) * 100);
|
||||
|
||||
let newVolume;
|
||||
if (delta > 0) {
|
||||
@@ -65,7 +66,11 @@ BasePill {
|
||||
newVolume = Math.max(0, currentVolume - 5);
|
||||
}
|
||||
|
||||
activePlayer.volume = newVolume / 100;
|
||||
if (usePlayerVolume) {
|
||||
activePlayer.volume = newVolume / 100;
|
||||
} else if (AudioService.sink?.audio) {
|
||||
AudioService.sink.audio.volume = newVolume / 100;
|
||||
}
|
||||
}
|
||||
|
||||
content: Component {
|
||||
|
||||
@@ -10,6 +10,18 @@ DankOSD {
|
||||
readonly property var player: MprisController.activePlayer
|
||||
readonly property int currentVolume: player ? Math.min(100, Math.round(player.volume * 100)) : 0
|
||||
readonly property bool volumeSupported: player?.volumeSupported ?? false
|
||||
property bool _suppressNewPlayer: false
|
||||
|
||||
onPlayerChanged: {
|
||||
_suppressNewPlayer = true;
|
||||
_suppressTimer.restart();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: _suppressTimer
|
||||
interval: 2000
|
||||
onTriggered: _suppressNewPlayer = false
|
||||
}
|
||||
|
||||
osdWidth: useVertical ? (40 + Theme.spacingS * 2) : Math.min(260, Screen.width - Theme.spacingM * 2)
|
||||
osdHeight: useVertical ? Math.min(260, Screen.height - Theme.spacingM * 2) : (40 + Theme.spacingS * 2)
|
||||
@@ -41,7 +53,7 @@ DankOSD {
|
||||
target: player
|
||||
|
||||
function onVolumeChanged() {
|
||||
if (SettingsData.osdMediaVolumeEnabled && volumeSupported) {
|
||||
if (SettingsData.osdMediaVolumeEnabled && volumeSupported && !_suppressNewPlayer) {
|
||||
root.show();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user