mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Merge pull request #1235 from Ultimaker/project_save_dialog
Project save dialog
This commit is contained in:
commit
8fdc0a40ce
6 changed files with 277 additions and 9 deletions
|
@ -215,7 +215,8 @@ class CuraApplication(QtApplication):
|
||||||
Preferences.getInstance().addPreference("view/center_on_select", True)
|
Preferences.getInstance().addPreference("view/center_on_select", True)
|
||||||
Preferences.getInstance().addPreference("mesh/scale_to_fit", True)
|
Preferences.getInstance().addPreference("mesh/scale_to_fit", True)
|
||||||
Preferences.getInstance().addPreference("mesh/scale_tiny_meshes", True)
|
Preferences.getInstance().addPreference("mesh/scale_tiny_meshes", True)
|
||||||
|
Preferences.getInstance().addPreference("cura/dialog_on_project_save", True)
|
||||||
|
Preferences.getInstance().addPreference("cura/asked_dialog_on_project_save", False)
|
||||||
for key in [
|
for key in [
|
||||||
"dialog_load_path", # dialog_save_path is in LocalFileOutputDevicePlugin
|
"dialog_load_path", # dialog_save_path is in LocalFileOutputDevicePlugin
|
||||||
"dialog_profile_path",
|
"dialog_profile_path",
|
||||||
|
|
|
@ -109,6 +109,10 @@ class MachineManager(QObject):
|
||||||
def printerOutputDevices(self):
|
def printerOutputDevices(self):
|
||||||
return self._printer_output_devices
|
return self._printer_output_devices
|
||||||
|
|
||||||
|
@pyqtProperty(int, constant=True)
|
||||||
|
def totalNumberOfSettings(self):
|
||||||
|
return len(UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id="fdmprinter")[0].getAllKeys())
|
||||||
|
|
||||||
def _onHotendIdChanged(self, index, hotend_id):
|
def _onHotendIdChanged(self, index, hotend_id):
|
||||||
if not self._global_container_stack:
|
if not self._global_container_stack:
|
||||||
return
|
return
|
||||||
|
@ -483,6 +487,15 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantList", notify = activeMaterialChanged)
|
||||||
|
def activeMaterialNames(self):
|
||||||
|
result = []
|
||||||
|
for stack in ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks():
|
||||||
|
material_container = stack.findContainer(type="material")
|
||||||
|
if material_container and material_container != self._empty_material_container:
|
||||||
|
result.append(material_container.getName())
|
||||||
|
return result
|
||||||
|
|
||||||
@pyqtProperty(str, notify=activeMaterialChanged)
|
@pyqtProperty(str, notify=activeMaterialChanged)
|
||||||
def activeMaterialId(self):
|
def activeMaterialId(self):
|
||||||
if self._active_container_stack:
|
if self._active_container_stack:
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# Copyright (c) 2016 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QUrl, pyqtSignal, pyqtSlot, QObject, pyqtProperty, QCoreApplication
|
from PyQt5.QtCore import Qt, QUrl, pyqtSignal, pyqtSlot, QObject, pyqtProperty, QCoreApplication
|
||||||
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
|
@ -11,6 +14,7 @@ import threading
|
||||||
import time
|
import time
|
||||||
i18n_catalog = i18nCatalog("cura")
|
i18n_catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
class WorkspaceDialog(QObject):
|
class WorkspaceDialog(QObject):
|
||||||
showDialogSignal = pyqtSignal()
|
showDialogSignal = pyqtSignal()
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,17 @@ UM.MainWindow
|
||||||
{
|
{
|
||||||
id: saveWorkspaceMenu
|
id: saveWorkspaceMenu
|
||||||
text: catalog.i18nc("@title:menu menubar:file","Save project")
|
text: catalog.i18nc("@title:menu menubar:file","Save project")
|
||||||
onTriggered: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "file_type": "workspace" });
|
onTriggered:
|
||||||
|
{
|
||||||
|
if(UM.Preferences.getValue("cura/dialog_on_project_save"))
|
||||||
|
{
|
||||||
|
saveWorkspaceDialog.open()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "file_type": "workspace" })
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuItem { action: Cura.Actions.reloadAll; }
|
MenuItem { action: Cura.Actions.reloadAll; }
|
||||||
|
@ -499,14 +509,17 @@ UM.MainWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
onVisibleChanged:
|
onVisibleChanged:
|
||||||
{
|
|
||||||
if(!visible)
|
|
||||||
{
|
{
|
||||||
// When the dialog closes, switch to the General page.
|
// When the dialog closes, switch to the General page.
|
||||||
// This prevents us from having a heavy page like Setting Visiblity active in the background.
|
// This prevents us from having a heavy page like Setting Visiblity active in the background.
|
||||||
setPage(0);
|
setPage(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorkspaceSummaryDialog
|
||||||
|
{
|
||||||
|
id: saveWorkspaceDialog
|
||||||
|
onYes: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "file_type": "workspace" })
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
|
@ -764,7 +777,7 @@ UM.MainWindow
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: Cura.Actions.loadWorkspace
|
target: Cura.Actions.loadWorkspace
|
||||||
onTriggered:openWorkspaceDialog.open()
|
onTriggered: openWorkspaceDialog.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineLog
|
EngineLog
|
||||||
|
|
|
@ -304,6 +304,20 @@ UM.PreferencesPage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UM.TooltipArea {
|
||||||
|
width: childrenRect.width
|
||||||
|
height: childrenRect.height
|
||||||
|
text: catalog.i18nc("@info:tooltip", "Should a summary be shown when saving a project file?")
|
||||||
|
|
||||||
|
CheckBox
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@option:check", "Show summary dialog when saving project")
|
||||||
|
checked: boolCheck(UM.Preferences.getValue("cura/dialog_on_project_save"))
|
||||||
|
onCheckedChanged: UM.Preferences.setValue("cura/dialog_on_project_save", checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
//: Spacer
|
//: Spacer
|
||||||
|
|
223
resources/qml/WorkspaceSummaryDialog.qml
Normal file
223
resources/qml/WorkspaceSummaryDialog.qml
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
// Copyright (c) 2016 Ultimaker B.V.
|
||||||
|
// Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Window 2.1
|
||||||
|
|
||||||
|
import UM 1.2 as UM
|
||||||
|
import Cura 1.0 as Cura
|
||||||
|
|
||||||
|
UM.Dialog
|
||||||
|
{
|
||||||
|
title: catalog.i18nc("@title:window", "Save Project")
|
||||||
|
|
||||||
|
width: 550
|
||||||
|
minimumWidth: 550
|
||||||
|
maximumWidth: 550
|
||||||
|
|
||||||
|
height: 350
|
||||||
|
minimumHeight: 350
|
||||||
|
maximumHeight: 350
|
||||||
|
property int spacerHeight: 10
|
||||||
|
|
||||||
|
property bool dontShowAgain: true
|
||||||
|
|
||||||
|
signal yes();
|
||||||
|
|
||||||
|
|
||||||
|
onClosing:
|
||||||
|
{
|
||||||
|
UM.Preferences.setValue("cura/asked_dialog_on_project_save", true)
|
||||||
|
UM.Preferences.setValue("cura/dialog_on_project_save", !dontShowAgainCheckbox.checked)
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibleChanged:
|
||||||
|
{
|
||||||
|
if(visible)
|
||||||
|
{
|
||||||
|
if (UM.Preferences.getValue("cura/asked_dialog_on_project_save"))
|
||||||
|
{
|
||||||
|
dontShowAgain = true
|
||||||
|
} else { dontShowAgain = UM.Preferences.setValue("cura/dialog_on_project_save")}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item
|
||||||
|
{
|
||||||
|
anchors.fill: parent
|
||||||
|
UM.SettingDefinitionsModel
|
||||||
|
{
|
||||||
|
id: definitionsModel
|
||||||
|
containerId: Cura.MachineManager.activeDefinitionId
|
||||||
|
showAll: true
|
||||||
|
exclude: ["command_line_settings"]
|
||||||
|
showAncestors: true
|
||||||
|
expanded: ["*"]
|
||||||
|
visibilityHandler: UM.SettingPreferenceVisibilityHandler { }
|
||||||
|
}
|
||||||
|
UM.I18nCatalog
|
||||||
|
{
|
||||||
|
id: catalog;
|
||||||
|
name: "cura";
|
||||||
|
}
|
||||||
|
|
||||||
|
Column
|
||||||
|
{
|
||||||
|
anchors.fill: parent
|
||||||
|
spacing: 2
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
id: titleLabel
|
||||||
|
text: catalog.i18nc("@action:title", "Summary - Cura Project")
|
||||||
|
font.pixelSize: 22
|
||||||
|
}
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
id: separator
|
||||||
|
color: "black"
|
||||||
|
width: parent.width
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
Item // Spacer
|
||||||
|
{
|
||||||
|
height: spacerHeight
|
||||||
|
width: height
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Printer settings")
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Row
|
||||||
|
{
|
||||||
|
width: parent.width
|
||||||
|
height: childrenRect.height
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Name")
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: Cura.MachineManager.activeMachineName
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Item // Spacer
|
||||||
|
{
|
||||||
|
height: spacerHeight
|
||||||
|
width: height
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Profile settings")
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Row
|
||||||
|
{
|
||||||
|
width: parent.width
|
||||||
|
height: childrenRect.height
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Name")
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: Cura.MachineManager.activeQualityName
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Item // Spacer
|
||||||
|
{
|
||||||
|
height: spacerHeight
|
||||||
|
width: height
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Material settings")
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater
|
||||||
|
{
|
||||||
|
model: Cura.MachineManager.activeMaterialNames
|
||||||
|
delegate: Row
|
||||||
|
{
|
||||||
|
width: parent.width
|
||||||
|
height: childrenRect.height
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Name")
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: modelData
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Item // Spacer
|
||||||
|
{
|
||||||
|
height: spacerHeight
|
||||||
|
width: height
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Setting visibility")
|
||||||
|
font.bold: true
|
||||||
|
}
|
||||||
|
Row
|
||||||
|
{
|
||||||
|
width: parent.width
|
||||||
|
height: childrenRect.height
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Visible settings:")
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(definitionsModel.visibleCount).arg(Cura.MachineManager.totalNumberOfSettings)
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CheckBox
|
||||||
|
{
|
||||||
|
id: dontShowAgainCheckbox
|
||||||
|
text: catalog.i18nc("@action:label", "Don't show project summary on save again")
|
||||||
|
checked: dontShowAgain
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rightButtons: [
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
id: cancel_button
|
||||||
|
text: catalog.i18nc("@action:button","Cancel");
|
||||||
|
enabled: true
|
||||||
|
onClicked: close()
|
||||||
|
},
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
id: ok_button
|
||||||
|
text: catalog.i18nc("@action:button","Save");
|
||||||
|
enabled: true
|
||||||
|
onClicked: {
|
||||||
|
close(); yes() }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue