small component patches + code cleanup
This commit is contained in:
@@ -51,11 +51,11 @@ ModuleChip {
|
||||
readonly property bool isLow: batReady && !charging && pct <= 30
|
||||
|
||||
readonly property color iconColor: {
|
||||
if (fullCharge) return t.batteryFull ?? t.accent
|
||||
if (charging) return t.batteryCharging ?? t.accent
|
||||
if (isCritical) return t.batteryCritical ?? "#ff5555"
|
||||
if (isLow) return t.batteryLow ?? "#ffb86c"
|
||||
return t.batteryIcon ?? t.clockIcon
|
||||
if (fullCharge) return t.batteryFull
|
||||
if (charging) return t.batteryCharging
|
||||
if (isCritical) return t.batteryCritical
|
||||
if (isLow) return t.batteryLow
|
||||
return t.batteryIcon
|
||||
}
|
||||
|
||||
readonly property var up: UPower
|
||||
@@ -92,21 +92,17 @@ ModuleChip {
|
||||
return names
|
||||
}
|
||||
|
||||
chipColor: t.batBg
|
||||
chipColorHovered: t.batBgHover
|
||||
chipBorderColor: t.batBorder
|
||||
chipBorderColorHovered: t.batBorderHover
|
||||
chipHoverEnabled: true
|
||||
chipTapAction: () => batteryPopup.toggle()
|
||||
chipAnimWidth: true
|
||||
|
||||
width: batLayout.implicitWidth + 24
|
||||
height: Cfg.Config.moduleHeight
|
||||
radius: panelRadius
|
||||
|
||||
color: hoverHandler.hovered ? t.batBgHover : t.batBg
|
||||
border.color: hoverHandler.hovered ? t.batBorderHover : t.batBorder
|
||||
border.width: borderWidth
|
||||
|
||||
Behavior on width { NumberAnimation { duration: 250; easing.type: Easing.OutCubic } }
|
||||
Behavior on color { ColorAnimation { duration: 150 } }
|
||||
Behavior on border.color { ColorAnimation { duration: 150 } }
|
||||
|
||||
HoverHandler { id: hoverHandler; cursorShape: Qt.PointingHandCursor }
|
||||
TapHandler { onTapped: batteryPopup.toggle() }
|
||||
|
||||
RowLayout {
|
||||
id: batLayout
|
||||
anchors.centerIn: parent
|
||||
@@ -144,8 +140,8 @@ ModuleChip {
|
||||
font.bold: true
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
opacity: (hoverHandler.hovered || batteryPopup.popupOpen) ? 1.0 : 0.0
|
||||
Layout.preferredWidth: (hoverHandler.hovered || batteryPopup.popupOpen)
|
||||
opacity: (root.hovered || batteryPopup.popupOpen) ? 1.0 : 0.0
|
||||
Layout.preferredWidth: (root.hovered || batteryPopup.popupOpen)
|
||||
? implicitWidth : 0
|
||||
clip: true
|
||||
|
||||
@@ -154,40 +150,19 @@ ModuleChip {
|
||||
}
|
||||
}
|
||||
|
||||
PopupPanel {
|
||||
StandardPopup {
|
||||
id: batteryPopup
|
||||
ns: "battery"
|
||||
chipRoot: root
|
||||
cardWidth: 260
|
||||
cardColor: t.batPopupBg
|
||||
cardBorderColor: t.batPopupBorder
|
||||
cardHeight: cardCol.implicitHeight + 28
|
||||
showShadow: true
|
||||
layerEnabled: true
|
||||
|
||||
Rectangle {
|
||||
id: cardShadow
|
||||
anchors.fill: card
|
||||
anchors.margins: -3
|
||||
radius: card.radius + 3
|
||||
color: "transparent"
|
||||
border.color: Qt.rgba(0, 0, 0, 0.35)
|
||||
border.width: 6
|
||||
visible: batteryPopup.popupOpen
|
||||
opacity: batteryPopup.popupOpen ? 0.6 : 0
|
||||
Behavior on opacity { NumberAnimation { duration: 200 } }
|
||||
}
|
||||
|
||||
PopupCard {
|
||||
id: card
|
||||
popupOpen: batteryPopup.popupOpen
|
||||
isTop: root.isTop
|
||||
animEnabled: batteryPopup.visible
|
||||
height: cardCol.implicitHeight + 28
|
||||
|
||||
color: root.t.batPopupBg
|
||||
radius: Cfg.Config.popupRadius
|
||||
border.color: root.t.batPopupBorder
|
||||
border.width: Cfg.Config.popupBorderWidth
|
||||
layer.enabled: true
|
||||
|
||||
ColumnLayout {
|
||||
id: cardCol
|
||||
ColumnLayout {
|
||||
id: cardCol
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
@@ -514,6 +489,5 @@ ModuleChip {
|
||||
|
||||
Item { height: 2 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user