mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Add support for displaying print time and print material amount
This commit is contained in:
parent
0175eb7b59
commit
1c11104dd2
2 changed files with 69 additions and 9 deletions
|
|
@ -56,6 +56,9 @@ class PrinterApplication(QtApplication):
|
||||||
'priority': 0
|
'priority': 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self._print_duration = -1
|
||||||
|
self._print_material_amount = -1
|
||||||
|
|
||||||
self.activeMachineChanged.connect(self._onActiveMachineChanged)
|
self.activeMachineChanged.connect(self._onActiveMachineChanged)
|
||||||
|
|
||||||
Preferences.getInstance().addPreference('cura/active_machine', '')
|
Preferences.getInstance().addPreference('cura/active_machine', '')
|
||||||
|
|
@ -114,6 +117,8 @@ class PrinterApplication(QtApplication):
|
||||||
|
|
||||||
self.getStorageDevice('LocalFileStorage').removableDrivesChanged.connect(self._removableDrivesChanged)
|
self.getStorageDevice('LocalFileStorage').removableDrivesChanged.connect(self._removableDrivesChanged)
|
||||||
|
|
||||||
|
self.getBackend().printDurationMessage.connect(self._onPrintDurationMessage)
|
||||||
|
|
||||||
if self.getMachines():
|
if self.getMachines():
|
||||||
active_machine_pref = Preferences.getInstance().getValue('cura/active_machine')
|
active_machine_pref = Preferences.getInstance().getValue('cura/active_machine')
|
||||||
if active_machine_pref:
|
if active_machine_pref:
|
||||||
|
|
@ -258,6 +263,16 @@ class PrinterApplication(QtApplication):
|
||||||
|
|
||||||
return log
|
return log
|
||||||
|
|
||||||
|
printDurationChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty(float, notify = printDurationChanged)
|
||||||
|
def printDuration(self):
|
||||||
|
return self._print_duration
|
||||||
|
|
||||||
|
@pyqtProperty(float, notify = printDurationChanged)
|
||||||
|
def printMaterialAmount(self):
|
||||||
|
return self._print_material_amount
|
||||||
|
|
||||||
def _onActiveMachineChanged(self):
|
def _onActiveMachineChanged(self):
|
||||||
machine = self.getActiveMachine()
|
machine = self.getActiveMachine()
|
||||||
if machine:
|
if machine:
|
||||||
|
|
@ -356,3 +371,8 @@ class PrinterApplication(QtApplication):
|
||||||
if device not in drives:
|
if device not in drives:
|
||||||
if self._output_devices[device]['function'] == self._writeToSD:
|
if self._output_devices[device]['function'] == self._writeToSD:
|
||||||
self.removeOutputDevice(device)
|
self.removeOutputDevice(device)
|
||||||
|
|
||||||
|
def _onPrintDurationMessage(self, duration, material_amount):
|
||||||
|
self._print_duration = duration
|
||||||
|
self._print_material_amount = material_amount
|
||||||
|
self.printDurationChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ Button {
|
||||||
property bool defaultOverride: false;
|
property bool defaultOverride: false;
|
||||||
property bool defaultAmbiguous: false;
|
property bool defaultAmbiguous: false;
|
||||||
|
|
||||||
|
property real printDurationHours: Math.floor(Printer.printDuration / 3600);
|
||||||
|
property real printDurationMinutes: Math.round(((Printer.printDuration / 3600) - printDurationHours) * 60);
|
||||||
|
property real printMaterialAmount: Printer.printMaterialAmount < 0 ? -1 : Math.round(Printer.printMaterialAmount / 10) / 100;
|
||||||
|
|
||||||
iconSource: UM.Theme.icons[Printer.outputDevices[base.currentDevice].icon];
|
iconSource: UM.Theme.icons[Printer.outputDevices[base.currentDevice].icon];
|
||||||
tooltip: Printer.outputDevices[base.currentDevice].description;
|
tooltip: Printer.outputDevices[base.currentDevice].description;
|
||||||
|
|
||||||
|
|
@ -115,10 +119,9 @@ Button {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
label: Label {
|
label: Column {
|
||||||
|
Label {
|
||||||
id: label;
|
id: label;
|
||||||
anchors.top: parent.top;
|
|
||||||
anchors.topMargin: UM.Theme.sizes.save_button_label_margin.height;
|
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
anchors.leftMargin: control.height + UM.Theme.sizes.save_button_label_margin.width;
|
anchors.leftMargin: control.height + UM.Theme.sizes.save_button_label_margin.width;
|
||||||
|
|
||||||
|
|
@ -127,6 +130,43 @@ Button {
|
||||||
|
|
||||||
text: control.text;
|
text: control.text;
|
||||||
}
|
}
|
||||||
|
Label {
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: control.height + UM.Theme.sizes.save_button_label_margin.width;
|
||||||
|
|
||||||
|
color: UM.Theme.colors.save_button_text;
|
||||||
|
font: UM.Theme.fonts.default;
|
||||||
|
|
||||||
|
text: {
|
||||||
|
if(control.printDurationHours < 0 || control.printDurationMinutes < 0)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(control.printDurationHours > 1)
|
||||||
|
{
|
||||||
|
return qsTr("%1 hours %2 minutes").arg(control.printDurationHours).arg(control.printDurationMinutes);
|
||||||
|
}
|
||||||
|
else if(control.printDurationHours > 0)
|
||||||
|
{
|
||||||
|
return qsTr("1 hour %1 minutes").arg(control.printDurationMinutes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return qsTr("%2 minutes").arg(control.printDurationMinutes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: control.height + UM.Theme.sizes.save_button_label_margin.width;
|
||||||
|
|
||||||
|
color: UM.Theme.colors.save_button_text;
|
||||||
|
font: UM.Theme.fonts.default;
|
||||||
|
|
||||||
|
text: control.printMaterialAmount < 0 ? "" : "%1m material".arg(control.printMaterialAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue