mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Show a save dialog when the save button is clicked in Printer
This commit is contained in:
parent
ff850c5bec
commit
8e1e37e2eb
2 changed files with 33 additions and 1 deletions
20
Printer.qml
20
Printer.qml
|
@ -1,9 +1,29 @@
|
||||||
import QtQuick 2.1
|
import QtQuick 2.1
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Dialogs 1.1
|
||||||
|
|
||||||
import UM 1.0 as UM
|
import UM 1.0 as UM
|
||||||
|
|
||||||
UM.DefaultWindow {
|
UM.DefaultWindow {
|
||||||
title: "Cura"
|
title: "Cura"
|
||||||
|
|
||||||
|
function saveClicked() {
|
||||||
|
saveDialog.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileDialog {
|
||||||
|
id: saveDialog
|
||||||
|
|
||||||
|
title: "Choose Filename"
|
||||||
|
|
||||||
|
modality: Qt.NonModal;
|
||||||
|
|
||||||
|
selectExisting: false;
|
||||||
|
|
||||||
|
onAccepted:
|
||||||
|
{
|
||||||
|
Printer.saveGCode(fileUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ from UM.Scene.Selection import Selection
|
||||||
from PlatformPhysics import PlatformPhysics
|
from PlatformPhysics import PlatformPhysics
|
||||||
from BuildVolume import BuildVolume
|
from BuildVolume import BuildVolume
|
||||||
|
|
||||||
|
from PyQt5.QtCore import pyqtSlot, QUrl
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
class PrinterApplication(QtApplication):
|
class PrinterApplication(QtApplication):
|
||||||
|
@ -104,7 +106,7 @@ class PrinterApplication(QtApplication):
|
||||||
self.getMachineSettings().saveValuesToFile(Resources.getStoragePath(Resources.SettingsLocation, 'ultimaker2.cfg'))
|
self.getMachineSettings().saveValuesToFile(Resources.getStoragePath(Resources.SettingsLocation, 'ultimaker2.cfg'))
|
||||||
|
|
||||||
def registerObjects(self, engine):
|
def registerObjects(self, engine):
|
||||||
pass
|
engine.rootContext().setContextProperty('Printer', self)
|
||||||
|
|
||||||
def onSelectionChanged(self):
|
def onSelectionChanged(self):
|
||||||
if Selection.getCount() > 0:
|
if Selection.getCount() > 0:
|
||||||
|
@ -115,3 +117,13 @@ class PrinterApplication(QtApplication):
|
||||||
else:
|
else:
|
||||||
if self.getController().getActiveTool() and self.getController().getActiveTool().getName() == 'TranslateTool':
|
if self.getController().getActiveTool() and self.getController().getActiveTool().getName() == 'TranslateTool':
|
||||||
self.getController().setActiveTool(None)
|
self.getController().setActiveTool(None)
|
||||||
|
|
||||||
|
@pyqtSlot(QUrl)
|
||||||
|
def saveGCode(self, file):
|
||||||
|
try:
|
||||||
|
gcode = self.getController().getScene().gcode
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(file.toLocalFile(), 'w') as f:
|
||||||
|
f.write(gcode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue