diff --git a/CenRa_AUTOMAP/canvas_editor.py b/CenRa_AUTOMAP/canvas_editor.py index 5e36bb7e..40c28cd7 100644 --- a/CenRa_AUTOMAP/canvas_editor.py +++ b/CenRa_AUTOMAP/canvas_editor.py @@ -49,6 +49,7 @@ from qgis.PyQt.QtWidgets import ( QDialog, QAction, QMessageBox, + QPushButton, QDockWidget, QFileDialog, QInputDialog, @@ -438,7 +439,18 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS): doc = QDomDocument() doc.setContent(template_content) self.layout.loadFromTemplate(doc, QgsReadWriteContext(), True) - self.layout.setName(layout_name) + + try: + cutLayout = layout_name.index("¶") + except: + cutLayout = 0 + + if cutLayout >= 1: + self.layout.setName(layout_name) + titre_layout_name=layout_name[:cutLayout] + else: + self.layout.setName(layout_name) + titre_layout_name = layout_name if self.radioButton_6.isChecked() and self.radioButton_7.isChecked(): logo_div = A4_size['Portrait']['RIGHT'] @@ -503,7 +515,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS): ## Ajout d'un titre à la mise en page title = QgsLayoutItemLabel(self.layout) self.layout.addLayoutItem(title) - titre = layout_name + titre = titre_layout_name title.setText(titre) title.setFont(QFont("Calibri", 15, QFont.Bold)) title.setItemRotation(self.template_parameters['Titre_rotate']) @@ -737,11 +749,32 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS): existing_layout = project.layoutManager().layoutByName(self.layout.name()) if existing_layout: - self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !","Mise en page existente, la mise en page vas être écraser !",QMessageBox.Yes | QMessageBox.No) + self.QMBquestion = QMessageBox() + self.QMBquestion.setWindowTitle(u"Attention !") + self.QMBquestion.setIcon(QMessageBox.Warning) + self.QMBquestion.setText("Mise en page existente, la mise en page vas être écraser !") + self.QMBquestion.setStandardButtons(QMessageBox.Yes|QMessageBox.No) + self.QMBquestion.addButton(QPushButton('Autre mise en page'),QMessageBox.AcceptRole) + self.QMBquestion = self.QMBquestion.exec() + #if self.radioButton_12.isChecked() != 1: if self.QMBquestion == QMessageBox.Yes: project.layoutManager().removeLayout(existing_layout) result = project.layoutManager().addLayout(self.layout) + if self.QMBquestion == QMessageBox.AcceptRole: + LayoutCOUNT=0 + arrayManager = [] + for AddArrayManager in project.layoutManager().layouts(): + arrayManager.append(AddArrayManager.name()) + arrayManager.sort() + for LayoutNAME in arrayManager: + if LayoutNAME == layout_name: + LayoutCOUNT = LayoutCOUNT+1 + if LayoutNAME == layout_name+"¶"+str(LayoutCOUNT): + LayoutCOUNT=LayoutCOUNT+1 + layout_name = (layout_name+"¶"+str(LayoutCOUNT)) + self.layout.setName(layout_name) + else: existing_layout = True @@ -757,11 +790,16 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS): fichier_mise_en_page = layout_name layout_modifie = QgsProject.instance().layoutManager().layoutByName(fichier_mise_en_page) try: - TryMessage = (self.QMBquestion == QMessageBox.Yes) + if (self.QMBquestion == QMessageBox.AcceptRole): + TryMessage = (self.QMBquestion == QMessageBox.AcceptRole) + elif (self.QMBquestion == QMessageBox.Yes): + TryMessage = (self.QMBquestion == QMessageBox.Yes) + else: + TryMessage = False del self.QMBquestion except: TryMessage = True - print(TryMessage) + if TryMessage == True: iface.openLayoutDesigner(layout_modifie) self.close() diff --git a/CenRa_AUTOMAP/metadata.txt b/CenRa_AUTOMAP/metadata.txt index 3d11e7ce..5c2416f6 100644 --- a/CenRa_AUTOMAP/metadata.txt +++ b/CenRa_AUTOMAP/metadata.txt @@ -6,7 +6,7 @@ name=CenRa_AutoMap qgisMinimumVersion=3.0 description=CenRa_AutoMap -version=1.0 +version=1.1 author=Conservatoire d'Espaces Naturels de Rhône-Alpes email=si_besoin@cen-rhonealpes.fr @@ -21,7 +21,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues hasProcessingProvider=no # Uncomment the following line and add your changelog: -changelog=