1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-27 06:52:50 -05:00

Add volume and brightness percentages (#1148)

This commit is contained in:
Aaron Tulino
2025-12-25 10:07:29 -07:00
committed by GitHub
parent df6c60213f
commit 6b6f51cd1f
8 changed files with 193 additions and 12 deletions

View File

@@ -16,9 +16,12 @@ BasePill {
property bool showNetworkIcon: widgetData?.showNetworkIcon !== undefined ? widgetData.showNetworkIcon : SettingsData.controlCenterShowNetworkIcon
property bool showBluetoothIcon: widgetData?.showBluetoothIcon !== undefined ? widgetData.showBluetoothIcon : SettingsData.controlCenterShowBluetoothIcon
property bool showAudioIcon: widgetData?.showAudioIcon !== undefined ? widgetData.showAudioIcon : SettingsData.controlCenterShowAudioIcon
property bool showAudioPercent: widgetData?.showAudioPercent !== undefined ? widgetData.showAudioPercent : SettingsData.controlCenterShowAudioPercent
property bool showVpnIcon: widgetData?.showVpnIcon !== undefined ? widgetData.showVpnIcon : SettingsData.controlCenterShowVpnIcon
property bool showBrightnessIcon: widgetData?.showBrightnessIcon !== undefined ? widgetData.showBrightnessIcon : SettingsData.controlCenterShowBrightnessIcon
property bool showBrightnessPercent: widgetData?.showBrightnessPercent !== undefined ? widgetData.showBrightnessPercent : SettingsData.controlCenterShowBrightnessPercent
property bool showMicIcon: widgetData?.showMicIcon !== undefined ? widgetData.showMicIcon : SettingsData.controlCenterShowMicIcon
property bool showMicPercent: widgetData?.showMicPercent !== undefined ? widgetData.showMicPercent : SettingsData.controlCenterShowMicPercent
property bool showBatteryIcon: widgetData?.showBatteryIcon !== undefined ? widgetData.showBatteryIcon : SettingsData.controlCenterShowBatteryIcon
property bool showPrinterIcon: widgetData?.showPrinterIcon !== undefined ? widgetData.showPrinterIcon : SettingsData.controlCenterShowPrinterIcon
property real touchpadThreshold: 100
@@ -187,6 +190,14 @@ BasePill {
DisplayService.setBrightness(newBrightness, deviceName);
}
function getBrightness() {
const deviceName = getPinnedBrightnessDevice();
if (!deviceName) {
return;
}
return DisplayService.getDeviceBrightness(deviceName) / 100;
}
function getBatteryIconColor() {
if (!BatteryService.batteryAvailable)
return Theme.widgetIconColor;
@@ -242,7 +253,7 @@ BasePill {
Rectangle {
width: audioIconV.implicitWidth + 4
height: audioIconV.implicitHeight + 4
height: audioIconV.implicitHeight + (root.showAudioPercent ? audioPercentV.implicitHeight : 0) + 4
color: "transparent"
anchors.horizontalCenter: parent.horizontalCenter
visible: root.showAudioIcon
@@ -252,7 +263,20 @@ BasePill {
name: root.getVolumeIconName()
size: Theme.barIconSize(root.barThickness, -4)
color: Theme.widgetIconColor
anchors.centerIn: parent
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent
anchors.topMargin: 2
}
StyledText {
id: audioPercentV
visible: root.showAudioPercent
text: Math.round(AudioService.sink.audio.volume * 100) + "%"
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: audioIconV.bottom
anchors.topMargin: 2
}
MouseArea {
@@ -270,7 +294,7 @@ BasePill {
Rectangle {
width: micIconV.implicitWidth + 4
height: micIconV.implicitHeight + 4
height: micIconV.implicitHeight + (root.showAudioPercent ? micPercentV.implicitHeight : 0) + 4
color: "transparent"
anchors.horizontalCenter: parent.horizontalCenter
visible: root.showMicIcon
@@ -280,7 +304,20 @@ BasePill {
name: root.getMicIconName()
size: Theme.barIconSize(root.barThickness, -4)
color: root.getMicIconColor()
anchors.centerIn: parent
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent
anchors.topMargin: 2
}
StyledText {
id: micPercentV
visible: root.showMicPercent
text: Math.round(AudioService.source.audio.volume * 100) + "%"
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: micIconV.bottom
anchors.topMargin: 2
}
MouseArea {
@@ -298,7 +335,7 @@ BasePill {
Rectangle {
width: brightnessIconV.implicitWidth + 4
height: brightnessIconV.implicitHeight + 4
height: brightnessIconV.implicitHeight + (root.showBrightnessPercent ? brightnessPercentV.implicitHeight : 0) + 4
color: "transparent"
anchors.horizontalCenter: parent.horizontalCenter
visible: root.showBrightnessIcon && DisplayService.brightnessAvailable && root.hasPinnedBrightnessDevice()
@@ -308,7 +345,20 @@ BasePill {
name: root.getBrightnessIconName()
size: Theme.barIconSize(root.barThickness, -4)
color: Theme.widgetIconColor
anchors.centerIn: parent
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent
anchors.topMargin: 2
}
StyledText {
id: brightnessPercentV
visible: root.showBrightnessPercent
text: Math.round(getBrightness() * 100) + "%"
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: brightnessIconV.bottom
anchors.topMargin: 2
}
MouseArea {
@@ -380,7 +430,7 @@ BasePill {
}
Rectangle {
width: audioIcon.implicitWidth + 4
width: audioIcon.implicitWidth + (root.showAudioPercent ? audioPercent.implicitWidth : 0) + 4
height: audioIcon.implicitHeight + 4
color: "transparent"
anchors.verticalCenter: parent.verticalCenter
@@ -391,7 +441,20 @@ BasePill {
name: root.getVolumeIconName()
size: Theme.barIconSize(root.barThickness, -4)
color: Theme.widgetIconColor
anchors.centerIn: parent
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent
anchors.leftMargin: 2
}
StyledText {
id: audioPercent
visible: root.showAudioPercent
text: Math.round(AudioService.sink.audio.volume * 100) + "%"
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.verticalCenter: parent.verticalCenter
anchors.left: audioIcon.right
anchors.leftMargin: 2
}
MouseArea {
@@ -409,7 +472,7 @@ BasePill {
}
Rectangle {
width: micIcon.implicitWidth + 4
width: micIcon.implicitWidth + (root.showMicPercent ? micPercent.implicitWidth : 0) + 4
height: micIcon.implicitHeight + 4
color: "transparent"
anchors.verticalCenter: parent.verticalCenter
@@ -420,7 +483,20 @@ BasePill {
name: root.getMicIconName()
size: Theme.barIconSize(root.barThickness, -4)
color: root.getMicIconColor()
anchors.centerIn: parent
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent
anchors.leftMargin: 2
}
StyledText {
id: micPercent
visible: root.showMicPercent
text: Math.round(AudioService.source.audio.volume * 100) + "%"
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.verticalCenter: parent.verticalCenter
anchors.left: micIcon.right
anchors.leftMargin: 2
}
MouseArea {
@@ -438,7 +514,7 @@ BasePill {
}
Rectangle {
width: brightnessIcon.implicitWidth + 4
width: brightnessIcon.implicitWidth + (root.showBrightnessPercent ? brightnessPercent.implicitWidth : 0) + 4
height: brightnessIcon.implicitHeight + 4
color: "transparent"
anchors.verticalCenter: parent.verticalCenter
@@ -449,7 +525,20 @@ BasePill {
name: root.getBrightnessIconName()
size: Theme.barIconSize(root.barThickness, -4)
color: Theme.widgetIconColor
anchors.centerIn: parent
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent
anchors.leftMargin: 2
}
StyledText {
id: brightnessPercent
visible: root.showBrightnessPercent
text: Math.round(getBrightness() * 100) + "%"
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor
anchors.verticalCenter: parent.verticalCenter
anchors.left: brightnessIcon.right
anchors.leftMargin: 2
}
MouseArea {