mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-10 06:19:01 +08:00
Merge pull request #6347 from Ultimaker/allow_hiding_new_cloud_printers_popup
Store in preferences if the user wants to hide the message
This commit is contained in:
commit
495ed17294
@ -28,7 +28,7 @@ class CloudFlowMessage(Message):
|
||||
lifetime=0,
|
||||
dismissable=True,
|
||||
option_state=False,
|
||||
image_source=image_path,
|
||||
image_source=QUrl.fromLocalFile(image_path),
|
||||
image_caption=I18N_CATALOG.i18nc("@info:status Ultimaker Cloud should not be translated.",
|
||||
"Connect to Ultimaker Cloud"),
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from UM import i18nCatalog
|
||||
from UM.Message import Message
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
|
||||
I18N_CATALOG = i18nCatalog("cura")
|
||||
|
||||
@ -13,16 +13,25 @@ class CloudPrinterDetectedMessage(Message):
|
||||
# Singleton used to prevent duplicate messages of this type at the same time.
|
||||
__is_visible = False
|
||||
|
||||
# Store in preferences to hide this message in the future.
|
||||
_preference_key = "cloud/block_new_printers_popup"
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__(
|
||||
title=I18N_CATALOG.i18nc("@info:title", "New cloud printers found"),
|
||||
text=I18N_CATALOG.i18nc("@info:message", "New printers have been found connected to your account, "
|
||||
"you can find them in your list of discovered printers."),
|
||||
lifetime=10,
|
||||
dismissable=True
|
||||
lifetime=0,
|
||||
dismissable=True,
|
||||
option_state=False,
|
||||
option_text=I18N_CATALOG.i18nc("@info:option_text", "Do not show this message again")
|
||||
)
|
||||
self.optionToggled.connect(self._onDontAskMeAgain)
|
||||
CuraApplication.getInstance().getPreferences().addPreference(self._preference_key, False)
|
||||
|
||||
def show(self) -> None:
|
||||
if CuraApplication.getInstance().getPreferences().getValue(self._preference_key):
|
||||
return
|
||||
if CloudPrinterDetectedMessage.__is_visible:
|
||||
return
|
||||
super().show()
|
||||
@ -31,3 +40,6 @@ class CloudPrinterDetectedMessage(Message):
|
||||
def hide(self, send_signal = True) -> None:
|
||||
super().hide(send_signal)
|
||||
CloudPrinterDetectedMessage.__is_visible = False
|
||||
|
||||
def _onDontAskMeAgain(self, checked: bool) -> None:
|
||||
CuraApplication.getInstance().getPreferences().setValue(self._preference_key, checked)
|
||||
|
Loading…
x
Reference in New Issue
Block a user