improved code by removing redundancies and done some optimizations
This commit is contained in:
@@ -108,7 +108,6 @@ Rectangle {
|
||||
onPaint: {
|
||||
var ctx = getContext("2d")
|
||||
ctx.reset()
|
||||
ctx.clearRect(0, 0, width, height)
|
||||
|
||||
var cx = width / 2
|
||||
var cy = height / 2
|
||||
@@ -134,19 +133,14 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler { id: hov }
|
||||
|
||||
HoverHandler {
|
||||
id: hov
|
||||
onHoveredChanged: if (!hovered) ring.showAlt = false
|
||||
}
|
||||
|
||||
property bool showAlt: false
|
||||
onShowAltChanged: arc.requestPaint()
|
||||
|
||||
Connections {
|
||||
target: hov
|
||||
function onHoveredChanged() {
|
||||
if (!hov.hovered) ring.showAlt = false
|
||||
}
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
enabled: !Cfg.Config.statsHideTextUntilHover || hov.hovered
|
||||
onTapped: ring.showAlt = !ring.showAlt
|
||||
@@ -155,21 +149,12 @@ Rectangle {
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
|
||||
|
||||
text: {
|
||||
if (Cfg.Config.statsHideTextUntilHover) {
|
||||
if (!hov.hovered) return ""
|
||||
var showPct = ring.showAlt
|
||||
? !Cfg.Config.statsShowPercentByDefault
|
||||
: Cfg.Config.statsShowPercentByDefault
|
||||
return showPct ? Math.round(ring.value) + "%" : ring.label
|
||||
} else {
|
||||
var baseShowPct = Cfg.Config.statsShowPercentByDefault
|
||||
? !hov.hovered
|
||||
: hov.hovered
|
||||
var finalShowPct = ring.showAlt ? !baseShowPct : baseShowPct
|
||||
return finalShowPct ? Math.round(ring.value) + "%" : ring.label
|
||||
}
|
||||
const hide = Cfg.Config.statsHideTextUntilHover
|
||||
const byDefault = Cfg.Config.statsShowPercentByDefault
|
||||
if (hide && !hov.hovered) return ""
|
||||
const showPct = ring.showAlt ? !byDefault : byDefault
|
||||
return showPct ? Math.round(ring.value) + "%" : ring.label
|
||||
}
|
||||
|
||||
color: ring.labelColor
|
||||
|
||||
Reference in New Issue
Block a user