Nom Prénom, sécurité d'ecrasement, police

This commit is contained in:
2025-01-27 17:14:31 +01:00
parent bbb41400e5
commit cbe6952c9a
4 changed files with 98 additions and 23 deletions
+36 -9
View File
@@ -48,6 +48,7 @@ from qgis.PyQt.QtWebKitWidgets import QWebPage
from qgis.PyQt.QtWidgets import (
QDialog,
QAction,
QMessageBox,
QDockWidget,
QFileDialog,
QInputDialog,
@@ -58,6 +59,7 @@ from qgis.PyQt.QtWidgets import (
QVBoxLayout,
)
from PyQt5 import QtGui
from PyQt5 import QtWidgets
from qgis.PyQt.QtXml import QDomDocument
from qgis.utils import iface
import glob
@@ -321,6 +323,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.comboBox_6.clear()
self.comboBox_7.clear()
if (self.s.value("automap/prenom_nom", "1", type=str) != "1"):
self.lineEdit_5.setText(self.s.value("automap/prenom_nom", 1, type=str))
couches = []
couche_vecteur = ['']
mapThemes = ['']
@@ -521,7 +525,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
if self.radioButton_9.isChecked() == 1:
titre = titre + ' [%' + self.comboBox_4.currentText() + '%]'
subtitle.setText(titre)
subtitle.setFont(QFont("MS Shell Dlg 2", 10))
subtitle.setFont(QFont("Calibri", 10))
subtitle.setItemRotation(self.template_parameters['Sous_titre_rotate'])
subtitle.attemptResize(self.template_parameters['Sous_titre_size'])
subtitle.attemptMove(self.template_parameters['Sous_titre_locals'])
@@ -628,6 +632,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.scalebarnumeric_qpt.setNumberOfSegments(2)
self.scalebarnumeric_qpt.setNumberOfSegmentsLeft(0)
self.scalebarnumeric_qpt.setFont(QFont("Calibri", 12))
self.scalebarnumeric_qpt.attemptMove(self.template_parameters['Echelle_locals'])
self.scalebarnumeric_qpt.attemptResize(self.template_parameters['Echelle_size'])
self.scalebarnumeric_qpt.setItemRotation(self.template_parameters['Echelle_rotate'])
@@ -647,6 +652,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.scalebar_qpt.setNumberOfSegments(2)
self.scalebar_qpt.setNumberOfSegmentsLeft(0)
self.scalebar_qpt.setFont(QFont("Calibri", 12))
self.scalebar_qpt.attemptMove(self.template_parameters['Echelle_2_locals'])
self.scalebar_qpt.attemptResize(self.template_parameters['Echelle_2_size'])
self.scalebar_qpt.setItemRotation(self.template_parameters['Echelle_2_rotate'])
@@ -664,6 +670,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
north.attemptMove(self.template_parameters['Arrow_locals'])
north.attemptResize(self.template_parameters['Arrow_size'])
north.setItemRotation(self.template_parameters['Arrow_rotate'])
north.setBackgroundEnabled(True)
north.setBackgroundColor(QColor(255, 255, 255, 130))
if self.radioButton_10.isChecked() == 1:
text_source = ' '
@@ -674,13 +682,19 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
else:
info_text = ["Source : " + self.lineEdit_4.text()][0]
# ajout note info:
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime(
"%d/%m/%Y") + ")"]
if self.radioButton_14.isChecked() == 1:
self.s.setValue("automap/prenom_nom",self.lineEdit_5.text())
prenom_nom = self.s.value("automap/prenom_nom", 1, type=str)
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ") par "+prenom_nom]
else:
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ")"]
credit_text = QgsLayoutItemLabel(self.layout)
credit_text.setText(info[0])
credit_text.setFont(QFont("Calibri", 9))
credit_text.setHAlign(Qt.AlignRight)
credit_text.setVAlign(Qt.AlignVCenter)
credit_text.setBackgroundEnabled(True)
credit_text.setBackgroundColor(QColor(255, 255, 255, 130))
credit_text2 = QgsLayoutItemLabel(self.layout)
credit_text2.setText(info_text)
credit_text2.setFont(QFont("Calibri", 9))
@@ -692,6 +706,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
credit_text2.setItemRotation(self.template_parameters['Source_rotate'])
credit_text2.attemptResize(self.template_parameters['Source_size'])
credit_text2.attemptMove(self.template_parameters['Source_locals'])
credit_text2.setBackgroundEnabled(True)
credit_text2.setBackgroundColor(QColor(255, 255, 255, 130))
self.layout.addLayoutItem(credit_text)
self.layout.addLayoutItem(credit_text2)
@@ -721,10 +737,13 @@ 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)
#if self.radioButton_12.isChecked() != 1:
project.layoutManager().removeLayout(existing_layout)
result = project.layoutManager().addLayout(self.layout)
if self.QMBquestion == QMessageBox.Yes:
project.layoutManager().removeLayout(existing_layout)
result = project.layoutManager().addLayout(self.layout)
else:
existing_layout = True
@@ -737,8 +756,17 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
fichier_mise_en_page = layout_name
layout_modifie = QgsProject.instance().layoutManager().layoutByName(fichier_mise_en_page)
iface.openLayoutDesigner(layout_modifie)
self.close()
try:
TryMessage = (self.QMBquestion == QMessageBox.Yes)
del self.QMBquestion
except:
TryMessage = True
print(TryMessage)
if TryMessage == True:
iface.openLayoutDesigner(layout_modifie)
self.close()
else:
self.activateWindow()
def actualisation_mise_en_page(self):
values_page = self.comboBox.currentText()
@@ -770,7 +798,6 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
bar_echelle.setUnits(QgsUnitTypes.DistanceKilometers)
bar_echelle.setUnitLabel("km")
bar_echelle.setUnitsPerSegment(round((echelle.scale()*0.04)/1000))
else:
bar_echelle.setUnits(QgsUnitTypes.DistanceMeters)
bar_echelle.setUnitLabel("m")