Plugin PyQt5 and PyQt6 compatible & CenRa_Copie bug fix

This commit is contained in:
2025-05-19 14:00:58 +02:00
parent 3b0758ea5c
commit 3ef37aa696
37 changed files with 434 additions and 321 deletions
+6 -3
View File
@@ -36,7 +36,10 @@ from .editor import Metabase_Editor
from .about_form import MetabaseAboutDialog
#from CenRa_Metabase.issues import CenRa_Issues
from PyQt5.QtCore import *
try:
from PyQt5.QtCore import *
except:
from PyQt6.QtCore import *
class PgMetadata:
def __init__(self):
@@ -106,7 +109,7 @@ class PgMetadata:
if not self.dock:
self.dock = CenRa_Metabase()
iface.addDockWidget(Qt.RightDockWidgetArea, self.dock)
iface.addDockWidget(Qt.DockWidgetArea(0x2), self.dock)
# Open/close the dock from plugin menu
self.dock_action = QAction(icon, 'CenRa_Metabase', iface.mainWindow())
@@ -157,7 +160,7 @@ class PgMetadata:
About dialog
"""
dialog = MetabaseAboutDialog(iface)
dialog.exec_()
dialog.exec()
def open_help():
""" Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
+1 -1
View File
@@ -12,7 +12,7 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
os.path.join(
str(Path(__file__).resolve().parent),
'tools/ui',
'CenRa_Metabase_about_form.ui'
'CenRa_about_form.ui'
)
)
+8 -8
View File
@@ -27,7 +27,7 @@ from qgis.core import (
from qgis.PyQt.QtCore import QLocale, QUrl
from qgis.PyQt.QtGui import QDesktopServices, QIcon
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,
@@ -84,8 +84,8 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
self.current_datasource_uri = None
self.current_connection = None
self.viewer.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.viewer.page().linkClicked.connect(self.open_link)
#self.viewer.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
#self.viewer.page().linkClicked.connect(self.open_link)
# Help button
self.external_help.setText('')
@@ -101,7 +101,7 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
# Settings menu
self.config.setAutoRaise(True)
#self.config.setToolTip(tr("Settings"))
self.config.setPopupMode(QToolButton.InstantPopup)
self.config.setPopupMode(QToolButton.ToolButtonPopupMode(2))
self.config.setIcon(QgsApplication.getThemeIcon("/mActionOptions.svg"))
self.auto_open_dock_action = QAction(
@@ -119,7 +119,7 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
# Setting PDF/HTML menu
self.save_button.setAutoRaise(True)
#self.save_button.setToolTip(tr("Save metadata"))
self.save_button.setPopupMode(QToolButton.InstantPopup)
self.save_button.setPopupMode(QToolButton.ToolButtonPopupMode(2))
self.save_button.setIcon(QIcon(QgsApplication.iconPath('mActionFileSave.svg')))
self.save_as_pdf = QAction(
@@ -191,8 +191,8 @@ class CenRa_Metabase(QDockWidget, DOCK_CLASS):
if output_format == OutputFormats.PDF:
printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setPageMargins(20, 20, 20, 20, QPrinter.Millimeter)
printer.setOutputFormat(QPrinter.OutputFormat(1))
#printer.setPageMargins(20,20,20,20,QPrinter.Unit(0))
printer.setOutputFileName(output_file_path)
self.viewer.print(printer)
iface.messageBar().pushSuccess(
@@ -357,7 +357,7 @@ publisher+
# It must be a file, even if it does not exist on the file system.
base_url = QUrl.fromLocalFile(resources_path('images', 'must_be_a_file.png'))
self.viewer.setHtml(html, base_url)
self.viewer.setHtml(html)#, base_url)
def ce_trouve_dans_psql(self,layer):
try:
+2 -2
View File
@@ -20,11 +20,11 @@ from qgis.core import (
QgsGeometry,
QgsWkbTypes,
)
from PyQt5 import QtGui
from qgis.PyQt import QtGui
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime
from qgis.PyQt.QtGui import QDesktopServices, QIcon
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,
+1
View File
@@ -5,6 +5,7 @@
[general]
name=CenRa_Metabase
qgisMinimumVersion=3.0
supportsQt6=True
description=CenRa_METABASE
version=0.2.3
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
@@ -64,24 +64,11 @@
</layout>
</item>
<item>
<widget class="QWebView" name="viewer" native="true">
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
<widget class="QTextBrowser" name="viewer"/>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Metabase</string>
<string>Journal des modifications</string>
</property>
<property name="windowIcon">
<iconset>
@@ -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>