Add always show battery percentage option
This commit is contained in:
parent
02e246ab8d
commit
ae5fada790
4 changed files with 45 additions and 10 deletions
|
|
@ -127,6 +127,7 @@ Singleton {
|
||||||
property bool showBrightness: true
|
property bool showBrightness: true
|
||||||
property bool showNotificationsHistory: true
|
property bool showNotificationsHistory: true
|
||||||
property bool showTray: true
|
property bool showTray: true
|
||||||
|
property bool alwaysShowBatteryPercentage: false
|
||||||
property real backgroundOpacity: 1.0
|
property real backgroundOpacity: 1.0
|
||||||
property list<string> monitors: []
|
property list<string> monitors: []
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ NPill {
|
||||||
icon: root.batteryIcon()
|
icon: root.batteryIcon()
|
||||||
text: Math.round(root.percent) + "%"
|
text: Math.round(root.percent) + "%"
|
||||||
textColor: charging ? Color.mPrimary : Color.mOnSurface
|
textColor: charging ? Color.mPrimary : Color.mOnSurface
|
||||||
|
forceShown: Settings.data.bar.alwaysShowBatteryPercentage
|
||||||
tooltipText: {
|
tooltipText: {
|
||||||
let lines = []
|
let lines = []
|
||||||
|
|
||||||
|
|
@ -76,8 +77,7 @@ NPill {
|
||||||
if (root.battery.changeRate !== undefined) {
|
if (root.battery.changeRate !== undefined) {
|
||||||
const rate = root.battery.changeRate
|
const rate = root.battery.changeRate
|
||||||
if (rate > 0) {
|
if (rate > 0) {
|
||||||
lines.push(root.charging ? "Charging rate: " + rate.toFixed(2) + " W" : "Discharging rate: " + rate.toFixed(
|
lines.push(root.charging ? "Charging rate: " + rate.toFixed(2) + " W" : "Discharging rate: " + rate.toFixed(2) + " W")
|
||||||
2) + " W")
|
|
||||||
} else if (rate < 0) {
|
} else if (rate < 0) {
|
||||||
lines.push("Discharging rate: " + Math.abs(rate).toFixed(2) + " W")
|
lines.push("Discharging rate: " + Math.abs(rate).toFixed(2) + " W")
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,15 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NToggle {
|
||||||
|
label: "Always show battery percentage"
|
||||||
|
description: "Show battery percentage at all times (otherwise only when charging or low)."
|
||||||
|
checked: Settings.data.bar.alwaysShowBatteryPercentage
|
||||||
|
onToggled: checked => {
|
||||||
|
Settings.data.bar.alwaysShowBatteryPercentage = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: Style.marginXXS * scaling
|
spacing: Style.marginXXS * scaling
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ Item {
|
||||||
property color collapsedIconColor: Color.mOnSurface
|
property color collapsedIconColor: Color.mOnSurface
|
||||||
property real sizeMultiplier: 0.8
|
property real sizeMultiplier: 0.8
|
||||||
property bool autoHide: false
|
property bool autoHide: false
|
||||||
|
// When true, keep the pill expanded regardless of hover state
|
||||||
|
property bool forceShown: false
|
||||||
|
// Effective shown state (true if hovered/animated open or forced)
|
||||||
|
readonly property bool effectiveShown: forceShown || showPill
|
||||||
|
|
||||||
signal shown
|
signal shown
|
||||||
signal hidden
|
signal hidden
|
||||||
|
|
@ -35,15 +39,15 @@ Item {
|
||||||
readonly property int pillOverlap: iconSize * 0.5
|
readonly property int pillOverlap: iconSize * 0.5
|
||||||
readonly property int maxPillWidth: Math.max(1, textItem.implicitWidth + pillPaddingHorizontal * 2 + pillOverlap)
|
readonly property int maxPillWidth: Math.max(1, textItem.implicitWidth + pillPaddingHorizontal * 2 + pillOverlap)
|
||||||
|
|
||||||
width: iconSize + (showPill ? maxPillWidth - pillOverlap : 0)
|
width: iconSize + (effectiveShown ? maxPillWidth - pillOverlap : 0)
|
||||||
height: pillHeight
|
height: pillHeight
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: pill
|
id: pill
|
||||||
width: showPill ? maxPillWidth : 1
|
width: effectiveShown ? maxPillWidth : 1
|
||||||
height: pillHeight
|
height: pillHeight
|
||||||
x: (iconCircle.x + iconCircle.width / 2) - width
|
x: (iconCircle.x + iconCircle.width / 2) - width
|
||||||
opacity: showPill ? Style.opacityFull : Style.opacityNone
|
opacity: effectiveShown ? Style.opacityFull : Style.opacityNone
|
||||||
color: pillColor
|
color: pillColor
|
||||||
topLeftRadius: pillHeight * 0.5
|
topLeftRadius: pillHeight * 0.5
|
||||||
bottomLeftRadius: pillHeight * 0.5
|
bottomLeftRadius: pillHeight * 0.5
|
||||||
|
|
@ -56,7 +60,7 @@ Item {
|
||||||
font.pointSize: Style.fontSizeXS * scaling
|
font.pointSize: Style.fontSizeXS * scaling
|
||||||
font.weight: Style.fontWeightBold
|
font.weight: Style.fontWeightBold
|
||||||
color: textColor
|
color: textColor
|
||||||
visible: showPill
|
visible: effectiveShown
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on width {
|
Behavior on width {
|
||||||
|
|
@ -80,7 +84,8 @@ Item {
|
||||||
width: iconSize
|
width: iconSize
|
||||||
height: iconSize
|
height: iconSize
|
||||||
radius: width * 0.5
|
radius: width * 0.5
|
||||||
color: showPill ? iconCircleColor : Color.mSurfaceVariant
|
// When forced shown, match pill background; otherwise use accent when hovered
|
||||||
|
color: forceShown ? pillColor : (showPill ? iconCircleColor : Color.mSurfaceVariant)
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
|
@ -94,7 +99,8 @@ Item {
|
||||||
NIcon {
|
NIcon {
|
||||||
text: root.icon
|
text: root.icon
|
||||||
font.pointSize: Style.fontSizeM * scaling
|
font.pointSize: Style.fontSizeM * scaling
|
||||||
color: showPill ? iconTextColor : Color.mOnSurface
|
// When forced shown, use pill text color; otherwise accent color when hovered
|
||||||
|
color: forceShown ? textColor : (showPill ? iconTextColor : Color.mOnSurface)
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -188,12 +194,16 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: {
|
||||||
|
if (!forceShown) {
|
||||||
showDelayed()
|
showDelayed()
|
||||||
|
}
|
||||||
tooltip.show()
|
tooltip.show()
|
||||||
root.entered()
|
root.entered()
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
|
if (!forceShown) {
|
||||||
hide()
|
hide()
|
||||||
|
}
|
||||||
tooltip.hide()
|
tooltip.hide()
|
||||||
root.exited()
|
root.exited()
|
||||||
}
|
}
|
||||||
|
|
@ -216,6 +226,9 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
|
if (forceShown) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (showPill) {
|
if (showPill) {
|
||||||
hideAnim.start()
|
hideAnim.start()
|
||||||
}
|
}
|
||||||
|
|
@ -231,4 +244,16 @@ Item {
|
||||||
delayedHideAnim.restart()
|
delayedHideAnim.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onForceShownChanged: {
|
||||||
|
if (forceShown) {
|
||||||
|
// Immediately lock open without animations
|
||||||
|
showAnim.stop()
|
||||||
|
hideAnim.stop()
|
||||||
|
delayedHideAnim.stop()
|
||||||
|
showPill = true
|
||||||
|
} else {
|
||||||
|
hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue