From e4dcabaa1c21645718a4ab237603bbdbd7d6e8e9 Mon Sep 17 00:00:00 2001 From: Fertuesta25 Date: Tue, 11 Aug 2026 09:26:28 -0500 Subject: [PATCH] Add Qt6/QGIS 4 compatibility Se realizaron los cambios con apoyo de Claude --- cmd/qad_dimstyle_cmd.py | 2 +- cmd/qad_dsettings_cmd.py | 2 +- cmd/qad_generic_cmd.py | 2 +- cmd/qad_options_cmd.py | 2 +- cmd/qad_pedit_cmd.py | 2 +- metadata.txt | 7 +- qad.py | 60 ++++++------- qad_cacheareas.py | 4 +- qad_commands.py | 4 +- qad_dimensioninput_settings_ui.py | 4 +- qad_dimstyle_details_dlg.py | 6 +- qad_dimstyle_details_ui.py | 2 +- qad_dimstyle_diff_dlg.py | 17 ++-- qad_dimstyle_diff_ui.py | 8 +- qad_dimstyle_dlg.py | 20 ++--- qad_dimstyle_new_dlg.py | 2 +- qad_dimstyle_new_ui.py | 2 +- qad_dimstyle_ui.py | 4 +- qad_dsettings_dlg.py | 82 ++++++++--------- qad_dsettings_rc.py | 2 +- qad_dsettings_ui.py | 18 ++-- qad_dynamicinput.py | 99 ++++++++++++--------- qad_getpoint.py | 32 +++---- qad_gripcolor_ui.py | 6 +- qad_maptool.py | 14 +-- qad_multi_geom.py | 6 +- qad_options_dlg.py | 71 ++++++++------- qad_options_ui.py | 20 ++--- qad_pointerinput_settings_ui.py | 4 +- qad_rc.py | 2 +- qad_rightclick_dlg.py | 6 +- qad_rightclick_ui.py | 2 +- qad_rubberband.py | 7 +- qad_shortcuts.py | 10 +-- qad_snappointsdisplaymanager.py | 13 ++- qad_textwindow.py | 141 ++++++++++++++++-------------- qad_tooltip_appearance_ui.py | 6 +- qad_ui_textwindow.py | 8 +- qad_utils.py | 21 +++-- qad_windowcolor_dlg.py | 28 +++--- qad_windowcolor_ui.py | 2 +- 41 files changed, 389 insertions(+), 361 deletions(-) diff --git a/cmd/qad_dimstyle_cmd.py b/cmd/qad_dimstyle_cmd.py index b9a39b55..96009be7 100644 --- a/cmd/qad_dimstyle_cmd.py +++ b/cmd/qad_dimstyle_cmd.py @@ -66,5 +66,5 @@ def run(self, msgMapTool = False, msg = None): self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n")) return True # fine comando Form = QadDIMSTYLEDialog(self.plugIn) - Form.exec_() + Form.exec() return True \ No newline at end of file diff --git a/cmd/qad_dsettings_cmd.py b/cmd/qad_dsettings_cmd.py index 05452a1f..cf3727a8 100644 --- a/cmd/qad_dsettings_cmd.py +++ b/cmd/qad_dsettings_cmd.py @@ -62,5 +62,5 @@ def __init__(self, plugIn): def run(self, msgMapTool = False, msg = None): Form = QadDSETTINGSDialog(self.plugIn) - Form.exec_() + Form.exec() return True \ No newline at end of file diff --git a/cmd/qad_generic_cmd.py b/cmd/qad_generic_cmd.py index cd35b480..7c76e68a 100644 --- a/cmd/qad_generic_cmd.py +++ b/cmd/qad_generic_cmd.py @@ -706,7 +706,7 @@ def setSnapTypeToDisableByPopupMenu(self): def showDSettingsByPopUpMenu(self): d = QadDSETTINGSDialog(self.plugIn) - d.exec_() + d.exec() self.plugIn.refreshCommandMapToolSnapType() self.plugIn.refreshCommandMapToolAutoSnap() self.plugIn.refreshCommandMapToolDynamicInput() diff --git a/cmd/qad_options_cmd.py b/cmd/qad_options_cmd.py index 788a187f..40f5e009 100644 --- a/cmd/qad_options_cmd.py +++ b/cmd/qad_options_cmd.py @@ -60,5 +60,5 @@ def __init__(self, plugIn): def run(self, msgMapTool = False, msg = None): Form = QadOPTIONSDialog(self.plugIn) - Form.exec_() + Form.exec() return True \ No newline at end of file diff --git a/cmd/qad_pedit_cmd.py b/cmd/qad_pedit_cmd.py index 5e6031e9..03287586 100644 --- a/cmd/qad_pedit_cmd.py +++ b/cmd/qad_pedit_cmd.py @@ -348,7 +348,7 @@ def join(self): vectorLayer = createMemoryLayer("QAD_SelfJoinLines", "LineString", crs) provider = vectorLayer.dataProvider() - provider.addAttributes([QgsField('index', QMetaType.Int, 'Int')]) + provider.addAttributes([QgsField('index', QMetaType.Type.Int, 'Int')]) vectorLayer.updateFields() if vectorLayer.startEditing() == False: diff --git a/metadata.txt b/metadata.txt index b8b82a49..bab640a1 100644 --- a/metadata.txt +++ b/metadata.txt @@ -11,10 +11,11 @@ name=QAD email=gam17@riseup.net author=gam17 -qgisMinimumVersion=3.40 +qgisMinimumVersion=3.40 +supportsQt6=True description=Quantum Aided Design: cad like commands in QGIS about=Quantum Aided Design: cad like commands in QGIS -version=3.0.8 +version=3.0.9 tracker=https://github.com/gam17/QAD/issues repository=https://github.com/gam17/QAD @@ -35,6 +36,6 @@ experimental=False # deprecated flag (applies to the whole plugin, not just a single version deprecated=False -qgisMaximumVersion=3.99 +qgisMaximumVersion=4.99 \ No newline at end of file diff --git a/qad.py b/qad.py index eb17bcf7..4c912f85 100644 --- a/qad.py +++ b/qad.py @@ -181,7 +181,7 @@ class Qad(QObject): # version # ============================================================================ def version(self): - return "3.0.8" # allinea con metadata.txt alla sez [general] voce "version" + return "3.0.9" # allinea con metadata.txt alla sez [general] voce "version" def setLastPointAndSegmentAng(self, point, segmentAng = None): @@ -462,35 +462,35 @@ def sendKeyToCurrentMapTool(self, keyEvent): mt.keyPressEvent(keyEvent) def send_a_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.NoModifier, "a")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier, "a")) def send_A_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.NoModifier, "A")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier, "A")) def send_c_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_C, Qt.NoModifier, "c")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_C, Qt.KeyboardModifier.NoModifier, "c")) def send_C_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_C, Qt.NoModifier, "C")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_C, Qt.KeyboardModifier.NoModifier, "C")) def send_d_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_D, Qt.NoModifier, "d")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_D, Qt.KeyboardModifier.NoModifier, "d")) def send_D_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_D, Qt.NoModifier, "D")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_D, Qt.KeyboardModifier.NoModifier, "D")) def send_p_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_P, Qt.NoModifier, "p")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_P, Qt.KeyboardModifier.NoModifier, "p")) def send_P_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_P, Qt.NoModifier, "P")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_P, Qt.KeyboardModifier.NoModifier, "P")) def send_x_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_X, Qt.NoModifier, "x")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_X, Qt.KeyboardModifier.NoModifier, "x")) def send_X_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_X, Qt.NoModifier, "X")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_X, Qt.KeyboardModifier.NoModifier, "X")) def send_y_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Y, Qt.NoModifier, "y")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Y, Qt.KeyboardModifier.NoModifier, "y")) def send_Y_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Y, Qt.NoModifier, "Y")) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Y, Qt.KeyboardModifier.NoModifier, "Y")) def send_F3_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_F3, Qt.NoModifier)) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_F3, Qt.KeyboardModifier.NoModifier)) def send_Backspace_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Backspace, Qt.NoModifier)) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Backspace, Qt.KeyboardModifier.NoModifier)) def send_Delete_toTxtWindow(self): - self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier)) + self.keyPressEvent(QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Delete, Qt.KeyboardModifier.NoModifier)) # ============================================================================ @@ -1274,7 +1274,7 @@ def createDimMenu(self): def createHelpToolButton(self): helpToolButton = QToolButton(self.toolBar) - helpToolButton.setPopupMode(QToolButton.MenuButtonPopup) + helpToolButton.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup) helpToolButton.setMenu(self.helpMenu) helpToolButton.setDefaultAction(self.helpMenu.actions()[0]) # prima voce di menu helpToolButton.triggered.connect(self.helpToolButtonTriggered) @@ -1285,7 +1285,7 @@ def helpToolButtonTriggered(self, action): def createArcToolButton(self): arcToolButton = QToolButton(self.toolBar) - arcToolButton.setPopupMode(QToolButton.MenuButtonPopup) + arcToolButton.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup) arcToolButton.setMenu(self.arcMenu) arcToolButton.setDefaultAction(self.arcMenu.actions()[0]) # prima voce di menu arcToolButton.triggered.connect(self.arcToolButtonTriggered) @@ -1296,7 +1296,7 @@ def arcToolButtonTriggered(self, action): def createArrayToolButton(self): arrayToolButton = QToolButton(self.toolBar) - arrayToolButton.setPopupMode(QToolButton.MenuButtonPopup) + arrayToolButton.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup) arrayToolButton.setMenu(self.arrayMenu) arrayToolButton.setDefaultAction(self.arrayMenu.actions()[0]) # prima voce di menu arrayToolButton.triggered.connect(self.arrayToolButtonTriggered) @@ -1307,7 +1307,7 @@ def arrayToolButtonTriggered(self, action): def createBreakToolButton(self): breakToolButton = QToolButton(self.toolBar) - breakToolButton.setPopupMode(QToolButton.MenuButtonPopup) + breakToolButton.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup) breakToolButton.setMenu(self.breakMenu) breakToolButton.setDefaultAction(self.breakMenu.actions()[0]) # prima voce di menu breakToolButton.triggered.connect(self.breakToolButtonTriggered) @@ -1318,7 +1318,7 @@ def breakToolButtonTriggered(self, action): def createCircleToolButton(self): circleToolButton = QToolButton(self.toolBar) - circleToolButton.setPopupMode(QToolButton.MenuButtonPopup) + circleToolButton.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup) circleToolButton.setMenu(self.circleMenu) circleToolButton.setDefaultAction(self.circleMenu.actions()[0]) # prima voce di menu circleToolButton.triggered.connect(self.circleToolButtonTriggered) @@ -1329,7 +1329,7 @@ def circleToolButtonTriggered(self, action): def createEllipseToolButton(self): ellipseToolButton = QToolButton(self.toolBar) - ellipseToolButton.setPopupMode(QToolButton.MenuButtonPopup) + ellipseToolButton.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup) ellipseToolButton.setMenu(self.ellipseMenu) ellipseToolButton.setDefaultAction(self.ellipseMenu.actions()[0]) # prima voce di menu ellipseToolButton.triggered.connect(self.ellipseToolButtonTriggered) @@ -2173,33 +2173,33 @@ def shortCutManagement(self, e): # ritorna True se la funzione li ha gestiti altrimenti ritorna False e quindi l'evento keyPressed va gestito altrove # Se é stato premuto il tasto CTRL (o META) + 9 oppure il tasto F2 - if (((e.modifiers() & Qt.ControlModifier) or (e.modifiers() & Qt.MetaModifier)) and e.key() == Qt.Key_9) or \ - e.key() == Qt.Key_F2: + if (((e.modifiers() & Qt.KeyboardModifier.ControlModifier) or (e.modifiers() & Qt.KeyboardModifier.MetaModifier)) and e.key() == Qt.Key.Key_9) or \ + e.key() == Qt.Key.Key_F2: # Accendo o spengo la finestra di testo if self.TextWindow is not None: self.TextWindow.toggleShow() return True # Se é stato premuto il tasto F3 - if e.key() == Qt.Key_F3: + if e.key() == Qt.Key.Key_F3: # Attivo o disattivo lo snap self.toggleOsMode() return True # Se é stato premuto il tasto F8 - if e.key() == Qt.Key_F8: + if e.key() == Qt.Key.Key_F8: # Attivo o disattivo la modalità ortogonale self.toggleOrthoMode() return True # Se é stato premuto il tasto F12 - if e.key() == Qt.Key_F12: + if e.key() == Qt.Key.Key_F12: # Attivo o disattivo l'input dinamico self.toggleDynamicInput() return True # Se é stato premuto il tasto ESC - if e.key() == Qt.Key_Escape: + if e.key() == Qt.Key.Key_Escape: # interrompo il comando corrente self.abortCommand() self.clearCurrentObjsSelection() @@ -2209,13 +2209,13 @@ def shortCutManagement(self, e): return True # Se é stato premuto il tasto F10 - if e.key() == Qt.Key_F10: + if e.key() == Qt.Key.Key_F10: # Attivo o disattivo il modo polare self.togglePolarMode() return True # Se é stato premuto il tasto F11 - if e.key() == Qt.Key_F11: + if e.key() == Qt.Key.Key_F11: # Attivo o disattivo il puntamento snap ad oggetto self.toggleObjectSnapTracking() return True diff --git a/qad_cacheareas.py b/qad_cacheareas.py index 05d892f9..27a7d0d6 100644 --- a/qad_cacheareas.py +++ b/qad_cacheareas.py @@ -63,7 +63,7 @@ def __create_internal_layer(self): self.cacheLayer = createMemoryLayer("QadLayerCacheArea", getStrLayerGeomType(self.layer), self.layer.crs()) provider = self.cacheLayer.dataProvider() - provider.addAttributes([QgsField("index", QMetaType.Int, "Int")]) + provider.addAttributes([QgsField("index", QMetaType.Type.Int, "Int")]) self.cacheLayer.updateFields() if provider.capabilities() & QgsVectorDataProvider.CreateSpatialIndex: @@ -448,4 +448,4 @@ def getStrLayerGeomType(layer): elif gType == QgsWkbTypes.PolygonGeometry: return "MultiPolygon" - return "NoGeometry" \ No newline at end of file + return "NoGeometry" \ No newline at end of file diff --git a/qad_commands.py b/qad_commands.py index 1eaf85b0..2284eb23 100644 --- a/qad_commands.py +++ b/qad_commands.py @@ -248,7 +248,7 @@ def run(self, command, param = None): if command != QadMsg.translate("Command_list", "SUPPORTERS"): if incrementDailyCmdCounter() > self.plugIn.maxDailyCmdCounter: if QMessageBox.question(None, "QAD", QadMsg.translate("QAD", "QAD lets you run 200 commands per day free of popups. Donations help us to fund software development, documentation, translation and bug-fixing efforts. Do you want to donate ?"), \ - QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes: + QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No) == QMessageBox.StandardButton.Yes: command = "_SUPPORTERS"; # if QMessageBox.critical(None, "QAD", QadMsg.translate("QAD", "You have run out of daily commands available for this version of QAD, your reasonable donation will allow us to adapt the product to your needs. Do you want to donate ?"), \ # QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes: @@ -315,7 +315,7 @@ def runMacro(self, args): if args[0] != QadMsg.translate("Command_list", "SUPPORTERS"): if incrementDailyCmdCounter() > self.plugIn.maxDailyCmdCounter: if QMessageBox.question(None, "QAD", QadMsg.translate("QAD", "QAD lets you run 200 commands per day free of popups. Donations help us to fund software development, documentation, translation and bug-fixing efforts. Do you want to donate ?"), \ - QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes: + QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No) == QMessageBox.StandardButton.Yes: args[0] = "_SUPPORTERS"; # if QMessageBox.critical(None, "QAD", QadMsg.translate("QAD", "You have run out of daily commands available for this version of QAD, your reasonable donation will allow us to adapt the product to your needs. Do you want to donate ?"), \ # QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes: diff --git a/qad_dimensioninput_settings_ui.py b/qad_dimensioninput_settings_ui.py index 417d0e85..2a85d7ec 100644 --- a/qad_dimensioninput_settings_ui.py +++ b/qad_dimensioninput_settings_ui.py @@ -8,14 +8,14 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_DimInput_Settings_Dialog(object): def setupUi(self, DimInput_Settings_Dialog): DimInput_Settings_Dialog.setObjectName("DimInput_Settings_Dialog") DimInput_Settings_Dialog.resize(400, 346) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(DimInput_Settings_Dialog.sizePolicy().hasHeightForWidth()) diff --git a/qad_dimstyle_details_dlg.py b/qad_dimstyle_details_dlg.py index 214f0fca..918ba624 100644 --- a/qad_dimstyle_details_dlg.py +++ b/qad_dimstyle_details_dlg.py @@ -847,8 +847,8 @@ def accept(self): if errMsg is not None: errMsg += QadMsg.translate("DimStyle_Details_Dialog", "\nDo you want to accepts these settings ?") res = QMessageBox.question(self, QadMsg.getQADTitle(), errMsg, \ - QMessageBox.Yes | QMessageBox.No) - if res == QMessageBox.No: + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) + if res == QMessageBox.StandardButton.No: return self.plugIn.dimStyleLastUsedTabIndex = self.tabWidget.currentIndex() @@ -862,7 +862,7 @@ class QadPreviewDim(QgsMapCanvas): def __init__(self, parent, plugIn): QgsMapCanvas.__init__(self, parent) self.plugIn = plugIn - self.setAttribute(Qt.WA_DeleteOnClose) + self.setAttribute(Qt.WidgetAttribute.WA_DeleteOnClose) self.iface = self.plugIn.iface self.layerId2canvasLayer = {} diff --git a/qad_dimstyle_details_ui.py b/qad_dimstyle_details_ui.py index d4bbcc07..7d052cb4 100644 --- a/qad_dimstyle_details_ui.py +++ b/qad_dimstyle_details_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_DimStyle_Details_Dialog(object): diff --git a/qad_dimstyle_diff_dlg.py b/qad_dimstyle_diff_dlg.py index 50f04cc8..311fdcfc 100644 --- a/qad_dimstyle_diff_dlg.py +++ b/qad_dimstyle_diff_dlg.py @@ -118,8 +118,8 @@ def showAllProps(self, dimStyle): self.tableWidget.sortItems(0) - self.tableWidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents) - self.tableWidget.horizontalHeader().setSectionResizeMode(1, QHeaderView.Interactive) + self.tableWidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.ResizeToContents) + self.tableWidget.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Interactive) self.msg.setText(QadMsg.translate("DimStyle_Diff_Dialog", "All properties of dimension style: ") + dimStyle.name) @@ -156,9 +156,9 @@ def showDiffProps(self, dimStyle1, dimStyle2): self.tableWidget.sortItems(0) - self.tableWidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents) - self.tableWidget.horizontalHeader().setSectionResizeMode(1, QHeaderView.Interactive) - self.tableWidget.horizontalHeader().setSectionResizeMode(2, QHeaderView.Interactive) + self.tableWidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.ResizeToContents) + self.tableWidget.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Interactive) + self.tableWidget.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.Interactive) self.msg.setText(QadMsg.translate("DimStyle_Diff_Dialog", "Found {0} differences: ").format(str(self.count))) @@ -167,16 +167,16 @@ def insertProp(self, description, val1, val2 = None): self.tableWidget.insertRow(self.count) item = QTableWidgetItem(unicode(description)) - item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) + item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable) self.tableWidget.setItem(self.count, 0, item) item = QTableWidgetItem(unicode(val1)) - item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) + item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable) self.tableWidget.setItem(self.count, 1, item) if val2 is not None: item = QTableWidgetItem(unicode(val2)) - item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) + item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable) self.tableWidget.setItem(self.count, 2, item) self.count += 1 @@ -215,4 +215,3 @@ def copyToClipboard(self): buffer += '\n' # vado a capo QApplication.clipboard().setText(buffer) - \ No newline at end of file diff --git a/qad_dimstyle_diff_ui.py b/qad_dimstyle_diff_ui.py index b8d499d7..7a71542f 100644 --- a/qad_dimstyle_diff_ui.py +++ b/qad_dimstyle_diff_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_DimStyle_Diff_Dialog(object): @@ -31,8 +31,8 @@ def setupUi(self, DimStyle_Diff_Dialog): self.dimStyle2.setObjectName("dimStyle2") self.line = QtWidgets.QFrame(DimStyle_Diff_Dialog) self.line.setGeometry(QtCore.QRect(10, 70, 421, 16)) - self.line.setFrameShape(QtWidgets.QFrame.HLine) - self.line.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line.setFrameShape(QtWidgets.QFrame.Shape.HLine) + self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) self.line.setObjectName("line") self.msg = QtWidgets.QLabel(DimStyle_Diff_Dialog) self.msg.setGeometry(QtCore.QRect(10, 80, 381, 21)) @@ -58,7 +58,7 @@ def setupUi(self, DimStyle_Diff_Dialog): self.copyButton.setGeometry(QtCore.QRect(404, 80, 31, 23)) self.copyButton.setText("") icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/plugins/qad/icons/copy.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(":/plugins/qad/icons/copy.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) self.copyButton.setIcon(icon) self.copyButton.setObjectName("copyButton") diff --git a/qad_dimstyle_dlg.py b/qad_dimstyle_dlg.py index 5832f2e6..fabd7c62 100644 --- a/qad_dimstyle_dlg.py +++ b/qad_dimstyle_dlg.py @@ -56,7 +56,7 @@ def __init__(self, plugIn): self.retranslateUi(self) # aggiungo alcune traduzioni personalizzate self.setWindowTitle(QadMsg.getQADTitle() + " - " + self.windowTitle()) - self.dimStyleList.setContextMenuPolicy(Qt.CustomContextMenu) + self.dimStyleList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) # aggiungo il canvans di preview della quota chiamato QadPreviewDim # che eredita la posizione di previewDummy (che viene nascosto) @@ -108,7 +108,7 @@ def init(self): if item is not None: index = self.dimStyleList.model().indexFromItem(item) - self.dimStyleList.selectionModel().setCurrentIndex(index, QItemSelectionModel.SelectCurrent) + self.dimStyleList.selectionModel().setCurrentIndex(index, QItemSelectionModel.SelectionFlag.SelectCurrent) def retranslateUi(self, DimStyle_Dialog): @@ -157,11 +157,11 @@ def updDescrSelectedDimStyle(self): title = QadMsg.translate("DimStyle_Dialog", "Editing dimension style description: ") + self.selectedDimStyle.name inputDlg = QInputDialog(self) inputDlg.setWindowTitle(QadMsg.getQADTitle() + " - " + title) - inputDlg.setInputMode(QInputDialog.TextInput) + inputDlg.setInputMode(QInputDialog.InputMode.TextInput) inputDlg.setLabelText(QadMsg.translate("DimStyle_Dialog", "New description:")) inputDlg.setTextValue(self.selectedDimStyle.description) inputDlg.resize(600,100) - if inputDlg.exec_(): + if inputDlg.exec(): self.selectedDimStyle.description = inputDlg.textValue() self.selectedDimStyle.save() self.init() @@ -171,8 +171,8 @@ def delSelectedDimStyle(self): return msg = QadMsg.translate("DimStyle_Dialog", "Remove dimension style {0} ?").format(self.selectedDimStyle.name) res = QMessageBox.question(self, QadMsg.getQADTitle(), msg, \ - QMessageBox.Yes | QMessageBox.No) - if res == QMessageBox.Yes: + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) + if res == QMessageBox.StandardButton.Yes: if QadDimStyles.removeDimStyle(self.selectedDimStyle.name, True) == False: QMessageBox.critical(self, QadMsg.getQADTitle(), \ QadMsg.translate("DimStyle_Dialog", "Dimension style not removed.")) @@ -184,7 +184,7 @@ def createNewStyle(self): self.previewDim.eraseDim() Form = QadDIMSTYLE_NEW_Dialog(self.plugIn, self, self.selectedDimStyle.name if self.selectedDimStyle is not None else None) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: Form.dimStyle.path = "" QadDimStyles.addDimStyle(Form.dimStyle, True) self.selectedDimStyle = QadDimStyles.findDimStyle(Form.dimStyle.name) @@ -202,7 +202,7 @@ def modStyle(self): Form = QadDIMSTYLE_DETAILS_Dialog(self.plugIn, self, self.selectedDimStyle) title = QadMsg.translate("DimStyle_Dialog", "Modify dimension style: ") + self.selectedDimStyle.name Form.setWindowTitle(QadMsg.getQADTitle() + " - " + title) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: self.selectedDimStyle.set(Form.dimStyle) self.selectedDimStyle.save() self.init() @@ -219,7 +219,7 @@ def temporaryModStyle(self): Form = QadDIMSTYLE_DETAILS_Dialog(self.plugIn, self, self.selectedDimStyle) title = QadMsg.translate("DimStyle_Dialog", "Set temporary overrides to dimension style: ") + self.selectedDimStyle.name Form.setWindowTitle(QadMsg.getQADTitle() + " - " + title) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: self.selectedDimStyle.set(Form.dimStyle) self.init() @@ -230,7 +230,7 @@ def showDiffBetweenStyles(self): if self.selectedDimStyle is None: return Form = QadDIMSTYLE_DIFF_Dialog(self.plugIn, self, self.selectedDimStyle.name) - Form.exec_() + Form.exec() # ============================================================================ diff --git a/qad_dimstyle_new_dlg.py b/qad_dimstyle_new_dlg.py index 85377b4a..454569a5 100644 --- a/qad_dimstyle_new_dlg.py +++ b/qad_dimstyle_new_dlg.py @@ -88,7 +88,7 @@ def ButtonBOX_continue(self): title = QadMsg.translate("DimStyle_Dialog", "New dimension style: ") + self.newDimStyle.name Form.setWindowTitle(QadMsg.getQADTitle() + " - " + title) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: self.dimStyle = Form.dimStyle QDialog.accept(self) else: diff --git a/qad_dimstyle_new_ui.py b/qad_dimstyle_new_ui.py index e4e81ce9..5e5b8429 100644 --- a/qad_dimstyle_new_ui.py +++ b/qad_dimstyle_new_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_DimStyle_New_Dialog(object): diff --git a/qad_dimstyle_ui.py b/qad_dimstyle_ui.py index 66e41f21..937df6f0 100644 --- a/qad_dimstyle_ui.py +++ b/qad_dimstyle_ui.py @@ -8,13 +8,13 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_DimStyle_Dialog(object): def setupUi(self, DimStyle_Dialog): DimStyle_Dialog.setObjectName("DimStyle_Dialog") - DimStyle_Dialog.setWindowModality(QtCore.Qt.WindowModal) + DimStyle_Dialog.setWindowModality(QtCore.Qt.WindowModality.WindowModal) DimStyle_Dialog.resize(539, 341) DimStyle_Dialog.setMinimumSize(QtCore.QSize(539, 341)) DimStyle_Dialog.setMaximumSize(QtCore.QSize(539, 341)) diff --git a/qad_dsettings_dlg.py b/qad_dsettings_dlg.py index 39d2a923..f97245b0 100644 --- a/qad_dsettings_dlg.py +++ b/qad_dsettings_dlg.py @@ -123,39 +123,39 @@ def init_osnap_tab(self): def accept_osnap_tab(self): # Memorizzo il valore di OSMODE newOSMODE = 0 - if self.checkBox_CENP.checkState() == Qt.Checked: + if self.checkBox_CENP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.CEN - if self.checkBox_ENDP.checkState() == Qt.Checked: + if self.checkBox_ENDP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.END - if self.checkBox_END_PLINE.checkState() == Qt.Checked: + if self.checkBox_END_PLINE.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.END_PLINE - if self.checkBox_EXTP.checkState() == Qt.Checked: + if self.checkBox_EXTP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.EXT - if self.checkBox_INTP.checkState() == Qt.Checked: + if self.checkBox_INTP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.INT - if self.checkBox_MIDP.checkState() == Qt.Checked: + if self.checkBox_MIDP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.MID - if self.checkBox_NODP.checkState() == Qt.Checked: + if self.checkBox_NODP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.NOD - if self.checkBox_QUADP.checkState() == Qt.Checked: + if self.checkBox_QUADP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.QUA #if self.checkBox_INSP.checkState() == Qt.Checked: # newOSMODE = newOSMODE | QadSnapTypeEnum.INS #if self.checkBox_INTAPP.checkState() == Qt.Checked: # newOSMODE = newOSMODE | QadSnapTypeEnum.APP - if self.checkBox_NEARP.checkState() == Qt.Checked: + if self.checkBox_NEARP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.NEA - if self.checkBox_PARALP.checkState() == Qt.Checked: + if self.checkBox_PARALP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.PAR - if self.checkBox_PERP.checkState() == Qt.Checked: + if self.checkBox_PERP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.PER - if self.checkBox_PROGRESP.checkState() == Qt.Checked: + if self.checkBox_PROGRESP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.PR - if self.checkBox_TANP.checkState() == Qt.Checked: + if self.checkBox_TANP.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.TAN - if self.checkBox_EXT_INT.checkState() == Qt.Checked: + if self.checkBox_EXT_INT.checkState() == Qt.CheckState.Checked: newOSMODE = newOSMODE | QadSnapTypeEnum.EXT_INT - if self.checkBox_IsOsnapON.checkState() == Qt.Unchecked: + if self.checkBox_IsOsnapON.checkState() == Qt.CheckState.Unchecked: newOSMODE = newOSMODE | QadSnapTypeEnum.DISABLE QadVariables.set(QadMsg.translate("Environment variables", "OSMODE"), newOSMODE) @@ -166,7 +166,7 @@ def accept_osnap_tab(self): # Memorizzo il valore di AUTOSNAP AutoSnap = QadVariables.get(QadMsg.translate("Environment variables", "AUTOSNAP")) - if self.checkBox_ObjectSnapTracking.checkState() == Qt.Checked: + if self.checkBox_ObjectSnapTracking.checkState() == Qt.CheckState.Checked: AutoSnap = AutoSnap | QadAUTOSNAPEnum.OBJ_SNAP_TRACKING elif AutoSnap & QadAUTOSNAPEnum.OBJ_SNAP_TRACKING: AutoSnap = AutoSnap - QadAUTOSNAPEnum.OBJ_SNAP_TRACKING @@ -267,7 +267,7 @@ def init_polar_tab(self): def accept_polar_tab(self): # Memorizzo il valore di AUTOSNAP AutoSnap = QadVariables.get(QadMsg.translate("Environment variables", "AUTOSNAP")) - if self.checkBox_PolarPickPoint.checkState() == Qt.Checked: + if self.checkBox_PolarPickPoint.checkState() == Qt.CheckState.Checked: AutoSnap = AutoSnap | QadAUTOSNAPEnum.POLAR_TRACKING elif AutoSnap & QadAUTOSNAPEnum.POLAR_TRACKING: AutoSnap = AutoSnap - QadAUTOSNAPEnum.POLAR_TRACKING @@ -311,7 +311,7 @@ def comboBox_increment_angle_Validation(self): def CheckAdditionalAngles(self): - if self.checkBox_AdditionaltAngles.checkState() == Qt.Checked: + if self.checkBox_AdditionaltAngles.checkState() == Qt.CheckState.Checked: self.pushButton_DelAngle.setEnabled(True) self.listView_AdditionalAngles.setEnabled(True) else: @@ -381,25 +381,25 @@ def init_dynamic_input_tab(self): def Button_DI_DimensionInputSettings_Pressed(self): Form = QadDIMINPUTDialog(self.plugIn, self) - Form.exec_() + Form.exec() def Button_DI_PointerInputSettings_Pressed(self): Form = QadPOINTERINPUTDialog(self.plugIn, self) - Form.exec_() + Form.exec() def Button_DI_TootipAppearance_Pressed(self): Form = QadTOOLTIPAPPEARANCEDialog(self.plugIn, self) - Form.exec_() + Form.exec() def accept_dynamic_input_tab(self): # Memorizzo il valore di DYNMODE = Attiva e disattiva le funzioni di input dinamico dynMode = 0 - if self.checkBox_DI_EnableInputPointer.checkState() == Qt.Checked: + if self.checkBox_DI_EnableInputPointer.checkState() == Qt.CheckState.Checked: dynMode = dynMode + 1 - if self.checkBox_DI_EnableDimPointer.checkState() == Qt.Checked: + if self.checkBox_DI_EnableDimPointer.checkState() == Qt.CheckState.Checked: dynMode = dynMode + 2 if QadVariables.get(QadMsg.translate("Environment variables", "DYNMODE")) < 0: @@ -407,7 +407,7 @@ def accept_dynamic_input_tab(self): QadVariables.set(QadMsg.translate("Environment variables", "DYNMODE"), dynMode) # Memorizzo il valore di DYNPROMPT = Controlla la visualizzazione dei messaggi di richiesta nelle descrizioni di input dinamico - dynPrompt = 1 if self.checkBox_DI_ShowPrompt.checkState() == Qt.Checked else 0 + dynPrompt = 1 if self.checkBox_DI_ShowPrompt.checkState() == Qt.CheckState.Checked else 0 QadVariables.set(QadMsg.translate("Environment variables", "DYNPROMPT"), dynPrompt) @@ -415,7 +415,7 @@ def accept_dynamic_input_tab(self): # Funzioni generiche def eventFilter(self, obj, event): if event is not None: - if event.type() == QEvent.FocusOut: + if event.type() == QEvent.Type.FocusOut: if obj == self.lineEdit_ProgrDistance: return not self.lineEdit_ProgrDistance_Validation() elif obj == self.comboBox_increment_angle: @@ -520,13 +520,13 @@ def ButtonBOX_Accepted(self): # Memorizzo il valore di DYNDIGRIP = Controlla la visualizzazione delle quote dinamiche durante la modifica dello stiramento dei grip dynDiGrip = 0 - if self.checkResultingDim.checkState() == Qt.Checked: + if self.checkResultingDim.checkState() == Qt.CheckState.Checked: dynDiGrip = dynDiGrip + 1 - if self.checkLengthChange.checkState() == Qt.Checked: + if self.checkLengthChange.checkState() == Qt.CheckState.Checked: dynDiGrip = dynDiGrip + 2 - if self.checkAbsoluteAngle.checkState() == Qt.Checked: + if self.checkAbsoluteAngle.checkState() == Qt.CheckState.Checked: dynDiGrip = dynDiGrip + 4 - if self.checkAngleChange.checkState() == Qt.Checked: + if self.checkAngleChange.checkState() == Qt.CheckState.Checked: dynDiGrip = dynDiGrip + 8 QadVariables.set(QadMsg.translate("Environment variables", "DYNDIGRIP"), dynDiGrip) @@ -718,7 +718,7 @@ def lineEdit_TOOLTIPTRANSPARENCY_Validation(self): def eventFilter(self, obj, event): if event is not None: - if event.type() == QEvent.FocusOut: + if event.type() == QEvent.Type.FocusOut: if obj == self.edit_size: return not self.lineEdit_TOOLTIPSIZE_Validation() elif obj == self.edit_transparency: @@ -731,7 +731,7 @@ def eventFilter(self, obj, event): def Button_TooltipColors_Pressed(self): Form = QadWindowColorDialog(self.plugIn, self, QadColorContextEnum.MODEL_SPACE_2D, QadColorElementEnum.DI_COMMAND_DESCR) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: # copio i valori dei colori in QadVariables self.ColorVariables = Form.getSysVariableList() @@ -778,22 +778,22 @@ def ButtonHELP_Pressed(self): # QadPreview class. # =============================================================================== class QadPreview(QWidget): - def __init__(self, plugIn, parent, size, transparency, windowFlags = Qt.Widget): + def __init__(self, plugIn, parent, size, transparency, windowFlags = Qt.WindowType.Widget): self.plugIn = plugIn self.size = size self.transparency = transparency QWidget.__init__(self, parent, windowFlags) self.edit1 = QTextEdit(self) - self.edit1.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.edit1.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.edit1.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.edit1.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.edit1.insertPlainText("12.3456") self.edit1.setReadOnly(True) self.edit2 = QTextEdit(self) - self.edit2.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.edit2.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.edit2.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) + self.edit2.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.edit2.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.edit2.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed) self.edit2.insertPlainText("78.9012") self.edit2.setReadOnly(True) @@ -849,7 +849,7 @@ def paint_preview(self): rect = self.rect() painter = QPainter(self) painter.fillRect(rect, self.plugIn.canvas.canvasColor()) - painter.setRenderHint(QPainter.Antialiasing) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) foregroundColor = QColor(QadVariables.get(QadMsg.translate("Environment variables", "DYNEDITFORECOLOR"))) backGroundColor = QColor(QadVariables.get(QadMsg.translate("Environment variables", "DYNEDITBACKCOLOR"))) @@ -858,18 +858,18 @@ def paint_preview(self): font_size = 8 + self.size height = font_size + 15 - selectionColor = QColor(Qt.white) + selectionColor = QColor(Qt.GlobalColor.white) selectionBackGroundColor = QColor(51, 153, 255) # azzurro (R=51 G=153 B=255) self.setEdit(self.edit1, foregroundColor, backGroundColor, borderColor, selectionColor, selectionBackGroundColor, opacity) fm = QFontMetrics(self.edit1.currentFont()) - width1 = fm.width(self.edit1.toPlainText() + "__") + 2 + width1 = fm.horizontalAdvance(self.edit1.toPlainText() + "__") + 2 self.edit1.resize(width1, height) self.edit1.selectAll() # seleziono tutto il testo self.setEdit(self.edit2, foregroundColor, backGroundColor, borderColor, backGroundColor, foregroundColor, opacity) fm = QFontMetrics(self.edit2.currentFont()) - width2 = fm.width(self.edit2.toPlainText() + "__") + 2 + width2 = fm.horizontalAdvance(self.edit2.toPlainText() + "__") + 2 self.edit2.resize(width2, height) offset = int(height / 3) diff --git a/qad_dsettings_rc.py b/qad_dsettings_rc.py index 09fc4de5..31cc7342 100644 --- a/qad_dsettings_rc.py +++ b/qad_dsettings_rc.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore +from qgis.PyQt import QtCore qt_resource_data = b"\ \x00\x00\x03\xfe\ diff --git a/qad_dsettings_ui.py b/qad_dsettings_ui.py index ec9fdfa6..d0724b73 100644 --- a/qad_dsettings_ui.py +++ b/qad_dsettings_ui.py @@ -8,18 +8,18 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_DSettings_Dialog(object): def setupUi(self, DSettings_Dialog): DSettings_Dialog.setObjectName("DSettings_Dialog") - DSettings_Dialog.setWindowModality(QtCore.Qt.ApplicationModal) + DSettings_Dialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) DSettings_Dialog.resize(550, 455) DSettings_Dialog.setMinimumSize(QtCore.QSize(550, 455)) DSettings_Dialog.setMaximumSize(QtCore.QSize(550, 455)) DSettings_Dialog.setMouseTracking(True) - DSettings_Dialog.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + DSettings_Dialog.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.DefaultContextMenu) DSettings_Dialog.setModal(True) self.tabWidget = QtWidgets.QTabWidget(DSettings_Dialog) self.tabWidget.setGeometry(QtCore.QRect(10, 0, 521, 401)) @@ -116,7 +116,7 @@ def setupUi(self, DSettings_Dialog): self.layoutWidget2.setGeometry(QtCore.QRect(30, 20, 171, 261)) self.layoutWidget2.setObjectName("layoutWidget2") self.gridLayout_2 = QtWidgets.QGridLayout(self.layoutWidget2) - self.gridLayout_2.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize) + self.gridLayout_2.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetMinimumSize) self.gridLayout_2.setContentsMargins(0, 0, 0, 0) self.gridLayout_2.setObjectName("gridLayout_2") self.checkBox_END_PLINE = QtWidgets.QCheckBox(self.layoutWidget2) @@ -209,7 +209,7 @@ def setupUi(self, DSettings_Dialog): self.checkBox_AdditionaltAngles.setObjectName("checkBox_AdditionaltAngles") self.listView_AdditionalAngles = QtWidgets.QListView(self.groupBox_PolarAngleSettings) self.listView_AdditionalAngles.setGeometry(QtCore.QRect(10, 90, 81, 221)) - self.listView_AdditionalAngles.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) + self.listView_AdditionalAngles.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.MultiSelection) self.listView_AdditionalAngles.setObjectName("listView_AdditionalAngles") self.pushButton_AddAngle = QtWidgets.QPushButton(self.groupBox_PolarAngleSettings) self.pushButton_AddAngle.setGeometry(QtCore.QRect(100, 90, 71, 23)) @@ -252,7 +252,7 @@ def setupUi(self, DSettings_Dialog): self.pushButton_DI_PointerInputSettings.setObjectName("pushButton_DI_PointerInputSettings") self.label = QtWidgets.QLabel(self.groupBox_2) self.label.setGeometry(QtCore.QRect(10, 20, 201, 81)) - self.label.setFrameShape(QtWidgets.QFrame.Box) + self.label.setFrameShape(QtWidgets.QFrame.Shape.Box) self.label.setText("") self.label.setPixmap(QtGui.QPixmap(":/plugins/qad/icons/dsettings/pointer_input.png")) self.label.setScaledContents(True) @@ -265,7 +265,7 @@ def setupUi(self, DSettings_Dialog): self.pushButton_DI_DimensionInputSettings.setObjectName("pushButton_DI_DimensionInputSettings") self.label_15 = QtWidgets.QLabel(self.groupBox_3) self.label_15.setGeometry(QtCore.QRect(10, 20, 241, 81)) - self.label_15.setFrameShape(QtWidgets.QFrame.Box) + self.label_15.setFrameShape(QtWidgets.QFrame.Shape.Box) self.label_15.setText("") self.label_15.setPixmap(QtGui.QPixmap(":/plugins/qad/icons/dsettings/dimension_input.png")) self.label_15.setScaledContents(True) @@ -275,7 +275,7 @@ def setupUi(self, DSettings_Dialog): self.groupBox_4.setObjectName("groupBox_4") self.checkBox_DI_ShowPrompt = QtWidgets.QCheckBox(self.groupBox_4) self.checkBox_DI_ShowPrompt.setGeometry(QtCore.QRect(219, 20, 261, 41)) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.checkBox_DI_ShowPrompt.sizePolicy().hasHeightForWidth()) @@ -284,7 +284,7 @@ def setupUi(self, DSettings_Dialog): self.checkBox_DI_ShowPrompt.setObjectName("checkBox_DI_ShowPrompt") self.label_16 = QtWidgets.QLabel(self.groupBox_4) self.label_16.setGeometry(QtCore.QRect(10, 20, 201, 81)) - self.label_16.setFrameShape(QtWidgets.QFrame.Box) + self.label_16.setFrameShape(QtWidgets.QFrame.Shape.Box) self.label_16.setText("") self.label_16.setPixmap(QtGui.QPixmap(":/plugins/qad/icons/dsettings/dynamic_prompts.png")) self.label_16.setScaledContents(True) diff --git a/qad_dynamicinput.py b/qad_dynamicinput.py index b99a5549..82720c2d 100644 --- a/qad_dynamicinput.py +++ b/qad_dynamicinput.py @@ -108,13 +108,13 @@ def __init__(self, QadDynamicInputObj): self.font_size = 8 + QadVariables.get(QadMsg.translate("Environment variables", "TOOLTIPSIZE")) height = self.font_size + 15 - self.setTextInteractionFlags(Qt.TextEditorInteraction) + self.setTextInteractionFlags(Qt.TextInteractionFlag.TextEditorInteraction) self.setMinimumSize(height, height) self.setMaximumHeight(height) self.setUndoRedoEnabled(False) self.setAcceptRichText(False) - self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.error = False # indica se il valore contenuto nella edit è errato self.lockedPos = False # indica se la posizione della edit è bloccata @@ -168,7 +168,7 @@ def setColors(self, foregroundColor = None, backGroundColor = None, borderColor # se è in stato di errore il bordo deve essere rosso largo 2 pixel if self.error: - c = QColor(Qt.red) + c = QColor(Qt.GlobalColor.red) rgbStrBorderColor = "border-color: " + fmt.format(str(c.red()), str(c.green()), str(c.blue()), str(opacity)) + ";" fmtBorder = "border:2px;border-style:solid;" else: @@ -242,8 +242,8 @@ def refreshWidth(self, updateCtrlsPos = True): def selectAllText(self): # seleziono tutto il testo cursor = self.textCursor() - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.Start, QTextCursor.KeepAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.Start, QTextCursor.MoveMode.KeepAnchor) self.setTextCursor(cursor) @@ -256,12 +256,12 @@ def showMsg(self, msg, dummy1 = False, dummy2 = False, updateCtrlsPos = True): sep = msg.rfind("\n") if sep >= 0: newMsg = msg[sep + 1:] - cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor) + cursor.movePosition(QTextCursor.MoveOperation.Start, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.KeepAnchor) else: newMsg = msg - cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor) + cursor.movePosition(QTextCursor.MoveOperation.Start, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.KeepAnchor) self.setTextCursor(cursor) self.insertPlainText(newMsg) @@ -285,7 +285,7 @@ class QadDynamicInputCmdLineEdit(QadDynamicEdit): def __init__(self, QadDynamicInputObj): QadDynamicEdit.__init__(self, QadDynamicInputObj) - self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) + self.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed) self.historyIndex = 0 @@ -390,12 +390,12 @@ def showCmdSuggestWindow(self, mode = True, filter = ""): ptEditRect = QPoint(editRect.left(), editRect.top()) if self.parentWidget(): ptEditRect = self.parentWidget().mapToGlobal(QPoint(editRect.left(), editRect.top())) - ptUp = QApplication.desktop().mapFromGlobal(ptEditRect) + ptUp = QPoint(ptEditRect) # coordinate globali (QDesktopWidget rimosso in Qt6) spaceUp = ptUp.y() if ptUp.y() - dataHeight < 0 else dataHeight ptDown = QPoint(ptUp.x(), ptUp.y() + editRect.height()) - desktopRect = QApplication.desktop().screenGeometry() + desktopRect = QApplication.primaryScreen().geometry() spaceDown = desktopRect.height() - ptDown.y() if ptDown.y() + dataHeight > desktopRect.height() else dataHeight # verifico se c'è più spazio sopra o sotto la finestra @@ -413,7 +413,7 @@ def showCmdSuggestWindow(self, mode = True, filter = ""): else: pt.setX(desktopRect.width() - dataWidth) - pt = QApplication.desktop().mapToGlobal(pt) + pt = QPoint(pt) # già in coordinate globali (QDesktopWidget rimosso in Qt6) self.cmdSuggestWindow.move(pt) self.cmdSuggestWindow.resize(dataWidth, dataHeight) @@ -454,8 +454,8 @@ def appendCmdTextForAutoComplete(self, cmdName, filterLen): self.insertPlainText(cmdName[filterLen:]) else: self.insertPlainText("") - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, len(cmdName) - filterLen) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.Left, QTextCursor.MoveMode.KeepAnchor, len(cmdName) - filterLen) self.setTextCursor(cursor) self.refreshWidth() @@ -501,33 +501,33 @@ def keyPressEvent(self, e): # if Up or Down is pressed if self.isVisibleCmdSuggestWindow() and \ - (e.key() == Qt.Key_Down or e.key() == Qt.Key_Up or e.key() == Qt.Key_PageDown or e.key() == Qt.Key_PageUp or - e.key() == Qt.Key_End or e.key() == Qt.Key_Home): + (e.key() == Qt.Key.Key_Down or e.key() == Qt.Key.Key_Up or e.key() == Qt.Key.Key_PageDown or e.key() == Qt.Key.Key_PageUp or + e.key() == Qt.Key.Key_End or e.key() == Qt.Key.Key_Home): self.cmdSuggestWindow.keyPressEvent(e) return else: # nascondo la finestra di suggerimento self.lockedPos = False self.showCmdSuggestWindow(False) - if e.key() == Qt.Key_Escape: + if e.key() == Qt.Key.Key_Escape: cmdsHistory = self.plugIn.cmdsHistory self.historyIndex = len(cmdsHistory) self.QadDynamicInputObj.abort() return # if Return or Space is pressed, then perform the commands - if e.key() == Qt.Key_Return or e.key() == Qt.Key_Space or e.key == Qt.Key_Enter: + if e.key() == Qt.Key.Key_Return or e.key() == Qt.Key.Key_Space or e.key == Qt.Key.Key_Enter: self.entered() return # if Up or Down is pressed - elif e.key() == Qt.Key_Down: + elif e.key() == Qt.Key.Key_Down: self.showNextCmd() return # per non far comparire la finestra di suggerimento - elif e.key() == Qt.Key_Up: + elif e.key() == Qt.Key.Key_Up: self.showPreviousCmd() return # per non far comparire la finestra di suggerimento else: - if (e.key() != Qt.Key_Tab and e.key() != Qt.Key_Backtab) or \ + if (e.key() != Qt.Key.Key_Tab and e.key() != Qt.Key.Key_Backtab) or \ e.text() != "": # all other keystrokes get sent to the input line QTextEdit.keyPressEvent(self, e) @@ -613,7 +613,7 @@ class QadDynamicInputEdit(QadDynamicEdit): def __init__(self, QadDynamicInputObj): QadDynamicEdit.__init__(self, QadDynamicInputObj) - self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) + self.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed) # il default è un numero reale non nullo self.inputMode = QadInputModeEnum.NOT_NULL @@ -633,7 +633,7 @@ def __init__(self, QadDynamicInputObj): height = self.height() - 4 self.LockedIcon = QLabel(self) self.LockedIcon.resize(height, height) - self.LockedIcon.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.LockedIcon.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) self.LockedIcon.setStyleSheet("border:0px;"); # senza bordo pixmap = QPixmap(":/plugins/qad/icons/locked.svg").scaled(height, height) self.LockedIcon.setPixmap(pixmap) @@ -733,20 +733,20 @@ def keyPressEvent(self, e): if self.plugIn.shortCutManagement(e): # se è stata gestita una sequenza di tasti scorciatoia return - if e.key() == Qt.Key_Tab: + if e.key() == Qt.Key.Key_Tab: if self.checkValid() is not None: # mi sposto sulla edit successiva self.QadDynamicInputObj.setNextCurrentEdit() else: # valore errato pass - elif e.key() == Qt.Key_Backtab: + elif e.key() == Qt.Key.Key_Backtab: if self.checkValid() is not None: self.QadDynamicInputObj.setPrevCurrentEdit() else: # valore errato pass - elif e.key() == Qt.Key_Return or e.key == Qt.Key_Enter: + elif e.key() == Qt.Key.Key_Return or e.key == Qt.Key.Key_Enter: self.QadDynamicInputObj.keyPressEvent(e) # lo faccio gestire da QadDynamicInputObj # if self.isLockedValue() == True: # value = self.toPlainText() @@ -758,11 +758,11 @@ def keyPressEvent(self, e): # else: # self.QadDynamicInputObj.keyPressEvent(e) # lo faccio gestire da QadDynamicInputObj - elif (e.key() == Qt.Key_Down or e.key() == Qt.Key_Up or e.key() == Qt.Key_PageDown or e.key() == Qt.Key_PageUp or \ - e.key() == Qt.Key_End or e.key() == Qt.Key_Home): + elif (e.key() == Qt.Key.Key_Down or e.key() == Qt.Key.Key_Up or e.key() == Qt.Key.Key_PageDown or e.key() == Qt.Key.Key_PageUp or \ + e.key() == Qt.Key.Key_End or e.key() == Qt.Key.Key_Home): pass # al momento si è deciso di non mostrare il menu delle opzioni del comando attivo da qui - elif e.key() == Qt.Key_Comma: # "," + elif e.key() == Qt.Key.Key_Comma: # "," self.QadDynamicInputObj.keyPressEvent(e) # lo faccio gestire da QadDynamicInputObj # se non si tratta di stringa e si tratta di un carattere speciale @@ -770,7 +770,7 @@ def keyPressEvent(self, e): (e.text() == "@" or e.text() == "#" or e.text() == "<"): self.QadDynamicInputObj.keyPressEvent(e) # lo faccio gestire da QadDynamicInputObj - elif e.key() == Qt.Key_Escape: + elif e.key() == Qt.Key.Key_Escape: self.QadDynamicInputObj.abort() elif e.text() != "": @@ -791,11 +791,11 @@ def keyPressEvent(self, e): # ============================================================================ def focusInEvent(self, e): # cambio il colore - foregroundColor = QColor(Qt.black) - backGroundColor = QColor(Qt.white) + foregroundColor = QColor(Qt.GlobalColor.black) + backGroundColor = QColor(Qt.GlobalColor.white) borderColor = QColor(QadVariables.get(QadMsg.translate("Environment variables", "DYNEDITBORDERCOLOR"))) opacity = 100 - QadVariables.get(QadMsg.translate("Environment variables", "TOOLTIPTRANSPARENCY")) - selectionColor = QColor(Qt.white) + selectionColor = QColor(Qt.GlobalColor.white) selectionBackGroundColor = QColor(51, 153, 255) # azzurro (R=51 G=153 B=255) self.setColors(foregroundColor, backGroundColor, borderColor, selectionColor, selectionBackGroundColor, opacity) self.selectAllText() # seleziono tutto il testo @@ -813,8 +813,8 @@ def focusOutEvent(self, e): self.setColors(foregroundColor, backGroundColor, borderColor, backGroundColor, foregroundColor, opacity) # seleziono il testo cursor = self.textCursor() - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.KeepAnchor) self.setTextCursor(cursor) @@ -898,7 +898,7 @@ def setLinesMarker(self, points): lineMarker = createRubberBand(self.canvas, QgsWkbTypes.LineGeometry, True) lineMarker.setColor(self.lineMarkerColor) - lineMarker.setLineStyle(Qt.DotLine) + lineMarker.setLineStyle(Qt.PenStyle.DotLine) if points is None: return None tot = len(points) @@ -2012,7 +2012,7 @@ def keyPressEvent(self, e): if self.currentEdit is None: return - if e.key() == Qt.Key_Return or e.key == Qt.Key_Enter: + if e.key() == Qt.Key.Key_Return or e.key == Qt.Key.Key_Enter: msg = self.resStr if self.refreshResult() == True else "" # ricalcolo il risultato e lo uso in formato stringa self.showEvaluateMsg(msg) else: @@ -3030,6 +3030,15 @@ def moveCtrls(self, mousePos = None): # ============================================================================ # refreshResult # ============================================================================ + def getOrthoAdjustedAngle(self, angle): + # se la modalita' ORTO e' attiva, arrotonda l'angolo (calcolato dalla posizione del mouse) + # all'asse ortogonale piu' vicino, in modo che la distanza digitata rispetti l'orto + if QadVariables.get(QadMsg.translate("Environment variables", "ORTHOMODE")) == 1: + halfPi = math.pi / 2 + angle = (round(angle / halfPi) % 4) * halfPi + return angle + + def refreshResult(self, mousePos = None): # calcola il risultato e restituisce True se l'operazione ha successo # a seconda del contesto può essere un punto -> self.resPt o un valore (numero, stringa, bool...) -> self.resValue @@ -3126,8 +3135,12 @@ def refreshResult(self, mousePos = None): angle = self.edits[QadDynamicInputEditEnum.EDIT_Y].checkValid() # ritorna il valore se valido if angle is None: angle = qad_utils.getAngleBy2Pts(prevPt, point, 0) # senza tolleranza + if relative and self.edits[QadDynamicInputEditEnum.EDIT_X].isLockedValue(): + angle = self.getOrthoAdjustedAngle(angle) # rispetta la modalita' ORTO else: angle = qad_utils.getAngleBy2Pts(prevPt, point, 0) # senza tolleranza + if relative and self.edits[QadDynamicInputEditEnum.EDIT_X].isLockedValue(): + angle = self.getOrthoAdjustedAngle(angle) # rispetta la modalita' ORTO if relative: pt = qad_utils.getPolarPointByPtAngle(prevPt, angle, dist) @@ -3151,10 +3164,14 @@ def refreshResult(self, mousePos = None): if self.edits[QadDynamicInputEditEnum.EDIT_ANG_PREV_PT].isLockedValue() == False: angle = qad_utils.getAngleBy2Pts(self.prevPoint, point, 0) # senza tolleranza + if self.edits[QadDynamicInputEditEnum.EDIT_DIST_PREV_PT].isLockedValue(): + angle = self.getOrthoAdjustedAngle(angle) # rispetta la modalita' ORTO else: angle = self.edits[QadDynamicInputEditEnum.EDIT_ANG_PREV_PT].checkValid() # ritorna il valore in radianti se valido if angle is None: angle = qad_utils.getAngleBy2Pts(self.prevPoint, point, 0) # senza tolleranza + if self.edits[QadDynamicInputEditEnum.EDIT_DIST_PREV_PT].isLockedValue(): + angle = self.getOrthoAdjustedAngle(angle) # rispetta la modalita' ORTO else: angleMouse = qad_utils.getAngleBy2Pts(self.prevPoint, point, 0) # senza tolleranza # se il mouse forma un angolo tra 180 e 360 allora l'angolo digitato va sottratto a 360 gradi @@ -3380,7 +3397,7 @@ def refreshResult(self, mousePos = None): def keyPressEvent(self, e): if self.currentEdit is None: return - if e.key() == Qt.Key_Comma: # "," + if e.key() == Qt.Key.Key_Comma: # "," # se il risultato può essere un punto if self.inputType & QadInputTypeEnum.POINT2D or self.inputType & QadInputTypeEnum.POINT2D: self.forcedCoordWidgetVisib = True # editaz forzata delle coordinate @@ -3420,7 +3437,7 @@ def keyPressEvent(self, e): self.edits[QadDynamicInputEditEnum.EDIT_X].showMsg(coord) self.show(True) - elif e.key() == Qt.Key_Return or e.key == Qt.Key_Enter: + elif e.key() == Qt.Key.Key_Return or e.key == Qt.Key.Key_Enter: # se non c'è alcun widget con valore bloccato if self.anyLockedValueEdit() == False: msg = "" diff --git a/qad_getpoint.py b/qad_getpoint.py index b90f526c..18862374 100644 --- a/qad_getpoint.py +++ b/qad_getpoint.py @@ -225,13 +225,13 @@ def setDrawMode(self, drawMode): if self.__drawMode == QadGetPointDrawModeEnum.ELASTIC_LINE: self.refreshOrthoMode() # setto il default self.__RubberBand = createRubberBand(self.canvas, QgsWkbTypes.LineGeometry) - self.__RubberBand.setLineStyle(Qt.DotLine) + self.__RubberBand.setLineStyle(Qt.PenStyle.DotLine) elif self.__drawMode == QadGetPointDrawModeEnum.ELASTIC_RECTANGLE: self.rectangleCrossingSelectionColor = getColorForCrossingSelectionArea() self.rectangleWindowSelectionColor = getColorForWindowSelectionArea() self.__RubberBand = createRubberBand(self.canvas, QgsWkbTypes.PolygonGeometry, False, None, self.rectangleCrossingSelectionColor) - self.__RubberBand.setLineStyle(Qt.DotLine) + self.__RubberBand.setLineStyle(Qt.PenStyle.DotLine) # ============================================================================ @@ -633,9 +633,9 @@ def setCursorType(self, cursorType): self.__csrRubberBand = QadCursorRubberBand(self.canvas, cursorType) if cursorType == QadCursorTypeEnum.NONE: - self.__cursor = QCursor(Qt.ArrowCursor) + self.__cursor = QCursor(Qt.CursorShape.ArrowCursor) else: - self.__cursor = QCursor(Qt.BlankCursor) + self.__cursor = QCursor(Qt.CursorShape.BlankCursor) self.__cursorType = cursorType @@ -787,9 +787,9 @@ def canvasMoveEvent(self, event): self.__csrRubberBand.moveEvent(self.tmpPoint) # tasto shift premuto durante il movimento del mouse - self.tmpShiftKey = True if event.modifiers() & Qt.ShiftModifier else False + self.tmpShiftKey = True if event.modifiers() & Qt.KeyboardModifier.ShiftModifier else False # tasto ctrl premuto durante il movimento del mouse - self.tmpCtrlKey = True if event.modifiers() & Qt.ControlModifier else False + self.tmpCtrlKey = True if event.modifiers() & Qt.KeyboardModifier.ControlModifier else False # se l'obiettivo é selezionare un punto if self.getSelectionMode() == QadGetPointSelectionModeEnum.POINT_SELECTION or \ @@ -986,19 +986,19 @@ def canvasMoveEventOnPointSel(self, event): # ============================================================================ def canvasPressEvent(self, event): # tasto shift premuto durante il click del mouse - self.shiftKey = True if event.modifiers() & Qt.ShiftModifier else False + self.shiftKey = True if event.modifiers() & Qt.KeyboardModifier.ShiftModifier else False # tasto ctrl premuto durante il click del mouse - self.ctrlKey = True if event.modifiers() & Qt.ControlModifier else False + self.ctrlKey = True if event.modifiers() & Qt.KeyboardModifier.ControlModifier else False # volevo mettere questo evento nel canvasReleaseEvent # ma il tasto destro non genera quel tipo di evento - if event.button() == Qt.RightButton: + if event.button() == Qt.MouseButton.RightButton: self.startDateTimeForRightClick = datetime.datetime.now() self.rightButton = True return # esco qui per non contiuare il comando dal maptool - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: self.rightButton = False if self.getSelectionMode() == QadGetPointSelectionModeEnum.ENTITY_SELECTION_DYNAMIC or \ @@ -1045,10 +1045,10 @@ def canvasPressEvent(self, event): # canvasReleaseEvent # ============================================================================ def canvasReleaseEvent(self, event): - if event.button() == Qt.RightButton: + if event.button() == Qt.MouseButton.RightButton: self.rightButton = True # Se é stato premuto il tasto CTRL (o META) - if ((event.modifiers() & Qt.ControlModifier) or (event.modifiers() & Qt.MetaModifier)): + if ((event.modifiers() & Qt.KeyboardModifier.ControlModifier) or (event.modifiers() & Qt.KeyboardModifier.MetaModifier)): self.displayOsnapPopupMenu(event.pos()) return # esco qui per non contiuare il comando dal maptool @@ -1089,7 +1089,7 @@ def canvasReleaseEvent(self, event): # se l'obiettivo é selezionare un rettangolo if self.getDrawMode() == QadGetPointDrawModeEnum.ELASTIC_RECTANGLE: - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: p1 = self.__RubberBand.getPoint(0, 0) # se il mouse é in una posizione diversa dal punto iniziale del rettangolo if p1 != self.toMapCoordinates(event.pos()): @@ -1105,10 +1105,10 @@ def canvasReleaseEvent(self, event): self.__QadSnapper.setProgressDistance(self.__oldSnapProgrDist) # tasto shift premuto durante il click del mouse - self.shiftKey = True if event.modifiers() & Qt.ShiftModifier else False + self.shiftKey = True if event.modifiers() & Qt.KeyboardModifier.ShiftModifier else False # tasto ctrl premuto durante il click del mouse - self.ctrlKey = True if event.modifiers() & Qt.ControlModifier else False + self.ctrlKey = True if event.modifiers() & Qt.KeyboardModifier.ControlModifier else False self.plugIn.QadCommands.continueCommandFromMapTool() #self.plugIn.setStandardMapTool() @@ -1444,7 +1444,7 @@ def setSnapTypeToDisableByPopupMenu(self): # ============================================================================ def showDSettingsByPopUpMenu(self): d = QadDSETTINGSDialog(self.plugIn, QadDSETTINGSTabIndexEnum.OBJECT_SNAP) - d.exec_() + d.exec() self.refreshSnapType() self.refreshAutoSnap() self.setPolarAngOffset(self.plugIn.lastSegmentAng) diff --git a/qad_gripcolor_ui.py b/qad_gripcolor_ui.py index 6c2a0f1c..84b40e78 100644 --- a/qad_gripcolor_ui.py +++ b/qad_gripcolor_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_GripColor_Dialog(object): @@ -19,8 +19,8 @@ def setupUi(self, GripColor_Dialog): GripColor_Dialog.setMaximumSize(QtCore.QSize(400, 208)) self.buttonBox = QtWidgets.QDialogButtonBox(GripColor_Dialog) self.buttonBox.setGeometry(QtCore.QRect(60, 170, 331, 32)) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Help|QtWidgets.QDialogButtonBox.Ok) + self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Help|QtWidgets.QDialogButtonBox.StandardButton.Ok) self.buttonBox.setObjectName("buttonBox") self.groupBox = QtWidgets.QGroupBox(GripColor_Dialog) self.groupBox.setGeometry(QtCore.QRect(10, 10, 381, 141)) diff --git a/qad_maptool.py b/qad_maptool.py index 83824f30..c7423162 100644 --- a/qad_maptool.py +++ b/qad_maptool.py @@ -64,7 +64,7 @@ def __init__(self, plugIn): self.plugIn = plugIn self.iface = self.plugIn.iface self.canvas = self.plugIn.iface.mapCanvas() - self.cursor = QCursor(Qt.BlankCursor) + self.cursor = QCursor(Qt.CursorShape.BlankCursor) self.__csrRubberBand = QadCursorRubberBand(self.canvas, QadCursorTypeEnum.BOX | QadCursorTypeEnum.CROSS) self.entitySet = QadEntitySet() self.entitySetGripPoints = QadEntitySetGripPoints(plugIn) @@ -174,11 +174,11 @@ def refreshEntityGripPoints(self, entitySet = None): # canvasPressEvent # ============================================================================ def canvasPressEvent(self, event): - if event.button() == Qt.RightButton: + if event.button() == Qt.MouseButton.RightButton: self.startDateTimeForRightClick = datetime.datetime.now() - elif event.button() == Qt.LeftButton: + elif event.button() == Qt.MouseButton.LeftButton: # verifico se tasto shift premuto - shiftKey = True if event.modifiers() & Qt.ShiftModifier else False + shiftKey = True if event.modifiers() & Qt.KeyboardModifier.ShiftModifier else False # posizione corrente del mouse point = self.toMapCoordinates(event.pos()) # leggo il punto grip che si interseca alla posizione del mouse @@ -271,7 +271,7 @@ def canvasMoveEvent(self, event): # canvasReleaseEvent # ============================================================================ def canvasReleaseEvent(self, event): - if event.button() == Qt.RightButton: + if event.button() == Qt.MouseButton.RightButton: shortCutMenu = QadVariables.get(QadMsg.translate("Environment variables", "SHORTCUTMENU")) if shortCutMenu == 0: # equivale a premere INVIO @@ -337,7 +337,9 @@ def keyPressEvent(self, e): # ============================================================================ def wheelEvent(self, event): QgsMapTool.wheelEvent(self, event) - self.__csrRubberBand.moveEvent(self.toMapCoordinates(event.pos())) + # QWheelEvent.pos() e' stato rimosso in Qt6: si usa position() (disponibile da Qt 5.14) + pos = event.position().toPoint() if hasattr(event, "position") else event.pos() + self.__csrRubberBand.moveEvent(self.toMapCoordinates(pos)) # ============================================================================ diff --git a/qad_multi_geom.py b/qad_multi_geom.py index ca5615f8..65840ce0 100644 --- a/qad_multi_geom.py +++ b/qad_multi_geom.py @@ -1220,9 +1220,9 @@ def __init__(self, geom): self.cacheLayer = createMemoryLayer("QadLayerCacheArea", "Polygon", qgis.utils.iface.mapCanvas().mapSettings().destinationCrs()) provider = self.cacheLayer.dataProvider() - provider.addAttributes([QgsField("geom_at", QMetaType.Int, "Int")]) # codice della geometria - provider.addAttributes([QgsField("sub_geom_at", QMetaType.Int, "Int")]) # codice della sotto geometria - provider.addAttributes([QgsField("part_at", QMetaType.Int, "Int")]) # codice della parte + provider.addAttributes([QgsField("geom_at", QMetaType.Type.Int, "Int")]) # codice della geometria + provider.addAttributes([QgsField("sub_geom_at", QMetaType.Type.Int, "Int")]) # codice della sotto geometria + provider.addAttributes([QgsField("part_at", QMetaType.Type.Int, "Int")]) # codice della parte self.cacheLayer.updateFields() if provider.capabilities() & QgsVectorDataProvider.CreateSpatialIndex: diff --git a/qad_options_dlg.py b/qad_options_dlg.py index c4914b9a..5080933b 100644 --- a/qad_options_dlg.py +++ b/qad_options_dlg.py @@ -170,7 +170,7 @@ def init_display_tab(self): def accept_display_tab(self): # Memorizzo il valore di SHOWTEXTWINDOW - newSHOWTEXTWINDOW = True if self.checkBox_SHOWTEXTWINDOW.checkState() == Qt.Checked else False + newSHOWTEXTWINDOW = True if self.checkBox_SHOWTEXTWINDOW.checkState() == Qt.CheckState.Checked else False self.tempQadVariables.set(QadMsg.translate("Environment variables", "SHOWTEXTWINDOW"), newSHOWTEXTWINDOW) # Memorizzo il valore di CMDINPUTHISTORYMAX @@ -180,15 +180,15 @@ def accept_display_tab(self): # Memorizzo il valore di INPUTSEARCHOPTIONS newInputSearchOptions = 0 - if self.checkBox_INPUTSEARCHOPTIONS_ON.checkState() == Qt.Checked: + if self.checkBox_INPUTSEARCHOPTIONS_ON.checkState() == Qt.CheckState.Checked: newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.ON - if self.checkBox_INPUTSEARCHOPTIONS_AUTOCOMPLETE.checkState() == Qt.Checked: + if self.checkBox_INPUTSEARCHOPTIONS_AUTOCOMPLETE.checkState() == Qt.CheckState.Checked: newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.AUTOCOMPLETE - if self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_LIST.checkState() == Qt.Checked: + if self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_LIST.checkState() == Qt.CheckState.Checked: newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.DISPLAY_LIST - if self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_ICON.checkState() == Qt.Checked: + if self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_ICON.checkState() == Qt.CheckState.Checked: newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.DISPLAY_ICON - if self.checkBox_INPUTSEARCHOPTIONS_EXCLUDE_SYS_VAR.checkState() == Qt.Checked: + if self.checkBox_INPUTSEARCHOPTIONS_EXCLUDE_SYS_VAR.checkState() == Qt.CheckState.Checked: newInputSearchOptions = newInputSearchOptions | QadINPUTSEARCHOPTIONSEnum.EXCLUDE_SYS_VAR self.tempQadVariables.set(QadMsg.translate("Environment variables", "INPUTSEARCHOPTIONS"), newInputSearchOptions) @@ -234,7 +234,7 @@ def accept_display_tab(self): def checkBox_INPUTSEARCHOPTIONS_ON_clicked(self): - value = True if self.checkBox_INPUTSEARCHOPTIONS_ON.checkState() == Qt.Checked else False + value = True if self.checkBox_INPUTSEARCHOPTIONS_ON.checkState() == Qt.CheckState.Checked else False self.checkBox_INPUTSEARCHOPTIONS_AUTOCOMPLETE.setEnabled(value) self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_LIST.setEnabled(value) self.checkBox_INPUTSEARCHOPTIONS_DISPLAY_ICON.setEnabled(value) @@ -327,7 +327,7 @@ def lineEdit_CURSORSIZE_Validation(self): def Button_TextWindowColor_clicked(self): Form = QadWindowColorDialog(self.plugIn, self, QadColorContextEnum.COMMAND_LINE, QadColorElementEnum.COMMAND_HISTORY_BACKGROUND) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: # copio i valori dei colori in self.tempQadVariables variables = Form.getSysVariableList() for variable in variables: @@ -350,7 +350,7 @@ def init_user_preferences_tab(self): self.checkBox_shortcutmenu_clicked() def checkBox_shortcutmenu_clicked(self): - if self.checkBox_shortcutmenu.checkState() == Qt.Checked: + if self.checkBox_shortcutmenu.checkState() == Qt.CheckState.Checked: self.button_rightclick.setEnabled(True) else: self.button_rightclick.setEnabled(False) @@ -358,7 +358,7 @@ def checkBox_shortcutmenu_clicked(self): def button_rightclick_clicked(self): Form = QadRightClickDialog(self.plugIn, self) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: # copio i valori dei colori in self.tempQadVariables variables = Form.getSysVariableList() for variable in variables: @@ -367,7 +367,7 @@ def button_rightclick_clicked(self): def accept_user_preferences_tab(self): - if self.checkBox_shortcutmenu.checkState() == Qt.Unchecked: + if self.checkBox_shortcutmenu.checkState() == Qt.CheckState.Unchecked: self.tempQadVariables.set(QadMsg.translate("Environment variables", "SHORTCUTMENU"), 0) elif self.tempQadVariables.get(QadMsg.translate("Environment variables", "SHORTCUTMENU")) == 0: self.tempQadVariables.set(QadMsg.translate("Environment variables", "SHORTCUTMENU"), 11) # inizializzo questo default @@ -429,7 +429,7 @@ def init_drafting_tab(self): def button_DraftingTooltipSettings_clicked(self): Form = QadTOOLTIPAPPEARANCEDialog(self.plugIn, self) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: # copio i valori dei colori in self.tempQadVariables variables = Form.getSysVariableList() for variable in variables: @@ -440,17 +440,17 @@ def accept_drafting_tab(self): # AUTOSNAP autoSnap = self.tempQadVariables.get(QadMsg.translate("Environment variables", "AUTOSNAP")) - if self.checkBox_AUTOSNAP_DISPLAY_MARK.checkState() == Qt.Checked: + if self.checkBox_AUTOSNAP_DISPLAY_MARK.checkState() == Qt.CheckState.Checked: autoSnap = autoSnap | QadAUTOSNAPEnum.DISPLAY_MARK # aggiungo i bit else: autoSnap = autoSnap &~ QadAUTOSNAPEnum.DISPLAY_MARK # tolgo il bit - if self.checkBox_AUTOSNAP_MAGNET.checkState() == Qt.Checked: + if self.checkBox_AUTOSNAP_MAGNET.checkState() == Qt.CheckState.Checked: autoSnap = autoSnap | QadAUTOSNAPEnum.MAGNET # aggiungo i bit else: autoSnap = autoSnap &~ QadAUTOSNAPEnum.MAGNET # tolgo il bit - if self.checkBox_AUTOSNAP_DISPLAY_TOOLTIPS.checkState() == Qt.Checked: + if self.checkBox_AUTOSNAP_DISPLAY_TOOLTIPS.checkState() == Qt.CheckState.Checked: autoSnap = autoSnap | QadAUTOSNAPEnum.DISPLAY_TOOLTIPS # aggiungo i bit else: autoSnap = autoSnap &~ QadAUTOSNAPEnum.DISPLAY_TOOLTIPS # tolgo il bit @@ -458,7 +458,7 @@ def accept_drafting_tab(self): self.tempQadVariables.set(QadMsg.translate("Environment variables", "AUTOSNAP"), autoSnap) # APBOX - newAPBOX = 1 if self.checkBox_APBOX.checkState() == Qt.Checked else 0 + newAPBOX = 1 if self.checkBox_APBOX.checkState() == Qt.CheckState.Checked else 0 self.tempQadVariables.set(QadMsg.translate("Environment variables", "APBOX"), newAPBOX) # AUTOSNAPSIZE @@ -493,7 +493,7 @@ def horizontalSlider_APERTURE_changed(self): def Button_AutoSnapWindowColor_clicked(self): Form = QadWindowColorDialog(self.plugIn, self, QadColorContextEnum.MODEL_SPACE_2D, QadColorElementEnum.AUTOSNAP_MARKER) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: # copio i valori dei colori in self.tempQadVariables variables = Form.getSysVariableList() for variable in variables: @@ -571,23 +571,23 @@ def accept_selection_tab(self): self.tempQadVariables.set(QadMsg.translate("Environment variables", "PICKBOX"), self.horizontalSlider_PICKBOX.value()) # PICKFIRST - pickFirst = 1 if self.checkBox_PICKFIRST.checkState() == Qt.Checked else 0 + pickFirst = 1 if self.checkBox_PICKFIRST.checkState() == Qt.CheckState.Checked else 0 self.tempQadVariables.set(QadMsg.translate("Environment variables", "PICKFIRST"), pickFirst) # PICKADD - pickAdd = 0 if self.checkBox_PICKADD.checkState() == Qt.Checked else 1 + pickAdd = 0 if self.checkBox_PICKADD.checkState() == Qt.CheckState.Checked else 1 self.tempQadVariables.set(QadMsg.translate("Environment variables", "PICKADD"), pickAdd) # GRIPSIZE self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPSIZE"), self.horizontalSlider_GRIPSIZE.value()) # GRIPS - grips = 1 if self.checkBox_GRIPS.checkState() == Qt.Checked else 0 + grips = 1 if self.checkBox_GRIPS.checkState() == Qt.CheckState.Checked else 0 self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPS"), grips) # GRIPMULTIFUNCTIONAL gripMultiFunctional = self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPMULTIFUNCTIONAL")) - if self.checkBox_GRIPMULTIFUNCTIONAL_ON_DYNAMIC_MENU_AND_HOT_GRIPT.checkState() == Qt.Checked: + if self.checkBox_GRIPMULTIFUNCTIONAL_ON_DYNAMIC_MENU_AND_HOT_GRIPT.checkState() == Qt.CheckState.Checked: gripMultiFunctional = gripMultiFunctional | QadGRIPMULTIFUNCTIONALEnum.ON_DYNAMIC_MENU_AND_HOT_GRIPT # aggiungo i bit else: gripMultiFunctional = gripMultiFunctional &~ QadGRIPMULTIFUNCTIONALEnum.ON_DYNAMIC_MENU_AND_HOT_GRIPT # tolgo i bit @@ -599,7 +599,7 @@ def accept_selection_tab(self): def checkBox_GRIPS_ON_clicked(self): - value = True if self.checkBox_GRIPS.checkState() == Qt.Checked else False + value = True if self.checkBox_GRIPS.checkState() == Qt.CheckState.Checked else False self.checkBox_GRIPMULTIFUNCTIONAL_ON_DYNAMIC_MENU_AND_HOT_GRIPT.setEnabled(value) self.lineEdit_GRIPOBJLIMIT.setEnabled(value) self.label_GRIPOBJLIMIT.setEnabled(value) @@ -632,7 +632,7 @@ def button_GripColor_clicked(self): self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPHOVER")), \ self.tempQadVariables.get(QadMsg.translate("Environment variables", "GRIPCONTOUR"))) - if Form.exec_() == QDialog.Accepted: + if Form.exec() == QDialog.DialogCode.Accepted: self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPCOLOR"), Form.gripColor) self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPHOT"), Form.gripHot) self.tempQadVariables.set(QadMsg.translate("Environment variables", "GRIPHOVER"), Form.gripHover) @@ -709,7 +709,7 @@ def floatLineEditWidgetValidation(self, widget, varName, msg): def eventFilter(self, obj, event): if event is not None: - if event.type() == QEvent.FocusOut: + if event.type() == QEvent.Type.FocusOut: if obj == self.lineEdit_CMDINPUTHISTORYMAX: return not self.lineEdit_CMDINPUTHISTORYMAX_Validation() elif obj == self.lineEdit_INPUTSEARCHDELAY: @@ -755,9 +755,9 @@ def ButtonBOX_Accepted(self): def ButtonBOX_Apply(self, button): - if self.buttonBox.standardButton(button) == QDialogButtonBox.Apply: + if self.buttonBox.standardButton(button) == QDialogButtonBox.StandardButton.Apply: self.apply() - elif self.buttonBox.standardButton(button) == QDialogButtonBox.Cancel: + elif self.buttonBox.standardButton(button) == QDialogButtonBox.StandardButton.Cancel: self.close() return True @@ -784,7 +784,7 @@ def ButtonHELP_Pressed(self): # QadPreviewAutoSnapMarker class. # =============================================================================== class QadPreviewAutoSnapMarker(QWidget): - def __init__(self, plugIn, color, parent = None, windowFlags = Qt.Widget): + def __init__(self, plugIn, color, parent = None, windowFlags = Qt.WindowType.Widget): self.plugIn = plugIn self.color = color self.size = 0 @@ -801,7 +801,7 @@ def paintEvent(self, event): x1 = center.x() - size y1 = center.y() - size dblSize = size * 2 + 1 - painter.setRenderHint(QPainter.Antialiasing) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) painter.setPen(QPen(self.color, 2)) #painter.setPen(QPen(self.color, 12, Qt.DashDotLine, Qt.RoundCap)) #painter.drawLine(x1, y1, x2, y2) @@ -812,7 +812,7 @@ def paintEvent(self, event): # QadPreviewAperture class. # =============================================================================== class QadPreviewAperture(QWidget): - def __init__(self, plugIn, color, cursorColor, parent = None, windowFlags = Qt.Widget): + def __init__(self, plugIn, color, cursorColor, parent = None, windowFlags = Qt.WindowType.Widget): self.plugIn = plugIn self.color = color self.cursorColor = cursorColor @@ -830,11 +830,11 @@ def paintEvent(self, event): x1 = center.x() - size y1 = center.y() - size dblSize = size * 2 + 1 - painter.setRenderHint(QPainter.Antialiasing) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) painter.setPen(QPen(self.cursorColor, 1)) painter.drawLine(center.x(), 0, center.x(), rect.height()) painter.drawLine(0, center.y(), rect.width(), center.y()) - painter.setPen(QPen(self.color, 1, Qt.DotLine)) + painter.setPen(QPen(self.color, 1, Qt.PenStyle.DotLine)) painter.drawRect(x1, y1, dblSize, dblSize) @@ -842,7 +842,7 @@ def paintEvent(self, event): # QadPreviewPickBox class. # =============================================================================== class QadPreviewPickBox(QWidget): - def __init__(self, plugIn, color, parent = None, windowFlags = Qt.Widget): + def __init__(self, plugIn, color, parent = None, windowFlags = Qt.WindowType.Widget): self.plugIn = plugIn self.color = color self.size = 0 @@ -860,7 +860,7 @@ def paintEvent(self, event): y1 = center.y() - size dblSize = size * 2 + 1 - painter.setRenderHint(QPainter.Antialiasing) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) painter.setPen(QPen(self.color, 1)) painter.drawRect(x1, y1, dblSize, dblSize) @@ -869,7 +869,7 @@ def paintEvent(self, event): # QadPreviewGripSize class. # =============================================================================== class QadPreviewGripSize(QWidget): - def __init__(self, plugIn, fillColor, borderColor, parent = None, windowFlags = Qt.Widget): + def __init__(self, plugIn, fillColor, borderColor, parent = None, windowFlags = Qt.WindowType.Widget): self.plugIn = plugIn self.fillColor = fillColor self.borderColor = borderColor @@ -888,8 +888,7 @@ def paintEvent(self, event): y1 = center.y() - size dblSize = size * 2 + 1 - painter.setRenderHint(QPainter.Antialiasing) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) painter.fillRect(x1, y1, dblSize, dblSize, self.fillColor) painter.setPen(QPen(self.borderColor, 1)) painter.drawRect(x1, y1, dblSize, dblSize) - \ No newline at end of file diff --git a/qad_options_ui.py b/qad_options_ui.py index ca73a5d3..b155a274 100644 --- a/qad_options_ui.py +++ b/qad_options_ui.py @@ -8,13 +8,13 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_Options_Dialog(object): def setupUi(self, Options_Dialog): Options_Dialog.setObjectName("Options_Dialog") - Options_Dialog.setWindowModality(QtCore.Qt.NonModal) + Options_Dialog.setWindowModality(QtCore.Qt.WindowModality.NonModal) Options_Dialog.resize(591, 386) Options_Dialog.setMinimumSize(QtCore.QSize(591, 386)) Options_Dialog.setMaximumSize(QtCore.QSize(591, 386)) @@ -22,8 +22,8 @@ def setupUi(self, Options_Dialog): Options_Dialog.setModal(False) self.buttonBox = QtWidgets.QDialogButtonBox(Options_Dialog) self.buttonBox.setGeometry(QtCore.QRect(240, 350, 341, 32)) - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Apply|QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Help|QtWidgets.QDialogButtonBox.Ok) + self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Apply|QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Help|QtWidgets.QDialogButtonBox.StandardButton.Ok) self.buttonBox.setObjectName("buttonBox") self.tabWidget = QtWidgets.QTabWidget(Options_Dialog) self.tabWidget.setGeometry(QtCore.QRect(10, 10, 571, 331)) @@ -122,7 +122,7 @@ def setupUi(self, Options_Dialog): self.lineEdit_CURSORSIZE.setObjectName("lineEdit_CURSORSIZE") self.horizontalSlider_CURSORSIZE = QtWidgets.QSlider(self.groupBox_3) self.horizontalSlider_CURSORSIZE.setGeometry(QtCore.QRect(50, 20, 221, 22)) - self.horizontalSlider_CURSORSIZE.setOrientation(QtCore.Qt.Horizontal) + self.horizontalSlider_CURSORSIZE.setOrientation(QtCore.Qt.Orientation.Horizontal) self.horizontalSlider_CURSORSIZE.setObjectName("horizontalSlider_CURSORSIZE") self.tabWidget.addTab(self.DisplayTab, "") self.UserPreferencesTab = QtWidgets.QWidget() @@ -171,7 +171,7 @@ def setupUi(self, Options_Dialog): self.groupBox_6.setObjectName("groupBox_6") self.horizontalSlider_AUTOSNAPSIZE = QtWidgets.QSlider(self.groupBox_6) self.horizontalSlider_AUTOSNAPSIZE.setGeometry(QtCore.QRect(70, 30, 181, 22)) - self.horizontalSlider_AUTOSNAPSIZE.setOrientation(QtCore.Qt.Horizontal) + self.horizontalSlider_AUTOSNAPSIZE.setOrientation(QtCore.Qt.Orientation.Horizontal) self.horizontalSlider_AUTOSNAPSIZE.setObjectName("horizontalSlider_AUTOSNAPSIZE") self.widget_AUTOSNAPSIZE = QtWidgets.QWidget(self.groupBox_6) self.widget_AUTOSNAPSIZE.setGeometry(QtCore.QRect(10, 20, 51, 51)) @@ -181,7 +181,7 @@ def setupUi(self, Options_Dialog): self.groupBox_7.setObjectName("groupBox_7") self.horizontalSlider_APERTURE = QtWidgets.QSlider(self.groupBox_7) self.horizontalSlider_APERTURE.setGeometry(QtCore.QRect(70, 30, 181, 22)) - self.horizontalSlider_APERTURE.setOrientation(QtCore.Qt.Horizontal) + self.horizontalSlider_APERTURE.setOrientation(QtCore.Qt.Orientation.Horizontal) self.horizontalSlider_APERTURE.setObjectName("horizontalSlider_APERTURE") self.widget_APERTURESIZE = QtWidgets.QWidget(self.groupBox_7) self.widget_APERTURESIZE.setGeometry(QtCore.QRect(10, 20, 51, 51)) @@ -197,7 +197,7 @@ def setupUi(self, Options_Dialog): self.groupBox_8.setObjectName("groupBox_8") self.horizontalSlider_PICKBOX = QtWidgets.QSlider(self.groupBox_8) self.horizontalSlider_PICKBOX.setGeometry(QtCore.QRect(70, 30, 181, 22)) - self.horizontalSlider_PICKBOX.setOrientation(QtCore.Qt.Horizontal) + self.horizontalSlider_PICKBOX.setOrientation(QtCore.Qt.Orientation.Horizontal) self.horizontalSlider_PICKBOX.setObjectName("horizontalSlider_PICKBOX") self.widget_PICKBOX = QtWidgets.QWidget(self.groupBox_8) self.widget_PICKBOX.setGeometry(QtCore.QRect(10, 20, 51, 51)) @@ -207,7 +207,7 @@ def setupUi(self, Options_Dialog): self.groupBox_9.setObjectName("groupBox_9") self.horizontalSlider_GRIPSIZE = QtWidgets.QSlider(self.groupBox_9) self.horizontalSlider_GRIPSIZE.setGeometry(QtCore.QRect(70, 30, 191, 22)) - self.horizontalSlider_GRIPSIZE.setOrientation(QtCore.Qt.Horizontal) + self.horizontalSlider_GRIPSIZE.setOrientation(QtCore.Qt.Orientation.Horizontal) self.horizontalSlider_GRIPSIZE.setObjectName("horizontalSlider_GRIPSIZE") self.widget_GRIPSIZE = QtWidgets.QWidget(self.groupBox_9) self.widget_GRIPSIZE.setGeometry(QtCore.QRect(10, 20, 51, 51)) @@ -239,7 +239,7 @@ def setupUi(self, Options_Dialog): self.label_GRIPOBJLIMIT = QtWidgets.QLabel(self.groupBox_11) self.label_GRIPOBJLIMIT.setGeometry(QtCore.QRect(60, 100, 201, 31)) self.label_GRIPOBJLIMIT.setToolTip("") - self.label_GRIPOBJLIMIT.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.label_GRIPOBJLIMIT.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.label_GRIPOBJLIMIT.setWordWrap(True) self.label_GRIPOBJLIMIT.setObjectName("label_GRIPOBJLIMIT") self.tabWidget.addTab(self.SelectionTab, "") diff --git a/qad_pointerinput_settings_ui.py b/qad_pointerinput_settings_ui.py index 3a184f22..efb9dfe9 100644 --- a/qad_pointerinput_settings_ui.py +++ b/qad_pointerinput_settings_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_PointerInput_Settings_Dialog(object): @@ -22,7 +22,7 @@ def setupUi(self, PointerInput_Settings_Dialog): self.groupBox.setObjectName("groupBox") self.label = QtWidgets.QLabel(self.groupBox) self.label.setGeometry(QtCore.QRect(10, 20, 231, 41)) - self.label.setTextFormat(QtCore.Qt.AutoText) + self.label.setTextFormat(QtCore.Qt.TextFormat.AutoText) self.label.setWordWrap(True) self.label.setObjectName("label") self.groupBox_3 = QtWidgets.QGroupBox(self.groupBox) diff --git a/qad_rc.py b/qad_rc.py index 9da304ad..cdb75b8e 100644 --- a/qad_rc.py +++ b/qad_rc.py @@ -6,7 +6,7 @@ # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore +from qgis.PyQt import QtCore qt_resource_data = b"\ \x00\x00\x07\x45\ diff --git a/qad_rightclick_dlg.py b/qad_rightclick_dlg.py index 90c24538..87aaadd2 100644 --- a/qad_rightclick_dlg.py +++ b/qad_rightclick_dlg.py @@ -58,7 +58,7 @@ def __init__(self, plugIn, parent): def eventFilter(self, obj, event): if event is not None: - if event.type() == QEvent.FocusOut: + if event.type() == QEvent.Type.FocusOut: if obj == self.lineEdit_duration: return not self.lineEdit_SHORTCUTMENUDURATION_Validation() @@ -70,7 +70,7 @@ def eventFilter(self, obj, event): # timeSensitive_clicked # ============================================================================ def timeSensitive_clicked(self): - if self.checkBox_timeSensitive.checkState() == Qt.Checked: + if self.checkBox_timeSensitive.checkState() == Qt.CheckState.Checked: self.lineEdit_duration.setEnabled(True) self.groupBox_default.setEnabled(False) self.groupBox_command.setEnabled(False) @@ -154,7 +154,7 @@ def getShortCutMenuValue(self): shortCutMenu = shortCutMenu | 8 # 16 = Enables the display of a shortcut menu when the right button on the pointing device is held down long enough - if self.checkBox_timeSensitive.checkState() == Qt.Checked: + if self.checkBox_timeSensitive.checkState() == Qt.CheckState.Checked: shortCutMenu = shortCutMenu | 16 return shortCutMenu diff --git a/qad_rightclick_ui.py b/qad_rightclick_ui.py index 086ee044..18aa0a9d 100644 --- a/qad_rightclick_ui.py +++ b/qad_rightclick_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_RightClick_Dialog(object): diff --git a/qad_rubberband.py b/qad_rubberband.py index 085d9c90..49b38c10 100644 --- a/qad_rubberband.py +++ b/qad_rubberband.py @@ -72,7 +72,7 @@ def __init__(self, mapCanvas, cursorType): self.__crosshairRubberBandDw.setColor(csrColor) self.__crosshairRubberBandUp = QgsRubberBand(mapCanvas, QgsWkbTypes.LineGeometry) self.__crosshairRubberBandUp.setColor(csrColor) - screenRect = QApplication.desktop().screenGeometry(mapCanvas) + screenRect = (mapCanvas.screen() if mapCanvas.screen() is not None else QApplication.primaryScreen()).geometry() self.__halfScreenSize = max(screenRect.height(), screenRect.width()) if csrSize < 100: self.__halfScreenSize = self.__halfScreenSize / 2 @@ -86,7 +86,7 @@ def __init__(self, mapCanvas, cursorType): if cursorType & QadCursorTypeEnum.APERTURE: self.__apertureRubberBand = QgsRubberBand(mapCanvas, QgsWkbTypes.LineGeometry) self.__apertureRubberBand.setColor(QColor(QadVariables.get(QadMsg.translate("Environment variables", "PICKBOXCOLOR")))) - self.__apertureRubberBand.setLineStyle(Qt.DotLine) + self.__apertureRubberBand.setLineStyle(Qt.PenStyle.DotLine) self.__apertureSize = QadVariables.get(QadMsg.translate("Environment variables", "APERTURE")) else: self.__apertureRubberBand = None @@ -304,7 +304,7 @@ def createRubberBand(mapCanvas, geometryType = QgsWkbTypes.LineGeometry, alterna rb = QgsRubberBand(mapCanvas, geometryType) if alternativeBand: - rb.setLineStyle(Qt.DotLine) + rb.setLineStyle(Qt.PenStyle.DotLine) if borderColor is None: borderColor = getQGISColorForRubberBand(geometryType, alternativeBand) @@ -440,4 +440,3 @@ def setWidth(self, width): self.__rubberBandPoint.setWidth(width) self.__rubberBandLine.setWidth(width) self.__rubberBandPolygon.setWidth(width) - \ No newline at end of file diff --git a/qad_shortcuts.py b/qad_shortcuts.py index 46e934b8..cc2e9428 100644 --- a/qad_shortcuts.py +++ b/qad_shortcuts.py @@ -65,31 +65,31 @@ def unregisterForPrintableAndQadFKeys(self): self.sManager.setObjectKeySequence(obj, QKeySequence().toString()) # lo annulla # rimuove gli shortcut e le action relative ai caratteri F2, F3, F8, F12, ESC - seq = QKeySequence(Qt.Key_F2) + seq = QKeySequence(Qt.Key.Key_F2) obj = self.sManager.objectForSequence(seq) if obj is not None: self.objList.append([obj, seq]) self.sManager.setObjectKeySequence(obj, QKeySequence().toString()) # lo annulla - seq = QKeySequence(Qt.Key_F3) + seq = QKeySequence(Qt.Key.Key_F3) obj = self.sManager.objectForSequence(seq) if obj is not None: self.objList.append([obj, seq]) self.sManager.setObjectKeySequence(obj, QKeySequence().toString()) # lo annulla - seq = QKeySequence(Qt.Key_F8) + seq = QKeySequence(Qt.Key.Key_F8) obj = self.sManager.objectForSequence(seq) if obj is not None: self.objList.append([obj, seq]) self.sManager.setObjectKeySequence(obj, QKeySequence().toString()) # lo annulla - seq = QKeySequence(Qt.Key_F12) + seq = QKeySequence(Qt.Key.Key_F12) obj = self.sManager.objectForSequence(seq) if obj is not None: self.objList.append([obj, seq]) self.sManager.setObjectKeySequence(obj, QKeySequence().toString()) # lo annulla - seq = QKeySequence(Qt.Key_Escape) + seq = QKeySequence(Qt.Key.Key_Escape) obj = self.sManager.objectForSequence(seq) if obj is not None: self.objList.append([obj, seq]) diff --git a/qad_snappointsdisplaymanager.py b/qad_snappointsdisplaymanager.py index 158d1122..94e954bb 100644 --- a/qad_snappointsdisplaymanager.py +++ b/qad_snappointsdisplaymanager.py @@ -234,19 +234,19 @@ def show(self, SnapPoints, \ yMax = boundBox.yMaximum() upperIntersX = qad_utils.getXOnInfinityLine(self.__startPoint, point, yMax) - if upperIntersX > xMax or upperIntersX < xMin: + if upperIntersX is None or upperIntersX > xMax or upperIntersX < xMin: upperIntersX = None lowerIntersX = qad_utils.getXOnInfinityLine(self.__startPoint, point, yMin) - if lowerIntersX > xMax or lowerIntersX < xMin: + if lowerIntersX is None or lowerIntersX > xMax or lowerIntersX < xMin: lowerIntersX = None leftIntersY = qad_utils.getYOnInfinityLine(self.__startPoint, point, xMin) - if leftIntersY > yMax or leftIntersY < yMin: + if leftIntersY is None or leftIntersY > yMax or leftIntersY < yMin: leftIntersY = None rightIntersY = qad_utils.getYOnInfinityLine(self.__startPoint, point, xMax) - if rightIntersY > yMax or rightIntersY < yMin: + if rightIntersY is None or rightIntersY > yMax or rightIntersY < yMin: rightIntersY = None p1 = None @@ -339,7 +339,7 @@ def getLineMarker(self, pt1, pt2): """ lineMarker = createRubberBand(self.__mapCanvas, QgsWkbTypes.LineGeometry, True) lineMarker.setColor(self.__color) - lineMarker.setLineStyle(Qt.DashLine) + lineMarker.setLineStyle(Qt.PenStyle.DashLine) lineMarker.addPoint(pt1, False) lineMarker.addPoint(pt2, True) return lineMarker @@ -410,7 +410,7 @@ def getLinearObjMarker(self, linearObj): """ lineMarker = createRubberBand(self.__mapCanvas, QgsWkbTypes.LineGeometry, True) lineMarker.setColor(self.__color) - lineMarker.setLineStyle(Qt.DotLine) + lineMarker.setLineStyle(Qt.PenStyle.DotLine) points = linearObj.asPolyline() if points is None: return None @@ -422,4 +422,3 @@ def getLinearObjMarker(self, linearObj): lineMarker.addPoint(points[i], True) return lineMarker - \ No newline at end of file diff --git a/qad_textwindow.py b/qad_textwindow.py index 19091638..87dc54ab 100644 --- a/qad_textwindow.py +++ b/qad_textwindow.py @@ -94,7 +94,7 @@ def __init__(self, plugin): QDockWidget.__init__(self, plugin.iface.mainWindow()) self.setupUi(self) - self.setAllowedAreas(Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea) + self.setAllowedAreas(Qt.DockWidgetArea.TopDockWidgetArea | Qt.DockWidgetArea.BottomDockWidgetArea) self.plugin = plugin self.cmdSuggestWindow = None self.topLevelChanged['bool'].connect(self.onTopLevelChanged) @@ -155,7 +155,8 @@ def writeDockWidgetSettings(self): s.setValue("qad/text_window_width", self.width()) s.setValue("qad/text_window_height", self.height()) s.setValue("qad/text_window_floating", self.isFloating()) - s.setValue("qad/text_window_area", self.plugin.iface.mainWindow().dockWidgetArea(self)) + area = self.plugin.iface.mainWindow().dockWidgetArea(self) + s.setValue("qad/text_window_area", getattr(area, "value", area)) #QMessageBox.warning(None, "titolo" , "altezza: " + str(self.height())) @@ -169,7 +170,13 @@ def readDockWidgetSettings(self): width = s.value("qad/text_window_width", 400, type=int,) height = s.value("qad/text_window_height", 400, type=int,) isFloating = s.value("qad/text_window_floating", False, type=bool,) - dockWidgetArea = s.value("qad/text_window_area", Qt.BottomDockWidgetArea, type=int,) + # il valore è memorizzato come intero: in Qt6 va riconvertito esplicitamente in Qt.DockWidgetArea + defaultArea = Qt.DockWidgetArea.BottomDockWidgetArea + areaInt = s.value("qad/text_window_area", getattr(defaultArea, "value", defaultArea), type=int,) + try: + dockWidgetArea = Qt.DockWidgetArea(areaInt) + except ValueError: + dockWidgetArea = defaultArea #QMessageBox.warning(None, "titolo" , "altezza: " + str(height)) @@ -265,7 +272,7 @@ def showCmdSuggestWindow(self, mode = True, filter = ""): spaceUp = ptUp.y() if ptUp.y() - dataHeight < 0 else dataHeight ptDown = QPoint(ptUp.x(), ptUp.y() + self.edit.height()) - rect = QApplication.desktop().screenGeometry() + rect = QApplication.primaryScreen().geometry() spaceDown = rect.height() - ptDown.y() if ptDown.y() + dataHeight > rect.height() else dataHeight # verifico se c'è più spazio sopra o sotto la finestra @@ -275,15 +282,15 @@ def showCmdSuggestWindow(self, mode = True, filter = ""): else: pt = QPoint(ptDown.x(), ptDown.y()) dataHeight = spaceDown - elif self.getDockWidgetArea() == Qt.BottomDockWidgetArea: + elif self.getDockWidgetArea() == Qt.DockWidgetArea.BottomDockWidgetArea: pt = self.edit.mapToGlobal(QPoint(0,0)) if pt.y() - dataHeight < 0: dataHeight = pt.y() pt.setY(pt.y() - dataHeight) - elif self.getDockWidgetArea() == Qt.TopDockWidgetArea: + elif self.getDockWidgetArea() == Qt.DockWidgetArea.TopDockWidgetArea: pt = self.edit.mapToGlobal(QPoint(0,0)) pt.setY(pt.y() + self.edit.height()) - rect = QApplication.desktop().screenGeometry() + rect = QApplication.primaryScreen().geometry() if pt.y() + dataHeight > rect.height(): dataHeight = rect.height() - pt.y() @@ -410,7 +417,7 @@ def __init__(self, parent): # ============================================================================ # set_Colors # ============================================================================ - def set_Colors(self, foregroundColor = Qt.black, backGroundColor = Qt.lightGray): + def set_Colors(self, foregroundColor = Qt.GlobalColor.black, backGroundColor = Qt.GlobalColor.lightGray): f = QColor(foregroundColor) b = QColor(backGroundColor) rgbStrForeColor = "rgb({0},{1},{2})" @@ -432,10 +439,10 @@ def insertText(self, txt): cursor = self.textCursor() for line in txt.split('\n'): if len(line) > 0: # to avoid one more empty line - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) # fine documento + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) # fine documento self.setTextCursor(cursor) self.insertPlainText('\n' + line) - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) # fine documento + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) # fine documento self.setTextCursor(cursor) self.ensureCursorVisible() @@ -456,12 +463,12 @@ def __init__(self, parent, chronologyEdit): self.default = None self.inputMode = QadInputModeEnum.NONE - self.setTextInteractionFlags(Qt.TextEditorInteraction) + self.setTextInteractionFlags(Qt.TextInteractionFlag.TextEditorInteraction) self.setMinimumSize(30, 21) self.setUndoRedoEnabled(False) self.setAcceptRichText(False) - self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.historyIndex = 0 @@ -472,9 +479,9 @@ def __init__(self, parent, chronologyEdit): self.cmdOptionPosList = [] # lista delle posizioni delle opzioni del comando corrente self.currentCmdOptionPos = None - self.upperKeyWordForegroundColor = Qt.blue + self.upperKeyWordForegroundColor = Qt.GlobalColor.blue self.keyWordBackGroundColor = QColor(210, 210, 210) - self.keyWordHighlightBackGroundColor = Qt.gray + self.keyWordHighlightBackGroundColor = Qt.GlobalColor.gray self.tcf_normal = QTextCharFormat() self.tcf_keyWord = QTextCharFormat() @@ -497,7 +504,7 @@ def __init__(self, parent, chronologyEdit): # ============================================================================ # set_Colors # ============================================================================ - def set_Colors(self, foregroundColor = Qt.black, backGroundColor = Qt.white): + def set_Colors(self, foregroundColor = Qt.GlobalColor.black, backGroundColor = Qt.GlobalColor.white): f = QColor(foregroundColor) b = QColor(backGroundColor) rgbStrForeColor = "rgb({0},{1},{2})" @@ -513,32 +520,32 @@ def set_Colors(self, foregroundColor = Qt.black, backGroundColor = Qt.white): self.tcf_normal.setForeground(foregroundColor) self.tcf_normal.setBackground(backGroundColor) - self.tcf_normal.setFontWeight(QFont.Normal) + self.tcf_normal.setFontWeight(QFont.Weight.Normal) # ============================================================================ # set_keyWordColors # ============================================================================ - def set_keyWordColors(self, backGroundColor = QColor(210, 210, 210), upperKeyWord_ForegroundColor = Qt.blue, \ - highlightKeyWord_BackGroundColor = Qt.gray): + def set_keyWordColors(self, backGroundColor = QColor(210, 210, 210), upperKeyWord_ForegroundColor = Qt.GlobalColor.blue, \ + highlightKeyWord_BackGroundColor = Qt.GlobalColor.gray): self.tcf_keyWord.setBackground(backGroundColor) self.tcf_upperKeyWord.setForeground(upperKeyWord_ForegroundColor) self.tcf_upperKeyWord.setBackground(backGroundColor) - self.tcf_upperKeyWord.setFontWeight(QFont.Bold) + self.tcf_upperKeyWord.setFontWeight(QFont.Weight.Bold) self.tcf_highlightKeyWord.setBackground(highlightKeyWord_BackGroundColor) self.tcf_highlightUpperKeyWord.setForeground(upperKeyWord_ForegroundColor) self.tcf_highlightUpperKeyWord.setBackground(highlightKeyWord_BackGroundColor) - self.tcf_highlightUpperKeyWord.setFontWeight(QFont.Bold) + self.tcf_highlightUpperKeyWord.setFontWeight(QFont.Weight.Bold) def setFormat(self, start, count, fmt): # 1-indexed if count == 0: return cursor = QTextCursor(self.textCursor()) - cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) # inizio documento - cursor.movePosition(QTextCursor.Right, QTextCursor.MoveAnchor, start) - cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor, count) + cursor.movePosition(QTextCursor.MoveOperation.Start, QTextCursor.MoveMode.MoveAnchor) # inizio documento + cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.MoveAnchor, start) + cursor.movePosition(QTextCursor.MoveOperation.Right, QTextCursor.MoveMode.KeepAnchor, count) cursor.setCharFormat(fmt); self.setCurrentCharFormat(self.tcf_normal) @@ -632,8 +639,8 @@ def appendCmdTextForAutoComplete(self, cmdName, filterLen): self.insertPlainText(cmdName[filterLen:]) else: self.insertPlainText("") - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, len(cmdName) - filterLen) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.Left, QTextCursor.MoveMode.KeepAnchor, len(cmdName) - filterLen) self.setTextCursor(cursor) @@ -644,16 +651,16 @@ def showMsg(self, msg, displayPromptAfterMsg = False, append = True): if sep >= 0: self.showMsgOnChronologyEdit(self.toPlainText() + msg[0:sep]) newMsg = msg[sep + 1:] - cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor) + cursor.movePosition(QTextCursor.MoveOperation.Start, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.KeepAnchor) else: if append == True: cursor = self.textCursor() - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) # fine documento + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) # fine documento newMsg = msg else: - cursor.movePosition(QTextCursor.Start, QTextCursor.MoveAnchor) - cursor.movePosition(QTextCursor.End, QTextCursor.KeepAnchor) + cursor.movePosition(QTextCursor.MoveOperation.Start, QTextCursor.MoveMode.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.KeepAnchor) newMsg = self.currentPrompt + msg self.setTextCursor(cursor) @@ -824,7 +831,7 @@ def mouseReleaseEvent(self, event): QTextEdit.mouseReleaseEvent(self, event) # se sono sull'ultima riga if self.textCursor().position() >= self.document().lastBlock().position(): - if event.button() == Qt.LeftButton: + if event.button() == Qt.MouseButton.LeftButton: cmdOptionPos = self.getCmdOptionPosUnderMouse(event.pos()) if cmdOptionPos is not None: # estraggo la parte maiuscola della parola chiave @@ -848,8 +855,8 @@ def keyPressEvent(self, e): if self.inputType & QadInputTypeEnum.COMMAND: # if Up or Down is pressed if self.parentWidget().isVisibleCmdSuggestWindow() and \ - (e.key() == Qt.Key_Down or e.key() == Qt.Key_Up or e.key() == Qt.Key_PageDown or e.key() == Qt.Key_PageUp or - e.key() == Qt.Key_End or e.key() == Qt.Key_Home): + (e.key() == Qt.Key.Key_Down or e.key() == Qt.Key.Key_Up or e.key() == Qt.Key.Key_PageDown or e.key() == Qt.Key.Key_PageUp or + e.key() == Qt.Key.Key_End or e.key() == Qt.Key.Key_Home): self.parentWidget().cmdSuggestWindow.keyPressEvent(e) return else: # nascondo la finestra di suggerimento @@ -860,12 +867,12 @@ def keyPressEvent(self, e): # if the cursor isn't in the edit zone, don't do anything except Ctrl+C if not self.isCursorInEditionZone(): - if e.modifiers() & Qt.ControlModifier or e.modifiers() & Qt.MetaModifier: - if e.key() == Qt.Key_C or e.key() == Qt.Key_A: + if e.modifiers() & Qt.KeyboardModifier.ControlModifier or e.modifiers() & Qt.KeyboardModifier.MetaModifier: + if e.key() == Qt.Key.Key_C or e.key() == Qt.Key.Key_A: QTextEdit.keyPressEvent(self, e) else: # all other keystrokes get sent to the input line - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) self.setTextCursor(cursor) QTextEdit.keyPressEvent(self, e) @@ -873,44 +880,44 @@ def keyPressEvent(self, e): self.ensureCursorVisible() else: # if Return is pressed, then perform the commands - if e.key() == Qt.Key_Return or e.key == Qt.Key_Enter: + if e.key() == Qt.Key.Key_Return or e.key == Qt.Key.Key_Enter: self.entered() # if Space is pressed during command request or value not string request - elif e.key() == Qt.Key_Space and \ + elif e.key() == Qt.Key.Key_Space and \ (self.inputType & QadInputTypeEnum.COMMAND or not(self.inputType & QadInputTypeEnum.STRING)): self.entered() return # if Up or Down is pressed - elif e.key() == Qt.Key_Down: + elif e.key() == Qt.Key.Key_Down: self.showNextCmd() return # per non far comparire la finestra di suggerimento - elif e.key() == Qt.Key_Up: + elif e.key() == Qt.Key.Key_Up: self.showPreviousCmd() return # per non far comparire la finestra di suggerimento # if backspace is pressed, delete until we get to the prompt - elif e.key() == Qt.Key_Backspace: + elif e.key() == Qt.Key.Key_Backspace: if not cursor.hasSelection() and cursor.columnNumber() == self.currentPromptLength: return QTextEdit.keyPressEvent(self, e) # if the left key is pressed, move left until we get to the prompt - elif e.key() == Qt.Key_Left and cursor.position() > self.document().lastBlock().position() + self.currentPromptLength: - anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor - move = QTextCursor.WordLeft if e.modifiers() & Qt.ControlModifier or e.modifiers() & Qt.MetaModifier else QTextCursor.Left + elif e.key() == Qt.Key.Key_Left and cursor.position() > self.document().lastBlock().position() + self.currentPromptLength: + anchor = QTextCursor.MoveMode.KeepAnchor if e.modifiers() & Qt.KeyboardModifier.ShiftModifier else QTextCursor.MoveMode.MoveAnchor + move = QTextCursor.MoveOperation.WordLeft if e.modifiers() & Qt.KeyboardModifier.ControlModifier or e.modifiers() & Qt.KeyboardModifier.MetaModifier else QTextCursor.MoveOperation.Left cursor.movePosition(move, anchor) # use normal operation for right key - elif e.key() == Qt.Key_Right: - anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor - move = QTextCursor.WordRight if e.modifiers() & Qt.ControlModifier or e.modifiers() & Qt.MetaModifier else QTextCursor.Right + elif e.key() == Qt.Key.Key_Right: + anchor = QTextCursor.MoveMode.KeepAnchor if e.modifiers() & Qt.KeyboardModifier.ShiftModifier else QTextCursor.MoveMode.MoveAnchor + move = QTextCursor.MoveOperation.WordRight if e.modifiers() & Qt.KeyboardModifier.ControlModifier or e.modifiers() & Qt.KeyboardModifier.MetaModifier else QTextCursor.MoveOperation.Right cursor.movePosition(move, anchor) # if home is pressed, move cursor to right of prompt - elif e.key() == Qt.Key_Home: - anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor - cursor.movePosition(QTextCursor.StartOfBlock, anchor, 1) - cursor.movePosition(QTextCursor.Right, anchor, self.currentPromptLength) + elif e.key() == Qt.Key.Key_Home: + anchor = QTextCursor.MoveMode.KeepAnchor if e.modifiers() & Qt.KeyboardModifier.ShiftModifier else QTextCursor.MoveMode.MoveAnchor + cursor.movePosition(QTextCursor.MoveOperation.StartOfBlock, anchor, 1) + cursor.movePosition(QTextCursor.MoveOperation.Right, anchor, self.currentPromptLength) # use normal operation for end key - elif e.key() == Qt.Key_End: - anchor = QTextCursor.KeepAnchor if e.modifiers() & Qt.ShiftModifier else QTextCursor.MoveAnchor - cursor.movePosition(QTextCursor.EndOfBlock, anchor, 1) + elif e.key() == Qt.Key.Key_End: + anchor = QTextCursor.MoveMode.KeepAnchor if e.modifiers() & Qt.KeyboardModifier.ShiftModifier else QTextCursor.MoveMode.MoveAnchor + cursor.movePosition(QTextCursor.MoveOperation.EndOfBlock, anchor, 1) # use normal operation for all remaining keys else: QTextEdit.keyPressEvent(self, e) @@ -950,7 +957,7 @@ def entered(self): cmdsHistory = self.parentWidget().plugin.cmdsHistory self.historyIndex = len(cmdsHistory) cursor = self.textCursor() - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) self.setTextCursor(cursor) self.evaluate(unicode(self.currentCommand())) @@ -969,7 +976,7 @@ def getCurrMsg(self): """ cursor = self.textCursor() prevPos = cursor.position() - cursor.movePosition(QTextCursor.End, QTextCursor.MoveAnchor) + cursor.movePosition(QTextCursor.MoveOperation.End, QTextCursor.MoveMode.MoveAnchor) self.setTextCursor(cursor) msg = unicode(self.currentCommand()) cursor.setPosition(prevPos) @@ -1198,7 +1205,7 @@ def evaluate(self, cmd): def getOptimalHeight(self): fm = QFontMetrics(self.currentFont()) - pixelsWidth = fm.width(QadMsg.translate("QAD", "Command: ")) + pixelsWidth = fm.horizontalAdvance(QadMsg.translate("QAD", "Command: ")) pixelsHeight = fm.height() # + 8 perché la QTextEdit ha un offset verticale sopra e sotto il testo return max(int(self.document().size().height()), pixelsHeight + 8) @@ -1216,7 +1223,7 @@ class QadCmdSuggestWindow(QWidget, Ui_QadCmdSuggestWindow, object): def __init__(self, parent, editWidget, infoCmds, infoVars): # lista composta da elementi con: # , , , - QWidget.__init__(self, parent, Qt.ToolTip) + QWidget.__init__(self, parent, Qt.WindowType.ToolTip) self.editWidget = editWidget self.setupUi(self) @@ -1302,7 +1309,7 @@ def setFilter(self, filter = ""): if l > 0: self.cmdNamesListView.set(filteredInfo) # seleziono il primo che incomincia per filter - items = self.cmdNamesListView.model.findItems(filter, Qt.MatchStartsWith) + items = self.cmdNamesListView.model.findItems(filter, Qt.MatchFlag.MatchStartsWith) if len(items) > 0: self.cmdNamesListView.setCurrentIndex(self.cmdNamesListView.model.indexFromItem(items[0])) @@ -1366,12 +1373,12 @@ class QadCmdSuggestListView(QListView): def __init__(self, parent): QListView.__init__(self, parent) - self.setViewMode(QListView.ListMode) - self.setSelectionBehavior(QAbstractItemView.SelectItems) + self.setViewMode(QListView.ViewMode.ListMode) + self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectItems) self.setUniformItemSizes(True) self.model = QStandardItemModel() self.setModel(self.model) - self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) def set(self, filteredCmdNames): # lista composta da elementi con , , @@ -1396,14 +1403,14 @@ def set(self, filteredCmdNames): def keyPressEvent(self, e): - if e.key() == Qt.Key_Up or e.key() == Qt.Key_Down or \ - e.key() == Qt.Key_PageUp or e.key() == Qt.Key_PageDown or \ - e.key() == Qt.Key_End or e.key() == Qt.Key_Home: + if e.key() == Qt.Key.Key_Up or e.key() == Qt.Key.Key_Down or \ + e.key() == Qt.Key.Key_PageUp or e.key() == Qt.Key.Key_PageDown or \ + e.key() == Qt.Key.Key_End or e.key() == Qt.Key.Key_Home: QListView.keyPressEvent(self, e) cmdName = self.selectionModel().currentIndex().data() self.parentWidget().showMsg(cmdName) # if Return is pressed, then perform the commands - elif e.key() == Qt.Key_Return or e.key == Qt.Key_Enter: + elif e.key() == Qt.Key.Key_Return or e.key == Qt.Key.Key_Enter: cmd = self.selectionModel().currentIndex().data() if cmd is not None: self.parentWidget().showMsg(cmd) diff --git a/qad_tooltip_appearance_ui.py b/qad_tooltip_appearance_ui.py index 0893f90f..6056510a 100644 --- a/qad_tooltip_appearance_ui.py +++ b/qad_tooltip_appearance_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_ToolTipAppearance_Dialog(object): @@ -38,14 +38,14 @@ def setupUi(self, ToolTipAppearance_Dialog): self.slider_size = QtWidgets.QSlider(self.groupBox_2) self.slider_size.setGeometry(QtCore.QRect(130, 20, 291, 22)) self.slider_size.setPageStep(1) - self.slider_size.setOrientation(QtCore.Qt.Horizontal) + self.slider_size.setOrientation(QtCore.Qt.Orientation.Horizontal) self.slider_size.setObjectName("slider_size") self.groupBox_3 = QtWidgets.QGroupBox(ToolTipAppearance_Dialog) self.groupBox_3.setGeometry(QtCore.QRect(10, 190, 431, 51)) self.groupBox_3.setObjectName("groupBox_3") self.slider_transparency = QtWidgets.QSlider(self.groupBox_3) self.slider_transparency.setGeometry(QtCore.QRect(130, 20, 291, 22)) - self.slider_transparency.setOrientation(QtCore.Qt.Horizontal) + self.slider_transparency.setOrientation(QtCore.Qt.Orientation.Horizontal) self.slider_transparency.setObjectName("slider_transparency") self.edit_transparency = QtWidgets.QLineEdit(self.groupBox_3) self.edit_transparency.setGeometry(QtCore.QRect(10, 20, 113, 20)) diff --git a/qad_ui_textwindow.py b/qad_ui_textwindow.py index 26af059f..351e91cd 100644 --- a/qad_ui_textwindow.py +++ b/qad_ui_textwindow.py @@ -21,7 +21,7 @@ """ -from PyQt5 import QtCore, QtGui +from qgis.PyQt import QtCore, QtGui from qgis.PyQt.QtWidgets import QWidget, QVBoxLayout, QMessageBox from .qad_msg import QadMsg @@ -29,7 +29,7 @@ class Ui_QadTextWindow(object): def setupUi(self, QadTextWindow): #QadTextWindow.setObjectName("QadTextWindow") - QadTextWindow.setWindowModality(QtCore.Qt.NonModal) + QadTextWindow.setWindowModality(QtCore.Qt.WindowModality.NonModal) QadTextWindow.setEnabled(True) QadTextWindow.resize(642, 193) QadTextWindow.setMinimumSize(100, 20) @@ -44,13 +44,13 @@ def retranslateUi(self, QadTextWindow): class Ui_QadCmdSuggestWindow(object): def setupUi(self, QadCmdSuggestWindow): QadCmdSuggestWindow.setObjectName("QadCmdsListWindow") - QadCmdSuggestWindow.setWindowModality(QtCore.Qt.NonModal) + QadCmdSuggestWindow.setWindowModality(QtCore.Qt.WindowModality.NonModal) QadCmdSuggestWindow.setEnabled(True) self.dockWidgetContents = QWidget() self.dockWidgetContents.setObjectName("QadCmdsListWindowDockWidgetContents") self.vboxlayout = QVBoxLayout(self.dockWidgetContents) self.vboxlayout.setObjectName("QadCmdsListWindowVBoxLayout") - self.vboxlayout.setMargin(0) + self.vboxlayout.setContentsMargins(0, 0, 0, 0) QadCmdSuggestWindow.setLayout(self.vboxlayout) QtCore.QMetaObject.connectSlotsByName(QadCmdSuggestWindow) diff --git a/qad_utils.py b/qad_utils.py index 2b595719..0dfa4546 100644 --- a/qad_utils.py +++ b/qad_utils.py @@ -146,8 +146,8 @@ def setMapCanvasToolTip(msg): else: font_size = QFont().pointSize() p = QPalette() - fColor = p.color(QPalette.Inactive, QPalette.ToolTipText) - bColor = p.color(QPalette.Inactive, QPalette.ToolTipBase) + fColor = p.color(QPalette.ColorGroup.Inactive, QPalette.ColorRole.ToolTipText) + bColor = p.color(QPalette.ColorGroup.Inactive, QPalette.ColorRole.ToolTipBase) toolTipFont = QToolTip.font() if toolTipFont.pointSize() != font_size: @@ -155,10 +155,10 @@ def setMapCanvasToolTip(msg): QToolTip.setFont(toolTipFont) toolTipPalette = QToolTip.palette() - if toolTipPalette.color(QPalette.Inactive, QPalette.ToolTipText) != fColor or \ - toolTipPalette.color(QPalette.Inactive, QPalette.ToolTipBase) != bColor: - toolTipPalette.setColor(QPalette.Inactive, QPalette.ToolTipText, fColor) - toolTipPalette.setColor(QPalette.Inactive, QPalette.ToolTipBase, bColor) + if toolTipPalette.color(QPalette.ColorGroup.Inactive, QPalette.ColorRole.ToolTipText) != fColor or \ + toolTipPalette.color(QPalette.ColorGroup.Inactive, QPalette.ColorRole.ToolTipBase) != bColor: + toolTipPalette.setColor(QPalette.ColorGroup.Inactive, QPalette.ColorRole.ToolTipText, fColor) + toolTipPalette.setColor(QPalette.ColorGroup.Inactive, QPalette.ColorRole.ToolTipBase, bColor) QToolTip.setPalette(toolTipPalette) QToolTip.showText(pt, msg) @@ -247,8 +247,8 @@ def isNumericField(field): La funzione verifica che il campo di tipo QgsField sia numerico """ fldType = field.type() - if fldType == QMetaType.Double or fldType == QMetaType.LongLong or fldType == QMetaType.Int or \ - fldType == QMetaType.ULongLong or fldType == QMetaType.UInt: + if fldType == QMetaType.Type.Double or fldType == QMetaType.Type.LongLong or fldType == QMetaType.Type.Int or \ + fldType == QMetaType.Type.ULongLong or fldType == QMetaType.Type.UInt: return True else: return False @@ -464,6 +464,11 @@ def str2QgsPoint(s, lastPoint = None, currenPoint = None, oneNumberAllowed = Tru return None angle = getAngleBy2Pts(lastPoint, currenPoint) + # se la modalita' ORTO e' attiva, l'angolo (derivato dalla posizione del cursore) + # viene arrotondato all'asse ortogonale piu' vicino (entrata diretta della distanza) + if QadVariables.get(QadMsg.translate("Environment variables", "ORTHOMODE")) == 1: + halfPi = math.pi / 2 + angle = (round(angle / halfPi) % 4) * halfPi coords = getPolarPointByPtAngle(lastPoint, angle, dist) return QgsPointXY(coords[0], coords[1]) diff --git a/qad_windowcolor_dlg.py b/qad_windowcolor_dlg.py index 3700011f..b6744aba 100644 --- a/qad_windowcolor_dlg.py +++ b/qad_windowcolor_dlg.py @@ -101,7 +101,7 @@ def __init__(self, plugIn, parent, contextEnum = QadColorContextEnum.NONE, eleme item = items[0] if item is not None: index = self.listView_Context.model().indexFromItem(item) - self.listView_Context.selectionModel().setCurrentIndex(index, QItemSelectionModel.SelectCurrent) + self.listView_Context.selectionModel().setCurrentIndex(index, QItemSelectionModel.SelectionFlag.SelectCurrent) if elementEnum != QadColorElementEnum.NONE: # elementi @@ -113,7 +113,7 @@ def __init__(self, plugIn, parent, contextEnum = QadColorContextEnum.NONE, eleme item = items[0] if item is not None: index = self.listView_Element.model().indexFromItem(item) - self.listView_Element.selectionModel().setCurrentIndex(index, QItemSelectionModel.SelectCurrent) + self.listView_Element.selectionModel().setCurrentIndex(index, QItemSelectionModel.SelectionFlag.SelectCurrent) # ============================================================================ @@ -416,7 +416,7 @@ def ButtonHELP_Pressed(self): # QadPreview class. # =============================================================================== class QadPreview(QWidget): - def __init__(self, plugIn, parent, tempQadVariables, context, windowFlags = Qt.Widget): + def __init__(self, plugIn, parent, tempQadVariables, context, windowFlags = Qt.WindowType.Widget): self.plugIn = plugIn self.context = context self.tempQadVariables = tempQadVariables @@ -437,20 +437,20 @@ def paint_MODEL_SPACE_2D(self): rect = self.rect() painter = QPainter(self) painter.fillRect(rect, self.plugIn.canvas.canvasColor()) - painter.setRenderHint(QPainter.Antialiasing) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) # PICKBOX x1 = (int) (rect.width() / 3) y1 = (int) (rect.height() - rect.height() / 3) color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "PICKBOXCOLOR"))) pickSize = 5 - painter.setPen(QPen(color, 1, Qt.SolidLine)) + painter.setPen(QPen(color, 1, Qt.PenStyle.SolidLine)) painter.drawRect(x1 - pickSize, y1 - pickSize, 2 * pickSize, 2 * pickSize) # CROSSHAIRS color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "CURSORCOLOR"))) cursorSize = 20 - painter.setPen(QPen(color, 1, Qt.SolidLine)) + painter.setPen(QPen(color, 1, Qt.PenStyle.SolidLine)) painter.drawLine(x1 - pickSize, y1, x1 - pickSize - cursorSize, y1) painter.drawLine(x1 + pickSize, y1, x1 + pickSize + cursorSize, y1) painter.drawLine(x1, y1 - pickSize, x1, y1 - pickSize - cursorSize) @@ -459,7 +459,7 @@ def paint_MODEL_SPACE_2D(self): # AUTOTRECK_VECTOR x1 = (int) (rect.width() / 3) color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "AUTOTRECKINGVECTORCOLOR"))) - painter.setPen(QPen(color, 1, Qt.DashLine)) + painter.setPen(QPen(color, 1, Qt.PenStyle.DashLine)) painter.drawLine(x1, 0, x1, rect.height()) painter.drawLine((int) (x1 + rect.height() * 2 / 3), 0, (int) (x1 - rect.height() / 3), rect.height()) @@ -468,7 +468,7 @@ def paint_MODEL_SPACE_2D(self): y1 = (int) (rect.height() / 3) color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "AUTOSNAPCOLOR"))) pickSize = 5 - painter.setPen(QPen(color, 2, Qt.SolidLine)) + painter.setPen(QPen(color, 2, Qt.PenStyle.SolidLine)) painter.drawRect(x1 - pickSize, y1 - pickSize, 2 * pickSize, 2 * pickSize) # DYNAMIC INPUT @@ -477,10 +477,10 @@ def paint_MODEL_SPACE_2D(self): cursorSize = 20 fMetrics = painter.fontMetrics() msg1 = "12.3456" - sz1 = fMetrics.size(Qt.TextSingleLine, msg1 + "__") + sz1 = fMetrics.size(Qt.TextFlag.TextSingleLine, msg1 + "__") dynInputRect1 = QRectF(x1 + cursorSize, y1 + cursorSize, sz1.width(), sz1.height() + 2) msg2 = "78.9012" - sz2 = fMetrics.size(Qt.TextSingleLine, msg2 + "__") + sz2 = fMetrics.size(Qt.TextFlag.TextSingleLine, msg2 + "__") dynInputRect2 = QRectF(dynInputRect1.right() + sz1.height() / 3, dynInputRect1.top(), sz2.width(), sz2.height() + 2) # DYNAMIC INPUT COMMAND DESCR BACKGROUND color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "DYNEDITBACKCOLOR"))) @@ -488,12 +488,12 @@ def paint_MODEL_SPACE_2D(self): painter.fillRect(dynInputRect2, color) # DYNAMIC INPUT COMMAND DESCR BORDER color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "DYNEDITBORDERCOLOR"))) - painter.setPen(QPen(color, 1, Qt.SolidLine)) + painter.setPen(QPen(color, 1, Qt.PenStyle.SolidLine)) painter.drawRect(dynInputRect1) painter.drawRect(dynInputRect2) # DYNAMIC INPUT COMMAND DESCR FOREGROUND color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "DYNEDITFORECOLOR"))) - painter.setPen(QPen(color, 1, Qt.SolidLine)) + painter.setPen(QPen(color, 1, Qt.PenStyle.SolidLine)) painter.drawText(dynInputRect1, msg1) painter.drawText(dynInputRect2, msg2) @@ -510,7 +510,7 @@ def paint_COMMAND_LINE(self): # CMDHISTORYFORECOLOR color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "CMDHISTORYFORECOLOR"))) painter.setPen(QPen(color)) - painter.drawText(QRectF(0, 0, rect.width(), sep), Qt.AlignCenter, QadMsg.translate("QAD", "Command: ")) + painter.drawText(QRectF(0, 0, rect.width(), sep), Qt.AlignmentFlag.AlignCenter, QadMsg.translate("QAD", "Command: ")) # CMDLINEBACKCOLOR color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "CMDLINEBACKCOLOR"))) @@ -519,5 +519,5 @@ def paint_COMMAND_LINE(self): # CMDLINEFORECOLOR color = QColor(self.tempQadVariables.get(QadMsg.translate("Environment variables", "CMDLINEFORECOLOR"))) painter.setPen(QPen(color)) - painter.drawText(QRectF(0, sep, rect.width(), rect.height() - sep), Qt.AlignCenter, QadMsg.translate("QAD", "Command: ")) + painter.drawText(QRectF(0, sep, rect.width(), rect.height() - sep), Qt.AlignmentFlag.AlignCenter, QadMsg.translate("QAD", "Command: ")) diff --git a/qad_windowcolor_ui.py b/qad_windowcolor_ui.py index f64620c7..46fb3d8c 100644 --- a/qad_windowcolor_ui.py +++ b/qad_windowcolor_ui.py @@ -8,7 +8,7 @@ # run again. Do not edit this file unless you know what you are doing. -from PyQt5 import QtCore, QtGui, QtWidgets +from qgis.PyQt import QtCore, QtGui, QtWidgets class Ui_WindowColor_Dialog(object):