fix merge conflicts

This commit is contained in:
ChrisTerBeke 2017-10-10 09:43:16 +02:00
commit 0b5fac28b9
23 changed files with 568 additions and 21 deletions

View file

@ -304,7 +304,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
num_visible_settings = 0
try:
temp_preferences = Preferences()
temp_preferences.readFromFile(io.TextIOWrapper(archive.open("Cura/preferences.cfg"))) # We need to wrap it, else the archive parser breaks.
serialized = archive.open("Cura/preferences.cfg").read().decode("utf-8")
temp_preferences.deserialize(serialized)
visible_settings_string = temp_preferences.getValue("general/visible_settings")
if visible_settings_string is not None:
@ -407,7 +408,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# Create a shadow copy of the preferences (we don't want all of the preferences, but we do want to re-use its
# parsing code.
temp_preferences = Preferences()
temp_preferences.readFromFile(io.TextIOWrapper(archive.open("Cura/preferences.cfg"))) # We need to wrap it, else the archive parser breaks.
serialized = archive.open("Cura/preferences.cfg").read().decode("utf-8")
temp_preferences.deserialize(serialized)
# Copy a number of settings from the temp preferences to the global
global_preferences = Preferences.getInstance()

View file

@ -285,6 +285,14 @@ class WorkspaceDialog(QObject):
except:
pass
@pyqtSlot(bool)
def _onVisibilityChanged(self, visible):
if not visible:
try:
self._lock.release()
except:
pass
@pyqtSlot()
def onOkButtonClicked(self):
self._view.hide()

View file

@ -364,7 +364,7 @@ UM.Dialog
Label
{
id: warningLabel
text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the buildplate")
text: catalog.i18nc("@action:warning", "Loading a project will clear all models on the build plate.")
wrapMode: Text.Wrap
}
}

View file

@ -1,7 +1,7 @@
// Copyright (c) 2017 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.1
@ -379,4 +379,9 @@ Item
}
}
}
FontMetrics {
id: fontMetrics
font: UM.Theme.getFont("default")
}
}

View file

@ -217,7 +217,7 @@ UM.Dialog
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
text: licenseDialog.pluginName + catalog.i18nc("@label", " plugin contains a license.\nYou need to accept this license to install this plugin.\nDo you agree with the terms below?")
text: licenseDialog.pluginName + catalog.i18nc("@label", "This plugin contains a license.\nYou need to accept this license to install this plugin.\nDo you agree with the terms below?")
wrapMode: Text.Wrap
}

View file

@ -1,15 +1,18 @@
# Copyright (c) 2015 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.
# Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
# Python built-ins
import threading
import time
from UM.Message import Message
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
# Uranium/Messaging
from UM.Logger import Logger
# Uranium/IO
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
from . import RemovableDriveOutputDevice
from UM.Logger import Logger
# Uranium/l18n
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")

View file

@ -378,7 +378,7 @@ Cura.MachineAction
},
Button {
id: btnOk
text: catalog.i18nc("@action:button", "Ok")
text: catalog.i18nc("@action:button", "OK")
onClicked:
{
manualPrinterDialog.accept()

View file

@ -26,10 +26,11 @@ import gzip
from time import time
i18n_catalog = i18nCatalog("cura")
from time import gmtime
from enum import IntEnum
i18n_catalog = i18nCatalog("cura")
class AuthState(IntEnum):
NotAuthenticated = 1
AuthenticationRequested = 2
@ -1138,6 +1139,11 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
else:
Logger.log("w", "Unable to save authentication for id %s and key %s", self._authentication_id, self._getSafeAuthKey())
# Request 'system' printer data once, when we know we have authentication, so we know we can set the system time.
url = QUrl("http://" + self._address + self._api_prefix + "system")
system_data_request = QNetworkRequest(url)
self._manager.get(system_data_request)
else: # Got a response that we didn't expect, so something went wrong.
Logger.log("e", "While trying to authenticate, we got an unexpected response: %s", reply.attribute(QNetworkRequest.HttpStatusCodeAttribute))
self.setAuthenticationState(AuthState.NotAuthenticated)
@ -1157,6 +1163,27 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
else:
pass
elif self._api_prefix + "system" in reply_url:
# Check if the printer has time, and if this has a valid system time.
try:
data = json.loads(bytes(reply.readAll()).decode("utf-8"))
except json.decoder.JSONDecodeError:
Logger.log("w", "Received an invalid authentication request reply from printer: Not valid JSON.")
return
if "time" in data and "utc" in data["time"]:
try:
printer_time = gmtime(float(data["time"]["utc"]))
Logger.log("i", "Printer has system time of: %s", str(printer_time))
except ValueError:
printer_time = None
if printer_time is not None and printer_time.tm_year < 1990:
# The system time is not valid, sync our current system time to it, so we at least have some reasonable time in the printer.
Logger.log("w", "Printer system time invalid, setting system time")
url = QUrl("http://" + self._address + self._api_prefix + "system/time/utc")
put_request = QNetworkRequest(url)
put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json")
self._manager.put(put_request, str(time()).encode())
elif reply.operation() == QNetworkAccessManager.PostOperation:
if "/auth/request" in reply_url:
# We got a response to requesting authentication.

View file

@ -31,6 +31,7 @@ class NetworkPrinterOutputDevicePlugin(QObject, OutputDevicePlugin):
self._zero_conf = None
self._browser = None
self._printers = {}
self._cluster_printers_seen = {} # do not forget a cluster printer when we have seen one, to not 'downgrade' from Connect to legacy printer
self._api_version = "1"
self._api_prefix = "/api/v" + self._api_version + "/"
@ -218,12 +219,16 @@ class NetworkPrinterOutputDevicePlugin(QObject, OutputDevicePlugin):
## Because the model needs to be created in the same thread as the QMLEngine, we use a signal.
def addPrinter(self, name, address, properties, force_cluster=False):
cluster_size = int(properties.get(b"cluster_size", -1))
if force_cluster or cluster_size >= 0:
was_cluster_before = name in self._cluster_printers_seen
if was_cluster_before:
Logger.log("d", "Printer [%s] had Cura Connect before, so assume it's still equipped with Cura Connect.", name)
if force_cluster or cluster_size >= 0 or was_cluster_before:
printer = NetworkClusterPrinterOutputDevice.NetworkClusterPrinterOutputDevice(
name, address, properties, self._api_prefix, self._plugin_path)
else:
printer = NetworkPrinterOutputDevice.NetworkPrinterOutputDevice(name, address, properties, self._api_prefix)
self._printers[printer.getKey()] = printer
self._cluster_printers_seen[printer.getKey()] = name # Cluster printers that may be temporary unreachable or is rebooted keep being stored here
global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack and printer.getKey() == global_container_stack.getMetaDataEntry("um_network_key"):
if printer.getKey() not in self._old_printers: # Was the printer already connected, but a re-scan forced?

View file

@ -11,7 +11,7 @@ Button {
UM.I18nCatalog { id: catalog; name: "cura"; }
height: UM.Theme.getSize("save_button_save_to_button").height
tooltip: catalog.i18nc("@info:tooltip", "Opens the print jobs page with your default web browser.")
tooltip: catalog.i18nc("@info:tooltip", "Opens the print jobs page with your default web browser.")
text: catalog.i18nc("@action:button", "View print jobs")
// FIXME: This button style is copied and duplicated from SaveButton.qml

View file

@ -119,7 +119,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
self._sendCommand("G0 Y%s F%s" % (z, speed))
def _homeHead(self):
self._sendCommand("G28")
self._sendCommand("G28 X")
self._sendCommand("G28 Y")
def _homeBed(self):
self._sendCommand("G28 Z")