Merge branch '2.1' of https://github.com/Ultimaker/Cura into 2.1

This commit is contained in:
fieldOfView 2016-02-11 09:26:48 +01:00
commit f8aa4cdade
7 changed files with 34 additions and 68 deletions

View File

@ -150,9 +150,6 @@ class CuraApplication(QtApplication):
parser.add_argument("--debug", dest="debug-mode", action="store_true", default=False, help="Enable detailed crash reports.") parser.add_argument("--debug", dest="debug-mode", action="store_true", default=False, help="Enable detailed crash reports.")
def run(self): def run(self):
if "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION" not in os.environ or os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] != "cpp":
Logger.log("w", "Using Python implementation of Protobuf, expect bad performance!")
self._i18n_catalog = i18nCatalog("cura"); self._i18n_catalog = i18nCatalog("cura");
i18nCatalog.setTagReplacements({ i18nCatalog.setTagReplacements({

View File

@ -12,15 +12,12 @@ def exceptHook(type, value, traceback):
sys.excepthook = exceptHook sys.excepthook = exceptHook
try: # Workaround for a race condition on certain systems where there
from google.protobuf.pyext import _message # is a race condition between Arcus and PyQt. Importing Arcus
except ImportError: # first seems to prevent Sip from going into a state where it
pass # tries to create PyQt objects on a non-main thread.
else: import Arcus
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "cpp" import cura.CuraApplication
if True: # To make the code style checker stop complaining
import cura.CuraApplication
if sys.platform == "win32" and hasattr(sys, "frozen"): if sys.platform == "win32" and hasattr(sys, "frozen"):
import os import os

View File

@ -13,17 +13,17 @@ class AutoSave(Extension):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
Preferences.getInstance().preferenceChanged.connect(self._onPreferenceChanged) #Preferences.getInstance().preferenceChanged.connect(self._onPreferenceChanged)
Preferences.getInstance().preferenceChanged.connect(self._triggerTimer)
machine_manager = Application.getInstance().getMachineManager() machine_manager = Application.getInstance().getMachineManager()
self._profile = None self._profile = None
machine_manager.activeProfileChanged.connect(self._onActiveProfileChanged) machine_manager.activeProfileChanged.connect(self._onActiveProfileChanged)
machine_manager.profileNameChanged.connect(self._onProfileNameChanged) machine_manager.profileNameChanged.connect(self._triggerTimer)
machine_manager.profilesChanged.connect(self._onProfilesChanged) machine_manager.profilesChanged.connect(self._triggerTimer)
machine_manager.machineInstanceNameChanged.connect(self._onInstanceNameChanged) machine_manager.machineInstanceNameChanged.connect(self._triggerTimer)
machine_manager.machineInstancesChanged.connect(self._onInstancesChanged) machine_manager.machineInstancesChanged.connect(self._triggerTimer)
Application
self._onActiveProfileChanged() self._onActiveProfileChanged()
Preferences.getInstance().addPreference("cura/autosave_delay", 1000 * 10) Preferences.getInstance().addPreference("cura/autosave_delay", 1000 * 10)
@ -33,53 +33,27 @@ class AutoSave(Extension):
self._change_timer.setSingleShot(True) self._change_timer.setSingleShot(True)
self._change_timer.timeout.connect(self._onTimeout) self._change_timer.timeout.connect(self._onTimeout)
self._save_preferences = False self._saving = False
self._save_profiles = False
self._save_instances = False
def _onPreferenceChanged(self, preference): def _triggerTimer(self, *args):
self._save_preferences = True if not self._saving:
self._change_timer.start() self._change_timer.start()
def _onSettingValueChanged(self, setting):
self._save_profiles = True
self._change_timer.start()
def _onActiveProfileChanged(self): def _onActiveProfileChanged(self):
if self._profile: if self._profile:
self._profile.settingValueChanged.disconnect(self._onSettingValueChanged) self._profile.settingValueChanged.disconnect(self._triggerTimer)
self._profile = Application.getInstance().getMachineManager().getWorkingProfile() self._profile = Application.getInstance().getMachineManager().getWorkingProfile()
if self._profile: if self._profile:
self._profile.settingValueChanged.connect(self._onSettingValueChanged) self._profile.settingValueChanged.connect(self._triggerTimer)
def _onProfileNameChanged(self, name):
self._onProfilesChanged()
def _onProfilesChanged(self):
self._save_profiles = True
self._change_timer.start()
def _onInstanceNameChanged(self, name):
self._onInstancesChanged()
def _onInstancesChanged(self):
self._save_instances = True
self._change_timer.start()
def _onTimeout(self): def _onTimeout(self):
self._saving = True # To prevent the save process from triggering another autosave.
Logger.log("d", "Autosaving preferences, instances and profiles") Logger.log("d", "Autosaving preferences, instances and profiles")
if self._save_preferences: Preferences.getInstance().writeToFile(Resources.getStoragePath(Resources.Preferences, Application.getInstance().getApplicationName() + ".cfg"))
Preferences.getInstance().writeToFile(Resources.getStoragePath(Resources.Preferences, Application.getInstance().getApplicationName() + ".cfg")) Application.getInstance().getMachineManager().saveMachineInstances()
Application.getInstance().getMachineManager().saveProfiles()
if self._save_instances: self._saving = False
Application.getInstance().getMachineManager().saveMachineInstances()
if self._save_profiles:
Application.getInstance().getMachineManager().saveProfiles()
self._save_preferences = False
self._save_instances = False
self._save_profiles = False

View File

@ -249,7 +249,6 @@ class CuraEngineBackend(Backend):
def _onToolOperationStopped(self, tool): def _onToolOperationStopped(self, tool):
self._enabled = True # Tool stop, start listening for changes again. self._enabled = True # Tool stop, start listening for changes again.
self._onChanged()
def _onActiveViewChanged(self): def _onActiveViewChanged(self):
if Application.getInstance().getController().getActiveView(): if Application.getInstance().getController().getActiveView():

View File

@ -25,20 +25,19 @@ class RemovableDriveOutputDevice(OutputDevice):
self._writing = False self._writing = False
def requestWrite(self, node, file_name = None): def requestWrite(self, node, file_name = None, filter_by_machine = False):
if self._writing: if self._writing:
raise OutputDeviceError.DeviceBusyError() raise OutputDeviceError.DeviceBusyError()
file_formats = Application.getInstance().getMeshFileHandler().getSupportedFileTypesWrite() #Formats supported by this application. file_formats = Application.getInstance().getMeshFileHandler().getSupportedFileTypesWrite() #Formats supported by this application.
machine_file_formats = Application.getInstance().getMachineManager().getActiveMachineInstance().getMachineDefinition().getFileFormats() if filter_by_machine:
for file_format in file_formats: machine_file_formats = Application.getInstance().getMachineManager().getActiveMachineInstance().getMachineDefinition().getFileFormats()
if file_format["mime_type"] in machine_file_formats: file_formats = list(filter(lambda file_format: file_format["mime_type"] in machine_file_formats, file_formats)) #Take the intersection between file_formats and machine_file_formats.
writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(file_format["mime_type"]) if len(file_formats) == 0:
extension = file_format["extension"] Logger.log("e", "There are no file formats available to write with!")
break #We have a valid mesh writer, supported by the machine. Just pick the first one.
else:
Logger.log("e", "None of the file formats supported by this machine are supported by the application!")
raise OutputDeviceError.WriteRequestFailedError() raise OutputDeviceError.WriteRequestFailedError()
writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(file_formats[0]["mime_type"]) #Just take the first file format available.
extension = file_formats[0]["extension"]
if file_name == None: if file_name == None:
for n in BreadthFirstIterator(node): for n in BreadthFirstIterator(node):

View File

@ -92,7 +92,7 @@ UM.MainWindow
text: catalog.i18nc("@action:inmenu menubar:file", "&Save Selection to File"); text: catalog.i18nc("@action:inmenu menubar:file", "&Save Selection to File");
enabled: UM.Selection.hasSelection; enabled: UM.Selection.hasSelection;
iconName: "document-save-as"; iconName: "document-save-as";
onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", Printer.jobName); onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", Printer.jobName, false);
} }
Menu Menu
{ {
@ -108,7 +108,7 @@ UM.MainWindow
MenuItem MenuItem
{ {
text: model.description; text: model.description;
onTriggered: UM.OutputDeviceManager.requestWriteToDevice(model.id, Printer.jobName); onTriggered: UM.OutputDeviceManager.requestWriteToDevice(model.id, Printer.jobName, false);
} }
onObjectAdded: saveAllMenu.insertItem(index, object) onObjectAdded: saveAllMenu.insertItem(index, object)
onObjectRemoved: saveAllMenu.removeItem(object) onObjectRemoved: saveAllMenu.removeItem(object)

View File

@ -84,7 +84,7 @@ Rectangle {
text: UM.OutputDeviceManager.activeDeviceShortDescription text: UM.OutputDeviceManager.activeDeviceShortDescription
onClicked: onClicked:
{ {
UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, Printer.jobName) UM.OutputDeviceManager.requestWriteToDevice(UM.OutputDeviceManager.activeDevice, Printer.jobName, true)
} }
style: ButtonStyle { style: ButtonStyle {