Plugin PyQt5 and PyQt6 compatible & CenRa_Copie bug fix
This commit is contained in:
@@ -36,7 +36,10 @@ from .canvas_editor import AutoMap_Editor
|
||||
from .style_invoke import AutoMap_Style
|
||||
from .about_form import AboutDialog
|
||||
|
||||
from PyQt5.QtCore import *
|
||||
try:
|
||||
from PyQt5.QtCore import *
|
||||
except:
|
||||
from PyQt6.QtCore import *
|
||||
|
||||
class PgAutoMap:
|
||||
def __init__(self):
|
||||
@@ -86,7 +89,7 @@ class PgAutoMap:
|
||||
self.style_dock = AutoMap_Style()
|
||||
|
||||
if os.environ['USERNAME'] == 'tlaveille' or os.environ['USERNAME'] == 'lpoulin' or os.environ['USERNAME'] == 'rclement':
|
||||
iface.addDockWidget(Qt.LeftDockWidgetArea, self.style_dock)
|
||||
iface.addDockWidget(Qt.DockWidgetArea(0x1), self.style_dock)
|
||||
|
||||
'''
|
||||
if not self.locator_filter:
|
||||
@@ -126,7 +129,7 @@ class PgAutoMap:
|
||||
About dialog
|
||||
"""
|
||||
dialog = AboutDialog(iface)
|
||||
dialog.exec_()
|
||||
dialog.exec()
|
||||
def open_help():
|
||||
""" Open the online help. """
|
||||
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
[general]
|
||||
name=CenRa_AutoMap
|
||||
qgisMinimumVersion=3.0
|
||||
supportsQt6=True
|
||||
description=CenRa_AutoMap
|
||||
version=1.7
|
||||
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
import os
|
||||
from PyQt5.QtCore import QSettings
|
||||
from collections import namedtuple
|
||||
from enum import Enum
|
||||
from functools import partial
|
||||
@@ -45,7 +44,6 @@ 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.QtWidgets import (
|
||||
QDockWidget,
|
||||
QAction,
|
||||
@@ -61,8 +59,14 @@ from qgis.PyQt.QtWidgets import (
|
||||
QVBoxLayout,
|
||||
)
|
||||
import psycopg2
|
||||
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
|
||||
|
||||
@@ -29,9 +29,6 @@
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -41,7 +38,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>453</width>
|
||||
<height>547</height>
|
||||
<height>570</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
@@ -56,7 +53,7 @@
|
||||
<property name="title">
|
||||
<string>DevLog</string>
|
||||
</property>
|
||||
<widget class="QWebView" name="viewer" native="true">
|
||||
<widget class="QTextBrowser" name="viewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
@@ -65,11 +62,6 @@
|
||||
<height>511</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="url" stdset="0">
|
||||
<url>
|
||||
<string>about:blank</string>
|
||||
</url>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
@@ -78,19 +70,12 @@
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::NoButton</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QWebView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">QtWebKitWidgets/QWebView</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user