mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-04 20:43:58 -06:00
Prevent auto selecting an invalid printer
CURA-6483
This commit is contained in:
parent
5b9c4e402e
commit
7d4c821551
2 changed files with 17 additions and 4 deletions
|
@ -192,7 +192,7 @@ class DiscoveredPrintersModel(QObject):
|
||||||
def discoveredPrintersByAddress(self) -> Dict[str, DiscoveredPrinter]:
|
def discoveredPrintersByAddress(self) -> Dict[str, DiscoveredPrinter]:
|
||||||
return self._discovered_printer_by_ip_dict
|
return self._discovered_printer_by_ip_dict
|
||||||
|
|
||||||
@pyqtProperty(list, notify = discoveredPrintersChanged)
|
@pyqtProperty("QVariantList", notify = discoveredPrintersChanged)
|
||||||
def discoveredPrinters(self) -> List["DiscoveredPrinter"]:
|
def discoveredPrinters(self) -> List["DiscoveredPrinter"]:
|
||||||
item_list = list(
|
item_list = list(
|
||||||
x for x in self._discovered_printer_by_ip_dict.values() if not parseBool(x.device.getProperty("temporary")))
|
x for x in self._discovered_printer_by_ip_dict.values() if not parseBool(x.device.getProperty("temporary")))
|
||||||
|
|
|
@ -76,15 +76,28 @@ Item
|
||||||
|
|
||||||
Component.onCompleted:
|
Component.onCompleted:
|
||||||
{
|
{
|
||||||
// Select the first one that's not "unknown" by default.
|
var toSelectIndex = -1
|
||||||
|
// Select the first one that's not "unknown" and is the host a group by default.
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (!model[i].isUnknownMachineType)
|
if (!model[i].isUnknownMachineType && model[i].isHostOfGroup)
|
||||||
{
|
{
|
||||||
currentIndex = i
|
toSelectIndex = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
currentIndex = toSelectIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
// CURA-6483 For some reason currentIndex can be reset to 0. This check is here to prevent automatically
|
||||||
|
// selecting an unknown or non-host printer.
|
||||||
|
onCurrentIndexChanged:
|
||||||
|
{
|
||||||
|
var item = model[currentIndex]
|
||||||
|
if (!item || item.isUnknownMachineType || !item.isHostOfGroup)
|
||||||
|
{
|
||||||
|
currentIndex = -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component
|
Component
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue