mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Support for manual device addition for plugins (WIP). [CURA-6294]
This commit is contained in:
parent
48cc9b3c1d
commit
7a7e710b2a
@ -7,6 +7,7 @@ from PyQt5.QtCore import QUrl, Qt
|
|||||||
|
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
|
from logging import Logger
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from PyQt5.QtCore import QObject
|
from PyQt5.QtCore import QObject
|
||||||
@ -17,6 +18,7 @@ class WelcomePagesModel(ListModel):
|
|||||||
PageUrlRole = Qt.UserRole + 2 # URL to the page's QML file
|
PageUrlRole = Qt.UserRole + 2 # URL to the page's QML file
|
||||||
NextPageIdRole = Qt.UserRole + 3 # The next page ID it should go to
|
NextPageIdRole = Qt.UserRole + 3 # The next page ID it should go to
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, parent: Optional["QObject"] = None) -> None:
|
def __init__(self, parent: Optional["QObject"] = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
@ -28,6 +30,7 @@ class WelcomePagesModel(ListModel):
|
|||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
|
|
||||||
# Add default welcome pages
|
# Add default welcome pages
|
||||||
self._pages.append({"id": "welcome",
|
self._pages.append({"id": "welcome",
|
||||||
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
||||||
@ -51,9 +54,7 @@ class WelcomePagesModel(ListModel):
|
|||||||
})
|
})
|
||||||
self._pages.append({"id": "add_printer_by_ip",
|
self._pages.append({"id": "add_printer_by_ip",
|
||||||
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
||||||
os.path.join("WelcomePages",
|
os.path.join("WelcomePages", "AddPrinterByIpContent.qml")))})
|
||||||
"AddPrinterByIpContent.qml"))),
|
|
||||||
})
|
|
||||||
self._pages.append({"id": "cloud",
|
self._pages.append({"id": "cloud",
|
||||||
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
||||||
os.path.join("WelcomePages",
|
os.path.join("WelcomePages",
|
||||||
|
@ -15,6 +15,7 @@ from cura.CuraApplication import CuraApplication
|
|||||||
from cura.PrinterOutputDevice import ConnectionType
|
from cura.PrinterOutputDevice import ConnectionType
|
||||||
from cura.Settings.GlobalStack import GlobalStack # typing
|
from cura.Settings.GlobalStack import GlobalStack # typing
|
||||||
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
|
from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin
|
||||||
|
from UM.OutputDevice.OutputDeviceManager import ManualDeviceAdditionAttempt
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Signal import Signal, signalemitter
|
from UM.Signal import Signal, signalemitter
|
||||||
from UM.Version import Version
|
from UM.Version import Version
|
||||||
@ -181,6 +182,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||||||
self._zero_conf.close()
|
self._zero_conf.close()
|
||||||
self._cloud_output_device_manager.stop()
|
self._cloud_output_device_manager.stop()
|
||||||
|
|
||||||
|
def canAddManualDevice(self, address: str) -> ManualDeviceAdditionAttempt:
|
||||||
|
return ManualDeviceAdditionAttempt.POSSIBLE
|
||||||
|
# TODO?: Check if address is a valid IP (by regexp?).
|
||||||
|
|
||||||
def removeManualDevice(self, key, address = None):
|
def removeManualDevice(self, key, address = None):
|
||||||
if key in self._discovered_devices:
|
if key in self._discovered_devices:
|
||||||
if not address:
|
if not address:
|
||||||
|
@ -148,6 +148,8 @@ Item
|
|||||||
{
|
{
|
||||||
addPrinterByIpScreen.hasPushedAdd = true
|
addPrinterByIpScreen.hasPushedAdd = true
|
||||||
tempTimerRequest.running = true
|
tempTimerRequest.running = true
|
||||||
|
|
||||||
|
UM.OutputDeviceManager.addManualDevice(hostnameField.text, hostnameField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user