mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Fix cluster host checking, show neat actionable message when not host
This commit is contained in:
parent
669e64afdb
commit
90c69e079c
4 changed files with 40 additions and 14 deletions
|
@ -1,26 +1,39 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
|
||||
from UM import i18nCatalog
|
||||
from UM.Message import Message
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..UltimakerNetworkedPrinterOutputDevice import UltimakerNetworkedPrinterOutputDevice
|
||||
|
||||
|
||||
I18N_CATALOG = i18nCatalog("cura")
|
||||
|
||||
|
||||
## Message shown when trying to connect to a printer that is not a host.
|
||||
class NotClusterHostMessage(Message):
|
||||
|
||||
|
||||
# Singleton used to prevent duplicate messages of this type at the same time.
|
||||
__is_visible = False
|
||||
|
||||
def __init__(self) -> None:
|
||||
|
||||
def __init__(self, device: "UltimakerNetworkedPrinterOutputDevice") -> None:
|
||||
super().__init__(
|
||||
text = I18N_CATALOG.i18nc("@info:status", "You are attempting to connect to a printer that is not "
|
||||
"the host of an Ultimaker Connect group. Please connect to "
|
||||
"the host instead."),
|
||||
title = I18N_CATALOG.i18nc("@info:title", "Not a cluster host"),
|
||||
lifetime = 10
|
||||
text = I18N_CATALOG.i18nc("@info:status", "You are attempting to connect to {0} but it is not "
|
||||
"the host of a group. You can visit the web page to configure "
|
||||
"it as a group host.", device.name),
|
||||
title = I18N_CATALOG.i18nc("@info:title", "Not a group host"),
|
||||
lifetime = 0,
|
||||
dismissable = True
|
||||
)
|
||||
self._address = device.address
|
||||
self.addAction("", I18N_CATALOG.i18nc("@action", "Configure group"), "", "")
|
||||
self.actionTriggered.connect(self._onConfigureClicked)
|
||||
|
||||
def show(self) -> None:
|
||||
if NotClusterHostMessage.__is_visible:
|
||||
|
@ -31,3 +44,7 @@ class NotClusterHostMessage(Message):
|
|||
def hide(self, send_signal = True) -> None:
|
||||
super().hide(send_signal)
|
||||
NotClusterHostMessage.__is_visible = False
|
||||
|
||||
def _onConfigureClicked(self, messageId: str, actionId: str) -> None:
|
||||
QDesktopServices.openUrl(QUrl("http://{}/print_jobs".format(self._address)))
|
||||
self.hide()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue