From 4a76ade1a2947cf318c8e55253c425da8e517ff4 Mon Sep 17 00:00:00 2001
From: Ismael Asensio <ismailof@github.com>
Date: Sun, 21 Jul 2019 01:13:39 +0200
Subject: [PATCH] Add moon transparent shadow
---
package/contents/ui/LunaIcon.qml | 14 ++++++++++++++
package/contents/ui/configGeneral.qml | 6 ++++++
package/contents/ui/main.qml | 2 ++
3 files changed, 22 insertions(+)
diff --git a/package/contents/ui/LunaIcon.qml b/package/contents/ui/LunaIcon.qml
index d43ed10..d6bc208 100644
--- a/package/contents/ui/LunaIcon.qml
+++ b/package/contents/ui/LunaIcon.qml
@@ -19,6 +19,7 @@
*/
import QtQuick 2.1
+import QtGraphicalEffects 1.12
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0
@@ -30,6 +31,8 @@ Item {
property int phaseNumber: 0
property int hemisphere: 0
property bool showShadow: true
+ property bool transparentShadow: true
+
property string lunarImage: ''
property color diskColour: '#ffffff'
property int lunarImageTweak: 0
@@ -58,12 +61,15 @@ Item {
// deal with northern <-> southern hemisphere
transformOrigin: Item.Center
rotation: (hemisphere == 0 ? 0 : 180) - lunarImageTweak
+ visible: !transparentShadow
}
Canvas {
id: shadow
width: lunaSvgItem.width
height: lunaSvgItem.height
+ visible: !transparentShadow
+
property int hemisphere: lunaIcon.hemisphere
property int theta: lunaIcon.theta
property bool showShadow: lunaIcon.showShadow
@@ -189,4 +195,12 @@ Item {
}
}
}
+
+ OpacityMask {
+ anchors.fill: lunaSvgItem
+ source: lunaSvgItem
+ maskSource: shadow
+ invert: true
+ visible: transparentShadow
+ }
}
diff --git a/package/contents/ui/configGeneral.qml b/package/contents/ui/configGeneral.qml
index ea03ca0..c153c80 100644
--- a/package/contents/ui/configGeneral.qml
+++ b/package/contents/ui/configGeneral.qml
@@ -26,6 +26,7 @@ Item {
id: generalPage
property alias cfg_hemisphere: hemisphere.currentIndex // 0=North 1=South
+ property alias cfg_transparentShadow: transparentShadow.checked // boolean
property alias cfg_showBackground: showBackground.checked // boolean
property alias cfg_dateFormat: dateFormat.currentIndex // code: 0= 1= 2=...
property alias cfg_dateFormatString: dateFormatString.text
@@ -83,6 +84,7 @@ Item {
height: 200
hemisphere: cfg_hemisphere
showShadow: false
+ transparentShadow: false
lunarImage: cfg_lunarImage
lunarImageTweak: cfg_lunarImageTweak
diskColour: cfg_diskColour
@@ -188,6 +190,10 @@ Item {
visible: dateFormat.currentIndex == 4
}
+ QtControls.CheckBox {
+ id: transparentShadow
+ text: i18n("Transparent shadow")
+ }
QtControls.CheckBox {
id: showBackground
text: i18n("Show background")
diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml
index ff0e18f..643041a 100644
--- a/package/contents/ui/main.qml
+++ b/package/contents/ui/main.qml
@@ -39,6 +39,7 @@ Item {
property var currentPhase
property bool showBackground: Plasmoid.configuration.showBackground
+ property bool transparentShadow: Plasmoid.configuration.transparentShadow
property int hemisphere: Plasmoid.configuration.hemisphere
property int dateFormat: Plasmoid.configuration.dateFormat
property string dateFormatString: Plasmoid.configuration.dateFormatString
@@ -96,6 +97,7 @@ Item {
hemisphere: hemisphere
lunarImage: main.lunarImage
lunarImageTweak: main.lunarImageTweak
+ transparentShadow: main.transparentShadow
diskColour: main.diskColour
anchors.fill: parent
--
GitLab