mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
autofmt
This commit is contained in:
@@ -4,76 +4,83 @@ import qs.Services
|
||||
import Quickshell
|
||||
|
||||
Item {
|
||||
id: clockRoot
|
||||
id: clockRoot
|
||||
|
||||
property var now
|
||||
property var now
|
||||
|
||||
// Default colors
|
||||
property color backgroundColor: Color.mPrimary
|
||||
property color clockColor: Color.mOnPrimary
|
||||
readonly property real markAlpha: 0.7 // alpha value of hour markers in AnalogClock
|
||||
property color secondHandColor: {
|
||||
var defaultColor = Color.mError
|
||||
var backgroundL = backgroundColor.hslLightness
|
||||
var hourMarkL
|
||||
// Default colors
|
||||
property color backgroundColor: Color.mPrimary
|
||||
property color clockColor: Color.mOnPrimary
|
||||
readonly property real markAlpha: 0.7 // alpha value of hour markers in AnalogClock
|
||||
property color secondHandColor: {
|
||||
var defaultColor = Color.mError
|
||||
var backgroundL = backgroundColor.hslLightness
|
||||
var hourMarkL
|
||||
|
||||
if (Settings.data.location.analogClockInCalendar) {
|
||||
hourMarkL = (clockColor.hslLightness * markAlpha) + (backgroundL * (1.0 - markAlpha))
|
||||
} else {
|
||||
hourMarkL = backgroundL
|
||||
}
|
||||
|
||||
var bestWorstContrast = -1
|
||||
var bestColor = defaultColor
|
||||
|
||||
var candidates = [
|
||||
Color.mSecondary,
|
||||
Color.mTertiary,
|
||||
Color.mError,
|
||||
]
|
||||
|
||||
for (var i = 0; i < candidates.length; i++) {
|
||||
var candidateColor = candidates[i]
|
||||
var candidateL = candidateColor.hslLightness
|
||||
|
||||
var diffBackground = Math.abs(backgroundL - candidateL)
|
||||
var diffHourMark = Math.abs(hourMarkL - candidateL)
|
||||
|
||||
var currentWorstContrast = Math.min(diffBackground, diffHourMark)
|
||||
|
||||
if (currentWorstContrast > bestWorstContrast) {
|
||||
bestWorstContrast = currentWorstContrast
|
||||
bestColor = candidateColor
|
||||
}
|
||||
}
|
||||
|
||||
return bestColor
|
||||
if (Settings.data.location.analogClockInCalendar) {
|
||||
hourMarkL = (clockColor.hslLightness * markAlpha) + (backgroundL * (1.0 - markAlpha))
|
||||
} else {
|
||||
hourMarkL = backgroundL
|
||||
}
|
||||
property color progressColor: clockRoot.secondHandColor
|
||||
|
||||
var bestWorstContrast = -1
|
||||
var bestColor = defaultColor
|
||||
|
||||
height: Math.round((Style.fontSizeXXXL * 1.9) / 2 * Style.uiScaleRatio) * 2
|
||||
width: clockRoot.height
|
||||
var candidates = [Color.mSecondary, Color.mTertiary, Color.mError]
|
||||
|
||||
Loader {
|
||||
id: clockLoader
|
||||
anchors.fill: parent
|
||||
for (var i = 0; i < candidates.length; i++) {
|
||||
var candidateColor = candidates[i]
|
||||
var candidateL = candidateColor.hslLightness
|
||||
|
||||
source: Settings.data.location.analogClockInCalendar ? "AnalogClock.qml" : "DigitalClock.qml"
|
||||
var diffBackground = Math.abs(backgroundL - candidateL)
|
||||
var diffHourMark = Math.abs(hourMarkL - candidateL)
|
||||
|
||||
onLoaded: {
|
||||
item.now = Qt.binding(function() { return clockRoot.now })
|
||||
item.backgroundColor = Qt.binding(function() { return clockRoot.backgroundColor })
|
||||
item.clockColor = Qt.binding(function() { return clockRoot.clockColor })
|
||||
if (item.hasOwnProperty("secondHandColor")) {
|
||||
item.secondHandColor = Qt.binding(function() { return clockRoot.secondHandColor })
|
||||
}
|
||||
if (item.hasOwnProperty("progressColor")) {
|
||||
item.progressColor = Qt.binding(function() { return clockRoot.progressColor })
|
||||
}
|
||||
if (item.hasOwnProperty("markAlpha")) {
|
||||
item.markAlpha = Qt.binding(function() { return clockRoot.markAlpha })
|
||||
}
|
||||
}
|
||||
var currentWorstContrast = Math.min(diffBackground, diffHourMark)
|
||||
|
||||
if (currentWorstContrast > bestWorstContrast) {
|
||||
bestWorstContrast = currentWorstContrast
|
||||
bestColor = candidateColor
|
||||
}
|
||||
}
|
||||
|
||||
return bestColor
|
||||
}
|
||||
property color progressColor: clockRoot.secondHandColor
|
||||
|
||||
height: Math.round((Style.fontSizeXXXL * 1.9) / 2 * Style.uiScaleRatio) * 2
|
||||
width: clockRoot.height
|
||||
|
||||
Loader {
|
||||
id: clockLoader
|
||||
anchors.fill: parent
|
||||
|
||||
source: Settings.data.location.analogClockInCalendar ? "AnalogClock.qml" : "DigitalClock.qml"
|
||||
|
||||
onLoaded: {
|
||||
item.now = Qt.binding(function () {
|
||||
return clockRoot.now
|
||||
})
|
||||
item.backgroundColor = Qt.binding(function () {
|
||||
return clockRoot.backgroundColor
|
||||
})
|
||||
item.clockColor = Qt.binding(function () {
|
||||
return clockRoot.clockColor
|
||||
})
|
||||
if (item.hasOwnProperty("secondHandColor")) {
|
||||
item.secondHandColor = Qt.binding(function () {
|
||||
return clockRoot.secondHandColor
|
||||
})
|
||||
}
|
||||
if (item.hasOwnProperty("progressColor")) {
|
||||
item.progressColor = Qt.binding(function () {
|
||||
return clockRoot.progressColor
|
||||
})
|
||||
}
|
||||
if (item.hasOwnProperty("markAlpha")) {
|
||||
item.markAlpha = Qt.binding(function () {
|
||||
return clockRoot.markAlpha
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user