mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
Bar (mediaplayer): Mouse wheel options for media player widget (#1248)
* Add different options for scroll on media widget. * Nicer lookup code. * Remove some checks I didn't need. * Update the search tags. * EOF.
This commit is contained in:
@@ -185,7 +185,7 @@ Singleton {
|
|||||||
property bool waveProgressEnabled: true
|
property bool waveProgressEnabled: true
|
||||||
property bool scrollTitleEnabled: true
|
property bool scrollTitleEnabled: true
|
||||||
property bool audioVisualizerEnabled: true
|
property bool audioVisualizerEnabled: true
|
||||||
property bool audioScrollEnabled: true
|
property string audioScrollMode: "volume"
|
||||||
property bool clockCompactMode: false
|
property bool clockCompactMode: false
|
||||||
property bool focusedWindowCompactMode: false
|
property bool focusedWindowCompactMode: false
|
||||||
property bool runningAppsCompactMode: true
|
property bool runningAppsCompactMode: true
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ var SPEC = {
|
|||||||
waveProgressEnabled: { def: true },
|
waveProgressEnabled: { def: true },
|
||||||
scrollTitleEnabled: { def: true },
|
scrollTitleEnabled: { def: true },
|
||||||
audioVisualizerEnabled: { def: true },
|
audioVisualizerEnabled: { def: true },
|
||||||
audioScrollEnabled: { def: true },
|
audioScrollMode: { def: "volume" },
|
||||||
clockCompactMode: { def: false },
|
clockCompactMode: { def: false },
|
||||||
focusedWindowCompactMode: { def: false },
|
focusedWindowCompactMode: { def: false },
|
||||||
runningAppsCompactMode: { def: true },
|
runningAppsCompactMode: { def: true },
|
||||||
|
|||||||
@@ -54,38 +54,67 @@ BasePill {
|
|||||||
property real touchpadThreshold: 100
|
property real touchpadThreshold: 100
|
||||||
|
|
||||||
onWheel: function (wheelEvent) {
|
onWheel: function (wheelEvent) {
|
||||||
if (!usePlayerVolume)
|
if (SettingsData.audioScrollMode === "nothing")
|
||||||
return;
|
|
||||||
if (!SettingsData.audioScrollEnabled)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wheelEvent.accepted = true;
|
if (SettingsData.audioScrollMode === "volume") {
|
||||||
|
if (!usePlayerVolume)
|
||||||
|
return;
|
||||||
|
|
||||||
const deltaY = wheelEvent.angleDelta.y;
|
wheelEvent.accepted = true;
|
||||||
const isMouseWheelY = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0;
|
|
||||||
|
|
||||||
const currentVolume = activePlayer.volume * 100;
|
const deltaY = wheelEvent.angleDelta.y;
|
||||||
|
const isMouseWheelY = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0;
|
||||||
|
|
||||||
let newVolume = currentVolume;
|
const currentVolume = activePlayer.volume * 100;
|
||||||
if (isMouseWheelY) {
|
|
||||||
if (deltaY > 0) {
|
let newVolume = currentVolume;
|
||||||
newVolume = Math.min(100, currentVolume + 5);
|
if (isMouseWheelY) {
|
||||||
} else if (deltaY < 0) {
|
if (deltaY > 0) {
|
||||||
newVolume = Math.max(0, currentVolume - 5);
|
newVolume = Math.min(100, currentVolume + 5);
|
||||||
}
|
} else if (deltaY < 0) {
|
||||||
} else {
|
newVolume = Math.max(0, currentVolume - 5);
|
||||||
scrollAccumulatorY += deltaY;
|
}
|
||||||
if (Math.abs(scrollAccumulatorY) >= touchpadThreshold) {
|
} else {
|
||||||
if (scrollAccumulatorY > 0) {
|
scrollAccumulatorY += deltaY;
|
||||||
newVolume = Math.min(100, currentVolume + 1);
|
if (Math.abs(scrollAccumulatorY) >= touchpadThreshold) {
|
||||||
} else {
|
if (scrollAccumulatorY > 0) {
|
||||||
newVolume = Math.max(0, currentVolume - 1);
|
newVolume = Math.min(100, currentVolume + 1);
|
||||||
|
} else {
|
||||||
|
newVolume = Math.max(0, currentVolume - 1);
|
||||||
|
}
|
||||||
|
scrollAccumulatorY = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
activePlayer.volume = newVolume / 100;
|
||||||
|
} else if (SettingsData.audioScrollMode === "song") {
|
||||||
|
if (!activePlayer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wheelEvent.accepted = true;
|
||||||
|
|
||||||
|
const deltaY = wheelEvent.angleDelta.y;
|
||||||
|
const isMouseWheelY = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0;
|
||||||
|
|
||||||
|
if (isMouseWheelY) {
|
||||||
|
if (deltaY > 0) {
|
||||||
|
activePlayer.previous();
|
||||||
|
} else {
|
||||||
|
activePlayer.next();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
scrollAccumulatorY += deltaY;
|
||||||
|
if (Math.abs(scrollAccumulatorY) >= touchpadThreshold) {
|
||||||
|
if (scrollAccumulatorY > 0) {
|
||||||
|
activePlayer.previous();
|
||||||
|
} else {
|
||||||
|
activePlayer.next();
|
||||||
|
}
|
||||||
|
scrollAccumulatorY = 0;
|
||||||
}
|
}
|
||||||
scrollAccumulatorY = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activePlayer.volume = newVolume / 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content: Component {
|
content: Component {
|
||||||
|
|||||||
@@ -46,11 +46,24 @@ Item {
|
|||||||
onToggled: checked => SettingsData.set("audioVisualizerEnabled", checked)
|
onToggled: checked => SettingsData.set("audioVisualizerEnabled", checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsToggleRow {
|
SettingsDropdownRow {
|
||||||
|
property var scrollOpts: {
|
||||||
|
"Change Volume": "volume",
|
||||||
|
"Change Song": "song",
|
||||||
|
"Nothing": "nothing"
|
||||||
|
}
|
||||||
|
|
||||||
text: I18n.tr("Scroll Wheel")
|
text: I18n.tr("Scroll Wheel")
|
||||||
description: I18n.tr("Scroll on widget changes media volume")
|
description: I18n.tr("Scroll wheel behavior on media widget")
|
||||||
checked: SettingsData.audioScrollEnabled
|
settingKey: "audioScrollMode"
|
||||||
onToggled: checked => SettingsData.set("audioScrollEnabled", checked)
|
tags: ["media", "music", "scroll"]
|
||||||
|
options: Object.keys(scrollOpts).sort()
|
||||||
|
currentValue: {
|
||||||
|
Object.keys(scrollOpts).find(key => scrollOpts[key] === SettingsData.audioScrollMode) ?? "volume"
|
||||||
|
}
|
||||||
|
onValueChanged: value => {
|
||||||
|
SettingsData.set("audioScrollMode", scrollOpts[value])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2549,6 +2549,27 @@
|
|||||||
"icon": "lock",
|
"icon": "lock",
|
||||||
"description": "If the field is hidden, it will appear as soon as a key is pressed."
|
"description": "If the field is hidden, it will appear as soon as a key is pressed."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"section": "lockBeforeSuspend",
|
||||||
|
"label": "Lock before suspend",
|
||||||
|
"tabIndex": 11,
|
||||||
|
"category": "Lock Screen",
|
||||||
|
"keywords": [
|
||||||
|
"automatic",
|
||||||
|
"automatically",
|
||||||
|
"before",
|
||||||
|
"lock",
|
||||||
|
"login",
|
||||||
|
"password",
|
||||||
|
"prepares",
|
||||||
|
"screen",
|
||||||
|
"security",
|
||||||
|
"sleep",
|
||||||
|
"suspend",
|
||||||
|
"system"
|
||||||
|
],
|
||||||
|
"description": "Automatically lock the screen when the system prepares to suspend"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"section": "lockScreenShowPasswordField",
|
"section": "lockScreenShowPasswordField",
|
||||||
"label": "Show Password Field",
|
"label": "Show Password Field",
|
||||||
@@ -2981,6 +3002,7 @@
|
|||||||
"playback",
|
"playback",
|
||||||
"player",
|
"player",
|
||||||
"progress",
|
"progress",
|
||||||
|
"scroll",
|
||||||
"settings",
|
"settings",
|
||||||
"spotify",
|
"spotify",
|
||||||
"statusbar",
|
"statusbar",
|
||||||
@@ -2991,6 +3013,24 @@
|
|||||||
"icon": "music_note",
|
"icon": "music_note",
|
||||||
"description": "Use animated wave progress bars for media playback"
|
"description": "Use animated wave progress bars for media playback"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"section": "audioScrollMode",
|
||||||
|
"label": "Scroll Wheel",
|
||||||
|
"tabIndex": 16,
|
||||||
|
"category": "Media Player",
|
||||||
|
"keywords": [
|
||||||
|
"behavior",
|
||||||
|
"media",
|
||||||
|
"mpris",
|
||||||
|
"music",
|
||||||
|
"player",
|
||||||
|
"scroll",
|
||||||
|
"spotify",
|
||||||
|
"wheel",
|
||||||
|
"widget"
|
||||||
|
],
|
||||||
|
"description": "Scroll wheel behavior on media widget"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"section": "notificationTimeoutCritical",
|
"section": "notificationTimeoutCritical",
|
||||||
"label": "Critical Priority",
|
"label": "Critical Priority",
|
||||||
@@ -3466,27 +3506,6 @@
|
|||||||
"icon": "schedule",
|
"icon": "schedule",
|
||||||
"description": "Gradually fade the screen before locking with a configurable grace period"
|
"description": "Gradually fade the screen before locking with a configurable grace period"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"section": "lockBeforeSuspend",
|
|
||||||
"label": "Lock before suspend",
|
|
||||||
"tabIndex": 21,
|
|
||||||
"category": "Power & Sleep",
|
|
||||||
"keywords": [
|
|
||||||
"automatically",
|
|
||||||
"before",
|
|
||||||
"energy",
|
|
||||||
"lock",
|
|
||||||
"power",
|
|
||||||
"prepares",
|
|
||||||
"screen",
|
|
||||||
"security",
|
|
||||||
"shutdown",
|
|
||||||
"sleep",
|
|
||||||
"suspend",
|
|
||||||
"system"
|
|
||||||
],
|
|
||||||
"description": "Automatically lock the screen when the system prepares to suspend"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"section": "powerConfirmation",
|
"section": "powerConfirmation",
|
||||||
"label": "Power Action Confirmation",
|
"label": "Power Action Confirmation",
|
||||||
|
|||||||
Reference in New Issue
Block a user