Plugin PyQt5 and PyQt6 compatible & CenRa_Copie bug fix
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
from PyQt5.QtCore import QSettings
|
||||
|
||||
from collections import namedtuple
|
||||
from enum import Enum
|
||||
from functools import partial
|
||||
@@ -44,7 +44,7 @@ from qgis.core import (
|
||||
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt
|
||||
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie
|
||||
from qgis.PyQt.QtPrintSupport import QPrinter
|
||||
from qgis.PyQt.QtWebKitWidgets import QWebPage
|
||||
#from qgis.PyQt.QtWebKitWidgets import QWebPage
|
||||
from qgis.PyQt.QtWidgets import (
|
||||
QDialog,
|
||||
QAction,
|
||||
@@ -59,8 +59,15 @@ from qgis.PyQt.QtWidgets import (
|
||||
QTableWidgetItem,
|
||||
QVBoxLayout,
|
||||
)
|
||||
from PyQt5 import QtGui
|
||||
from PyQt5 import QtWidgets
|
||||
try:
|
||||
from PyQt5.QtCore import QSettings
|
||||
from PyQt5 import QtGui
|
||||
from PyQt5 import QtWidgets
|
||||
except:
|
||||
from PyQt6.QtCore import QSettings
|
||||
from PyQt6 import QtGui
|
||||
from PyQt6 import QtWidgets
|
||||
|
||||
from qgis.PyQt.QtXml import QDomDocument
|
||||
from qgis.utils import iface
|
||||
import glob
|
||||
@@ -121,7 +128,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||
for i in plugin_dir[1:]:
|
||||
ix = ix+1
|
||||
path = path+'/'+i
|
||||
self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);')
|
||||
#self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);')
|
||||
|
||||
self.verticalScrollBar.hide()
|
||||
self.commandLinkButton.clicked.connect(self.chargement_qpt)
|
||||
@@ -526,7 +533,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||
self.layout.addLayoutItem(title)
|
||||
titre = titre_layout_name
|
||||
title.setText(titre)
|
||||
title.setFont(QFont("Calibri", 15, QFont.Bold))
|
||||
title.setFont(QFont("Calibri", 15, False))
|
||||
title.setItemRotation(self.template_parameters['Titre_rotate'])
|
||||
title.attemptResize(self.template_parameters['Titre_size'])
|
||||
title.attemptMove(self.template_parameters['Titre_locals'])
|
||||
@@ -535,8 +542,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||
title.setBackgroundColor(QColor(255, 255, 255, 130))
|
||||
self.layout.addItem(title)
|
||||
# title.adjustSizeToText() on n'utilise plutot setFixedSize pour pouvoir centrer le titre de manière plus optimale ici
|
||||
title.setHAlign(Qt.AlignHCenter)
|
||||
title.setVAlign(Qt.AlignVCenter)
|
||||
title.setHAlign(Qt.AlignmentFlag(0x0004))
|
||||
title.setVAlign(Qt.AlignmentFlag(0x0080))
|
||||
|
||||
|
||||
## Ajout d'un sous titre à la mise en page
|
||||
@@ -554,8 +561,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||
subtitle.setBackgroundEnabled(True)
|
||||
subtitle.setBackgroundColor(QColor(255, 255, 255, 130))
|
||||
self.layout.addItem(subtitle)
|
||||
subtitle.setHAlign(Qt.AlignHCenter)
|
||||
subtitle.setVAlign(Qt.AlignVCenter)
|
||||
subtitle.setHAlign(Qt.AlignmentFlag(0x0004))
|
||||
subtitle.setVAlign(Qt.AlignmentFlag(0x0080))
|
||||
|
||||
|
||||
## Ajout du logo CEN NA en haut à gauche de la page
|
||||
@@ -712,15 +719,15 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||
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.setHAlign(Qt.AlignmentFlag(0x0002))
|
||||
credit_text.setVAlign(Qt.AlignmentFlag(0x0080))
|
||||
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))
|
||||
credit_text2.setHAlign(Qt.AlignRight)
|
||||
credit_text2.setVAlign(Qt.AlignVCenter)
|
||||
credit_text2.setHAlign(Qt.AlignmentFlag(0x0002))
|
||||
credit_text2.setVAlign(Qt.AlignmentFlag(0x0080))
|
||||
credit_text.setItemRotation(self.template_parameters['Credit_rotate'])
|
||||
credit_text.attemptResize(self.template_parameters['Credit_size'])
|
||||
credit_text.attemptMove(self.template_parameters['Credit_locals'])
|
||||
@@ -740,7 +747,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||
logo_credit.setMode(QgsLayoutItemPicture.FormatRaster)
|
||||
cur_x = self.template_parameters['Logo_2_locals'].x()
|
||||
logo_credit.attemptMove(self.template_parameters['Logo_2_locals'])
|
||||
logo_credit.setPictureAnchor(4)
|
||||
print(logo_credit.pictureAnchor())
|
||||
#logo_credit.setPictureAnchor(4)
|
||||
self.template_parameters['Logo_2_locals'].setX(cur_x+(logo_div/len_item))
|
||||
logo_credit.setFixedSize(self.template_parameters['Logo_2_size'])
|
||||
if logo_run[0] == ' ':
|
||||
@@ -760,17 +768,17 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
|
||||
if existing_layout:
|
||||
self.QMBquestion = QMessageBox()
|
||||
self.QMBquestion.setWindowTitle(u"Attention !")
|
||||
self.QMBquestion.setIcon(QMessageBox.Warning)
|
||||
self.QMBquestion.setIcon(QMessageBox.Icon.Warning)
|
||||
self.QMBquestion.setText("Mise en page existante, la mise en page va être écrasée !")
|
||||
self.QMBquestion.setStandardButtons(QMessageBox.Yes|QMessageBox.No)
|
||||
self.QMBquestion.addButton(QPushButton('Autre mise en page'),QMessageBox.AcceptRole)
|
||||
self.QMBquestion.setStandardButtons(QMessageBox.StandardButton(0x00004000)|QMessageBox.StandardButton(0x00010000))
|
||||
self.QMBquestion.addButton(QPushButton('Autre mise en page'),QMessageBox.ButtonRole(0))
|
||||
self.QMBquestion = self.QMBquestion.exec()
|
||||
|
||||
#if self.radioButton_12.isChecked() != 1:
|
||||
if self.QMBquestion == QMessageBox.Yes:
|
||||
if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
|
||||
project.layoutManager().removeLayout(existing_layout)
|
||||
result = project.layoutManager().addLayout(self.layout)
|
||||
if self.QMBquestion == QMessageBox.AcceptRole:
|
||||
elif self.QMBquestion != QMessageBox.StandardButton(0x00010000):
|
||||
LayoutCOUNT=0
|
||||
arrayManager = []
|
||||
for AddArrayManager in project.layoutManager().layouts():
|
||||
|
||||
Reference in New Issue
Block a user