From 1dd468f6145389c2b3019aa5e988463f952b5c7d Mon Sep 17 00:00:00 2001 From: bogind Date: Thu, 1 Oct 2020 19:44:15 +0300 Subject: [PATCH] added saveQML function and connected it --- qlyrx.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/qlyrx.py b/qlyrx.py index 6b4f986..83e63b8 100644 --- a/qlyrx.py +++ b/qlyrx.py @@ -265,7 +265,6 @@ def load_vectors(self): def enableQmlSaving(self): - print(self.dlg.saveQmlCheck.checkState()) if self.dlg.saveQmlCheck.isChecked(): self.dlg.QMLSaveLocation.setEnabled(True) self.dlg.qmlLabel.setEnabled(True) @@ -273,6 +272,17 @@ def enableQmlSaving(self): self.dlg.QMLSaveLocation.setDisabled(True) self.dlg.qmlLabel.setDisabled(True) + + def saveQML(self,layer): + try: + if(len(self.dlg.QMLSaveLocation.filePath())) > 0: + QmlPath = self.dlg.QMLSaveLocation.filePath() + layer.saveNamedStyle(QmlPath) + else: + self.mb.pushWarning('QML Not Saved','missing Path') + except Exception as e: + self.mb.pushCritical('Error',"Something went wrong with saving the QML, please send us the following error: {}".format(e)) + def read_lyrx(self, file=None): with open(file, mode="r", encoding="utf-8") as json_file: @@ -1486,5 +1496,7 @@ def run(self): geometry_general_type_str = self.generalise_geom_type(layer) if not isRaster else 'raster' self.apply_lyrx_symbols(layer, j_data, geometry_general_type_str) + if self.dlg.saveQmlCheck.isChecked(): + self.saveQML(layer) self.mb.pushSuccess('Yay',"It's Working") #pass