Skip to content

Commit 10a7110

Browse files
committed
fix: use new plugin mechanism
1 parent ef32874 commit 10a7110

37 files changed

Lines changed: 2088 additions & 579 deletions

Makefile

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
#/***************************************************************************
2+
# ShogunEditor
3+
#
4+
# A QGIS plugin to connect with a SHOGun instance on a remote or local server and edit it's content from QGIS
5+
# -------------------
6+
# begin : 2025-09-21
7+
# git sha : $Format:%H$
8+
# copyright : (C) 2025 by terrestris GmbH & Co. KG
9+
# email : info@terrestris.de
10+
# ***************************************************************************/
11+
#
12+
#/***************************************************************************
13+
# * *
14+
# * This program is free software; you can redistribute it and/or modify *
15+
# * it under the terms of the GNU General Public License as published by *
16+
# * the Free Software Foundation; either version 2 of the License, or *
17+
# * (at your option) any later version. *
18+
# * *
19+
# ***************************************************************************/
20+
21+
#################################################
22+
# Edit the following to match your sources lists
23+
#################################################
24+
25+
26+
#Add iso code for any locales you want to support here (space separated)
27+
# default is no locales
28+
# LOCALES = af
29+
LOCALES =
30+
31+
# If locales are enabled, set the name of the lrelease binary on your system. If
32+
# you have trouble compiling the translations, you may have to specify the full path to
33+
# lrelease
34+
#LRELEASE = lrelease
35+
#LRELEASE = lrelease-qt4
36+
37+
38+
# translation
39+
SOURCES = \
40+
__init__.py \
41+
shogun_editor.py shogun_editor_dialog.py
42+
43+
PLUGINNAME = shogun_editor
44+
45+
PY_FILES = \
46+
__init__.py \
47+
shogun_editor.py shogun_editor_dialog.py
48+
49+
UI_FILES = shogun_editor_dialog_base.ui
50+
51+
EXTRAS = metadata.txt icon.png
52+
53+
EXTRA_DIRS =
54+
55+
COMPILED_RESOURCE_FILES = resources.py
56+
57+
PEP8EXCLUDE=pydev,resources.py,conf.py,third_party,ui
58+
59+
# QGISDIR points to the location where your plugin should be installed.
60+
# This varies by platform, relative to your HOME directory:
61+
# * Linux:
62+
# .local/share/QGIS/QGIS3/profiles/default/python/plugins/
63+
# * Mac OS X:
64+
# Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
65+
# * Windows:
66+
# AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins'
67+
68+
QGISDIR=/home/ahenn/.local/share/QGIS/QGIS3/profiles/default/python/plugins/
69+
70+
#################################################
71+
# Normally you would not need to edit below here
72+
#################################################
73+
74+
HELP = help/build/html
75+
76+
PLUGIN_UPLOAD = $(c)/plugin_upload.py
77+
78+
RESOURCE_SRC=$(shell grep '^ *<file' resources.qrc | sed 's@</file>@@g;s/.*>//g' | tr '\n' ' ')
79+
80+
.PHONY: default
81+
default:
82+
@echo While you can use make to build and deploy your plugin, pb_tool
83+
@echo is a much better solution.
84+
@echo A Python script, pb_tool provides platform independent management of
85+
@echo your plugins and runs anywhere.
86+
@echo You can install pb_tool using: pip install pb_tool
87+
@echo See https://g-sherman.github.io/plugin_build_tool/ for info.
88+
89+
compile: $(COMPILED_RESOURCE_FILES)
90+
91+
%.py : %.qrc $(RESOURCES_SRC)
92+
pyrcc5 -o $*.py $<
93+
94+
%.qm : %.ts
95+
$(LRELEASE) $<
96+
97+
test: compile transcompile
98+
@echo
99+
@echo "----------------------"
100+
@echo "Regression Test Suite"
101+
@echo "----------------------"
102+
103+
@# Preceding dash means that make will continue in case of errors
104+
@-export PYTHONPATH=`pwd`:$(PYTHONPATH); \
105+
export QGIS_DEBUG=0; \
106+
export QGIS_LOG_FILE=/dev/null; \
107+
nosetests -v --with-id --with-coverage --cover-package=. \
108+
3>&1 1>&2 2>&3 3>&- || true
109+
@echo "----------------------"
110+
@echo "If you get a 'no module named qgis.core error, try sourcing"
111+
@echo "the helper script we have provided first then run make test."
112+
@echo "e.g. source run-env-linux.sh <path to qgis install>; make test"
113+
@echo "----------------------"
114+
115+
deploy: compile doc transcompile
116+
@echo
117+
@echo "------------------------------------------"
118+
@echo "Deploying plugin to your .qgis2 directory."
119+
@echo "------------------------------------------"
120+
# The deploy target only works on unix like operating system where
121+
# the Python plugin directory is located at:
122+
# $HOME/$(QGISDIR)/python/plugins
123+
mkdir -p $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
124+
cp -vf $(PY_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
125+
cp -vf $(UI_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
126+
cp -vf $(COMPILED_RESOURCE_FILES) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
127+
cp -vf $(EXTRAS) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
128+
cp -vfr i18n $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
129+
cp -vfr $(HELP) $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)/help
130+
# Copy extra directories if any
131+
(foreach EXTRA_DIR,(EXTRA_DIRS), cp -R (EXTRA_DIR) (HOME)/(QGISDIR)/python/plugins/(PLUGINNAME)/;)
132+
133+
134+
# The dclean target removes compiled python files from plugin directory
135+
# also deletes any .git entry
136+
dclean:
137+
@echo
138+
@echo "-----------------------------------"
139+
@echo "Removing any compiled python files."
140+
@echo "-----------------------------------"
141+
find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname "*.pyc" -delete
142+
find $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME) -iname ".git" -prune -exec rm -Rf {} \;
143+
144+
145+
derase:
146+
@echo
147+
@echo "-------------------------"
148+
@echo "Removing deployed plugin."
149+
@echo "-------------------------"
150+
rm -Rf $(HOME)/$(QGISDIR)/python/plugins/$(PLUGINNAME)
151+
152+
zip: deploy dclean
153+
@echo
154+
@echo "---------------------------"
155+
@echo "Creating plugin zip bundle."
156+
@echo "---------------------------"
157+
# The zip target deploys the plugin and creates a zip file with the deployed
158+
# content. You can then upload the zip file on http://plugins.qgis.org
159+
rm -f $(PLUGINNAME).zip
160+
cd $(HOME)/$(QGISDIR)/python/plugins; zip -9r $(CURDIR)/$(PLUGINNAME).zip $(PLUGINNAME)
161+
162+
package: compile
163+
# Create a zip package of the plugin named $(PLUGINNAME).zip.
164+
# This requires use of git (your plugin development directory must be a
165+
# git repository).
166+
# To use, pass a valid commit or tag as follows:
167+
# make package VERSION=Version_0.3.2
168+
@echo
169+
@echo "------------------------------------"
170+
@echo "Exporting plugin to zip package. "
171+
@echo "------------------------------------"
172+
rm -f $(PLUGINNAME).zip
173+
git archive --prefix=$(PLUGINNAME)/ -o $(PLUGINNAME).zip $(VERSION)
174+
echo "Created package: $(PLUGINNAME).zip"
175+
176+
upload: zip
177+
@echo
178+
@echo "-------------------------------------"
179+
@echo "Uploading plugin to QGIS Plugin repo."
180+
@echo "-------------------------------------"
181+
$(PLUGIN_UPLOAD) $(PLUGINNAME).zip
182+
183+
transup:
184+
@echo
185+
@echo "------------------------------------------------"
186+
@echo "Updating translation files with any new strings."
187+
@echo "------------------------------------------------"
188+
@chmod +x scripts/update-strings.sh
189+
@scripts/update-strings.sh $(LOCALES)
190+
191+
transcompile:
192+
@echo
193+
@echo "----------------------------------------"
194+
@echo "Compiled translation files to .qm files."
195+
@echo "----------------------------------------"
196+
@chmod +x scripts/compile-strings.sh
197+
@scripts/compile-strings.sh $(LRELEASE) $(LOCALES)
198+
199+
transclean:
200+
@echo
201+
@echo "------------------------------------"
202+
@echo "Removing compiled translation files."
203+
@echo "------------------------------------"
204+
rm -f i18n/*.qm
205+
206+
clean:
207+
@echo
208+
@echo "------------------------------------"
209+
@echo "Removing uic and rcc generated files"
210+
@echo "------------------------------------"
211+
rm $(COMPILED_UI_FILES) $(COMPILED_RESOURCE_FILES)
212+
213+
doc:
214+
@echo
215+
@echo "------------------------------------"
216+
@echo "Building documentation using sphinx."
217+
@echo "------------------------------------"
218+
cd help; make html
219+
220+
pylint:
221+
@echo
222+
@echo "-----------------"
223+
@echo "Pylint violations"
224+
@echo "-----------------"
225+
@pylint --reports=n --rcfile=pylintrc . || true
226+
@echo
227+
@echo "----------------------"
228+
@echo "If you get a 'no module named qgis.core' error, try sourcing"
229+
@echo "the helper script we have provided first then run make pylint."
230+
@echo "e.g. source run-env-linux.sh <path to qgis install>; make pylint"
231+
@echo "----------------------"
232+
233+
234+
# Run pep8 style checking
235+
#http://pypi.python.org/pypi/pep8
236+
pep8:
237+
@echo
238+
@echo "-----------"
239+
@echo "PEP8 issues"
240+
@echo "-----------"
241+
@pep8 --repeat --ignore=E203,E121,E122,E123,E124,E125,E126,E127,E128 --exclude $(PEP8EXCLUDE) . || true
242+
@echo "-----------"
243+
@echo "Ignored in PEP8 check:"
244+
@echo $(PEP8EXCLUDE)

README.html

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,42 @@
11
<html>
22
<body>
3-
<h3>Shogun Editor for QGIS. A plugin</h3>
4-
<br/>
5-
<br/>
3+
<h3>Plugin Builder Results</h3>
64

7-
<div id='help' style='font-size:.9em;'>
8-
<h3>Info:</h3>
9-
A QGIS plugin for editing a Shogun GIS client instance. See <a href="https://github.com/terrestris/shogun2">https://github.com/terrestris/shogun2</a><br>
10-
--Link will be replaced when Shogun2-webapp will be released--<br>
11-
After connecting with the Shogun ressource (note: that ressource needs to have basic authentication possibility),<br>
12-
the user can edit applications and layers on the Shogun server, in interaction with the QGIS interface. <br>
13-
<br>
14-
<br>
15-
<b>Features:</b>
16-
<ul>
17-
<li>Add layers from Shogun to QGIS (as WFS, WMS or raw data)
18-
<li>
19-
<li>Upload new layers (vector and raster format) from QGIS to the Shogun server
20-
<li>
21-
<li>Upload layer style (vector layers only) from QGIS and apply to the layers in Shogun -> most basic styling is implemented, also the upload of custom symbols for point layers
22-
<li>
23-
<li>Edit static data like names, descriptions, ...
24-
<li>
25-
<li>Create new Shogun applications
26-
<li>
27-
<li>Set applications homeview directly from the QGIS interface
28-
</ul>
5+
Congratulations! You just built a plugin for QGIS!<br/><br />
296

30-
31-
<h3>Installation</h3>
32-
You can install the plugin via the QGIS plugin repository or manually.
33-
Manually installing: Copy the shogun-editor directory to your qgis plugins
34-
directory which you should find at:
35-
<ul>
36-
<li><b>QGIS 2.x:</b>
37-
<br>usually in your home directory you find:
38-
.qgis2/python/plugins/ - if you need more details see this
39-
<a href="https://github.com/g-sherman/Qgis-Plugin-Builder/blob/master/help/source/index.rst#the-copy-method"
40-
>link</a> (chapter "The Copy Method")
41-
<br>
42-
<li>
43-
<li><b>QGIS 3.x:</b>
44-
<br>To find the plugins folder, open up QGIS, in the menu go to
45-
Settings->User Profiles -> Open active profile folder
46-
<br>In the file explorer, go to python/plugins/ and paste
47-
the folder there
48-
</ul>
49-
<br>After copying just open up QGIS, activate the plugin in the
50-
plugin manager and you are done
51-
<br>
52-
<br>
53-
<h3>Important notes & missing features</h3>
7+
<div id='help' style='font-size:.9em;'>
8+
Your plugin <b>ShogunEditor</b> was created in:<br>
9+
&nbsp;&nbsp;<b>/home/ahenn/tmp/SHOGunEditor/shogun_editor</b>
10+
<p>
11+
Your QGIS plugin directory is located at:<br>
12+
&nbsp;&nbsp;<b>/home/ahenn/.local/share/QGIS/QGIS3/profiles/default/python/plugins</b>
13+
<p>
14+
<h3>What's Next</h3>
15+
<ol>
16+
<li>If resources.py is not present in your plugin directory, compile the resources file using pyrcc5 (simply use <b>pb_tool</b> or <b>make</b> if you have automake)
17+
<li>Optionally, test the generated sources using <b>make test</b> (or run tests from your IDE)
18+
<li>Copy the entire directory containing your new plugin to the QGIS plugin directory (see Notes below)
19+
<li>Test the plugin by enabling it in the QGIS plugin manager
20+
<li>Customize it by editing the implementation file <b>shogun_editor.py</b>
21+
<li>Create your own custom icon, replacing the default <b>icon.png</b>
22+
<li>Modify your user interface by opening <b>shogun_editor_dialog_base.ui</b> in Qt Designer
23+
</ol>
24+
Notes:
5425
<ul>
55-
<li>The plugin works with QGIS 2.x and 3.x, but currently there is a problem with adding wfs layers
56-
to QGIS ins 3.x, which has to be resolved
57-
<li>
58-
<li>As already mentioned, the plugin works with basic authentication requests and
59-
therefore can only be used with Shogun2-Webapp installations which support basic authentication
60-
<li>
61-
<li>Layer styles based on custom icons in Shogun currently cannot be imported
62-
to QGIS, but styles with custom icons created in QGIS can be uploaded to Shogun
63-
<li>
64-
<li>Layer styles based on font symbols are currently not supported by the plugin
26+
<li>You can use <b>pb_tool</b> to compile, deploy, and manage your plugin. Tweak the <i>pb_tool.cfg</i> file included with your plugin as you add files. Install <b>pb_tool</b> using
27+
<i>pip</i> or <i>easy_install</i>. See <b>http://loc8.cc/pb_tool</b> for more information.
28+
<li>You can also use the <b>Makefile</b> to compile and deploy when you
29+
make changes. This requires GNU make (gmake). The Makefile is ready to use, however you
30+
will have to edit it to add addional Python source files, dialogs, and translations.
6531
</ul>
66-
6732
</div>
33+
<div style='font-size:.9em;'>
34+
<p>
35+
For information on writing PyQGIS code, see <b>http://loc8.cc/pyqgis_resources</b> for a list of resources.
36+
</p>
37+
</div>
38+
<p>
39+
&copy;2011-2019 GeoApt LLC - geoapt.com
40+
</p>
6841
</body>
6942
</html>

0 commit comments

Comments
 (0)