From df9d9f990ae97904f01af3b710042713d31da7f6 Mon Sep 17 00:00:00 2001
From: "kali kaneko (leap communications)" <kali@leap.se>
Date: Wed, 7 Jul 2021 20:57:29 +0200
Subject: [PATCH] [ux] customize background for calyxvpn

---
 Makefile                    |  4 ++++
 gui/qml/BackgroundImage.qml | 11 ++++++++++-
 gui/qml/logic.js            |  5 +++++
 gui/qml/main.qml            |  8 ++++++++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 1a6d423c..82a805d5 100644
--- a/Makefile
+++ b/Makefile
@@ -353,7 +353,11 @@ gen_pkg_deb:
 ifeq (${PLATFORM}, linux)
 	@cp -r ${TEMPLATES}/debian build/${PROVIDER}
 	@VERSION=${VERSION} VENDOR_PATH=${VENDOR_PATH} ${SCRIPTS}/generate-debian build/${PROVIDER}/debian/data.json
+ifeq (${VENDOR_PATH}, providers)
 	@mkdir -p build/${PROVIDER}/debian/icons/scalable && cp ${VENDOR_PATH}/${PROVIDER}/assets/icon.svg build/${PROVIDER}/debian/icons/scalable/icon.svg
+else
+	@mkdir -p build/${PROVIDER}/debian/icons/scalable && cp ${VENDOR_PATH}/assets/icon.svg build/${PROVIDER}/debian/icons/scalable/icon.svg
+endif
 	@cd build/${PROVIDER}/debian && python3 generate.py
 	@cd build/${PROVIDER}/debian && rm app.desktop-template changelog-template rules-template control-template generate.py data.json && chmod +x rules
 endif
diff --git a/gui/qml/BackgroundImage.qml b/gui/qml/BackgroundImage.qml
index 86b8cba7..3071bf45 100644
--- a/gui/qml/BackgroundImage.qml
+++ b/gui/qml/BackgroundImage.qml
@@ -6,10 +6,19 @@ Rectangle {
     anchors.fill: parent;
     anchors.topMargin: 40;
 
+    property var backgroundSrc
+    property var backgroundVisible
+
     Image {
-        source: "qrc:/assets/img/bird.jpg";
+        source: parent.backgroundSrc;
+        visible: parent.backgroundVisible;
         fillMode: Image.PreserveAspectCrop;
         anchors.fill: parent; 
         opacity: 0.8;
     }
+
+    Component.onCompleted: {
+        /* default for riseup, needs customizing */
+        backgroundSrc = "qrc:/assets/img/bird.jpg";
+    }
 }
diff --git a/gui/qml/logic.js b/gui/qml/logic.js
index 10ebfcd6..47090089 100644
--- a/gui/qml/logic.js
+++ b/gui/qml/logic.js
@@ -65,6 +65,11 @@ function shouldAllowEmptyPass(providers) {
     return false
 }
 
+function getSelectedProvider(providers) {
+    let obj = JSON.parse(providers.getJson())
+    return obj['default']
+}
+
 function debugInit() {
     console.debug("Platform:", Qt.platform.os)
     console.debug("DEBUG: Pre-seeded providers:")
diff --git a/gui/qml/main.qml b/gui/qml/main.qml
index e12c61da..b30fa0a3 100644
--- a/gui/qml/main.qml
+++ b/gui/qml/main.qml
@@ -276,6 +276,14 @@ ApplicationWindow {
         allowEmptyPass = Logic.shouldAllowEmptyPass(providers)
         needsRestart = false;
         shownDonate = false;
+
+        /* this is a temporary workaround until general GUI revamp for 0.21.8 */
+        let provider = Logic.getSelectedProvider(providers);
+        if (provider == "calyx") {
+            background.backgroundVisible = false;
+            background.color = "#8EA844";
+        }
+
         if (!systrayAvailable) {
           app.visible = true
           app.raise()
-- 
GitLab