Skip to content

Commit 6f81d44

Browse files
committed
Add basic compatibility with PyQt6
1 parent cacac20 commit 6f81d44

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

SidebarGUIPlugin.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
from UM.Resources import Resources
88
from UM.Logger import Logger
99

10-
from PyQt5.QtCore import QUrl
11-
from PyQt5.QtQml import qmlRegisterSingletonType
10+
try:
11+
from PyQt6.QtCore import QUrl
12+
from PyQt6.QtQml import qmlRegisterSingletonType
13+
except ImportError:
14+
from PyQt5.QtCore import QUrl
15+
from PyQt5.QtQml import qmlRegisterSingletonType
1216

1317
from .SidebarGUIProxy import SidebarGUIProxy
1418

@@ -42,9 +46,14 @@ def _onEngineCreated(self):
4246
Logger.log("d", "Registering replacement stages")
4347

4448
engine = Application.getInstance()._qml_engine
45-
qmlRegisterSingletonType(
46-
SidebarGUIProxy, "Cura", 1, 0, "SidebarGUIPlugin", self.getProxy
47-
)
49+
try:
50+
qmlRegisterSingletonType(
51+
SidebarGUIProxy, "Cura", 1, 0, self.getProxy, "SidebarGUIPlugin"
52+
)
53+
except TypeError:
54+
qmlRegisterSingletonType(
55+
SidebarGUIProxy, "Cura", 1, 0, "SidebarGUIPlugin", self.getProxy
56+
)
4857

4958
sidebar_component_path = os.path.join(
5059
os.path.dirname(os.path.abspath(__file__)),

SidebarGUIProxy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
from UM.Logger import Logger
66
from UM.FlameProfiler import pyqtSlot
77

8-
from PyQt5.QtCore import QObject, QRectF
8+
try:
9+
from PyQt6.QtCore import QObject, QRectF
10+
except ImportError:
11+
from PyQt5.QtCore import QObject, QRectF
912

1013
try:
1114
from cura.Machines.ContainerTree import ContainerTree

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
"author": "fieldOfView",
44
"version": "4.2.3-DEV",
55
"minimum_cura_version": "4.0",
6-
"maximum_cura_version": "4.13",
6+
"maximum_cura_version": "5.0",
77
"description": "Provides an alternative interface which restores the sidebar",
88
"api": "6.0.0",
99
"supported_sdk_versions": [
10-
"6.0.0", "6.1.0", "6.2.0", "6.3.0", "7.0.0", "7.1.0", "7.2.0", "7.3.0", "7.4.0", "7.5.0", "7.6.0", "7.7.0", "7.8.0", "7.9.0"
10+
"6.0.0", "6.1.0", "6.2.0", "6.3.0", "7.0.0", "7.1.0", "7.2.0", "7.3.0", "7.4.0", "7.5.0", "7.6.0", "7.7.0", "7.8.0", "7.9.0", "8.0.0"
1111
],
1212
"i18n-catalog": "cura"
1313
}

0 commit comments

Comments
 (0)