Commit 0cb8d246 authored by Nate Graham's avatar Nate Graham 🔩
Browse files

Colorize volume percentage text when over 100%

We've now made it easier to increase the maximum volume to 150% for
those who need it due to quiet speakers. However since this could
potentially lead to excessive volume or damage to loud speakers with
long-term use, let's colorize the text to subtly indicate that this is
not a normal state.
parent 3f2040d4
......@@ -251,10 +251,25 @@ PlasmaComponents.ListItem {
PlasmaComponents.Label {
id: percentText
readonly property real value: PulseObject.volume > slider.maximumValue ? PulseObject.volume : slider.value
readonly property real displayValue: Math.round(value / PulseAudio.NormalVolume * 100.0)
Layout.alignment: Qt.AlignHCenter
Layout.minimumWidth: percentMetrics.advanceWidth
horizontalAlignment: Qt.AlignRight
text: i18nc("volume percentage", "%1%", Math.round(value / PulseAudio.NormalVolume * 100.0))
text: i18nc("volume percentage", "%1%", displayValue)
// Display a subtle visual indication that the volume
// might be dangerously high
// ------------------------------------------------
// Keep this in sync with the copies in VolumeSlider.qml
// and plasma-workspace:OSDItem.qml
color: {
if (displayValue <= 100) {
return theme.textColor
} else if (displayValue > 100 && displayValue <= 125) {
return theme.neutralTextColor
} else {
return theme.negativeTextColor
}
}
}
TextMetrics {
......
......@@ -67,10 +67,25 @@ RowLayout {
QQC2.Label {
id: percentText
readonly property real value: PulseObject.volume > slider.maximumValue ? PulseObject.volume : slider.value
readonly property real displayValue: Math.round(value / PulseAudio.NormalVolume * 100.0)
Layout.alignment: Qt.AlignHCenter
Layout.minimumWidth: percentMetrics.advanceWidth
horizontalAlignment: Qt.AlignRight
text: i18ndc("kcm_pulseaudio", "volume percentage", "%1%", Math.round(value / PulseAudio.NormalVolume * 100.0))
text: i18ndc("kcm_pulseaudio", "volume percentage", "%1%", displayValue)
// Display a subtle visual indication that the volume might be
// dangerously high
// ------------------------------------------------
// Keep this in sync with the copies in ListItemBase.qml
// and plasma-workspace:OSDItem.qml
color: {
if (displayValue <= 100) {
return theme.textColor
} else if (displayValue > 100 && displayValue <= 125) {
return theme.neutralTextColor
} else {
return theme.negativeTextColor
}
}
}
TextMetrics {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment