From d960da68aa6cd831e6e80eeff626d8ba65219f5a Mon Sep 17 00:00:00 2001 From: samuel <53528911+samuel-jimenez@users.noreply.github.com> Date: Wed, 6 Nov 2024 11:04:55 -0600 Subject: [PATCH] Rework phase preview --- package/contents/config/config.qml | 2 +- package/contents/config/main.xml | 3 +- package/contents/ui/LunaIcon.qml | 2 +- package/contents/ui/LunaWidget.qml | 2 +- package/contents/ui/configGeneral.qml | 71 ++++++++++++++------------- package/contents/ui/main.qml | 2 +- 6 files changed, 44 insertions(+), 38 deletions(-) diff --git a/package/contents/config/config.qml b/package/contents/config/config.qml index 9b1023e..3010bcc 100644 --- a/package/contents/config/config.qml +++ b/package/contents/config/config.qml @@ -15,7 +15,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>. */ -import QtQuick 2.1 +import QtQuick import org.kde.plasma.configuration ConfigModel { diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index 42c8a08..028db03 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -6,7 +6,7 @@ <default>90</default> </entry> <entry name="latitudeAuto" type="Bool"> - <default>false</default> + <default>true</default> </entry> <entry name="showBackground" type="Bool"> <default>false</default> @@ -21,6 +21,7 @@ <default>3</default> </entry> <entry name="dateFormatString" type="String"> + <default>hh</default> </entry> <entry name="lunarIndex" type="int"> <default>1</default> diff --git a/package/contents/ui/LunaIcon.qml b/package/contents/ui/LunaIcon.qml index 9ddb3dd..f62fd6a 100644 --- a/package/contents/ui/LunaIcon.qml +++ b/package/contents/ui/LunaIcon.qml @@ -21,7 +21,7 @@ */ -import QtQuick 2.14 +import QtQuick import QtQuick.Shapes import org.kde.ksvg as KSvg import org.kde.plasma.core as PlasmaCore diff --git a/package/contents/ui/LunaWidget.qml b/package/contents/ui/LunaWidget.qml index 8080237..fc10ad8 100644 --- a/package/contents/ui/LunaWidget.qml +++ b/package/contents/ui/LunaWidget.qml @@ -22,7 +22,7 @@ */ -import QtQuick 2.7 +import QtQuick import QtQuick.Controls as QtControls import QtQuick.Layouts as QtLayouts import "code/lunacalc.js" as LunaCalc diff --git a/package/contents/ui/configGeneral.qml b/package/contents/ui/configGeneral.qml index 3f1fed5..f2dca5c 100644 --- a/package/contents/ui/configGeneral.qml +++ b/package/contents/ui/configGeneral.qml @@ -19,10 +19,12 @@ */ import QtPositioning -import QtQuick 2.7 +import QtQuick import QtQuick.Controls as QtControls import QtQuick.Dialogs as QtDialogs import QtQuick.Layouts as QtLayouts +import "code/lunacalc.js" as LunaCalc +import "code/phases.js" as Phases import org.kde.kcmutils as KCM import org.kde.kirigami as Kirigami import org.kde.plasma.plasma5support as Plasma5Support @@ -30,9 +32,9 @@ import org.kde.plasma.plasma5support as Plasma5Support KCM.SimpleKCM { id: generalPage + property alias previewPhase: phase.value property alias cfg_latitudeAuto: latitudeAuto.checked // 0=Equator, +90=North Pole, -90=South Pole property alias cfg_latitude: latitude.value // 0=Equator, +90=North Pole, -90=South Pole - property alias cfg_phase: phase.value property alias cfg_transparentShadow: transparentShadow.checked // boolean property alias cfg_showBackground: showBackground.checked // boolean property alias cfg_dateFormat: dateFormat.currentIndex // code: 0= 1= 2=... @@ -50,6 +52,9 @@ KCM.SimpleKCM { cfg_lunarImage = imageChoices.get(cfg_lunarIndex).filename; cfg_lunarImageTweak = imageChoices.get(cfg_lunarIndex).tweak; } + Component.onCompleted: { + previewPhase = LunaCalc.getCurrentPhase(true).terminator; + } PositionSource { id: geoSource @@ -60,7 +65,7 @@ KCM.SimpleKCM { active: cfg_latitudeAuto onPositionChanged: { // lbl_place.text = i18n(geoSource.data.location.country); - cfg_latitude = Math.round(geoSource.position.coordinate.latitude * 100) / 100; + cfg_latitude = Math.round(geoSource.position.coordinate.latitude); } } @@ -104,7 +109,7 @@ KCM.SimpleKCM { width: 200 height: 200 latitude: cfg_latitude - theta: cfg_phase + theta: previewPhase showShadow: cfg_showShadow transparentShadow: false lunarImage: cfg_lunarImage @@ -156,6 +161,35 @@ KCM.SimpleKCM { } + QtControls.Label { + text: i18n("Phase Preview") + QtLayouts.Layout.preferredWidth: 85 + horizontalAlignment: Text.AlignRight + } + + QtLayouts.RowLayout { + spacing: 20 + + QtControls.Label { + id: lbl_phase + + text: Math.abs(phase.value) + "º " + QtLayouts.Layout.preferredWidth: 40 + horizontalAlignment: Text.AlignRight + } + + QtControls.Slider { + id: phase + + value: lunaPreview.theta + QtLayouts.Layout.fillWidth: true + from: 0 + to: 360 + stepSize: 1 + } + + } + QtControls.Label { text: i18n("Disk Color") visible: cfg_lunarImage === "" @@ -229,35 +263,6 @@ KCM.SimpleKCM { } - QtControls.Label { - text: i18n("Phase Preview") - QtLayouts.Layout.preferredWidth: 85 - horizontalAlignment: Text.AlignRight - } - - QtLayouts.RowLayout { - spacing: 20 - - QtControls.Label { - id: lbl_phase - - text: Math.abs(phase.value) + "º " - QtLayouts.Layout.preferredWidth: 40 - horizontalAlignment: Text.AlignRight - } - - QtControls.Slider { - id: phase - - value: lunaPreview.theta - QtLayouts.Layout.fillWidth: true - from: 0 - to: 360 - stepSize: 1 - } - - } - QtControls.Label { text: i18n("Date Format") } diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml index 9099545..4402909 100644 --- a/package/contents/ui/main.qml +++ b/package/contents/ui/main.qml @@ -21,7 +21,7 @@ */ -import QtQuick 2.7 +import QtQuick import QtQuick.Controls as QtControls import QtQuick.Layouts as QtLayouts import "code/lunacalc.js" as LunaCalc -- GitLab