From e0a7afb2cda95e40ec84610b06f5892fb676e9f0 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 5 Aug 2021 02:00:54 +0300 Subject: [PATCH] - fixed fullscreen functionality for PyQt6 and a few other fixes regarding the port to PyQt6 --- CHANGELOG.md | 1 + FlatCAM.py | 15 ++++-- appEditors/AppGerberEditor.py | 7 +-- appGUI/GUIElements.py | 17 +++--- appGUI/MainGUI.py | 62 +++++++++++---------- appGUI/VisPyCanvas.py | 3 +- appGUI/preferences/PreferencesUIManager.py | 12 ++--- appPlugins/ToolIsolation.py | 2 +- appPlugins/ToolNCC.py | 2 +- appTranslation.py | 12 ++--- app_Main.py | 63 +++++++++++----------- 11 files changed, 107 insertions(+), 89 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70033bdd..fae68728 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta - continuing to fix the PyQt6 port - added an Exception when App.on_canvas_setup() fails +- fixed fullscreen functionality for PyQt6 and a few other fixes regarding the port to PyQt6 4.08.2021 diff --git a/FlatCAM.py b/FlatCAM.py index 2c378a12..172a86ad 100644 --- a/FlatCAM.py +++ b/FlatCAM.py @@ -4,7 +4,7 @@ import traceback from datetime import datetime from PyQt6 import QtWidgets -from PyQt6.QtCore import QSettings, Qt +from PyQt6.QtCore import QSettings, Qt, QTimer from app_Main import App from appGUI import VisPyPatches @@ -95,10 +95,11 @@ if __name__ == '__main__': with open(log_file_path, 'w') as f: f.write(msg) - if minor_v >= 8: - os._exit(0) - else: - sys.exit(0) + # if minor_v >= 8: + # os._exit(0) + # else: + # sys.exit(0) + sys.exit(0) debug_trace() VisPyPatches.apply_patches() @@ -159,5 +160,9 @@ if __name__ == '__main__': fc = App(qapp=app) + timer = QTimer() + timer.timeout.connect(lambda: None) + timer.start(100) + sys.exit(app.exec()) # app.exec_() diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index 1933a3b1..61acc0da 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -3425,7 +3425,7 @@ class AppGerberEditor(QtCore.QObject): self.app.ui.aperture_delete_btn.triggered.connect(self.on_delete_btn) self.ui.name_entry.returnPressed.connect(self.on_name_activate) - self.ui.aptype_cb.currentIndexChanged[str].connect(self.on_aptype_changed) + self.ui.aptype_cb.currentIndexChanged.connect(self.on_aptype_changed) self.ui.addaperture_btn.clicked.connect(self.on_aperture_add) self.ui.apsize_entry.returnPressed.connect(self.on_aperture_add) @@ -4222,9 +4222,10 @@ class AppGerberEditor(QtCore.QObject): def on_name_activate(self): self.edited_obj_name = self.ui.name_entry.get_value() - def on_aptype_changed(self, current_text): + def on_aptype_changed(self, current_index): # 'O' is letter O not zero. - if current_text == 'R' or current_text == 'O': + print(current_index) + if current_index == 1 or current_index == 2: # 1 == 'R' and 2 == 'O' self.ui.apdim_lbl.setDisabled(False) self.ui.apdim_entry.setDisabled(False) self.ui.apsize_entry.setDisabled(True) diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py index 6a9b96e7..2a39c3d6 100644 --- a/appGUI/GUIElements.py +++ b/appGUI/GUIElements.py @@ -3178,11 +3178,12 @@ class FCDetachableTab(QtWidgets.QTabWidget): :param event: a mouse press event :return: """ - if event.button() == QtCore.Qt.MouseButton.RightButton and self.prev_index == self.tabAt(event.pos()): + if event.button() == QtCore.Qt.MouseButton.RightButton and \ + self.prev_index == self.tabAt(event.position().toPoint()): self.right_click.emit(self.prev_index) if event.button() == QtCore.Qt.MouseButton.MiddleButton: - self.onCloseTabSignal.emit(int(self.tabAt(event.pos()))) + self.onCloseTabSignal.emit(int(self.tabAt(event.position().toPoint()))) self.prev_index = -1 @@ -4701,13 +4702,13 @@ class FCJog(QtWidgets.QFrame): super(FCJog, self).__init__(*args, **kwargs) self.app = app - self.setFrameShape(QtWidgets.QFrame.Box) + self.setFrameShape(QtWidgets.QFrame.Shape.Box) self.setLineWidth(1) # JOG axes grbl_jog_grid = QtWidgets.QGridLayout() grbl_jog_grid.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) - grbl_jog_grid.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize) + grbl_jog_grid.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetMinimumSize) grbl_jog_grid.setContentsMargins(2, 4, 2, 4) self.setLayout(grbl_jog_grid) @@ -4780,7 +4781,7 @@ class FCZeroAxes(QtWidgets.QFrame): super(FCZeroAxes, self).__init__(*args, **kwargs) self.app = app - self.setFrameShape(QtWidgets.QFrame.Box) + self.setFrameShape(QtWidgets.QFrame.Shape.Box) self.setLineWidth(1) # Zero the axes @@ -5152,9 +5153,9 @@ def message_dialog(title, message, kind="info", parent=None): :param parent: parent :return: None """ - icon = {"info": QtWidgets.QMessageBox.Information, - "warning": QtWidgets.QMessageBox.Warning, - "error": QtWidgets.QMessageBox.Critical}[str(kind)] + icon = {"info": QtWidgets.QMessageBox.Icon.Information, + "warning": QtWidgets.QMessageBox.Icon.Warning, + "error": QtWidgets.QMessageBox.Icon.Critical}[str(kind)] dlg = QtWidgets.QMessageBox(icon, title, message, parent=parent) dlg.setText(message) dlg.exec() diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 4d194143..aee897f0 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -2201,10 +2201,10 @@ class MainGUI(QtWidgets.QMainWindow): msgbox.setText(_("Are you sure you want to delete the GUI Settings? \n")) msgbox.setWindowTitle(_("Clear GUI Settings")) msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/trash32.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.setDefaultButton(bt_no) msgbox.exec() @@ -3080,10 +3080,10 @@ class MainGUI(QtWidgets.QMainWindow): messagebox.setText(msg) messagebox.setWindowTitle(_("Warning")) messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png')) - messagebox.setIcon(QtWidgets.QMessageBox.Question) + messagebox.setIcon(QtWidgets.QMessageBox.Icon.Question) - messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok) - messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok) + messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) + messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok) messagebox.exec() return # SHIFT @@ -3240,10 +3240,10 @@ class MainGUI(QtWidgets.QMainWindow): messagebox.setText(msg) messagebox.setWindowTitle(_("Warning")) messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png')) - messagebox.setIcon(QtWidgets.QMessageBox.Warning) + messagebox.setIcon(QtWidgets.QMessageBox.Icon.Warning) - messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok) - messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok) + messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) + messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok) messagebox.exec() # Paint @@ -3287,10 +3287,10 @@ class MainGUI(QtWidgets.QMainWindow): messagebox.setText(msg) messagebox.setWindowTitle(_("Warning")) messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png')) - messagebox.setIcon(QtWidgets.QMessageBox.Warning) + messagebox.setIcon(QtWidgets.QMessageBox.Icon.Warning) - messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok) - messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok) + messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) + messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok) messagebox.exec() # Add Text Tool @@ -3309,10 +3309,10 @@ class MainGUI(QtWidgets.QMainWindow): messagebox.setText(msg) messagebox.setWindowTitle(_("Warning")) messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png')) - messagebox.setIcon(QtWidgets.QMessageBox.Warning) + messagebox.setIcon(QtWidgets.QMessageBox.Icon.Warning) - messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok) - messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok) + messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) + messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok) messagebox.exec() # Flip on X axis @@ -4041,7 +4041,10 @@ class MainGUI(QtWidgets.QMainWindow): if not self.isMaximized(): self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0]) - self.final_save.emit() + try: + self.final_save.emit() + except SystemError: + sys.exit(0) event.ignore() def on_fullscreen(self, disable=False): @@ -4059,24 +4062,27 @@ class MainGUI(QtWidgets.QMainWindow): self.y_pos = a.y() self.width = a.width() self.height = a.height() - self.titlebar_height = self.app.qapp.style().pixelMetric(QtWidgets.QStyle.PM_TitleBarHeight) + self.titlebar_height = self.app.qapp.style().pixelMetric(QtWidgets.QStyle.PixelMetric.PM_TitleBarHeight) # set new geometry to full desktop rect # Subtracting and adding the pixels below it's hack to bypass a bug in Qt5 and OpenGL that made that a # window drawn with OpenGL in fullscreen will not show any other windows on top which means that menus and # everything else will not work without this hack. This happen in Windows. # https://bugreports.qt.io/browse/QTBUG-41309 - desktop = self.app.qapp.desktop() - screen = desktop.screenNumber(QtGui.QCursor.pos()) + # desktop = self.app.qapp.desktop() + # screen = desktop.screenNumber(QtGui.QCursor.pos()) - rec = desktop.screenGeometry(screen) - x = rec.x() - 1 - y = rec.y() - 1 - h = rec.height() + 2 - w = rec.width() + 2 + # rec = desktop.screenGeometry(screen) - self.setGeometry(x, y, w, h) - self.show() + # x = rec.x() - 1 + # y = rec.y() - 1 + # h = rec.height() + 2 + # w = rec.width() + 2 + # + # self.setGeometry(x, y, w, h) + # self.show() + + self.app.ui.showFullScreen() # hide all Toolbars for tb in self.findChildren(QtWidgets.QToolBar): @@ -4092,7 +4098,9 @@ class MainGUI(QtWidgets.QMainWindow): elif self.toggle_fscreen is True or disable is True: self.setWindowFlags(flags & ~Qt.WindowType.FramelessWindowHint) # the additions are made to account for the pixels we subtracted/added above in the (x, y, h, w) - self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+4, self.width, self.height) + # self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+4, self.width, self.height) + self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+13, self.width, self.height) + self.showNormal() self.restore_toolbar_view() self.toggle_fscreen = False diff --git a/appGUI/VisPyCanvas.py b/appGUI/VisPyCanvas.py index 36f322f4..0b638999 100644 --- a/appGUI/VisPyCanvas.py +++ b/appGUI/VisPyCanvas.py @@ -71,7 +71,8 @@ class VisPyCanvas(scene.SceneCanvas): orientation='bottom', axis_color=tick_color, text_color=tick_color, font_size=a_fsize, axis_width=1, anchors=['center', 'bottom'] ) - self.xaxis.height_max = 30 + self.xaxis.height_min = 5 + self.xaxis.height_max = 35 self.grid_widget.add_widget(self.xaxis, row=2, col=1) right_padding = self.grid_widget.add_widget(row=0, col=2, row_span=2) diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index 1ca2563a..7f00e8d0 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -1035,10 +1035,10 @@ class PreferencesUIManager: msgbox.setText(_("Are you sure you want to continue?")) msgbox.setWindowTitle(_("Application will restart")) msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/warning.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.NoRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.setDefaultButton(bt_yes) msgbox.exec() @@ -1284,10 +1284,10 @@ class PreferencesUIManager: "Do you want to save?")) msgbox.setWindowTitle(_("Save Preferences")) msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/save_as.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.setDefaultButton(bt_yes) msgbox.exec() diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py index f5f1fb8b..f9ff5b81 100644 --- a/appPlugins/ToolIsolation.py +++ b/appPlugins/ToolIsolation.py @@ -3316,7 +3316,7 @@ class IsoUI: self.find_optimal_button = QtWidgets.QToolButton() self.find_optimal_button.setText(_('Optimal')) self.find_optimal_button.setIcon(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png')) - self.find_optimal_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) + self.find_optimal_button.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonTextBesideIcon) self.find_optimal_button.setToolTip( _("Find a tool diameter that is guaranteed\n" "to do a complete isolation.") diff --git a/appPlugins/ToolNCC.py b/appPlugins/ToolNCC.py index fabce9a8..3091ed3d 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -4287,7 +4287,7 @@ class NccUI: self.find_optimal_button = QtWidgets.QToolButton() self.find_optimal_button.setText(_('Optimal')) self.find_optimal_button.setIcon(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png')) - self.find_optimal_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) + self.find_optimal_button.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonTextBesideIcon) self.find_optimal_button.setToolTip( _("Find a tool diameter that is guaranteed\n" "to do a complete isolation.") diff --git a/appTranslation.py b/appTranslation.py index 9b302101..0565707b 100644 --- a/appTranslation.py +++ b/appTranslation.py @@ -106,10 +106,10 @@ def on_language_apply_click(app, restart=False): (_("Are you sure do you want to change the current language to"), name.capitalize())) msgbox.setWindowTitle('%s ...' % _("Apply Language")) msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/language32.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_("Yes"), QtWidgets.QMessageBox.YesRole) - bt_no = msgbox.addButton(_("No"), QtWidgets.QMessageBox.NoRole) + bt_yes = msgbox.addButton(_("Yes"), QtWidgets.QMessageBox.ButtonRole.YesRole) + bt_no = msgbox.addButton(_("No"), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.setDefaultButton(bt_yes) msgbox.exec() @@ -208,10 +208,10 @@ def restart_program(app, ask=None): "Do you want to Save the project?")) msgbox.setWindowTitle(_("Save changes")) msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/save_as.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.setDefaultButton(bt_yes) msgbox.exec() diff --git a/app_Main.py b/app_Main.py index 7df8e784..c30ba131 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2652,12 +2652,12 @@ class App(QtCore.QObject): msgbox.setText(_("Do you want to save the edited object?")) msgbox.setWindowTitle(_("Exit Editor")) msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/save_as.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) if edited_obj.kind in ["geometry", "gerber", "excellon"] or force_cancel is not None: - bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole) + bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.RejectRole) else: bt_cancel = None @@ -3854,9 +3854,9 @@ class App(QtCore.QObject): msgbox.setWindowTitle(_("Alternative website")) msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/globe16.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Close'), QtWidgets.QMessageBox.YesRole) + bt_yes = msgbox.addButton(_('Close'), QtWidgets.QMessageBox.ButtonRole.YesRole) msgbox.setDefaultButton(bt_yes) msgbox.exec() @@ -3881,11 +3881,11 @@ class App(QtCore.QObject): "Do you want to Save the project?")) msgbox.setWindowTitle(_("Save changes")) msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/save_as.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) - bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) + bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.RejectRole) msgbox.setDefaultButton(bt_yes) msgbox.exec() @@ -4017,15 +4017,16 @@ class App(QtCore.QObject): self.clear_pool() # quit app by signalling for self.kill_app() method - self.close_app_signal.emit() + # self.close_app_signal.emit() + sys.exit(0) @staticmethod def kill_app(): QtCore.QCoreApplication.instance().quit() # When the main event loop is not started yet in which case the qApp.quit() will do nothing # we use the following command - # sys.exit(0) - raise SystemExit + sys.exit(0) + # raise SystemExit def on_portable_checked(self, state): """ @@ -4807,13 +4808,13 @@ class App(QtCore.QObject): msgbox = QtWidgets.QMessageBox() msgbox.setWindowTitle(_("Toggle Units")) msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/toggle_units32.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) msgbox.setText(_("Changing the units of the project\n" "will scale all objects.\n\n" "Do you want to continue?")) - bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole) - msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole) + bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.ButtonRole.AcceptRole) + msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.RejectRole) msgbox.setDefaultButton(bt_ok) msgbox.exec() @@ -4974,9 +4975,9 @@ class App(QtCore.QObject): "Go to Preferences -> General - Show Advanced Options.")) msgbox.setWindowTitle("Tool adding ...") msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/warning.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Warning) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Warning) - bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole) + bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.ButtonRole.AcceptRole) msgbox.setDefaultButton(bt_ok) msgbox.exec() @@ -5060,13 +5061,13 @@ class App(QtCore.QObject): msgbox = QtWidgets.QMessageBox() msgbox.setWindowTitle(_("Delete objects")) msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/deleteshape32.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) # msgbox.setText("%s" % _("Change project units ...")) msgbox.setText(_("Are you sure you want to permanently delete\n" "the selected objects?")) - bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole) - msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole) + bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.ButtonRole.AcceptRole) + msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.RejectRole) msgbox.setDefaultButton(bt_ok) msgbox.exec() @@ -6632,8 +6633,8 @@ class App(QtCore.QObject): msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/save_as.png')) msgbox.setIcon(QtWidgets.QMessageBox.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.setDefaultButton(bt_yes) msgbox.exec() @@ -9274,10 +9275,10 @@ class MenuFileHandlers(QtCore.QObject): and not isinstance(obj, ExcellonObject)): msg = '[ERROR_NOTCL] %s' % _("Only Geometry, Gerber and CNCJob objects can be used.") msgbox = QtWidgets.QMessageBox() - msgbox.setIcon(QtWidgets.QMessageBox.Warning) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Warning) msgbox.setInformativeText(msg) - bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole) + bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.ButtonRole.AcceptRole) msgbox.setDefaultButton(bt_ok) msgbox.exec() return @@ -9622,10 +9623,10 @@ class MenuFileHandlers(QtCore.QObject): if obj.kind != 'geometry': msg = '[ERROR_NOTCL] %s' % _("Only Geometry objects can be used.") msgbox = QtWidgets.QMessageBox() - msgbox.setIcon(QtWidgets.QMessageBox.Warning) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Warning) msgbox.setInformativeText(msg) - bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole) + bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.ButtonRole.AcceptRole) msgbox.setDefaultButton(bt_ok) msgbox.exec() return @@ -9730,11 +9731,11 @@ class MenuFileHandlers(QtCore.QObject): "Do you want to Save the project?")) msgbox.setWindowTitle(_("Save changes")) msgbox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) - msgbox.setIcon(QtWidgets.QMessageBox.Question) + msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question) - bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole) - bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole) - bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole) + bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole) + bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole) + bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.RejectRole) msgbox.setDefaultButton(bt_yes) msgbox.exec()