From bfb8f3195258a95c8c8b2acb01ce3909a74297d6 Mon Sep 17 00:00:00 2001 From: vini Date: Sun, 19 Jul 2026 13:52:31 -0300 Subject: [PATCH] =?UTF-8?q?refactor:=20controla=20constela=C3=A7=C3=B5es?= =?UTF-8?q?=20por=20script=20de=20atalho?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/contents/config/main.xml | 3 --- plugin/contents/ui/config.qml | 7 ------- plugin/contents/ui/dancer.html | 17 +++++++++++++++++ plugin/contents/ui/main.qml | 2 -- toggle-constellations.sh | 9 +++++++++ 5 files changed, 26 insertions(+), 12 deletions(-) create mode 100755 toggle-constellations.sh diff --git a/plugin/contents/config/main.xml b/plugin/contents/config/main.xml index 58cc5ea..58bb539 100644 --- a/plugin/contents/config/main.xml +++ b/plugin/contents/config/main.xml @@ -14,9 +14,6 @@ false - - true - -24.72 diff --git a/plugin/contents/ui/config.qml b/plugin/contents/ui/config.qml index 3c154b2..cc054f0 100644 --- a/plugin/contents/ui/config.qml +++ b/plugin/contents/ui/config.qml @@ -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) diff --git a/plugin/contents/ui/dancer.html b/plugin/contents/ui/dancer.html index b694558..babd3c6 100644 --- a/plugin/contents/ui/dancer.html +++ b/plugin/contents/ui/dancer.html @@ -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); } }); diff --git a/plugin/contents/ui/main.qml b/plugin/contents/ui/main.qml index c954c25..28fee2a 100644 --- a/plugin/contents/ui/main.qml +++ b/plugin/contents/ui/main.qml @@ -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() } } diff --git a/toggle-constellations.sh b/toggle-constellations.sh new file mode 100755 index 0000000..4044e9c --- /dev/null +++ b/toggle-constellations.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +STATE_FILE=/tmp/skeledance-constellations + +if [ "$(cat "$STATE_FILE" 2>/dev/null)" = "1" ]; then + printf '0\n' > "$STATE_FILE" +else + printf '1\n' > "$STATE_FILE" +fi