diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index b09113ed468e4ebc8f250f053844280940f4ef1c..621afe11f1635bdbe730f9a4498bbf3a74b81939 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -6,8 +6,11 @@ <kcfgfile name=""/> <group name="General"> - <entry name="hemisphere" type="int"> - <default>0</default> + <entry name="latitude" type="int"> + <default>90</default> + </entry> + <entry name="latitudeAuto" type="Bool"> + <default>false</default> </entry> <entry name="showBackground" type="Bool"> <default>false</default> diff --git a/package/contents/po/es.po b/package/contents/po/es.po index aa06f3d69de4b614f6a973f033a007a16e78bbc8..cf4b26fdd4626fd5ca0ecc6cd9f20f6f6c810bda 100644 Binary files a/package/contents/po/es.po and b/package/contents/po/es.po differ diff --git a/package/contents/po/fr.po b/package/contents/po/fr.po index 30663295c32f78e0329eac9f9fdd8c614e1ae366..fb7ee03d0a46bd91ab625217b9ef8e942360d2e6 100644 Binary files a/package/contents/po/fr.po and b/package/contents/po/fr.po differ diff --git a/package/contents/po/locale/es/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo b/package/contents/po/locale/es/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo index 251bc685e4214cedb614002e1d2db1e71b02d6fe..e6fd577b8f27ff851f5ae0f16fa85a051e44d85d 100644 Binary files a/package/contents/po/locale/es/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo and b/package/contents/po/locale/es/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo differ diff --git a/package/contents/po/locale/fr/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo b/package/contents/po/locale/fr/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo index 33c2e4c4e554989154a46f78ceabbdb57ee0b0b8..d264afce9d79663421f73eab90bb1231084311b4 100644 Binary files a/package/contents/po/locale/fr/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo and b/package/contents/po/locale/fr/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo differ diff --git a/package/contents/po/locale/ru/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo b/package/contents/po/locale/ru/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo index b8307bac52ab2dd067b5aa1bc61a677504ab91af..a02817f2afc99dc74e15ac0f05c750eeb3e219f2 100644 Binary files a/package/contents/po/locale/ru/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo and b/package/contents/po/locale/ru/LC_MESSAGES/plasma_applet_org.kde.userbase.plasma.luna-ii.mo differ diff --git a/package/contents/po/plasma_applet_org.kde.userbase.plasma.luna-ii.pot b/package/contents/po/plasma_applet_org.kde.userbase.plasma.luna-ii.pot index 070d3d91b1bcbbb181e5406fe482a84dea192dc3..2d671f4b8eb6d07cc99d5fd6261fd3cfa89012c8 100644 Binary files a/package/contents/po/plasma_applet_org.kde.userbase.plasma.luna-ii.pot and b/package/contents/po/plasma_applet_org.kde.userbase.plasma.luna-ii.pot differ diff --git a/package/contents/po/ru.po b/package/contents/po/ru.po index 949265688013f15e7772f9daa2b255dfdc99cdb2..4392004cf9a7cf51f72c23e24716bf520acf83ef 100644 Binary files a/package/contents/po/ru.po and b/package/contents/po/ru.po differ diff --git a/package/contents/ui/ImageChoices.qml b/package/contents/ui/ImageChoices.qml index 935985d04cedbbc40f9eb375f2e05c119145f83f..8d6ba4849e70bce2a11043a5eb8d984536b5018a 100644 --- a/package/contents/ui/ImageChoices.qml +++ b/package/contents/ui/ImageChoices.qml @@ -17,7 +17,7 @@ import QtQuick 2.1 as QtQuick -/* +/*lunarIndex Defines the list of images of the moon. key - was a string name to be be shown in a ComboBox - not used value - not used because elsewhere just uses the index into this model diff --git a/package/contents/ui/LunaIcon.qml b/package/contents/ui/LunaIcon.qml index d6bc208b2dfe82c751b31eed0259f6e0e6faab9f..b587a4d830aa3c65f7bc7dab81eb1c4142002e83 100644 --- a/package/contents/ui/LunaIcon.qml +++ b/package/contents/ui/LunaIcon.qml @@ -29,7 +29,7 @@ Item { id: lunaIcon property int phaseNumber: 0 - property int hemisphere: 0 + property int latitude: 90 //Degrees: 0=Equator, 90=North Pole, -90=South Pole property bool showShadow: true property bool transparentShadow: true @@ -51,26 +51,27 @@ Item { PlasmaCore.SvgItem { id: lunaSvgItem + visible: false anchors.centerIn: parent - width: Math.min(parent.width,parent.height) - height: Math.min(parent.width,parent.height) + width: Math.min(parent.width, parent.height) + height: Math.min(parent.width, parent.height) svg: lunaSvg - // deal with northern <-> southern hemisphere + // Rotation to compensate the moon's image basic position to a north pole view + // FIXME: Somehow it does not work when applied to OpacityMask or Blend transformOrigin: Item.Center - rotation: (hemisphere == 0 ? 0 : 180) - lunarImageTweak - visible: !transparentShadow + rotation: -lunarImageTweak } Canvas { id: shadow width: lunaSvgItem.width height: lunaSvgItem.height - visible: !transparentShadow + visible: false - property int hemisphere: lunaIcon.hemisphere + property int latitude: lunaIcon.latitude property int theta: lunaIcon.theta property bool showShadow: lunaIcon.showShadow property string lunarImage: lunaIcon.lunarImage @@ -82,7 +83,7 @@ Item { anchors.centerIn: parent contextType: "2d" - onHemisphereChanged: requestPaint() + onLatitudeChanged: requestPaint() onThetaChanged: requestPaint() @@ -149,8 +150,6 @@ Item { //console.log("radius: " + radius.toString()) context.translate(radius,radius) - if (hemisphere>0) - context.rotate(Math.PI) // These two determine which side of the centre meridan to draw // the two arcs enclosing the shadow area. @@ -196,11 +195,23 @@ Item { } } + // Shadow acts as a transparecy mask OpacityMask { anchors.fill: lunaSvgItem source: lunaSvgItem maskSource: shadow invert: true + rotation: latitude - 90 visible: transparentShadow } + + // Shadow is printed on top of the moon image + Blend { + anchors.fill: lunaSvgItem + source: lunaSvgItem + foregroundSource: shadow + rotation: latitude - 90 + mode: "normal" + visible: !transparentShadow + } } diff --git a/package/contents/ui/configGeneral.qml b/package/contents/ui/configGeneral.qml index 73823feb8c798e27a81ecb131c4f0635ad47e9c2..4e8565f076f240944884d15d8692965dc813b276 100644 --- a/package/contents/ui/configGeneral.qml +++ b/package/contents/ui/configGeneral.qml @@ -21,11 +21,14 @@ import QtQuick.Layouts 1.2 as QtLayouts import QtQuick.Dialogs 1.0 as QtDialogs import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.core 2.0 as PlasmaCore + Item { id: generalPage - property alias cfg_hemisphere: hemisphere.currentIndex // 0=North 1=South + 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_transparentShadow: transparentShadow.checked // boolean property alias cfg_showBackground: showBackground.checked // boolean property alias cfg_dateFormat: dateFormat.currentIndex // code: 0= 1= 2=... @@ -43,12 +46,32 @@ Item { onCfg_lunarIndexChanged: { cfg_lunarImage = imageChoices.get(cfg_lunarIndex).filename cfg_lunarImageTweak = imageChoices.get(cfg_lunarIndex).tweak - } + if (cfg_lunarImage == '') { + cfg_transparentShadow = false //transparentShadow does not work with diskColour + } + } + + onCfg_latitudeAutoChanged: { + if (cfg_latitudeAuto) { + cfg_latitude = geoSource.data.location.latitude + } + } ImageChoices { id: imageChoices } + PlasmaCore.DataSource { + id: geoSource + engine: "geolocation" + connectedSources: ["location"] + interval: 3600 * 1000 + + onNewData:{ + lbl_place.text = i18n(geoSource.data.location.country) + } + } + QtDialogs.ColorDialog { id: colorDialog title: i18n("Pick a colour for the moon") @@ -82,7 +105,7 @@ Item { id: lunaPreview width: 200 height: 200 - hemisphere: cfg_hemisphere + latitude: cfg_latitude showShadow: false transparentShadow: false lunarImage: cfg_lunarImage @@ -146,18 +169,41 @@ Item { } QtControls.Label { - text: i18n("Hemisphere") + text: i18n("Latitude") } - QtControls.ComboBox { - id: hemisphere - QtLayouts.Layout.fillWidth: true - textRole: "key" - model: ListModel { - dynamicRoles: true - Component.onCompleted: { - append({key : i18n("Northern"), value: 0 }) - append({key : i18n("Southern"), value: 1 }) - } + QtLayouts.RowLayout { + spacing: 20 + + QtControls.Label { + id: lbl_latitude + text: Math.abs(latitude.value) + "º " + (latitude.value < 0 ? "S" : "N") + QtLayouts.Layout.preferredWidth: 40 + horizontalAlignment: Text.AlignRight + } + + QtControls.Slider { + id: latitude + QtLayouts.Layout.fillWidth: true + minimumValue: -90.0 + maximumValue: 90.0 + stepSize: 5.0 + tickmarksEnabled: true + enabled: !cfg_latitudeAuto + } + } + QtControls.Label { + text: i18n("") + } + QtLayouts.RowLayout { + spacing: 20 + QtControls.CheckBox { + id: latitudeAuto + text: i18n("Use current latitude") + } + QtControls.Label { + id: lbl_place + QtLayouts.Layout.fillWidth: true + horizontalAlignment: Text.AlignRight } } @@ -202,6 +248,7 @@ Item { QtControls.CheckBox { id: transparentShadow text: i18n("Transparent shadow") + enabled: cfg_lunarImage != "" } } } diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml index 643041ad73a597ce769d98b95fdc8cef9e8cb8cc..a7d1af4b0fab34f4da2a509ea1d79d4883ddb2c1 100644 --- a/package/contents/ui/main.qml +++ b/package/contents/ui/main.qml @@ -40,7 +40,7 @@ Item { property bool showBackground: Plasmoid.configuration.showBackground property bool transparentShadow: Plasmoid.configuration.transparentShadow - property int hemisphere: Plasmoid.configuration.hemisphere + property int latitude: Plasmoid.configuration.latitude property int dateFormat: Plasmoid.configuration.dateFormat property string dateFormatString: Plasmoid.configuration.dateFormatString @@ -59,13 +59,13 @@ Item { Plasmoid.compactRepresentation: Item { id: compact - property int hemisphere: main.hemisphere + property int latitude: main.latitude property bool showBackground: main.showBackground property int lunarIndex: main.lunarIndex Component.onCompleted: updateDetails() - onHemisphereChanged: updateDetails() + onLatitudeChanged: updateDetails() onLunarIndexChanged: updateDetails() @@ -74,7 +74,7 @@ Item { currentPhase = LunaCalc.getCurrentPhase(true); lunaIcon.phaseNumber = 13; //currentPhase.number; lunaIcon.theta = currentPhase.terminator; - lunaIcon.hemisphere = hemisphere; + lunaIcon.latitude = latitude; main.lunarImage = imageChoices.get(main.lunarIndex).filename main.lunarImageTweak = imageChoices.get(main.lunarIndex).tweak @@ -94,7 +94,7 @@ Item { LunaIcon { id: lunaIcon - hemisphere: hemisphere + latitude: main.latitude lunarImage: main.lunarImage lunarImageTweak: main.lunarImageTweak transparentShadow: main.transparentShadow