diff --git a/.github/workflows/urlcheck.yml b/.github/workflows/urlcheck.yml
index 67bb5cbd..2d90befd 100644
--- a/.github/workflows/urlcheck.yml
+++ b/.github/workflows/urlcheck.yml
@@ -4,12 +4,12 @@ on:
push:
branches:
- main
- - 'releases/**'
+ - 'release_**'
- urlcheck
pull_request:
branches:
- main
- - 'releases/**'
+ - 'release_**'
jobs:
build:
@@ -34,7 +34,7 @@ jobs:
force_pass : false
exclude_files:
- test_glossary.py,snippets/grabPotsdamWmsData.py
+ test_glossary.py,snippets/grabPotsdamWmsData.py,scripts/update_splashscreen.py
# {z}/{x}/{y}: ESRI
# {z]/{y}/{x}: CartoDB, Open Weather, OpenTopoMap, OSM, Stamen, Strava, Wikimedia
diff --git a/enmapbox/eo4qapps/locationbrowserapp/locationbrowserdockwidget.py b/enmapbox/eo4qapps/locationbrowserapp/locationbrowserdockwidget.py
index 49b283bf..4a1c6e21 100644
--- a/enmapbox/eo4qapps/locationbrowserapp/locationbrowserdockwidget.py
+++ b/enmapbox/eo4qapps/locationbrowserapp/locationbrowserdockwidget.py
@@ -130,11 +130,12 @@ def onRequestNominatimClicked(self):
url = 'https://nominatim.openstreetmap.org/search?q=' \
f'{urllib.parse.quote(text)}' \
'&limit=50&extratags=1&polygon_geojson=1&format=json'
- nominatimResults = requests.get(url).json()
+ headers = {'User-Agent': 'EnMAP-Box QGIS Plugin (enmapbox@enmap.org)'} # Required user agent
+ nominatimResults = requests.get(url, headers=headers).json()
# find additional results
if len(nominatimResults) == 1:
url += f'&exclude_place_ids={nominatimResults[0]["place_id"]}'
- nominatimResults.extend(requests.get(url).json())
+ nominatimResults.extend(requests.get(url, headers=headers).json())
self.mResult.mList.clear()
item = QListWidgetItem('')
diff --git a/enmapbox/gui/splashscreen/splashscreen.png b/enmapbox/gui/splashscreen/splashscreen.png
new file mode 100644
index 00000000..fa9cddbe
Binary files /dev/null and b/enmapbox/gui/splashscreen/splashscreen.png differ
diff --git a/enmapbox/gui/splashscreen/splashscreen.py b/enmapbox/gui/splashscreen/splashscreen.py
new file mode 100644
index 00000000..e9a00c4c
--- /dev/null
+++ b/enmapbox/gui/splashscreen/splashscreen.py
@@ -0,0 +1,57 @@
+from pathlib import Path
+
+from qgis.PyQt.QtCore import Qt
+from qgis.PyQt.QtGui import QPixmap, QColor
+from qgis.PyQt.QtWidgets import QSplashScreen, QGraphicsDropShadowEffect, QApplication
+
+PATH_SPLASHSCREEN = Path(__file__).parent / 'splashscreen.png'
+
+
+class EnMAPBoxSplashScreen(QSplashScreen):
+ """
+ Thr EnMAP-Box Splash Screen
+ """
+
+ def __init__(self, parent=None):
+ pm = QPixmap(PATH_SPLASHSCREEN.as_posix())
+ super(EnMAPBoxSplashScreen, self).__init__(parent, pixmap=pm)
+
+ effect = QGraphicsDropShadowEffect()
+ effect.setBlurRadius(5)
+ effect.setColor(QColor('white'))
+ self.setGraphicsEffect(effect)
+
+ css = "" \
+ ""
+
+ def showMessage(self, text: str, alignment: Qt.Alignment = None, color: QColor = None):
+ """
+ Shows a message
+ :param text:
+ :param alignment:
+ :param color:
+ :return:
+ """
+ if alignment is None:
+ alignment = int(Qt.AlignLeft | Qt.AlignBottom)
+ if color is None:
+ color = QColor('black')
+ super(EnMAPBoxSplashScreen, self).showMessage(text, alignment, color)
+ QApplication.processEvents()
+
+ """
+ def drawContents(self, painter: QPainter) -> None:
+ # color = QColor('black')
+ color = QColor('white')
+ color.setAlpha(125)
+
+ painter.setBrush(color)
+ painter.setPen(color)
+ size = self.size()
+ h = 25
+ d = 10
+ rect = QRect(QRect(0, size.height()-h-d, size.width(), size.height()-d) )
+ painter.drawRect(rect)
+ #painter.setPen(QColor('white'))
+ super().drawContents(painter)
+ """
diff --git a/enmapbox/gui/splashscreen/splashscreen.svg b/enmapbox/gui/splashscreen/splashscreen.svg
new file mode 100644
index 00000000..87a0cc32
--- /dev/null
+++ b/enmapbox/gui/splashscreen/splashscreen.svg
@@ -0,0 +1,319 @@
+
+
diff --git a/enmapbox/gui/ui/logo/splashscreen.png b/enmapbox/gui/ui/logo/splashscreen.png
deleted file mode 100644
index a5175af3..00000000
Binary files a/enmapbox/gui/ui/logo/splashscreen.png and /dev/null differ
diff --git a/enmapbox/gui/ui/logo/splashscreen.svg b/enmapbox/gui/ui/logo/splashscreen.svg
deleted file mode 100644
index 9af78678..00000000
--- a/enmapbox/gui/ui/logo/splashscreen.svg
+++ /dev/null
@@ -1,310 +0,0 @@
-
-
diff --git a/scripts/update_splashscreen.py b/scripts/update_splashscreen.py
index 2b400be2..091f87f9 100644
--- a/scripts/update_splashscreen.py
+++ b/scripts/update_splashscreen.py
@@ -3,73 +3,116 @@
Requires that Inkscape (https://inkscape.org) is installed an can be used from shell
Does not update the version number in splashscreen.svg (!), but create a temporary svg only.
"""
+import argparse
import configparser
import os
import re
+import shutil
import subprocess
import xml.etree.ElementTree as ET
from pathlib import Path
from typing import Match
-from qgis.testing import start_app
-
-app = start_app()
from enmapbox import DIR_REPO
+from enmapbox.gui.splashscreen.splashscreen import PATH_SPLASHSCREEN
DIR_REPO = Path(DIR_REPO)
PATH_CONFIG_FILE = DIR_REPO / '.plugin.ini'
-PATH_SVG = DIR_REPO / 'enmapbox/gui/ui/logo/splashscreen.svg'
+PATH_SVG = DIR_REPO / 'enmapbox/gui/splashscreen/splashscreen.svg'
+ENV_INKSCAPE_BIN = 'INKSCAPE_BIN'
+
+
+def inkscapeBin() -> Path:
+ """
+ Searches for the Inkscape binary
+ """
+ if ENV_INKSCAPE_BIN in os.environ:
+ path = os.environ[ENV_INKSCAPE_BIN]
+ else:
+ path = shutil.which('inkscape')
+ if path:
+ path = Path(path)
+
+ assert path.is_file(), f'Could not find inkscape executable. Set {ENV_INKSCAPE_BIN}='
+ return path
-def update_splashscreen():
- assert PATH_CONFIG_FILE.is_file()
- config = configparser.ConfigParser()
- config.read(PATH_CONFIG_FILE)
- VERSION = config['metadata']['version']
+def update_splashscreen(version: str = None, path_png=None):
+ assert PATH_SVG.is_file()
+ PATH_INKSCAPE = inkscapeBin()
+
+ if path_png:
+ path_png = Path(path_png)
+ else:
+ path_png = PATH_SVG.parent / PATH_SVG.name.replace('.svg', '.png')
+
+ if version is None:
+ assert PATH_CONFIG_FILE.is_file()
+ config = configparser.ConfigParser()
+ config.read(PATH_CONFIG_FILE)
+ version = config['metadata']['version']
rxVersion = re.compile(r'(?P\d+)\.(?P\d+)(?P.*)')
- match = rxVersion.match(VERSION)
+ match = rxVersion.match(version)
assert isinstance(match, Match)
- txt_major = match.group('major') + '.'
- txt_minor = match.group('minor')
+ txt_major = match.group('major')
+ txt_minor = '.' + match.group('minor')
- tree = ET.parse(PATH_SVG)
+ with open(PATH_SVG, encoding='utf-8') as f:
+ tree = ET.parse(f)
root = tree.getroot()
- namespaces = dict([node for _, node in ET.iterparse(PATH_SVG, events=['start-ns'])])
+ # namespaces = dict([node for _, node in ET.iterparse(PATH_SVG, events=['start-ns'])])
+ namespaces = {'inkscape': "http://www.inkscape.org/namespaces/inkscape",
+ 'sodipodi': "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd",
+ 'svg': 'http://www.w3.org/2000/svg'}
+
for prefix, namespace in namespaces.items():
ET.register_namespace(prefix, namespace)
- node_major_id = 'tspan_major_version'
- node_minor_id = 'tspan_minor_version'
- node_major = root.find(f".//*[@id='{node_major_id}']")
- node_minor = root.find(f".//*[@id='{node_minor_id}']")
- assert isinstance(node_major, ET.Element), f'SVG misses text element with id "{node_major}"'
- assert isinstance(node_minor, ET.Element), f'SVG misses text element with id "{node_minor}"'
+
+ node_major = root.find(".//*[@inkscape:label='maj_version']/*", namespaces)
+ node_minor = root.find(".//*[@inkscape:label='min_version']/*", namespaces)
+ assert isinstance(node_major, ET.Element), 'SVG misses tspan element below inkscape:label = "maj_version"'
+ assert isinstance(node_minor, ET.Element), 'SVG misses tspan element below inkscape:label = "min_version"'
+
node_major.text = txt_major
node_minor.text = txt_minor
- PATH_EXPORT = PATH_SVG.parent / 'splashscreen_tmp.svg'
+ PATH_EXPORT_TMP = PATH_SVG.parent / 'splashscreen_tmp.svg'
+
# PATH_EXPORT = PATH_SVG
- PATH_PNG = PATH_SVG.parent / PATH_EXPORT.name.replace('.svg', '.png')
- tree.write(PATH_EXPORT, encoding='utf8')
+ tree.write(PATH_EXPORT_TMP, encoding='utf8')
# see https://inkscape.org/doc/inkscape-man.html
cmd = [
# 'inkscape',
- r'"C:\Program Files\Inkscape\inkscape.exe"',
+ f'{PATH_INKSCAPE}',
'--export-type=png',
'--export-area-page',
- f'--export-filename={PATH_PNG}',
- f'{PATH_EXPORT}'
+ f'--export-filename={path_png}',
+ f'{PATH_EXPORT_TMP}'
]
print('Run:\n' + ' '.join(cmd))
print('to export the svg as png with Inkscape (https://inkscape.org)')
- subprocess.run(cmd)
-
- os.remove(PATH_EXPORT)
+ subprocess.run(cmd, check=True)
+ os.remove(PATH_EXPORT_TMP)
if __name__ == "__main__":
- update_splashscreen()
+
+ parser = argparse.ArgumentParser(description='Update the EnMAP-Box splashscreen.',
+ formatter_class=argparse.RawTextHelpFormatter)
+ parser.add_argument('-v', '--version',
+ required=False,
+ default=None,
+ help='A version string with major and minor version, like "3.12"')
+
+ parser.add_argument('--png',
+ required=False,
+ default=PATH_SPLASHSCREEN,
+ help=f'Path of PNG file to create. Defaults to {PATH_SPLASHSCREEN}')
+
+ args = parser.parse_args()
+ update_splashscreen(version=args.version)
diff --git a/tests/enmap-box/enmapbox/eo4qapps/locationbrowserapp/__init__.py b/tests/enmap-box/enmapbox/eo4qapps/locationbrowserapp/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/enmap-box/enmapbox/eo4qapps/locationbrowserapp/test_LocationBrowserApp.py b/tests/enmap-box/enmapbox/eo4qapps/locationbrowserapp/test_LocationBrowserApp.py
new file mode 100644
index 00000000..9fd76601
--- /dev/null
+++ b/tests/enmap-box/enmapbox/eo4qapps/locationbrowserapp/test_LocationBrowserApp.py
@@ -0,0 +1,11 @@
+import requests
+from enmapboxprocessing.testcase import TestCase
+
+
+class LocationBrowserApp(TestCase):
+
+ def test_nominatim(self):
+ url = 'https://nominatim.openstreetmap.org/search?q=berlin&limit=50&extratags=1&polygon_geojson=1&format=json'
+ headers = {"User-Agent": "EnMAP-Box QGIS Plugin (enmapbox@enmap.org)"} # Required user agent
+ nominatimResults = requests.get(url, headers=headers)
+ self.assertEqual(nominatimResults.status_code, 200)
diff --git a/tests/enmap-box/enmapbox/gui/test_splashscreen.py b/tests/enmap-box/enmapbox/gui/test_splashscreen.py
index 8eba7f5d..cae8284f 100644
--- a/tests/enmap-box/enmapbox/gui/test_splashscreen.py
+++ b/tests/enmap-box/enmapbox/gui/test_splashscreen.py
@@ -1,16 +1,17 @@
import unittest
-
+import time
from qgis.PyQt.QtCore import QTimer
from qgis.PyQt.QtWidgets import QWidget
-from enmapbox.gui.enmapboxgui import EnMAPBoxSplashScreen
-from enmapbox.testing import EnMAPBoxTestCase
+from enmapbox.gui.splashscreen.splashscreen import EnMAPBoxSplashScreen
+from enmapbox.testing import EnMAPBoxTestCase, start_app
+
+start_app()
class TestEnMAPBoxSplashScreen(EnMAPBoxTestCase):
def test_splashScreen(self):
- import time
w = QWidget()
splash = EnMAPBoxSplashScreen(parent=w)