mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-11 16:22:09 -04:00
osd: optimize bindings
This commit is contained in:
@@ -7,9 +7,10 @@ DankOSD {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property bool useVertical: isVerticalLayout
|
readonly property bool useVertical: isVerticalLayout
|
||||||
property int targetBrightness: {
|
property int _displayBrightness: 0
|
||||||
DisplayService.brightnessVersion;
|
|
||||||
return DisplayService.brightnessLevel;
|
function _syncBrightness() {
|
||||||
|
_displayBrightness = DisplayService.brightnessLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
osdWidth: useVertical ? (40 + Theme.spacingS * 2) : Math.min(260, Screen.width - Theme.spacingM * 2)
|
osdWidth: useVertical ? (40 + Theme.spacingS * 2) : Math.min(260, Screen.width - Theme.spacingM * 2)
|
||||||
@@ -20,9 +21,9 @@ DankOSD {
|
|||||||
Connections {
|
Connections {
|
||||||
target: DisplayService
|
target: DisplayService
|
||||||
function onBrightnessChanged(showOsd) {
|
function onBrightnessChanged(showOsd) {
|
||||||
if (showOsd && SettingsData.osdBrightnessEnabled) {
|
root._syncBrightness();
|
||||||
|
if (showOsd && SettingsData.osdBrightnessEnabled)
|
||||||
root.show();
|
root.show();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,13 +54,11 @@ DankOSD {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
name: {
|
name: {
|
||||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||||
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc") {
|
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc")
|
||||||
return "brightness_medium";
|
return "brightness_medium";
|
||||||
} else if (deviceInfo.name.includes("kbd")) {
|
if (deviceInfo.name.includes("kbd"))
|
||||||
return "keyboard";
|
return "keyboard";
|
||||||
} else {
|
return "lightbulb";
|
||||||
return "lightbulb";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
@@ -77,20 +76,16 @@ DankOSD {
|
|||||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||||
if (!deviceInfo)
|
if (!deviceInfo)
|
||||||
return 1;
|
return 1;
|
||||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||||
if (isExponential) {
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0;
|
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0;
|
||||||
}
|
}
|
||||||
maximum: {
|
maximum: {
|
||||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||||
if (!deviceInfo)
|
if (!deviceInfo)
|
||||||
return 100;
|
return 100;
|
||||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||||
if (isExponential) {
|
|
||||||
return 100;
|
return 100;
|
||||||
}
|
|
||||||
return deviceInfo.displayMax || 100;
|
return deviceInfo.displayMax || 100;
|
||||||
}
|
}
|
||||||
enabled: DisplayService.brightnessAvailable
|
enabled: DisplayService.brightnessAvailable
|
||||||
@@ -99,28 +94,24 @@ DankOSD {
|
|||||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||||
if (!deviceInfo)
|
if (!deviceInfo)
|
||||||
return "%";
|
return "%";
|
||||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||||
if (isExponential) {
|
|
||||||
return "%";
|
return "%";
|
||||||
}
|
|
||||||
return deviceInfo.class === "ddc" ? "" : "%";
|
return deviceInfo.class === "ddc" ? "" : "%";
|
||||||
}
|
}
|
||||||
thumbOutlineColor: Theme.surfaceContainer
|
thumbOutlineColor: Theme.surfaceContainer
|
||||||
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
||||||
|
|
||||||
onSliderValueChanged: newValue => {
|
onSliderValueChanged: newValue => {
|
||||||
if (DisplayService.brightnessAvailable) {
|
if (!DisplayService.brightnessAvailable)
|
||||||
DisplayService.setBrightness(newValue, DisplayService.lastIpcDevice, true);
|
return;
|
||||||
resetHideTimer();
|
DisplayService.setBrightness(newValue, DisplayService.lastIpcDevice, true);
|
||||||
}
|
resetHideTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse)
|
||||||
setChildHovered(containsMouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
Binding on value {
|
Binding on value {
|
||||||
value: root.targetBrightness
|
value: root._displayBrightness
|
||||||
when: !brightnessSlider.isDragging
|
when: !brightnessSlider.isDragging
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,13 +137,11 @@ DankOSD {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
name: {
|
name: {
|
||||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||||
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc") {
|
if (!deviceInfo || deviceInfo.class === "backlight" || deviceInfo.class === "ddc")
|
||||||
return "brightness_medium";
|
return "brightness_medium";
|
||||||
} else if (deviceInfo.name.includes("kbd")) {
|
if (deviceInfo.name.includes("kbd"))
|
||||||
return "keyboard";
|
return "keyboard";
|
||||||
} else {
|
return "lightbulb";
|
||||||
return "lightbulb";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: Theme.primary
|
color: Theme.primary
|
||||||
@@ -170,7 +159,7 @@ DankOSD {
|
|||||||
property int value: 50
|
property int value: 50
|
||||||
|
|
||||||
Binding on value {
|
Binding on value {
|
||||||
value: root.targetBrightness
|
value: root._displayBrightness
|
||||||
when: !vertSlider.dragging
|
when: !vertSlider.dragging
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,8 +167,7 @@ DankOSD {
|
|||||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||||
if (!deviceInfo)
|
if (!deviceInfo)
|
||||||
return 1;
|
return 1;
|
||||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||||
if (isExponential)
|
|
||||||
return 1;
|
return 1;
|
||||||
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0;
|
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0;
|
||||||
}
|
}
|
||||||
@@ -188,8 +176,7 @@ DankOSD {
|
|||||||
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
const deviceInfo = DisplayService.getCurrentDeviceInfo();
|
||||||
if (!deviceInfo)
|
if (!deviceInfo)
|
||||||
return 100;
|
return 100;
|
||||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id);
|
if (SessionData.getBrightnessExponential(deviceInfo.id))
|
||||||
if (isExponential)
|
|
||||||
return 100;
|
return 100;
|
||||||
return deviceInfo.displayMax || 100;
|
return deviceInfo.displayMax || 100;
|
||||||
}
|
}
|
||||||
@@ -240,33 +227,25 @@ DankOSD {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse)
|
||||||
setChildHovered(containsMouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: mouse => {
|
onPressed: mouse => {
|
||||||
vertSlider.dragging = true;
|
vertSlider.dragging = true;
|
||||||
updateBrightness(mouse);
|
updateBrightness(mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: {
|
onReleased: vertSlider.dragging = false
|
||||||
vertSlider.dragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPositionChanged: mouse => {
|
onPositionChanged: mouse => {
|
||||||
if (pressed) {
|
if (pressed)
|
||||||
updateBrightness(mouse);
|
updateBrightness(mouse);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: mouse => {
|
onClicked: mouse => updateBrightness(mouse)
|
||||||
updateBrightness(mouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateBrightness(mouse) {
|
function updateBrightness(mouse) {
|
||||||
if (!DisplayService.brightnessAvailable) {
|
if (!DisplayService.brightnessAvailable)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
const ratio = 1.0 - (mouse.y / height);
|
const ratio = 1.0 - (mouse.y / height);
|
||||||
const newValue = Math.round(vertSlider.minimum + ratio * (vertSlider.maximum - vertSlider.minimum));
|
const newValue = Math.round(vertSlider.minimum + ratio * (vertSlider.maximum - vertSlider.minimum));
|
||||||
vertSlider.value = newValue;
|
vertSlider.value = newValue;
|
||||||
|
|||||||
@@ -8,13 +8,20 @@ DankOSD {
|
|||||||
|
|
||||||
readonly property bool useVertical: isVerticalLayout
|
readonly property bool useVertical: isVerticalLayout
|
||||||
readonly property var player: MprisController.activePlayer
|
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
|
readonly property bool volumeSupported: player?.volumeSupported ?? false
|
||||||
property bool _suppressNewPlayer: false
|
property bool _suppressNewPlayer: false
|
||||||
|
property int _displayVolume: 0
|
||||||
|
|
||||||
|
function _syncVolume() {
|
||||||
|
if (!player)
|
||||||
|
return;
|
||||||
|
_displayVolume = Math.min(100, Math.round(player.volume * 100));
|
||||||
|
}
|
||||||
|
|
||||||
onPlayerChanged: {
|
onPlayerChanged: {
|
||||||
_suppressNewPlayer = true;
|
_suppressNewPlayer = true;
|
||||||
_suppressTimer.restart();
|
_suppressTimer.restart();
|
||||||
|
_syncVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
@@ -37,25 +44,25 @@ DankOSD {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleMute() {
|
function toggleMute() {
|
||||||
if (player) {
|
if (!player)
|
||||||
player.volume = player.volume > 0 ? 0 : 1;
|
return;
|
||||||
}
|
player.volume = player.volume > 0 ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVolume(volumePercent) {
|
function setVolume(volumePercent) {
|
||||||
if (player) {
|
if (!player)
|
||||||
player.volume = volumePercent / 100;
|
return;
|
||||||
resetHideTimer();
|
player.volume = volumePercent / 100;
|
||||||
}
|
resetHideTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: player
|
target: player
|
||||||
|
|
||||||
function onVolumeChanged() {
|
function onVolumeChanged() {
|
||||||
if (SettingsData.osdMediaVolumeEnabled && volumeSupported && !_suppressNewPlayer) {
|
root._syncVolume();
|
||||||
|
if (SettingsData.osdMediaVolumeEnabled && volumeSupported && !_suppressNewPlayer)
|
||||||
root.show();
|
root.show();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,9 +103,7 @@ DankOSD {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: toggleMute()
|
onClicked: toggleMute()
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse || volumeSlider.containsMouse)
|
||||||
setChildHovered(containsMouse || volumeSlider.containsMouse);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,29 +120,21 @@ DankOSD {
|
|||||||
showValue: true
|
showValue: true
|
||||||
unit: "%"
|
unit: "%"
|
||||||
thumbOutlineColor: Theme.surfaceContainer
|
thumbOutlineColor: Theme.surfaceContainer
|
||||||
valueOverride: currentVolume
|
valueOverride: root._displayVolume
|
||||||
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
value = currentVolume;
|
root._syncVolume();
|
||||||
|
value = root._displayVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSliderValueChanged: newValue => {
|
onSliderValueChanged: newValue => setVolume(newValue)
|
||||||
setVolume(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse || muteButton.containsMouse)
|
||||||
setChildHovered(containsMouse || muteButton.containsMouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Binding on value {
|
||||||
target: player
|
value: root._displayVolume
|
||||||
|
when: !volumeSlider.pressed
|
||||||
function onVolumeChanged() {
|
|
||||||
if (volumeSlider && !volumeSlider.pressed) {
|
|
||||||
volumeSlider.value = currentVolume;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,9 +169,7 @@ DankOSD {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: toggleMute()
|
onClicked: toggleMute()
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse || vertSliderArea.containsMouse)
|
||||||
setChildHovered(containsMouse || vertSliderArea.containsMouse);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +181,7 @@ DankOSD {
|
|||||||
y: gap * 2 + Theme.iconSize
|
y: gap * 2 + Theme.iconSize
|
||||||
|
|
||||||
property bool dragging: false
|
property bool dragging: false
|
||||||
property int value: currentVolume
|
property int value: root._displayVolume
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: vertTrack
|
id: vertTrack
|
||||||
@@ -231,28 +226,21 @@ DankOSD {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse || muteButtonVert.containsMouse)
|
||||||
setChildHovered(containsMouse || muteButtonVert.containsMouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: mouse => {
|
onPressed: mouse => {
|
||||||
vertSlider.dragging = true;
|
vertSlider.dragging = true;
|
||||||
updateVolume(mouse);
|
updateVolume(mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: {
|
onReleased: vertSlider.dragging = false
|
||||||
vertSlider.dragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPositionChanged: mouse => {
|
onPositionChanged: mouse => {
|
||||||
if (pressed) {
|
if (pressed)
|
||||||
updateVolume(mouse);
|
updateVolume(mouse);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: mouse => {
|
onClicked: mouse => updateVolume(mouse)
|
||||||
updateVolume(mouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateVolume(mouse) {
|
function updateVolume(mouse) {
|
||||||
const ratio = 1.0 - (mouse.y / height);
|
const ratio = 1.0 - (mouse.y / height);
|
||||||
@@ -260,16 +248,6 @@ DankOSD {
|
|||||||
setVolume(volume);
|
setVolume(volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: player
|
|
||||||
|
|
||||||
function onVolumeChanged() {
|
|
||||||
if (!vertSlider.dragging) {
|
|
||||||
vertSlider.value = currentVolume;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
@@ -283,15 +261,4 @@ DankOSD {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOsdShown: {
|
|
||||||
if (player && contentLoader.item && contentLoader.item.item) {
|
|
||||||
if (!useVertical) {
|
|
||||||
const slider = contentLoader.item.item.children[0].children[1];
|
|
||||||
if (slider && slider.value !== undefined) {
|
|
||||||
slider.value = currentVolume;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,13 @@ DankOSD {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property bool useVertical: isVerticalLayout
|
readonly property bool useVertical: isVerticalLayout
|
||||||
|
property int _displayVolume: 0
|
||||||
|
|
||||||
|
function _syncVolume() {
|
||||||
|
if (!AudioService.sink?.audio)
|
||||||
|
return;
|
||||||
|
_displayVolume = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
||||||
|
}
|
||||||
|
|
||||||
osdWidth: useVertical ? (40 + Theme.spacingS * 2) : Math.min(260, Screen.width - Theme.spacingM * 2)
|
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)
|
osdHeight: useVertical ? Math.min(260, Screen.height - Theme.spacingM * 2) : (40 + Theme.spacingS * 2)
|
||||||
@@ -14,18 +21,17 @@ DankOSD {
|
|||||||
enableMouseInteraction: true
|
enableMouseInteraction: true
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
target: AudioService.sink?.audio ?? null
|
||||||
|
|
||||||
function onVolumeChanged() {
|
function onVolumeChanged() {
|
||||||
if (SettingsData.osdVolumeEnabled) {
|
root._syncVolume();
|
||||||
|
if (SettingsData.osdVolumeEnabled)
|
||||||
root.show();
|
root.show();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMutedChanged() {
|
function onMutedChanged() {
|
||||||
if (SettingsData.osdVolumeEnabled) {
|
if (SettingsData.osdVolumeEnabled)
|
||||||
root.show();
|
root.show();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,9 +39,9 @@ DankOSD {
|
|||||||
target: AudioService
|
target: AudioService
|
||||||
|
|
||||||
function onSinkChanged() {
|
function onSinkChanged() {
|
||||||
if (root.shouldBeVisible && SettingsData.osdVolumeEnabled) {
|
root._syncVolume();
|
||||||
|
if (root.shouldBeVisible && SettingsData.osdVolumeEnabled)
|
||||||
root.show();
|
root.show();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +70,7 @@ DankOSD {
|
|||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ? "volume_off" : "volume_up"
|
name: AudioService.sink?.audio?.muted ? "volume_off" : "volume_up"
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: muteButton.containsMouse ? Theme.primary : Theme.surfaceText
|
color: muteButton.containsMouse ? Theme.primary : Theme.surfaceText
|
||||||
}
|
}
|
||||||
@@ -75,60 +81,45 @@ DankOSD {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: AudioService.toggleMute()
|
||||||
AudioService.toggleMute();
|
onContainsMouseChanged: setChildHovered(containsMouse || volumeSlider.containsMouse)
|
||||||
}
|
|
||||||
onContainsMouseChanged: {
|
|
||||||
setChildHovered(containsMouse || volumeSlider.containsMouse);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DankSlider {
|
DankSlider {
|
||||||
id: volumeSlider
|
id: volumeSlider
|
||||||
|
|
||||||
readonly property real actualVolumePercent: AudioService.sink && AudioService.sink.audio ? Math.round(AudioService.sink.audio.volume * 100) : 0
|
|
||||||
readonly property real displayPercent: actualVolumePercent
|
|
||||||
|
|
||||||
width: parent.width - Theme.iconSize - parent.gap * 3
|
width: parent.width - Theme.iconSize - parent.gap * 3
|
||||||
height: 40
|
height: 40
|
||||||
x: parent.gap * 2 + Theme.iconSize
|
x: parent.gap * 2 + Theme.iconSize
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: AudioService.sinkMaxVolume
|
maximum: AudioService.sinkMaxVolume
|
||||||
enabled: AudioService.sink && AudioService.sink.audio
|
enabled: AudioService.sink?.audio
|
||||||
showValue: true
|
showValue: true
|
||||||
unit: "%"
|
unit: "%"
|
||||||
thumbOutlineColor: Theme.surfaceContainer
|
thumbOutlineColor: Theme.surfaceContainer
|
||||||
valueOverride: displayPercent
|
valueOverride: root._displayVolume
|
||||||
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
alwaysShowValue: SettingsData.osdAlwaysShowValue
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (AudioService.sink && AudioService.sink.audio) {
|
root._syncVolume();
|
||||||
value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
value = root._displayVolume;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onSliderValueChanged: newValue => {
|
onSliderValueChanged: newValue => {
|
||||||
if (AudioService.sink && AudioService.sink.audio) {
|
if (!AudioService.sink?.audio)
|
||||||
SessionData.suppressOSDTemporarily();
|
return;
|
||||||
AudioService.sink.audio.volume = newValue / 100;
|
SessionData.suppressOSDTemporarily();
|
||||||
resetHideTimer();
|
AudioService.sink.audio.volume = newValue / 100;
|
||||||
}
|
resetHideTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse || muteButton.containsMouse)
|
||||||
setChildHovered(containsMouse || muteButton.containsMouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
Binding on value {
|
||||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
value: root._displayVolume
|
||||||
|
when: !volumeSlider.pressed
|
||||||
function onVolumeChanged() {
|
|
||||||
if (volumeSlider && !volumeSlider.pressed) {
|
|
||||||
volumeSlider.value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +142,7 @@ DankOSD {
|
|||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
name: AudioService.sink && AudioService.sink.audio && AudioService.sink.audio.muted ? "volume_off" : "volume_up"
|
name: AudioService.sink?.audio?.muted ? "volume_off" : "volume_up"
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: muteButtonVert.containsMouse ? Theme.primary : Theme.surfaceText
|
color: muteButtonVert.containsMouse ? Theme.primary : Theme.surfaceText
|
||||||
}
|
}
|
||||||
@@ -162,12 +153,8 @@ DankOSD {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: AudioService.toggleMute()
|
||||||
AudioService.toggleMute();
|
onContainsMouseChanged: setChildHovered(containsMouse || vertSliderArea.containsMouse)
|
||||||
}
|
|
||||||
onContainsMouseChanged: {
|
|
||||||
setChildHovered(containsMouse || vertSliderArea.containsMouse);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +166,7 @@ DankOSD {
|
|||||||
y: gap * 2 + Theme.iconSize
|
y: gap * 2 + Theme.iconSize
|
||||||
|
|
||||||
property bool dragging: false
|
property bool dragging: false
|
||||||
property int value: AudioService.sink && AudioService.sink.audio ? Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100)) : 0
|
property int value: root._displayVolume
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: vertTrack
|
id: vertTrack
|
||||||
@@ -220,50 +207,35 @@ DankOSD {
|
|||||||
id: vertSliderArea
|
id: vertSliderArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: -12
|
anchors.margins: -12
|
||||||
enabled: AudioService.sink && AudioService.sink.audio
|
enabled: AudioService.sink?.audio
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: setChildHovered(containsMouse || muteButtonVert.containsMouse)
|
||||||
setChildHovered(containsMouse || muteButtonVert.containsMouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
onPressed: mouse => {
|
onPressed: mouse => {
|
||||||
vertSlider.dragging = true;
|
vertSlider.dragging = true;
|
||||||
updateVolume(mouse);
|
updateVolume(mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReleased: {
|
onReleased: vertSlider.dragging = false
|
||||||
vertSlider.dragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPositionChanged: mouse => {
|
onPositionChanged: mouse => {
|
||||||
if (pressed) {
|
if (pressed)
|
||||||
updateVolume(mouse);
|
updateVolume(mouse);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: mouse => {
|
onClicked: mouse => updateVolume(mouse)
|
||||||
updateVolume(mouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateVolume(mouse) {
|
function updateVolume(mouse) {
|
||||||
if (AudioService.sink && AudioService.sink.audio) {
|
if (!AudioService.sink?.audio)
|
||||||
const maxVol = AudioService.sinkMaxVolume;
|
return;
|
||||||
const ratio = 1.0 - (mouse.y / height);
|
const maxVol = AudioService.sinkMaxVolume;
|
||||||
const volume = Math.max(0, Math.min(maxVol, Math.round(ratio * maxVol)));
|
const ratio = 1.0 - (mouse.y / height);
|
||||||
SessionData.suppressOSDTemporarily();
|
const volume = Math.max(0, Math.min(maxVol, Math.round(ratio * maxVol)));
|
||||||
AudioService.sink.audio.volume = volume / 100;
|
SessionData.suppressOSDTemporarily();
|
||||||
resetHideTimer();
|
AudioService.sink.audio.volume = volume / 100;
|
||||||
}
|
resetHideTimer();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: AudioService.sink && AudioService.sink.audio ? AudioService.sink.audio : null
|
|
||||||
|
|
||||||
function onVolumeChanged() {
|
|
||||||
vertSlider.value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,15 +251,4 @@ DankOSD {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onOsdShown: {
|
|
||||||
if (AudioService.sink && AudioService.sink.audio && contentLoader.item && contentLoader.item.item) {
|
|
||||||
if (!useVertical) {
|
|
||||||
const slider = contentLoader.item.item.children[0].children[1];
|
|
||||||
if (slider && slider.value !== undefined) {
|
|
||||||
slider.value = Math.min(AudioService.sinkMaxVolume, Math.round(AudioService.sink.audio.volume * 100));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,36 +18,41 @@ Column {
|
|||||||
property bool isInitialized: false
|
property bool isInitialized: false
|
||||||
|
|
||||||
function loadValue() {
|
function loadValue() {
|
||||||
const settings = findSettings()
|
const settings = findSettings();
|
||||||
if (settings && settings.pluginService) {
|
if (settings && settings.pluginService) {
|
||||||
const loadedValue = settings.loadValue(settingKey, defaultValue)
|
const loadedValue = settings.loadValue(settingKey, defaultValue);
|
||||||
value = loadedValue
|
if (textField.activeFocus && isInitialized)
|
||||||
textField.text = loadedValue
|
return;
|
||||||
isInitialized = true
|
value = loadedValue;
|
||||||
|
textField.text = loadedValue;
|
||||||
|
isInitialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Qt.callLater(loadValue)
|
Qt.callLater(loadValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
onValueChanged: {
|
function commit() {
|
||||||
if (!isInitialized) return
|
if (!isInitialized)
|
||||||
const settings = findSettings()
|
return;
|
||||||
if (settings) {
|
if (textField.text === value)
|
||||||
settings.saveValue(settingKey, value)
|
return;
|
||||||
}
|
value = textField.text;
|
||||||
|
const settings = findSettings();
|
||||||
|
if (settings)
|
||||||
|
settings.saveValue(settingKey, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findSettings() {
|
function findSettings() {
|
||||||
let item = parent
|
let item = parent;
|
||||||
while (item) {
|
while (item) {
|
||||||
if (item.saveValue !== undefined && item.loadValue !== undefined) {
|
if (item.saveValue !== undefined && item.loadValue !== undefined) {
|
||||||
return item
|
return item;
|
||||||
}
|
}
|
||||||
item = item.parent
|
item = item.parent;
|
||||||
}
|
}
|
||||||
return null
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
@@ -70,16 +75,10 @@ Column {
|
|||||||
id: textField
|
id: textField
|
||||||
width: parent.width
|
width: parent.width
|
||||||
placeholderText: root.placeholder
|
placeholderText: root.placeholder
|
||||||
onTextEdited: {
|
onEditingFinished: root.commit()
|
||||||
root.value = text
|
|
||||||
}
|
|
||||||
onEditingFinished: {
|
|
||||||
root.value = text
|
|
||||||
}
|
|
||||||
onActiveFocusChanged: {
|
onActiveFocusChanged: {
|
||||||
if (!activeFocus) {
|
if (!activeFocus)
|
||||||
root.value = text
|
root.commit();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -375,8 +375,20 @@ FocusScope {
|
|||||||
if (!plugin || !PluginService.isPluginLoaded(pluginId))
|
if (!plugin || !PluginService.isPluginLoaded(pluginId))
|
||||||
return;
|
return;
|
||||||
var isLauncher = plugin.type === "launcher" || (plugin.capabilities && plugin.capabilities.includes("launcher"));
|
var isLauncher = plugin.type === "launcher" || (plugin.capabilities && plugin.capabilities.includes("launcher"));
|
||||||
if (isLauncher)
|
if (isLauncher) {
|
||||||
PluginService.reloadPlugin(pluginId);
|
pluginReloadTimer.pendingPluginId = pluginId;
|
||||||
|
pluginReloadTimer.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: pluginReloadTimer
|
||||||
|
property string pendingPluginId: ""
|
||||||
|
interval: 500
|
||||||
|
onTriggered: {
|
||||||
|
if (pendingPluginId)
|
||||||
|
PluginService.reloadPlugin(pendingPluginId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ PanelWindow {
|
|||||||
function show() {
|
function show() {
|
||||||
if (SessionData.suppressOSD)
|
if (SessionData.suppressOSD)
|
||||||
return;
|
return;
|
||||||
|
if (shouldBeVisible) {
|
||||||
|
hideTimer.restart();
|
||||||
|
return;
|
||||||
|
}
|
||||||
OSDManager.showOSD(root);
|
OSDManager.showOSD(root);
|
||||||
closeTimer.stop();
|
closeTimer.stop();
|
||||||
shouldBeVisible = true;
|
shouldBeVisible = true;
|
||||||
@@ -257,7 +261,7 @@ PanelWindow {
|
|||||||
property real shadowSpreadPx: 0
|
property real shadowSpreadPx: 0
|
||||||
property real shadowBaseAlpha: 0.60
|
property real shadowBaseAlpha: 0.60
|
||||||
readonly property real popupSurfaceAlpha: SettingsData.popupTransparency
|
readonly property real popupSurfaceAlpha: SettingsData.popupTransparency
|
||||||
readonly property real effectiveShadowAlpha: Math.max(0, Math.min(1, shadowBaseAlpha * popupSurfaceAlpha * osdContainer.opacity))
|
readonly property real effectiveShadowAlpha: shouldBeVisible ? Math.max(0, Math.min(1, shadowBaseAlpha * popupSurfaceAlpha)) : 0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: background
|
id: background
|
||||||
|
|||||||
Reference in New Issue
Block a user