diff --git a/Makefile b/Makefile
index 714285d..01843be 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/__init__.py b/__init__.py
index 6f190f7..cba67ea 100644
--- a/__init__.py
+++ b/__init__.py
@@ -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$
***************************************************************************/
/***************************************************************************
@@ -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)
diff --git a/i18n/en.ts b/i18n/en.ts
new file mode 100644
index 0000000..4d26598
--- /dev/null
+++ b/i18n/en.ts
@@ -0,0 +1,78 @@
+
+
+
+ @default
+
+
+
+
+
+
+
+ RealCentroid
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RealCentroidDialogBase
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/i18n/hu.qm b/i18n/hu.qm
new file mode 100644
index 0000000..5b2b2d2
Binary files /dev/null and b/i18n/hu.qm differ
diff --git a/i18n/hu.ts b/i18n/hu.ts
new file mode 100644
index 0000000..7ade958
--- /dev/null
+++ b/i18n/hu.ts
@@ -0,0 +1,79 @@
+
+
+
+
+ @default
+
+
+
+ Jó reggelt
+
+
+
+ RealCentroid
+
+
+
+ &realcentroid
+
+
+
+
+ RealCentroid
+
+
+
+
+ Hiba a shape fájl betöltése közben
+
+
+
+
+ Hibás vagy üres geometriát találtam, lásd a naplófájlt
+
+
+
+
+ Nem választottál felület réteget
+
+
+
+
+ Nem adtal megpont réteget
+
+
+
+ RealCentroidDialogBase
+
+
+
+ realcentroid
+
+
+
+
+ Felület réteg
+
+
+
+
+ Csak a szelektált elemek
+
+
+
+
+ Eredmény pont réteg
+
+
+
+
+ Tallóz
+
+
+
+
+ Hozzáadás a térképhez
+
+
+
diff --git a/i18n/realcentroid_en.ts b/i18n/realcentroid_en.ts
deleted file mode 100644
index 9552569..0000000
--- a/i18n/realcentroid_en.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
- RealCentroid
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/realcentroid.py b/realcentroid.py
index 96ee04b..28ebcaa 100644
--- a/realcentroid.py
+++ b/realcentroid.py
@@ -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
@@ -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()
@@ -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"""
diff --git a/realcentroid_dialog.py b/realcentroid_dialog.py
index 09414c9..d59d437 100644
--- a/realcentroid_dialog.py
+++ b/realcentroid_dialog.py
@@ -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 """
@@ -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)
@@ -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
diff --git a/realcentroid_dialog_base.ui b/realcentroid_dialog_base.ui
index 328f490..95e9ad3 100644
--- a/realcentroid_dialog_base.ui
+++ b/realcentroid_dialog_base.ui
@@ -7,28 +7,12 @@
0
0
400
- 240
+ 215
realcentroid
-
-
-
- 30
- 200
- 341
- 32
-
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
@@ -46,7 +30,7 @@
10
- 80
+ 60
321
23
@@ -59,7 +43,7 @@
20
- 110
+ 90
311
17
@@ -75,7 +59,7 @@
10
- 130
+ 110
261
25
@@ -85,7 +69,7 @@
280
- 130
+ 110
89
25
@@ -98,7 +82,7 @@
10
- 160
+ 140
251
23
@@ -117,6 +101,35 @@
+
+
+
+ 200
+ 170
+ 168
+ 27
+
+
+
+ -
+
+
+ Cancel
+
+
+
+ -
+
+
+ Ok
+
+
+ true
+
+
+
+
+
@@ -126,38 +139,5 @@
-
-
- button_box
- accepted()
- RealCentroidDialogBase
- accept()
-
-
- 20
- 20
-
-
- 20
- 20
-
-
-
-
- button_box
- rejected()
- RealCentroidDialogBase
- reject()
-
-
- 20
- 20
-
-
- 20
- 20
-
-
-
-
+