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.")
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");
i18nCatalog.setTagReplacements({

View File

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

View File

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

View File

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

View File

@ -25,20 +25,19 @@ class RemovableDriveOutputDevice(OutputDevice):
self._writing = False
def requestWrite(self, node, file_name = None):
def requestWrite(self, node, file_name = None, filter_by_machine = False):
if self._writing:
raise OutputDeviceError.DeviceBusyError()
file_formats = Application.getInstance().getMeshFileHandler().getSupportedFileTypesWrite() #Formats supported by this application.
if filter_by_machine:
machine_file_formats = Application.getInstance().getMachineManager().getActiveMachineInstance().getMachineDefinition().getFileFormats()
for file_format in file_formats:
if file_format["mime_type"] in machine_file_formats:
writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType(file_format["mime_type"])
extension = file_format["extension"]
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!")
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.
if len(file_formats) == 0:
Logger.log("e", "There are no file formats available to write with!")
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:
for n in BreadthFirstIterator(node):

View File

@ -92,7 +92,7 @@ UM.MainWindow
text: catalog.i18nc("@action:inmenu menubar:file", "&Save Selection to File");
enabled: UM.Selection.hasSelection;
iconName: "document-save-as";
onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", Printer.jobName);
onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", Printer.jobName, false);
}
Menu
{
@ -108,7 +108,7 @@ UM.MainWindow
MenuItem
{
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)
onObjectRemoved: saveAllMenu.removeItem(object)

View File

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