v1.3.0: live-bind display mode to config (dialog changes apply without restart); add configurable split-flap cascade seconds
This commit is contained in:
+28
-1
@@ -25,11 +25,29 @@ Item {
|
||||
|
||||
readonly property int refreshMinutes: Math.max(5, plasmoid.configuration.refreshMinutes)
|
||||
|
||||
// Seconds over which the split-flap display cascades to a new price
|
||||
readonly property int flapSeconds: Math.max(1, plasmoid.configuration.flapSeconds)
|
||||
|
||||
// 0 = plain text, 1 = split-flap board, 2 = nixie tubes
|
||||
property int displayMode: 0
|
||||
readonly property string modeSource: displayMode === 1 ? "DisplayFlip.qml"
|
||||
: displayMode === 2 ? "DisplayNixie.qml"
|
||||
: "DisplayText.qml"
|
||||
|
||||
// Enum config values arrive either as an int index or as the choice
|
||||
// name, depending on the Plasma version — accept both.
|
||||
function modeFromConfig(v) {
|
||||
if (typeof v === "number") {
|
||||
return Math.max(0, Math.min(2, Math.round(v)));
|
||||
}
|
||||
if (v === "SplitFlap") {
|
||||
return 1;
|
||||
}
|
||||
if (v === "Nixie") {
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
readonly property string apiUrl: "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=eur"
|
||||
|
||||
// -1 = down, 0 = unchanged / no previous reading yet, 1 = up
|
||||
@@ -72,7 +90,10 @@ Item {
|
||||
|
||||
Component.onCompleted: {
|
||||
try {
|
||||
displayMode = Math.max(0, Math.min(2, plasmoid.configuration.displayMode));
|
||||
// live binding: config changes from the dialog apply immediately
|
||||
displayMode = Qt.binding(function () {
|
||||
return modeFromConfig(plasmoid.configuration.displayMode);
|
||||
});
|
||||
} catch (e) {
|
||||
// outside a real plasmoid shell (tests): keep the default
|
||||
}
|
||||
@@ -119,6 +140,9 @@ Item {
|
||||
onLoaded: {
|
||||
item.display = Qt.binding(function () { return root.displayText; });
|
||||
item.trendColor = Qt.binding(function () { return root.priceColor; });
|
||||
if (item.flapSeconds !== undefined) {
|
||||
item.flapSeconds = Qt.binding(function () { return root.flapSeconds; });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,6 +178,9 @@ Item {
|
||||
onLoaded: {
|
||||
item.display = Qt.binding(function () { return root.displayText; });
|
||||
item.trendColor = Qt.binding(function () { return root.priceColor; });
|
||||
if (item.flapSeconds !== undefined) {
|
||||
item.flapSeconds = Qt.binding(function () { return root.flapSeconds; });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user