Skip to content
Snippets Groups Projects
Unverified Commit f15d21ca authored by dxtwjb's avatar dxtwjb Committed by GitHub
Browse files

Merge pull request #9 from ismailof/latitude_rotation

Latitude rotation
parents ddf33cf5 26229aae
Branches
Tags
No related merge requests found
Showing with 94 additions and 33 deletions
......@@ -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>
......
File suppressed by a .gitattributes entry, the file's encoding is unsupported, or the file size exceeds the limit.
File suppressed by a .gitattributes entry, the file's encoding is unsupported, or the file size exceeds the limit.
No preview for this file type
No preview for this file type
No preview for this file type
File suppressed by a .gitattributes entry, the file's encoding is unsupported, or the file size exceeds the limit.
File suppressed by a .gitattributes entry, the file's encoding is unsupported, or the file size exceeds the limit.
......@@ -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
......
......@@ -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,6 +51,7 @@ Item {
PlasmaCore.SvgItem {
id: lunaSvgItem
visible: false
anchors.centerIn: parent
width: Math.min(parent.width, parent.height)
......@@ -58,19 +59,19 @@ Item {
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
}
}
......@@ -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.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
textRole: "key"
model: ListModel {
dynamicRoles: true
Component.onCompleted: {
append({key : i18n("Northern"), value: 0 })
append({key : i18n("Southern"), value: 1 })
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 != ""
}
}
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment