171 lines
5.3 KiB
QML
171 lines
5.3 KiB
QML
/*
|
|
* Nixie tube display mode — retro amber glowing digits in glass tubes.
|
|
* Glow is faked with layered text copies, so no QtGraphicalEffects
|
|
* dependency. Tubes flicker randomly (nixie cathode style); the
|
|
* flicker intensity is configurable (0 = off, 100 = nervous).
|
|
* The euro sign is rendered as plain text (default font, white).
|
|
* Pure QtQuick: testable outside the plasmoid shell.
|
|
*/
|
|
|
|
import QtQuick 2.15
|
|
|
|
Row {
|
|
id: root
|
|
|
|
// wired by the parent loader
|
|
property string display: "--"
|
|
property color trendColor: "#9e9e9e"
|
|
// 0 = no flicker, 100 = frequent and deep flicker
|
|
property int flickerIntensity: 40
|
|
|
|
spacing: height * 0.05
|
|
|
|
function digitsOf(s) {
|
|
var out = "";
|
|
for (var i = 0; i < s.length; i++) {
|
|
var ch = s.charAt(i);
|
|
if (ch >= "0" && ch <= "9") {
|
|
out += ch;
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
readonly property string digits: digitsOf(display)
|
|
readonly property real tubeWidth: height * 0.52
|
|
readonly property real glowFont: height * 0.80
|
|
readonly property bool flickerOn: flickerIntensity > 0 && digits.length > 0
|
|
|
|
Repeater {
|
|
model: root.digits.length
|
|
|
|
delegate: Rectangle {
|
|
id: tube
|
|
|
|
width: root.tubeWidth
|
|
height: root.height
|
|
radius: width * 0.30
|
|
gradient: Gradient {
|
|
GradientStop { position: 0.0; color: "#3a2410" }
|
|
GradientStop { position: 0.5; color: "#241505" }
|
|
GradientStop { position: 1.0; color: "#160c03" }
|
|
}
|
|
border.color: "#4a2e12"
|
|
border.width: 1
|
|
|
|
// glass reflection strip
|
|
Rectangle {
|
|
anchors.top: parent.top
|
|
anchors.topMargin: parent.height * 0.06
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
width: parent.width * 0.5
|
|
height: parent.height * 0.16
|
|
radius: height / 2
|
|
color: "#ffffff"
|
|
opacity: 0.06
|
|
}
|
|
|
|
// digit + glow layers, flickered as one group
|
|
Item {
|
|
id: glowGroup
|
|
anchors.fill: parent
|
|
|
|
Text {
|
|
id: glowText
|
|
anchors.centerIn: parent
|
|
text: root.digits[index]
|
|
color: "#ffb648"
|
|
font.family: "DejaVu Serif"
|
|
font.pixelSize: root.glowFont
|
|
|
|
// layered glow: two scaled copies behind the crisp digit
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: parent.text
|
|
color: "#ff8c00"
|
|
opacity: 0.30
|
|
font: parent.font
|
|
scale: 1.24
|
|
}
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: parent.text
|
|
color: "#ff9d1e"
|
|
opacity: 0.50
|
|
font: parent.font
|
|
scale: 1.10
|
|
}
|
|
}
|
|
}
|
|
|
|
// nixie flicker: random dropout of the cathode glow
|
|
Timer {
|
|
id: flickTimer
|
|
repeat: false
|
|
running: root.flickerOn
|
|
onTriggered: {
|
|
flick.restart();
|
|
scheduleNext();
|
|
}
|
|
|
|
function scheduleNext() {
|
|
// intensity 40 -> ~4 s between flicks, 100 -> ~1.5 s
|
|
var base = 6000 - root.flickerIntensity * 45;
|
|
interval = Math.max(700, base * (0.6 + Math.random() * 0.8));
|
|
}
|
|
|
|
Component.onCompleted: scheduleNext()
|
|
}
|
|
|
|
SequentialAnimation {
|
|
id: flick
|
|
ScriptAction {
|
|
script: {
|
|
var range = root.flickerIntensity / 100 * 0.75;
|
|
glowGroup.opacity = 1 - (0.15 + Math.random() * range);
|
|
}
|
|
}
|
|
PauseAnimation { duration: 40 + Math.random() * 140 }
|
|
NumberAnimation {
|
|
target: glowGroup
|
|
property: "opacity"
|
|
to: 1.0
|
|
duration: 90 + Math.random() * 160
|
|
easing.type: Easing.OutQuad
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// euro sign in the plain-text font, white
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: "\u20AC"
|
|
visible: root.digits.length > 0
|
|
color: "#ffffff"
|
|
font.family: Qt.application.font.family
|
|
font.pixelSize: root.height * 0.60
|
|
}
|
|
|
|
// error / empty state
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: "--"
|
|
color: "#7a4e1c"
|
|
font.family: "DejaVu Serif"
|
|
font.pixelSize: root.glowFont * 0.8
|
|
visible: root.digits.length === 0
|
|
}
|
|
|
|
// trend LED (green/red/grey)
|
|
Rectangle {
|
|
width: root.height * 0.11
|
|
height: width
|
|
radius: width / 2
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
color: root.trendColor
|
|
border.color: "#4a2e12"
|
|
border.width: 1
|
|
}
|
|
}
|