diff --git a/OutputGCodeButton.qml b/OutputGCodeButton.qml index 0b1c64b3b9..1c9a18f98e 100644 --- a/OutputGCodeButton.qml +++ b/OutputGCodeButton.qml @@ -13,6 +13,7 @@ Rectangle { border.color: UM.Theme.borderColor; signal saveRequested(); + signal saveToSdRequested(); Label { id: label; @@ -54,10 +55,7 @@ Rectangle { onClicked: { switch(base.state) { case 'sdcard': - base.state = 'usb'; - break; - case 'usb': - base.state = ''; + base.saveToSdRequested(); break; default: base.saveRequested(); @@ -69,6 +67,7 @@ Rectangle { states: [ State { name: 'sdcard'; + when: Printer.removableDrives.length > 0; PropertyChanges { target: label; //: Write to SD card button diff --git a/PrinterApplication.py b/PrinterApplication.py index 906e335d2e..9409cd0d70 100644 --- a/PrinterApplication.py +++ b/PrinterApplication.py @@ -13,7 +13,7 @@ from PlatformPhysics import PlatformPhysics from BuildVolume import BuildVolume from CameraAnimation import CameraAnimation -from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal +from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty from PyQt5.QtGui import QColor import os.path @@ -85,6 +85,8 @@ class PrinterApplication(QtApplication): self.setMainQml(os.path.dirname(__file__) + "/Printer.qml") self.initializeEngine() + self.getStorageDevice('LocalFileStorage').removableDrivesChanged.connect(self._removableDrivesChanged) + #TODO: Add support for active machine preference if self.getMachines(): self.setActiveMachine(self.getMachines()[0]) @@ -132,3 +134,13 @@ class PrinterApplication(QtApplication): self._volume.setHeight(machine.getSettingValueByKey('machine_height')) self._volume.setDepth(machine.getSettingValueByKey('machine_depth')) self._volume.rebuild() + + removableDrivesChanged = pyqtSignal() + + @pyqtProperty("QStringList", notify = removableDrivesChanged) + def removableDrives(self): + return list(self.getStorageDevice('LocalFileStorage').getRemovableDrives().keys()) + + def _removableDrivesChanged(self): + print(self.getStorageDevice('LocalFileStorage').getRemovableDrives()) + self.removableDrivesChanged.emit()