refactor: controla constelações por script de atalho

This commit is contained in:
vini 2026-07-19 13:52:31 -03:00
parent 740c9b836b
commit bfb8f31952
5 changed files with 26 additions and 12 deletions

View file

@ -14,9 +14,6 @@
<entry name="ChuvaMode" type="Bool">
<default>false</default>
</entry>
<entry name="ShowConstellations" type="Bool">
<default>true</default>
</entry>
<entry name="Latitude" type="Double">
<default>-24.72</default>
</entry>

View file

@ -9,7 +9,6 @@ ColumnLayout {
property alias cfg_ShowSkeleton: skeletonCheck.checked
property alias cfg_BaladaMode: baladaCheck.checked
property alias cfg_ChuvaMode: chuvaCheck.checked
property alias cfg_ShowConstellations: constellationsCheck.checked
property double cfg_Latitude
property double cfg_Longitude
@ -38,12 +37,6 @@ ColumnLayout {
onCheckedChanged: if (checked) baladaCheck.checked = false
}
CheckBox {
id: constellationsCheck
Kirigami.FormData.label: i18n("Constelações:")
text: i18n("Ligar estrelas e mostrar os nomes")
}
Kirigami.Separator { Kirigami.FormData.isSection: true }
// Observador do céu realista (aceita vírgula ou ponto decimal)

View file

@ -1467,6 +1467,22 @@ function setShowConstellations(on) {
projectSky();
}
/* Estado controlado por toggle-constellations.sh. A primeira leitura também
é aplicada, então o modo sobrevive a reloads do WebEngine. */
let constellationsFileVal = null;
(function pollConstellationsFile() {
fetch('file:///tmp/skeledance-constellations?t=' + Date.now())
.then(r => r.text())
.then(t => {
const v = t.trim();
if (v === constellationsFileVal) return;
constellationsFileVal = v;
setShowConstellations(v === '1');
})
.catch(() => {})
.finally(() => setTimeout(pollConstellationsFile, 800));
})();
/* ── Passo de projeção: recalcula posições de tela (a cada 30s o céu gira
~0.125°, imperceptível). Camada estática (Via Láctea + estrelas fracas)
é pré-renderizada em baseCanvas; só as brilhantes cintilam por frame ── */
@ -2332,6 +2348,7 @@ document.addEventListener('keydown', e => {
if (!e.target.matches('input,textarea')) {
if (e.key === 'b' || e.key === 'B') toggleBalada();
if (e.key === 'r' || e.key === 'R') toggleChuva();
if (e.key === 'c' || e.key === 'C') setShowConstellations(!showConstellations);
}
});

View file

@ -11,7 +11,6 @@ WallpaperItem {
webView.runJavaScript("setShowSkeleton(" + Plasmoid.configuration.ShowSkeleton + ")")
webView.runJavaScript("setBaladaMode(" + Plasmoid.configuration.BaladaMode + ")")
webView.runJavaScript("setChuvaMode(" + Plasmoid.configuration.ChuvaMode + ")")
webView.runJavaScript("setShowConstellations(" + Plasmoid.configuration.ShowConstellations + ")")
webView.runJavaScript("setObserverLocation(" + Plasmoid.configuration.Latitude + ","
+ Plasmoid.configuration.Longitude + ")")
}
@ -21,7 +20,6 @@ WallpaperItem {
function onShowSkeletonChanged() { applyConfig() }
function onBaladaModeChanged() { applyConfig() }
function onChuvaModeChanged() { applyConfig() }
function onShowConstellationsChanged() { applyConfig() }
function onLatitudeChanged() { applyConfig() }
function onLongitudeChanged() { applyConfig() }
}