Skip to content

Commit 04d8d25

Browse files
committed
retain compatibility with older Cura versions because the Ultimaker Marketplace only supports one plugin version globally for all Cura's
1 parent b8d39a3 commit 04d8d25

File tree

10 files changed

+218
-14
lines changed

10 files changed

+218
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog of Cura-DuetRRFPlugin
22

3+
## v1.2.7: 2022-04-26
4+
* bump compatibility for Cura 5.0 / API 8.0, while retaining compatibility with Cura 4.11 / 7.7 and up
5+
36
## v1.2.6: 2022-04-23
47
* bump compatibility for Cura 5.0 / API 8.0, for older Cura versions, please use plugin v1.2.5 or older
58
* fixed simulation progress reports

DuetRRFAction.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import os
22
import re
3+
import sys
34
from typing import Optional
45

5-
from PyQt6.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
6+
try: # Cura 5
7+
from PyQt6.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
8+
except: # Cura 4
9+
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
610

711
from cura.CuraApplication import CuraApplication
812
from cura.MachineAction import MachineAction
@@ -20,7 +24,10 @@ class DuetRRFAction(MachineAction):
2024
def __init__(self, parent: QObject = None) -> None:
2125
super().__init__("DuetRRFAction", catalog.i18nc("@action", "Connect Duet RepRapFirmware"))
2226

23-
self._qml_url = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', 'qml', 'DuetRRFAction.qml')
27+
extra_path = ""
28+
if "PyQt5" in sys.modules: # Cura 4
29+
extra_path = "legacy"
30+
self._qml_url = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', 'qml', extra_path, 'DuetRRFAction.qml')
2431

2532
self._application = CuraApplication.getInstance()
2633
self._application.globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)

DuetRRFOutputDevice.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import os.path
23
import datetime
34
import urllib
@@ -7,9 +8,14 @@
78
from typing import cast
89
from enum import Enum
910

10-
from PyQt6.QtNetwork import QNetworkReply
11-
from PyQt6.QtCore import QUrl, QObject, QByteArray, QTimer
12-
from PyQt6.QtGui import QDesktopServices
11+
try: # Cura 5
12+
from PyQt6.QtNetwork import QNetworkReply
13+
from PyQt6.QtCore import QUrl, QObject, QByteArray, QTimer
14+
from PyQt6.QtGui import QDesktopServices
15+
except: # Cura 4
16+
from PyQt5.QtNetwork import QNetworkReply
17+
from PyQt5.QtCore import QUrl, QObject, QByteArray, QTimer
18+
from PyQt5.QtGui import QDesktopServices
1319

1420
from cura.CuraApplication import CuraApplication
1521

@@ -171,7 +177,11 @@ def requestWrite(self, node, fileName=None, *args, **kwargs):
171177
fileName = "%s.gcode" % Application.getInstance().getPrintInformation().jobName
172178
self._fileName = fileName
173179

174-
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', 'qml', 'UploadFilename.qml')
180+
extra_path = ""
181+
if "PyQt5" in sys.modules: # Cura 4
182+
extra_path = "legacy"
183+
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', 'qml', extra_path, 'UploadFilename.qml')
184+
175185
self._dialog = CuraApplication.getInstance().createQmlComponent(path, {"manager": self})
176186
self._dialog.textChanged.connect(self._onFilenameChanged)
177187
self._dialog.accepted.connect(self._onFilenameAccepted)

DuetRRFPlugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import json
22

3-
from PyQt6.QtCore import QTimer
3+
try: # Cura 5
4+
from PyQt6.QtCore import QTimer
5+
except: # Cura 4
6+
from PyQt5.QtCore import QTimer
47

58
from cura.CuraApplication import CuraApplication
69
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry

plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "DuetRRF",
33
"author": "Thomas Kriechbaumer",
44
"description": "Upload and Print to Duet 2 Wifi / Duet 2 Ethernet / Duet 2 Maestro / Duet 3 with RepRapFirmware.",
5-
"version": "1.2.6",
6-
"supported_sdk_versions": ["8.0.0"]
5+
"version": "1.2.7",
6+
"supported_sdk_versions": ["7.7.0", "7.8.0", "7.9.0", "8.0.0"]
77
}

resources/qml/DuetRRFAction.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import QtQuick.Window 2.2
66
import UM 1.5 as UM
77
import Cura 1.1 as Cura
88

9-
109
Cura.MachineAction
1110
{
1211
id: base;

resources/qml/UploadFilename.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import QtQuick 2.10
22
import QtQuick.Controls 2.3
33
import QtQuick.Window 2.2
4-
import QtQuick.Dialogs
54

65
import UM 1.5 as UM
76
import Cura 1.1 as Cura
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import QtQuick 2.2
2+
import QtQuick.Controls 1.1
3+
import QtQuick.Layouts 1.1
4+
import QtQuick.Window 2.1
5+
6+
import UM 1.2 as UM
7+
import Cura 1.0 as Cura
8+
9+
10+
Cura.MachineAction
11+
{
12+
id: base;
13+
14+
property var finished: manager.finished
15+
onFinishedChanged: if(manager.finished) {completed()}
16+
17+
function reset()
18+
{
19+
manager.reset()
20+
}
21+
22+
anchors.fill: parent;
23+
property var selectedInstance: null
24+
25+
property bool validUrl: true;
26+
27+
Component.onCompleted: {
28+
actionDialog.minimumWidth = screenScaleFactor * 500;
29+
actionDialog.minimumHeight = screenScaleFactor * 255;
30+
actionDialog.maximumWidth = screenScaleFactor * 500;
31+
actionDialog.maximumHeight = screenScaleFactor * 255;
32+
}
33+
34+
Column {
35+
anchors.fill: parent;
36+
37+
Item { width: parent.width; }
38+
Label { text: catalog.i18nc("@label", "Duet Address (URL)"); }
39+
TextField {
40+
id: urlField;
41+
text: manager.printerSettingUrl;
42+
maximumLength: 1024;
43+
anchors.left: parent.left;
44+
anchors.right: parent.right;
45+
onTextChanged: {
46+
base.validUrl = manager.validUrl(urlField.text);
47+
}
48+
}
49+
50+
Item { width: parent.width; }
51+
Label { text: catalog.i18nc("@label", "Duet Password (if you used M551)"); }
52+
TextField {
53+
id: duet_passwordField;
54+
text: manager.printerSettingDuetPassword;
55+
maximumLength: 1024;
56+
anchors.left: parent.left;
57+
anchors.right: parent.right;
58+
}
59+
60+
Item { width: parent.width; }
61+
Label { text: catalog.i18nc("@label", "HTTP Basic Auth: user (if you run a reverse proxy)"); }
62+
TextField {
63+
id: http_userField;
64+
text: manager.printerSettingHTTPUser;
65+
maximumLength: 1024;
66+
anchors.left: parent.left;
67+
anchors.right: parent.right;
68+
}
69+
70+
Item { width: parent.width; }
71+
Label { text: catalog.i18nc("@label", "HTTP Basic Auth: password (if you run a reverse proxy)"); }
72+
TextField {
73+
id: http_passwordField;
74+
text: manager.printerSettingHTTPPassword;
75+
maximumLength: 1024;
76+
anchors.left: parent.left;
77+
anchors.right: parent.right;
78+
}
79+
80+
Item { width: parent.width; }
81+
Label {
82+
visible: !base.validUrl;
83+
text: catalog.i18nc("@error", "URL not valid. Example: http://192.168.1.42/");
84+
color: "red";
85+
}
86+
87+
Item {
88+
width: saveButton.implicitWidth
89+
height: saveButton.implicitHeight
90+
}
91+
92+
Button {
93+
id: saveButton;
94+
text: catalog.i18nc("@action:button", "Save Config");
95+
width: screenScaleFactor * 100;
96+
onClicked: {
97+
manager.saveConfig(urlField.text, duet_passwordField.text, http_userField.text, http_passwordField.text);
98+
actionDialog.reject();
99+
}
100+
enabled: base.validUrl;
101+
}
102+
103+
Button {
104+
id: deleteButton;
105+
text: catalog.i18nc("@action:button", "Delete Config");
106+
width: screenScaleFactor * 100;
107+
onClicked: {
108+
manager.deleteConfig();
109+
actionDialog.reject();
110+
}
111+
}
112+
}
113+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import QtQuick 2.1
2+
import QtQuick.Controls 1.1
3+
import QtQuick.Dialogs 1.2
4+
import QtQuick.Window 2.1
5+
6+
import UM 1.1 as UM
7+
8+
UM.Dialog
9+
{
10+
id: base;
11+
property string object: "";
12+
13+
property alias newName: nameField.text;
14+
property bool validName: true;
15+
property string validationError;
16+
property string dialogTitle: "Upload Filename";
17+
18+
title: dialogTitle;
19+
20+
minimumWidth: screenScaleFactor * 400
21+
minimumHeight: screenScaleFactor * 120
22+
23+
property variant catalog: UM.I18nCatalog { name: "uranium"; }
24+
25+
signal textChanged(string text);
26+
signal selectText()
27+
onSelectText: {
28+
nameField.selectAll();
29+
nameField.focus = true;
30+
}
31+
32+
Column {
33+
anchors.fill: parent;
34+
35+
TextField {
36+
objectName: "nameField";
37+
id: nameField;
38+
width: parent.width;
39+
text: base.object;
40+
maximumLength: 100;
41+
onTextChanged: base.textChanged(text);
42+
Keys.onReturnPressed: { if (base.validName) base.accept(); }
43+
Keys.onEnterPressed: { if (base.validName) base.accept(); }
44+
Keys.onEscapePressed: base.reject();
45+
}
46+
47+
Label {
48+
visible: !base.validName;
49+
text: base.validationError;
50+
}
51+
}
52+
53+
rightButtons: [
54+
Button {
55+
text: catalog.i18nc("@action:button", "Cancel");
56+
onClicked: base.reject();
57+
},
58+
Button {
59+
text: catalog.i18nc("@action:button", "OK");
60+
onClicked: base.accept();
61+
enabled: base.validName;
62+
isDefault: true;
63+
}
64+
]
65+
}

thumbnails.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
import traceback
33
from io import StringIO
44

5-
from PyQt6 import QtCore
6-
from PyQt6.QtCore import QCoreApplication, QBuffer
7-
from PyQt6.QtGui import QImage
5+
try: # Cura 5
6+
from PyQt6 import QtCore
7+
from PyQt6.QtCore import QCoreApplication, QBuffer
8+
from PyQt6.QtGui import QImage
9+
except: # Cura 4
10+
from PyQt5 import QtCore
11+
from PyQt5.QtCore import QCoreApplication, QBuffer
12+
from PyQt5.QtGui import QImage
813

914
from UM.Application import Application
1015
from UM.Logger import Logger

0 commit comments

Comments
 (0)