Browse Source

Investigate: How hard is upgrading to Qt6.x?

Originally done as part of CURA-8730 -- committed a few month later (because found again) in branch because people might find it useful to refer back to this (or even work further on it?). See also branch of the same name in Uranium.
Remco Burema 3 years ago
parent
commit
8c20523601

+ 4 - 3
cura/API/Account.py

@@ -1,9 +1,10 @@
 # Copyright (c) 2018 Ultimaker B.V.
 # Copyright (c) 2018 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 from datetime import datetime
 from datetime import datetime
+from enum import IntEnum
 from typing import Optional, Dict, TYPE_CHECKING, Callable
 from typing import Optional, Dict, TYPE_CHECKING, Callable
 
 
-from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QTimer, Q_ENUMS
+from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QTimer, pyqtEnum
 
 
 from UM.Logger import Logger
 from UM.Logger import Logger
 from UM.Message import Message
 from UM.Message import Message
@@ -18,7 +19,7 @@ if TYPE_CHECKING:
 i18n_catalog = i18nCatalog("cura")
 i18n_catalog = i18nCatalog("cura")
 
 
 
 
-class SyncState:
+class SyncState(IntEnum):
     """QML: Cura.AccountSyncState"""
     """QML: Cura.AccountSyncState"""
     SYNCING = 0
     SYNCING = 0
     SUCCESS = 1
     SUCCESS = 1
@@ -41,7 +42,7 @@ class Account(QObject):
 
 
     # The interval in which sync services are automatically triggered
     # The interval in which sync services are automatically triggered
     SYNC_INTERVAL = 60.0  # seconds
     SYNC_INTERVAL = 60.0  # seconds
-    Q_ENUMS(SyncState)
+    pyqtEnum(SyncState)
 
 
     loginStateChanged = pyqtSignal(bool)
     loginStateChanged = pyqtSignal(bool)
     """Signal emitted when user logged in or out"""
     """Signal emitted when user logged in or out"""

+ 1 - 1
cura/API/ConnectionStatus.py

@@ -1,6 +1,6 @@
 from typing import Optional
 from typing import Optional
 
 
-from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty
+from PyQt6.QtCore import QObject, pyqtSignal, pyqtProperty
 
 
 from UM.TaskManagement.HttpRequestManager import HttpRequestManager
 from UM.TaskManagement.HttpRequestManager import HttpRequestManager
 
 

+ 1 - 1
cura/API/__init__.py

@@ -2,7 +2,7 @@
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 from typing import Optional, TYPE_CHECKING
 from typing import Optional, TYPE_CHECKING
 
 
-from PyQt5.QtCore import QObject, pyqtProperty
+from PyQt6.QtCore import QObject, pyqtProperty
 
 
 from cura.API.Backups import Backups
 from cura.API.Backups import Backups
 from cura.API.ConnectionStatus import ConnectionStatus
 from cura.API.ConnectionStatus import ConnectionStatus

+ 1 - 1
cura/Arranging/ArrangeObjectsJob.py

@@ -8,7 +8,7 @@ from UM.Logger import Logger
 from UM.Message import Message
 from UM.Message import Message
 from UM.Scene.SceneNode import SceneNode
 from UM.Scene.SceneNode import SceneNode
 from UM.i18n import i18nCatalog
 from UM.i18n import i18nCatalog
-from cura.Arranging.Nest2DArrange import arrange
+#from cura.Arranging.Nest2DArrange import arrange
 
 
 i18n_catalog = i18nCatalog("cura")
 i18n_catalog = i18nCatalog("cura")
 
 

+ 1 - 1
cura/Arranging/Nest2DArrange.py

@@ -2,7 +2,7 @@
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 
 import numpy
 import numpy
-from pynest2d import Point, Box, Item, NfpConfig, nest
+#from pynest2d import Point, Box, Item, NfpConfig, nest
 from typing import List, TYPE_CHECKING, Optional, Tuple
 from typing import List, TYPE_CHECKING, Optional, Tuple
 
 
 from UM.Application import Application
 from UM.Application import Application

+ 1 - 1
cura/AutoSave.py

@@ -1,7 +1,7 @@
 # Copyright (c) 2021 Ultimaker B.V.
 # Copyright (c) 2021 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 
-from PyQt5.QtCore import QTimer
+from PyQt6.QtCore import QTimer
 from typing import Any, TYPE_CHECKING
 from typing import Any, TYPE_CHECKING
 
 
 from UM.Logger import Logger
 from UM.Logger import Logger

+ 1 - 1
cura/BuildVolume.py

@@ -30,7 +30,7 @@ from cura.Settings.GlobalStack import GlobalStack
 from cura.Scene.CuraSceneNode import CuraSceneNode
 from cura.Scene.CuraSceneNode import CuraSceneNode
 from cura.Settings.ExtruderManager import ExtruderManager
 from cura.Settings.ExtruderManager import ExtruderManager
 
 
-from PyQt5.QtCore import QTimer
+from PyQt6.QtCore import QTimer
 
 
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:

+ 3 - 3
cura/CameraAnimation.py

@@ -2,8 +2,8 @@
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 
 
 
-from PyQt5.QtCore import QVariantAnimation, QEasingCurve
-from PyQt5.QtGui import QVector3D
+from PyQt6.QtCore import QVariantAnimation, QEasingCurve
+from PyQt6.QtGui import QVector3D
 
 
 from UM.Math.Vector import Vector
 from UM.Math.Vector import Vector
 
 
@@ -13,7 +13,7 @@ class CameraAnimation(QVariantAnimation):
         super().__init__(parent)
         super().__init__(parent)
         self._camera_tool = None
         self._camera_tool = None
         self.setDuration(300)
         self.setDuration(300)
-        self.setEasingCurve(QEasingCurve.OutQuad)
+        self.setEasingCurve(QEasingCurve.Type.OutQuad)
 
 
     def setCameraTool(self, camera_tool):
     def setCameraTool(self, camera_tool):
         self._camera_tool = camera_tool
         self._camera_tool = camera_tool

+ 8 - 8
cura/CrashHandler.py

@@ -20,9 +20,9 @@ try:
 except ImportError:
 except ImportError:
     with_sentry_sdk = False
     with_sentry_sdk = False
 
 
-from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, QUrl
-from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox, QCheckBox, QPushButton
-from PyQt5.QtGui import QDesktopServices
+from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, QUrl
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QTextEdit, QGroupBox, QCheckBox, QPushButton
+from PyQt6.QtGui import QDesktopServices
 
 
 from UM.Application import Application
 from UM.Application import Application
 from UM.Logger import Logger
 from UM.Logger import Logger
@@ -136,8 +136,8 @@ class CrashHandler:
 
 
         # "backup and start clean" and "close" buttons
         # "backup and start clean" and "close" buttons
         buttons = QDialogButtonBox()
         buttons = QDialogButtonBox()
-        buttons.addButton(QDialogButtonBox.Close)
-        buttons.addButton(catalog.i18nc("@action:button", "Backup and Reset Configuration"), QDialogButtonBox.AcceptRole)
+        buttons.addButton(QDialogButtonBox.StandardButton.Close)
+        buttons.addButton(catalog.i18nc("@action:button", "Backup and Reset Configuration"), QDialogButtonBox.ButtonRole.AcceptRole)
         buttons.rejected.connect(self._closeEarlyCrashDialog)
         buttons.rejected.connect(self._closeEarlyCrashDialog)
         buttons.accepted.connect(self._backupAndStartClean)
         buttons.accepted.connect(self._backupAndStartClean)
 
 
@@ -161,7 +161,7 @@ class CrashHandler:
         QDesktopServices.openUrl(QUrl.fromLocalFile( path ))
         QDesktopServices.openUrl(QUrl.fromLocalFile( path ))
 
 
     def _showDetailedReport(self):
     def _showDetailedReport(self):
-        self.dialog.exec_()
+        self.dialog.exec()
 
 
     def _createDialog(self):
     def _createDialog(self):
         """Creates a modal dialog."""
         """Creates a modal dialog."""
@@ -409,12 +409,12 @@ class CrashHandler:
 
 
     def _buttonsWidget(self):
     def _buttonsWidget(self):
         buttons = QDialogButtonBox()
         buttons = QDialogButtonBox()
-        buttons.addButton(QDialogButtonBox.Close)
+        buttons.addButton(QDialogButtonBox.StandardButton.Close)
         # Like above, this will be served as a separate detailed report dialog if the application has not yet been
         # Like above, this will be served as a separate detailed report dialog if the application has not yet been
         # fully loaded. In this case, "send report" will be a check box in the early crash dialog, so there is no
         # fully loaded. In this case, "send report" will be a check box in the early crash dialog, so there is no
         # need for this extra button.
         # need for this extra button.
         if self.has_started:
         if self.has_started:
-            buttons.addButton(catalog.i18nc("@action:button", "Send report"), QDialogButtonBox.AcceptRole)
+            buttons.addButton(catalog.i18nc("@action:button", "Send report"), QDialogButtonBox.ButtonRole.AcceptRole)
             buttons.accepted.connect(self._sendCrashReport)
             buttons.accepted.connect(self._sendCrashReport)
         buttons.rejected.connect(self.dialog.close)
         buttons.rejected.connect(self.dialog.close)
 
 

+ 2 - 2
cura/CuraActions.py

@@ -1,8 +1,8 @@
 # Copyright (c) 2018 Ultimaker B.V.
 # Copyright (c) 2018 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 
-from PyQt5.QtCore import QObject, QUrl
-from PyQt5.QtGui import QDesktopServices
+from PyQt6.QtCore import QObject, QUrl
+from PyQt6.QtGui import QDesktopServices
 from typing import List, cast
 from typing import List, cast
 
 
 from UM.Event import CallFunctionEvent
 from UM.Event import CallFunctionEvent

Some files were not shown because too many files changed in this diff