Fix merge conflicts

This commit is contained in:
Lipu Fei 2019-03-22 10:00:57 +01:00
commit 80dff49b8a
4 changed files with 14 additions and 7 deletions

View file

@ -88,7 +88,7 @@ class DiscoveredPrintersModel(QObject):
discoveredPrintersChanged = pyqtSignal() discoveredPrintersChanged = pyqtSignal()
@pyqtProperty(list, notify = discoveredPrintersChanged) @pyqtProperty(list, notify = discoveredPrintersChanged)
def discovered_printers(self) -> "List[DiscoveredPrinter]": def discovered_printers(self) -> List["DiscoveredPrinter"]:
item_list = list(x for x in self._discovered_printer_by_ip_dict.values()) item_list = list(x for x in self._discovered_printer_by_ip_dict.values())
item_list.sort(key = lambda x: x.name) item_list.sort(key = lambda x: x.name)
return item_list return item_list
@ -125,6 +125,8 @@ class DiscoveredPrintersModel(QObject):
del self._discovered_printer_by_ip_dict[ip_address] del self._discovered_printer_by_ip_dict[ip_address]
self.discoveredPrintersChanged.emit() self.discoveredPrintersChanged.emit()
# A convenience function for QML to create a machine (GlobalStack) out of the given discovered printer.
# This function invokes the given discovered printer's "create_callback" to do this.
@pyqtSlot("QVariant") @pyqtSlot("QVariant")
def createMachineFromDiscoveredPrinter(self, discovered_printer: "DiscoveredPrinter") -> None: def createMachineFromDiscoveredPrinter(self, discovered_printer: "DiscoveredPrinter") -> None:
discovered_printer.create_callback(discovered_printer.getKey()) discovered_printer.create_callback(discovered_printer.getKey())

View file

@ -1,24 +1,25 @@
# Copyright (c) 2019 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import json import json
import os
from queue import Queue from queue import Queue
from threading import Event, Thread from threading import Event, Thread
from time import time from time import time
import os from typing import Optional, TYPE_CHECKING, Dict
from typing import Optional, TYPE_CHECKING
from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo
from PyQt5.QtNetwork import QNetworkRequest, QNetworkAccessManager from PyQt5.QtNetwork import QNetworkRequest, QNetworkAccessManager
from PyQt5.QtCore import QUrl from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QDesktopServices from PyQt5.QtGui import QDesktopServices
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
from UM.OutputDevice.OutputDeviceManager import ManualDeviceAdditionAttempt
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
from UM.Logger import Logger from UM.Logger import Logger
from UM.Message import Message from UM.Message import Message
from UM.OutputDevice.OutputDeviceManager import ManualDeviceAdditionAttempt
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from UM.Signal import Signal, signalemitter from UM.Signal import Signal, signalemitter
@ -28,6 +29,7 @@ from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice
from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager
if TYPE_CHECKING: if TYPE_CHECKING:
from PyQt5.QtNetwork import QNetworkReply
from cura.Settings.GlobalStack import GlobalStack from cura.Settings.GlobalStack import GlobalStack
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
@ -254,7 +256,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
name_request = QNetworkRequest(url) name_request = QNetworkRequest(url)
self._network_manager.get(name_request) self._network_manager.get(name_request)
def _onNetworkRequestFinished(self, reply): def _onNetworkRequestFinished(self, reply: "QNetworkReply") -> None:
reply_url = reply.url().toString() reply_url = reply.url().toString()
address = "" address = ""
@ -324,7 +326,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
self.getOutputDeviceManager().addOutputDevice(device) self.getOutputDeviceManager().addOutputDevice(device)
self.addManualDeviceSignal.emit(self.getPluginId(), device.getId(), address, properties) self.addManualDeviceSignal.emit(self.getPluginId(), device.getId(), address, properties)
def _onRemoveDevice(self, device_id): def _onRemoveDevice(self, device_id: str) -> None:
device = self._discovered_devices.pop(device_id, None) device = self._discovered_devices.pop(device_id, None)
if device: if device:
if device.isConnected(): if device.isConnected():

View file

@ -16,10 +16,13 @@ ScrollView
{ {
id: base id: base
// The currently selected machine item in the local machine list.
property var currentItem: (machineList.currentIndex >= 0) property var currentItem: (machineList.currentIndex >= 0)
? machineList.model.getItem(machineList.currentIndex) ? machineList.model.getItem(machineList.currentIndex)
: null : null
// The currently active (expanded) section/category, where section/category is the grouping of local machine items.
property string currentSection: preferredCategory property string currentSection: preferredCategory
// By default (when this list shows up) we always expand the "Ultimaker" section.
property string preferredCategory: "Ultimaker" property string preferredCategory: "Ultimaker"
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ScrollBar.horizontal.policy: ScrollBar.AlwaysOff

View file

@ -91,7 +91,7 @@ Item
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 10 anchors.rightMargin: UM.Theme.getSize("default_margin").width
outputDevice: modelData.device outputDevice: modelData.device
enabled: !modelData.is_unknown_machine_type enabled: !modelData.is_unknown_machine_type