Skip to content

Commit

Permalink
bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
zsiki committed Dec 7, 2018
1 parent 2ab3d90 commit b64bf62
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 126 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#Add iso code for any locales you want to support here (space separated)
# default is no locales
# LOCALES = af
LOCALES =
LOCALES = en hu

# If locales are enabled, set the name of the lrelease binary on your system. If
# you have trouble compiling the translations, you may have to specify the full path to
Expand Down
22 changes: 15 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
/***************************************************************************
RealCentroid
A QGIS plugin
Create point shape from polygon centroids
Create internal point for a polygon layer
Generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2013-10-27
copyright : (C) 2013 by Zoltan Siki
email : siki at agt.bme.hu
begin : 2018-12-01
copyright : (C) 2018 by Zotan Siki
email : siki1958@gmail.com
git sha : $Format:%H$
***************************************************************************/
/***************************************************************************
Expand All @@ -20,9 +22,15 @@
***************************************************************************/
This script initializes the plugin, making it known to QGIS.
"""
from __future__ import absolute_import

def classFactory(iface):
# load RealCentroid class from file RealCentroid

# noinspection PyPep8Naming
def classFactory(iface): # pylint: disable=invalid-name
"""Load RealCentroid class from file RealCentroid.
:param iface: A QGIS interface instance.
:type iface: QgsInterface
"""
#
from .realcentroid import RealCentroid
return RealCentroid(iface)
78 changes: 78 additions & 0 deletions i18n/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
<name>@default</name>
<message>
<location filename="../test/test_translations.py" line="48"/>
<source>Good morning</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RealCentroid</name>
<message>
<location filename="../realcentroid.py" line="163"/>
<source>&amp;realcentroid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid.py" line="157"/>
<source>RealCentroid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid.py" line="212"/>
<source>Error loading shapefile:
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid.py" line="217"/>
<source>Invalid or empty geometries found, see log messages</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid_dialog.py" line="93"/>
<source>No polygon layer selected</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid_dialog.py" line="98"/>
<source>No point layer given</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RealCentroidDialogBase</name>
<message>
<location filename="../realcentroid_dialog_base.ui" line="14"/>
<source>realcentroid</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="42"/>
<source>Polygon layer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="55"/>
<source>Selected features only</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="68"/>
<source>Output point on surface layer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="94"/>
<source>Browse</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="107"/>
<source>Add to map canvas</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
Binary file added i18n/hu.qm
Binary file not shown.
79 changes: 79 additions & 0 deletions i18n/hu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="hu_HU" sourcelanguage="en">
<context>
<name>@default</name>
<message>
<location filename="../test/test_translations.py" line="48"/>
<source>Good morning</source>
<translation>Jó reggelt</translation>
</message>
</context>
<context>
<name>RealCentroid</name>
<message>
<location filename="../realcentroid.py" line="163"/>
<source>&amp;realcentroid</source>
<translation>&amp;realcentroid</translation>
</message>
<message>
<location filename="../realcentroid.py" line="157"/>
<source>RealCentroid</source>
<translation>RealCentroid</translation>
</message>
<message>
<location filename="../realcentroid.py" line="212"/>
<source>Error loading shapefile:
</source>
<translation>Hiba a shape fájl betöltése közben</translation>
</message>
<message>
<location filename="../realcentroid.py" line="217"/>
<source>Invalid or empty geometries found, see log messages</source>
<translation>Hibás vagy üres geometriát találtam, lásd a naplófájlt</translation>
</message>
<message>
<location filename="../realcentroid_dialog.py" line="93"/>
<source>No polygon layer selected</source>
<translation>Nem választottál felület réteget</translation>
</message>
<message>
<location filename="../realcentroid_dialog.py" line="98"/>
<source>No point layer given</source>
<translation>Nem adtal megpont réteget</translation>
</message>
</context>
<context>
<name>RealCentroidDialogBase</name>
<message>
<location filename="../realcentroid_dialog_base.ui" line="14"/>
<source>realcentroid</source>
<translation>realcentroid</translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="42"/>
<source>Polygon layer</source>
<translation>Felület réteg</translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="55"/>
<source>Selected features only</source>
<translation>Csak a szelektált elemek</translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="68"/>
<source>Output point on surface layer</source>
<translation>Eredmény pont réteg</translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="94"/>
<source>Browse</source>
<translation>Tallóz</translation>
</message>
<message>
<location filename="../realcentroid_dialog_base.ui" line="107"/>
<source>Add to map canvas</source>
<translation>Hozzáadás a térképhez</translation>
</message>
</context>
</TS>
46 changes: 0 additions & 46 deletions i18n/realcentroid_en.ts

This file was deleted.

23 changes: 12 additions & 11 deletions realcentroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from PyQt5.QtWidgets import QAction

from qgis.core import QgsVectorFileWriter, QgsWkbTypes, QgsFeature, \
QgsMessageLog
QgsMessageLog, QgsVectorLayer, QgsProject
# Initialize Qt resources from file resources.py
from .resources import *
# Import the code for the dialog
Expand Down Expand Up @@ -173,7 +173,7 @@ def generate(self):
vprovider = vlayer.dataProvider()
writer = QgsVectorFileWriter(self.dlg.pointEdit.text(), \
self.dlg.encoding, vprovider.fields(), QgsWkbTypes.Point, \
vprovider.crs())
vprovider.crs(), "ESRI Shapefile")
outFeat = QgsFeature()
if self.dlg.selectedBox.isChecked():
features = vlayer.selectedFeatures()
Expand Down Expand Up @@ -205,18 +205,19 @@ def generate(self):
outFeat.setGeometry(outGeom)
writer.addFeature(outFeat)
del writer
if nError > 0:
QMessageBox.warning(None, "RealCentroid", \
tr("Invalid or empty geometries found, see log messages"))
# add centroid shape to canvas
if self.dlg.addBox.checkState() == Qt.Checked:
# TODO
if not self.dlg.pointEdit.text():
p, name = os.path.split(self.dlg.pointEdit.text())
w = QgsVectorLayer(self.dlg.pointEdit.text(), name, 'ogr')
if w.isValid():
QgsProject.instance().addMapLayer(w)
else:
QMessageBox.warning(None, "RealCentroid", \
QApplication.translate("RealCentroid", \
"Error loading shapefile:\n", None, \
QApplication.UnicodeUTF8) + self.dlg.shapefileName)
if nError > 0:
QMessageBox.warning(None, "RealCentroid", \
QApplication.translate("RealCentroid", \
"Invalid or empty geometries found, see log messages"))
tr("Error loading shapefile\n") +
self.dlg.pointEdit.text())

def run(self):
"""Run method that performs all the real work"""
Expand Down
10 changes: 5 additions & 5 deletions realcentroid_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def __init__(self, parent=None):
self.encoding = None
self.layerBox.currentIndexChanged.connect(self.sel)
self.browseButton.clicked.connect(self.browse)
self.button_box.button(QtGui.QDialogButtonBox.Cancel).clicked.connect(self.reject)
self.button_box.button(QtGui.QDialogButtonBox.Ok).clicked.connect(self.ok)
self.cancelBtn.clicked.connect(self.reject)
self.okBtn.clicked.connect(self.ok)

def showEvent(self, event):
""" initialize dialog widgets """
Expand Down Expand Up @@ -76,7 +76,7 @@ def browse(self):
dirName = settings.value("/UI/lastShapefileDir")
encode = settings.value("/UI/encoding")
fileDialog = QgsEncodingFileDialog(self, "Output shape file", dirName,
"GeoPackage (*.gpkg)", encode)
"Shape file (*.shp)", encode)
fileDialog.setDefaultSuffix("shp")
fileDialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
fileDialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
Expand All @@ -90,12 +90,12 @@ def browse(self):
def ok(self):
""" check widgets """
if len(self.layerBox.currentText()) == 0:
QtGui.QMessageBox.information(self, "Realcentroid", \
QtGui.QMessageBox.warning(self, "Realcentroid", \
QtGui.QApplication.translate("RealCentroid", \
"No polygon layer selected", None))
return
if len(self.pointEdit.text()) == 0:
QtGui.QMessageBox.information(self, "Realcentroid", \
QtGui.QMessageBox.warning(self, "Realcentroid", \
QtGui.QApplication.translate("RealCentroid", \
"No point layer given", None))
return
Expand Down
Loading

0 comments on commit b64bf62

Please sign in to comment.